diff --git a/Source/Framework/Constants/SmartAIConst.cs b/Source/Framework/Constants/SmartAIConst.cs index ef291bf97..d0d847098 100644 --- a/Source/Framework/Constants/SmartAIConst.cs +++ b/Source/Framework/Constants/SmartAIConst.cs @@ -397,6 +397,7 @@ namespace Framework.Constants AddToStoredTargetList = 148, // varID BecomePersonalCloneForPlayer = 149, // summonType 1-8, duration in ms TriggerGameEvent = 150, // eventId, useSaiTargetAsGameEventSource + DoAction = 151, End } diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index 2a3bcce89..ce7ae086e 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -805,6 +805,7 @@ namespace Game.AI SmartActions.AddToStoredTargetList => Marshal.SizeOf(typeof(SmartAction.AddToStoredTargets)), SmartActions.BecomePersonalCloneForPlayer => Marshal.SizeOf(typeof(SmartAction.BecomePersonalClone)), SmartActions.TriggerGameEvent => Marshal.SizeOf(typeof(SmartAction.TriggerGameEvent)), + SmartActions.DoAction => Marshal.SizeOf(typeof(SmartAction.DoAction)), _ => Marshal.SizeOf(typeof(SmartAction.Raw)), }; @@ -2071,6 +2072,7 @@ namespace Game.AI case SmartActions.TriggerRandomTimedEvent: case SmartActions.SpawnSpawngroup: case SmartActions.AddToStoredTargetList: + case SmartActions.DoAction: break; case SmartActions.BecomePersonalCloneForPlayer: { @@ -3136,6 +3138,9 @@ namespace Game.AI [FieldOffset(4)] public TriggerGameEvent triggerGameEvent; + [FieldOffset(4)] + public DoAction doAction; + [FieldOffset(4)] public Raw raw; @@ -3674,6 +3679,10 @@ namespace Game.AI public uint eventId; public uint useSaiTargetAsGameEventSource; } + public struct DoAction + { + public uint actionId; + } public struct Raw { public uint param1; diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 6f31d1d09..052d30c7e 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -2480,6 +2480,23 @@ namespace Game.AI break; } + case SmartActions.DoAction: + { + foreach (WorldObject target in targets) + { + Unit unitTarget = target?.ToUnit(); + if (unitTarget != null) + unitTarget.GetAI()?.DoAction((int)e.Action.doAction.actionId); + else + { + GameObject goTarget = target?.ToGameObject(); + if (goTarget != null) + goTarget.GetAI()?.DoAction((int)e.Action.doAction.actionId); + } + } + + break; + } default: Log.outError(LogFilter.Sql, "SmartScript.ProcessAction: Entry {0} SourceType {1}, Event {2}, Unhandled Action type {3}", e.EntryOrGuid, e.GetScriptType(), e.EventId, e.GetActionType()); break;