Core/SAI: don't allow to start a new SAI actionlist while the entity is already running one.

Port From (https://github.com/TrinityCore/TrinityCore/commit/e846d4c3ef04d75839325409df109156d8ccced0)
This commit is contained in:
hondacrx
2021-12-22 20:09:35 -05:00
parent 47ddf51999
commit 2cbed03883
2 changed files with 18 additions and 15 deletions
+3 -3
View File
@@ -907,7 +907,7 @@ namespace Game.AI
public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker)
{
GetScript().SetScript9(e, entry, invoker);
GetScript().SetTimedActionList(e, entry, invoker);
}
public override void OnGameEvent(bool start, ushort eventId)
@@ -1156,7 +1156,7 @@ namespace Game.AI
public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker)
{
GetScript().SetScript9(e, entry, invoker);
GetScript().SetTimedActionList(e, entry, invoker);
}
public override void OnGameEvent(bool start, ushort eventId)
@@ -1217,7 +1217,7 @@ namespace Game.AI
public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker)
{
GetScript().SetScript9(e, entry, invoker);
GetScript().SetTimedActionList(e, entry, invoker);
}
public SmartScript GetScript() { return _script; }
+15 -12
View File
@@ -4161,28 +4161,31 @@ namespace Game.AI
return searcher.GetTarget();
}
public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker)
public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker)
{
// Do NOT allow to start a new actionlist if a previous one is already running, unless explicitly allowed. We need to always finish the current actionlist
if (!_timedActionList.Empty())
return;
_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())
for (var i = 0; i < _timedActionList.Count; ++i)
{
if (i++ == 0)
{
holder.EnableTimed = true;//enable processing only for the first action
}
else holder.EnableTimed = false;
var scriptHolder = _timedActionList[i];
scriptHolder.EnableTimed = i == 0;//enable processing only for the first action
if (e.Action.timedActionList.timerType == 1)
holder.Event.type = SmartEvents.UpdateIc;
if (e.Action.timedActionList.timerType == 0)
scriptHolder.Event.type = SmartEvents.UpdateOoc;
else if (e.Action.timedActionList.timerType == 1)
scriptHolder.Event.type = SmartEvents.UpdateIc;
else if (e.Action.timedActionList.timerType > 1)
holder.Event.type = SmartEvents.Update;
InitTimer(holder);
scriptHolder.Event.type = SmartEvents.Update;
InitTimer(scriptHolder);
}
}