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
|
ActivateGameobject = 147, // GameObjectActions
|
||||||
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
|
||||||
End
|
End
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -804,6 +804,7 @@ namespace Game.AI
|
|||||||
SmartActions.ActivateGameobject => Marshal.SizeOf(typeof(SmartAction.ActivateGameObject)),
|
SmartActions.ActivateGameobject => Marshal.SizeOf(typeof(SmartAction.ActivateGameObject)),
|
||||||
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)),
|
||||||
_ => Marshal.SizeOf(typeof(SmartAction.Raw)),
|
_ => Marshal.SizeOf(typeof(SmartAction.Raw)),
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -2088,6 +2089,11 @@ namespace Game.AI
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SmartActions.TriggerGameEvent:
|
||||||
|
{
|
||||||
|
TC_SAI_IS_BOOLEAN_VALID(e, e.Action.triggerGameEvent.useSaiTargetAsGameEventSource);
|
||||||
|
break;
|
||||||
|
}
|
||||||
// No longer supported
|
// No longer supported
|
||||||
case SmartActions.SetUnitFlag:
|
case SmartActions.SetUnitFlag:
|
||||||
case SmartActions.RemoveUnitFlag:
|
case SmartActions.RemoveUnitFlag:
|
||||||
@@ -3135,6 +3141,9 @@ namespace Game.AI
|
|||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public BecomePersonalClone becomePersonalClone;
|
public BecomePersonalClone becomePersonalClone;
|
||||||
|
|
||||||
|
[FieldOffset(4)]
|
||||||
|
public TriggerGameEvent triggerGameEvent;
|
||||||
|
|
||||||
[FieldOffset(4)]
|
[FieldOffset(4)]
|
||||||
public Raw raw;
|
public Raw raw;
|
||||||
|
|
||||||
@@ -3668,6 +3677,11 @@ namespace Game.AI
|
|||||||
public uint type;
|
public uint type;
|
||||||
public uint duration;
|
public uint duration;
|
||||||
}
|
}
|
||||||
|
public struct TriggerGameEvent
|
||||||
|
{
|
||||||
|
public uint eventId;
|
||||||
|
public uint useSaiTargetAsGameEventSource;
|
||||||
|
}
|
||||||
public struct Raw
|
public struct Raw
|
||||||
{
|
{
|
||||||
public uint param1;
|
public uint param1;
|
||||||
|
|||||||
@@ -2467,6 +2467,19 @@ namespace Game.AI
|
|||||||
_timedActionList.RemoveAll(script => { return script.EventId > e.EventId; });
|
_timedActionList.RemoveAll(script => { return script.EventId > e.EventId; });
|
||||||
break;
|
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:
|
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;
|
||||||
|
|||||||
Reference in New Issue
Block a user