From c34fe71311507be02ab9faec16fa013310754d56 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Thu, 17 Feb 2022 17:02:50 -0500 Subject: [PATCH] Core/SAI: Allow SMART_TARGET_ACTION_INVOKER to target GameObjects Port From (https://github.com/TrinityCore/TrinityCore/commit/a947ee191276578d9bfa23e2f678574e5f5fa5a0) --- Source/Game/AI/SmartScripts/SmartScript.cs | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index a6c3b2fb9..24946dcfa 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -130,7 +130,7 @@ namespace Game.AI if (tempInvoker != null) Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction: Invoker: {0} (guidlow: {1})", tempInvoker.GetName(), tempInvoker.GetGUID().ToString()); - var targets = GetTargets(e, unit); + var targets = GetTargets(e, unit != null ? unit : gob); switch (e.GetActionType()) { @@ -2631,14 +2631,17 @@ namespace Game.AI return script; } - List GetTargets(SmartScriptHolder e, Unit invoker = null) + List GetTargets(SmartScriptHolder e, WorldObject invoker = null) { - Unit scriptTrigger = null; - Unit tempLastInvoker = GetLastInvoker(); + WorldObject scriptTrigger = null; if (invoker != null) scriptTrigger = invoker; - else if (tempLastInvoker != null) - scriptTrigger = tempLastInvoker; + else + { + Unit tempLastInvoker = GetLastInvoker(); + if (tempLastInvoker != null) + scriptTrigger = tempLastInvoker; + } WorldObject baseObject = GetBaseObject(); @@ -2734,8 +2737,8 @@ namespace Game.AI targets.Add(scriptTrigger); break; case SmartTargets.ActionInvokerVehicle: - if (scriptTrigger != null && scriptTrigger.GetVehicle() != null && scriptTrigger.GetVehicle().GetBase() != null) - targets.Add(scriptTrigger.GetVehicle().GetBase()); + if (scriptTrigger != null && scriptTrigger.ToUnit()?.GetVehicle() != null && scriptTrigger.ToUnit().GetVehicle().GetBase() != null) + targets.Add(scriptTrigger.ToUnit().GetVehicle().GetBase()); break; case SmartTargets.InvokerParty: if (scriptTrigger != null) @@ -3375,7 +3378,7 @@ namespace Game.AI (e.Event.spellHit.school == 0 || Convert.ToBoolean((uint)spell.SchoolMask & e.Event.spellHit.school))) { RecalcTimer(e, e.Event.spellHit.cooldownMin, e.Event.spellHit.cooldownMax); - ProcessAction(e, unit, 0, 0, bvar, spell); + ProcessAction(e, unit, 0, 0, bvar, spell, gob); } break; }