From d12ae8cde2ec4ff39dfeeba94b70b2318a919633 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 23 Jun 2021 22:51:38 -0400 Subject: [PATCH] oops, now it builds (and a bonus refactor that annoyed me) Port From (https://github.com/TrinityCore/TrinityCore/commit/bd158f6c29581e08633c3971a130b0720f90b630) --- Source/Game/AI/SmartScripts/SmartAI.cs | 18 ++++++++-------- Source/Game/AI/SmartScripts/SmartScript.cs | 24 +++++++++++----------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartAI.cs b/Source/Game/AI/SmartScripts/SmartAI.cs index 272254d37..eb45275e0 100644 --- a/Source/Game/AI/SmartScripts/SmartAI.cs +++ b/Source/Game/AI/SmartScripts/SmartAI.cs @@ -567,6 +567,8 @@ namespace Game.AI public override void InitializeAI() { + GetScript().OnInitialize(me); + _despawnTime = 0; _respawnTime = 0; _despawnState = 0; @@ -574,11 +576,11 @@ namespace Game.AI me.SetVisible(true); - if (me.GetFaction() != me.GetCreatureTemplate().Faction) - me.RestoreFaction(); - - GetScript().OnReset(); - GetScript().ProcessEventsFor(SmartEvents.Respawn); + if (!me.IsDead()) + { + GetScript().ProcessEventsFor(SmartEvents.Respawn); + GetScript().OnReset(); + } _followGuid.Clear();//do not reset follower on Reset(), we need it after combat evade _followDist = 0; @@ -883,7 +885,7 @@ namespace Game.AI GetScript().ProcessEventsFor(SmartEvents.FollowCompleted, player); } - public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker) + public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker) { GetScript().SetScript9(e, entry, invoker); } @@ -1127,7 +1129,7 @@ namespace Game.AI GetScript().ProcessEventsFor(SmartEvents.DataSet, null, id, value); } - public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker) + public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker) { GetScript().SetScript9(e, entry, invoker); } @@ -1178,7 +1180,7 @@ namespace Game.AI GetScript().ProcessEventsFor(SmartEvents.AreatriggerOntrigger, unit); } - public void SetScript9(SmartScriptHolder e, uint entry, Unit invoker) + public void SetTimedActionList(SmartScriptHolder e, uint entry, Unit invoker) { GetScript().SetScript9(e, entry, invoker); } diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index 14df4ec9a..fb4f0a95a 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -1571,7 +1571,7 @@ namespace Game.AI if (creature != null) { if (IsSmart(creature)) - creature.GetAI().SetScript9(e, e.Action.timedActionList.id, GetLastInvoker()); + creature.GetAI().SetTimedActionList(e, e.Action.timedActionList.id, GetLastInvoker()); } else { @@ -1579,7 +1579,7 @@ namespace Game.AI if (go != null) { if (IsSmartGO(go)) - go.GetAI().SetScript9(e, e.Action.timedActionList.id, GetLastInvoker()); + go.GetAI().SetTimedActionList(e, e.Action.timedActionList.id, GetLastInvoker()); } else { @@ -1588,7 +1588,7 @@ namespace Game.AI { SmartAreaTriggerAI atSAI = areaTriggerTarget.GetAI(); if (atSAI != null) - atSAI.SetScript9(e, e.Action.timedActionList.id, GetLastInvoker()); + atSAI.SetTimedActionList(e, e.Action.timedActionList.id, GetLastInvoker()); } } } @@ -1672,7 +1672,7 @@ namespace Game.AI if (creature != null) { if (IsSmart(creature)) - creature.GetAI().SetScript9(e, randomId, GetLastInvoker()); + creature.GetAI().SetTimedActionList(e, randomId, GetLastInvoker()); } else { @@ -1680,7 +1680,7 @@ namespace Game.AI if (go != null) { if (IsSmartGO(go)) - go.GetAI().SetScript9(e, randomId, GetLastInvoker()); + go.GetAI().SetTimedActionList(e, randomId, GetLastInvoker()); } else { @@ -1689,7 +1689,7 @@ namespace Game.AI { SmartAreaTriggerAI atSAI = areaTriggerTarget.GetAI(); if (atSAI != null) - atSAI.SetScript9(e, randomId, GetLastInvoker()); + atSAI.SetTimedActionList(e, randomId, GetLastInvoker()); } } } @@ -1711,7 +1711,7 @@ namespace Game.AI if (creature != null) { if (IsSmart(creature)) - creature.GetAI().SetScript9(e, id, GetLastInvoker()); + creature.GetAI().SetTimedActionList(e, id, GetLastInvoker()); } else { @@ -1719,7 +1719,7 @@ namespace Game.AI if (go != null) { if (IsSmartGO(go)) - go.GetAI().SetScript9(e, id, GetLastInvoker()); + go.GetAI().SetTimedActionList(e, id, GetLastInvoker()); } else { @@ -1728,7 +1728,7 @@ namespace Game.AI { SmartAreaTriggerAI atSAI = areaTriggerTarget.GetAI(); if (atSAI != null) - atSAI.SetScript9(e, id, GetLastInvoker()); + atSAI.SetTimedActionList(e, id, GetLastInvoker()); } } } @@ -3641,10 +3641,10 @@ namespace Game.AI { if (e.GetScriptType() == SmartScriptType.TimedActionlist) { - Unit invoker9 = null; + Unit invoker = null; if (_me != null && !mTimedActionListInvoker.IsEmpty()) - invoker9 = Global.ObjAccessor.GetUnit(_me, mTimedActionListInvoker); - ProcessEvent(e, invoker9); + invoker = Global.ObjAccessor.GetUnit(_me, mTimedActionListInvoker); + ProcessEvent(e, invoker); e.EnableTimed = false;//disable event if it is in an ActionList and was processed once foreach (var holder in _timedActionList) {