diff --git a/Source/Framework/Constants/SmartAIConst.cs b/Source/Framework/Constants/SmartAIConst.cs index 2e801bc6b..3990eaa6b 100644 --- a/Source/Framework/Constants/SmartAIConst.cs +++ b/Source/Framework/Constants/SmartAIConst.cs @@ -381,7 +381,7 @@ namespace Framework.Constants LoadEquipment = 124, // id TriggerRandomTimedEvent = 125, // id min range, id max range RemoveAllGameobjects = 126, - RemoveMovement = 127, // movementType, forced + PauseMovement = 127, // MovementSlot (default = 0, active = 1, controlled = 2), PauseTime (ms), Force PlayAnimkit = 128, ScenePlay = 129, // sceneId SceneCancel = 130, // sceneId @@ -392,6 +392,8 @@ namespace Framework.Constants PlayCinematic = 135, // entry, cinematic SetMovementSpeed = 136, // movementType, speedInteger, speedFraction PlaySpellVisualKit = 137, // spellVisualKitId, kitType (unknown values, copypaste from packet dumps), duration + OverrideLight = 138, // zoneId, lightId, fadeInTime + OverrideWeather = 139, // zoneId, weatherId, weatherGrade CreateConversation = 143, // conversation_template.id End = 144 } diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 1a443f8a2..6a122277e 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -1450,6 +1450,46 @@ namespace Game.AI break; } + case SmartActions.OverrideLight: + { + var areaEntry = CliDB.AreaTableStorage.LookupByKey(e.Action.overrideLight.zoneId); + if (areaEntry == null) + { + Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-existent zoneId {e.Action.overrideLight.zoneId}, skipped."); + return false; + } + + if (areaEntry.ParentAreaID != 0) + { + Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses subzone (ID: {e.Action.overrideLight.zoneId}) instead of zone, skipped."); + return false; + } + + if (!CliDB.LightStorage.ContainsKey(e.Action.overrideLight.lightId)) + { + Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-existent lightId {e.Action.overrideLight.lightId}, skipped."); + return false; + } + + break; + } + case SmartActions.OverrideWeather: + { + var areaEntry = CliDB.AreaTableStorage.LookupByKey(e.Action.overrideWeather.zoneId); + if (areaEntry == null) + { + Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-existent zoneId {e.Action.overrideWeather.zoneId}, skipped."); + return false; + } + + if (areaEntry.ParentAreaID != 0) + { + Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses subzone (ID: {e.Action.overrideWeather.zoneId}) instead of zone, skipped."); + return false; + } + + break; + } case SmartActions.CreateConversation: { if (Global.ConversationDataStorage.GetConversationTemplate(e.Action.conversation.id) == null) @@ -2562,6 +2602,12 @@ namespace Game.AI [FieldOffset(4)] public SpellVisualKit spellVisualKit; + [FieldOffset(4)] + public OverrideLight overrideLight; + + [FieldOffset(4)] + public OverrideWeather overrideWeather; + [FieldOffset(4)] public Conversation conversation; @@ -3091,6 +3137,18 @@ namespace Game.AI public uint kitType; public uint duration; } + public struct OverrideLight + { + public uint zoneId; + public uint lightId; + public uint fadeInTime; + } + public struct OverrideWeather + { + public uint zoneId; + public uint weatherId; + public uint weatherGrade; + } public struct Conversation { public uint id; diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 5147feb71..db9f8282d 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -2414,6 +2414,28 @@ namespace Game.AI break; } + case SmartActions.OverrideLight: + { + WorldObject obj = GetBaseObject(); + if (obj != null) + { + obj.GetMap().SetZoneOverrideLight(e.Action.overrideLight.zoneId, e.Action.overrideLight.lightId, e.Action.overrideLight.fadeInTime); + Log.outDebug(LogFilter.ScriptsAi, $"SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_LIGHT: {obj.GetGUID()} sets zone override light (zoneId: {e.Action.overrideLight.zoneId}, " + + $"lightId: {e.Action.overrideLight.lightId}, fadeInTime: {e.Action.overrideLight.fadeInTime})"); + } + break; + } + case SmartActions.OverrideWeather: + { + WorldObject obj = GetBaseObject(); + if (obj != null) + { + obj.GetMap().SetZoneWeather(e.Action.overrideWeather.zoneId, (WeatherState)e.Action.overrideWeather.weatherId, e.Action.overrideWeather.weatherGrade); + Log.outDebug(LogFilter.ScriptsAi, $"SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_WEATHER: {obj.GetGUID()} sets zone weather (zoneId: {e.Action.overrideWeather.zoneId}, " + + $"weatherId: {e.Action.overrideWeather.weatherId}, weatherGrade: {e.Action.overrideWeather.weatherGrade})"); + } + break; + } case SmartActions.PlaySpellVisualKit: { foreach (var target in targets)