Core/SAI: Implemented new action SMART_ACTION_TRIGGER_GAME_EVENT
Port From (https://github.com/TrinityCore/TrinityCore/commit/9d0187dd5669d73bcb94ffe76b4fc3975a5455cc)
This commit is contained in:
@@ -396,6 +396,7 @@ namespace Framework.Constants
|
||||
ActivateGameobject = 147, // GameObjectActions
|
||||
AddToStoredTargetList = 148, // varID
|
||||
BecomePersonalCloneForPlayer = 149, // summonType 1-8, duration in ms
|
||||
TriggerGameEvent = 150, // eventId, useSaiTargetAsGameEventSource
|
||||
End
|
||||
}
|
||||
|
||||
|
||||
@@ -804,6 +804,7 @@ namespace Game.AI
|
||||
SmartActions.ActivateGameobject => Marshal.SizeOf(typeof(SmartAction.ActivateGameObject)),
|
||||
SmartActions.AddToStoredTargetList => Marshal.SizeOf(typeof(SmartAction.AddToStoredTargets)),
|
||||
SmartActions.BecomePersonalCloneForPlayer => Marshal.SizeOf(typeof(SmartAction.BecomePersonalClone)),
|
||||
SmartActions.TriggerGameEvent => Marshal.SizeOf(typeof(SmartAction.TriggerGameEvent)),
|
||||
_ => Marshal.SizeOf(typeof(SmartAction.Raw)),
|
||||
};
|
||||
|
||||
@@ -2088,6 +2089,11 @@ namespace Game.AI
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SmartActions.TriggerGameEvent:
|
||||
{
|
||||
TC_SAI_IS_BOOLEAN_VALID(e, e.Action.triggerGameEvent.useSaiTargetAsGameEventSource);
|
||||
break;
|
||||
}
|
||||
// No longer supported
|
||||
case SmartActions.SetUnitFlag:
|
||||
case SmartActions.RemoveUnitFlag:
|
||||
@@ -3135,6 +3141,9 @@ namespace Game.AI
|
||||
[FieldOffset(4)]
|
||||
public BecomePersonalClone becomePersonalClone;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public TriggerGameEvent triggerGameEvent;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public Raw raw;
|
||||
|
||||
@@ -3668,6 +3677,11 @@ namespace Game.AI
|
||||
public uint type;
|
||||
public uint duration;
|
||||
}
|
||||
public struct TriggerGameEvent
|
||||
{
|
||||
public uint eventId;
|
||||
public uint useSaiTargetAsGameEventSource;
|
||||
}
|
||||
public struct Raw
|
||||
{
|
||||
public uint param1;
|
||||
|
||||
@@ -2467,6 +2467,19 @@ namespace Game.AI
|
||||
_timedActionList.RemoveAll(script => { return script.EventId > e.EventId; });
|
||||
break;
|
||||
}
|
||||
case SmartActions.TriggerGameEvent:
|
||||
{
|
||||
WorldObject sourceObject = GetBaseObjectOrUnit(unit);
|
||||
foreach (WorldObject target in targets)
|
||||
{
|
||||
if (e.Action.triggerGameEvent.useSaiTargetAsGameEventSource != 0)
|
||||
GameEvents.Trigger(e.Action.triggerGameEvent.eventId, sourceObject, target);
|
||||
else
|
||||
GameEvents.Trigger(e.Action.triggerGameEvent.eventId, target, sourceObject);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
Reference in New Issue
Block a user