Core/SAI: Added Action SMART_ACTION_DO_ACTION for calling DoAction on target AI

Port From (https://github.com/TrinityCore/TrinityCore/commit/a4eafbd3f6a4d4ea4934dca564cd6c4beae54280)
This commit is contained in:
hondacrx
2022-06-14 17:57:47 -04:00
parent f95aec30d8
commit 793fbda3cd
3 changed files with 27 additions and 0 deletions
@@ -397,6 +397,7 @@ namespace Framework.Constants
AddToStoredTargetList = 148, // varID AddToStoredTargetList = 148, // varID
BecomePersonalCloneForPlayer = 149, // summonType 1-8, duration in ms BecomePersonalCloneForPlayer = 149, // summonType 1-8, duration in ms
TriggerGameEvent = 150, // eventId, useSaiTargetAsGameEventSource TriggerGameEvent = 150, // eventId, useSaiTargetAsGameEventSource
DoAction = 151,
End End
} }
@@ -805,6 +805,7 @@ namespace Game.AI
SmartActions.AddToStoredTargetList => Marshal.SizeOf(typeof(SmartAction.AddToStoredTargets)), SmartActions.AddToStoredTargetList => Marshal.SizeOf(typeof(SmartAction.AddToStoredTargets)),
SmartActions.BecomePersonalCloneForPlayer => Marshal.SizeOf(typeof(SmartAction.BecomePersonalClone)), SmartActions.BecomePersonalCloneForPlayer => Marshal.SizeOf(typeof(SmartAction.BecomePersonalClone)),
SmartActions.TriggerGameEvent => Marshal.SizeOf(typeof(SmartAction.TriggerGameEvent)), SmartActions.TriggerGameEvent => Marshal.SizeOf(typeof(SmartAction.TriggerGameEvent)),
SmartActions.DoAction => Marshal.SizeOf(typeof(SmartAction.DoAction)),
_ => Marshal.SizeOf(typeof(SmartAction.Raw)), _ => Marshal.SizeOf(typeof(SmartAction.Raw)),
}; };
@@ -2071,6 +2072,7 @@ namespace Game.AI
case SmartActions.TriggerRandomTimedEvent: case SmartActions.TriggerRandomTimedEvent:
case SmartActions.SpawnSpawngroup: case SmartActions.SpawnSpawngroup:
case SmartActions.AddToStoredTargetList: case SmartActions.AddToStoredTargetList:
case SmartActions.DoAction:
break; break;
case SmartActions.BecomePersonalCloneForPlayer: case SmartActions.BecomePersonalCloneForPlayer:
{ {
@@ -3136,6 +3138,9 @@ namespace Game.AI
[FieldOffset(4)] [FieldOffset(4)]
public TriggerGameEvent triggerGameEvent; public TriggerGameEvent triggerGameEvent;
[FieldOffset(4)]
public DoAction doAction;
[FieldOffset(4)] [FieldOffset(4)]
public Raw raw; public Raw raw;
@@ -3674,6 +3679,10 @@ namespace Game.AI
public uint eventId; public uint eventId;
public uint useSaiTargetAsGameEventSource; public uint useSaiTargetAsGameEventSource;
} }
public struct DoAction
{
public uint actionId;
}
public struct Raw public struct Raw
{ {
public uint param1; public uint param1;
@@ -2480,6 +2480,23 @@ namespace Game.AI
break; 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: 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()); 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; break;