Scripts/SmartAI: Forward invoker to invoked action list actions. Also JustAppeared -> InitializeAI.
Port From (https://github.com/TrinityCore/TrinityCore/commit/1f26122528ad31a9dedbfcf5c1029cf750dfd1d4)
This commit is contained in:
@@ -565,7 +565,7 @@ namespace Game.AI
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void JustAppeared()
|
||||
public override void InitializeAI()
|
||||
{
|
||||
_despawnTime = 0;
|
||||
_respawnTime = 0;
|
||||
@@ -711,14 +711,6 @@ namespace Game.AI
|
||||
GetScript().ProcessEventsFor(apply ? SmartEvents.PassengerBoarded : SmartEvents.PassengerRemoved, passenger, (uint)seatId, 0, apply);
|
||||
}
|
||||
|
||||
public override void InitializeAI()
|
||||
{
|
||||
_script.OnInitialize(me);
|
||||
|
||||
if (!me.IsDead())
|
||||
GetScript().OnReset();
|
||||
}
|
||||
|
||||
public override void OnCharmed(bool apply)
|
||||
{
|
||||
if (apply) // do this before we change charmed state, as charmed state might prevent these things from processing
|
||||
@@ -893,9 +885,7 @@ namespace Game.AI
|
||||
|
||||
public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker)
|
||||
{
|
||||
if (invoker != null)
|
||||
GetScript().LastInvoker = invoker.GetGUID();
|
||||
GetScript().SetScript9(e, entry);
|
||||
GetScript().SetScript9(e, entry, invoker);
|
||||
}
|
||||
|
||||
public override void OnGameEvent(bool start, ushort eventId)
|
||||
@@ -1088,9 +1078,6 @@ namespace Game.AI
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
// call respawn event on reset
|
||||
GetScript().ProcessEventsFor(SmartEvents.Respawn);
|
||||
|
||||
GetScript().OnReset();
|
||||
}
|
||||
|
||||
@@ -1142,9 +1129,7 @@ namespace Game.AI
|
||||
|
||||
public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker)
|
||||
{
|
||||
if (invoker != null)
|
||||
GetScript().LastInvoker = invoker.GetGUID();
|
||||
GetScript().SetScript9(e, entry);
|
||||
GetScript().SetScript9(e, entry, invoker);
|
||||
}
|
||||
|
||||
public override void OnGameEvent(bool start, ushort eventId)
|
||||
@@ -1195,10 +1180,7 @@ namespace Game.AI
|
||||
|
||||
public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker)
|
||||
{
|
||||
if (invoker)
|
||||
GetScript().LastInvoker = invoker.GetGUID();
|
||||
|
||||
GetScript().SetScript9(e, entry);
|
||||
GetScript().SetScript9(e, entry, invoker);
|
||||
}
|
||||
|
||||
public SmartScript GetScript() { return _script; }
|
||||
|
||||
@@ -491,8 +491,8 @@ namespace Game.AI
|
||||
Log.outError(LogFilter.Sql, "SmartAIMgr: Entry {e.entryOrGuid} SourceType {e.GetScriptType()} Event {e.GetEventType()} Action {}e.GetActionType() has invoker target, but action does not provide any invoker!");
|
||||
// allow this to load for now
|
||||
// return false;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case SmartTargets.PlayerRange:
|
||||
case SmartTargets.Self:
|
||||
case SmartTargets.Victim:
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace Game.AI
|
||||
List<SmartScriptHolder> _events = new();
|
||||
List<SmartScriptHolder> _installEvents = new();
|
||||
List<SmartScriptHolder> _timedActionList = new();
|
||||
ObjectGuid mTimedActionListInvoker;
|
||||
Creature _me;
|
||||
ObjectGuid _meOrigGUID;
|
||||
GameObject _go;
|
||||
@@ -3638,9 +3639,12 @@ namespace Game.AI
|
||||
case SmartEvents.DistanceCreature:
|
||||
case SmartEvents.DistanceGameobject:
|
||||
{
|
||||
ProcessEvent(e);
|
||||
if (e.GetScriptType() == SmartScriptType.TimedActionlist)
|
||||
{
|
||||
Unit invoker9 = null;
|
||||
if (_me != null && !mTimedActionListInvoker.IsEmpty())
|
||||
invoker9 = Global.ObjAccessor.GetUnit(_me, mTimedActionListInvoker);
|
||||
ProcessEvent(e, invoker9);
|
||||
e.EnableTimed = false;//disable event if it is in an ActionList and was processed once
|
||||
foreach (var holder in _timedActionList)
|
||||
{
|
||||
@@ -3652,6 +3656,8 @@ namespace Game.AI
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
ProcessEvent(e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -3994,12 +4000,14 @@ namespace Game.AI
|
||||
return searcher.GetTarget();
|
||||
}
|
||||
|
||||
public void SetScript9(SmartScriptHolder e, uint entry)
|
||||
public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker)
|
||||
{
|
||||
_timedActionList.Clear();
|
||||
_timedActionList = Global.SmartAIMgr.GetScript((int)entry, SmartScriptType.TimedActionlist);
|
||||
if (_timedActionList.Empty())
|
||||
return;
|
||||
|
||||
mTimedActionListInvoker = invoker != null ? invoker.GetGUID() : ObjectGuid.Empty;
|
||||
int i = 0;
|
||||
foreach (var holder in _timedActionList.ToList())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user