From 8858e58f46d9b2b833bfc73a2cf23bdf18105a64 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 17 Dec 2021 17:15:30 -0500 Subject: [PATCH] Core/SAI: add action_param3 to SMART_ACTION_REMOVEAURASFROMSPELL to allow it to remove only auras from spells that were cast by the entity itself. Port From (https://github.com/TrinityCore/TrinityCore/commit/d037c6b08634c5d0d4cc0462ae28e15baf8498bb) --- Source/Game/AI/SmartScripts/SmartAIManager.cs | 2 ++ Source/Game/AI/SmartScripts/SmartScript.cs | 22 ++++++++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Source/Game/AI/SmartScripts/SmartAIManager.cs b/Source/Game/AI/SmartScripts/SmartAIManager.cs index f29901dcd..546b2ccc6 100644 --- a/Source/Game/AI/SmartScripts/SmartAIManager.cs +++ b/Source/Game/AI/SmartScripts/SmartAIManager.cs @@ -2682,6 +2682,8 @@ namespace Game.AI public struct RemoveAura { public uint spell; + public uint charges; + public uint onlyOwnedAuras; } public struct Follow { diff --git a/Source/Game/AI/SmartScripts/SmartScript.cs b/Source/Game/AI/SmartScripts/SmartScript.cs index b10203596..2ea1154fa 100644 --- a/Source/Game/AI/SmartScripts/SmartScript.cs +++ b/Source/Game/AI/SmartScripts/SmartScript.cs @@ -779,10 +779,26 @@ namespace Game.AI if (!IsUnit(target)) continue; - if (e.Action.removeAura.spell == 0) - target.ToUnit().RemoveAllAuras(); - else + if (e.Action.removeAura.spell != 0) + { + ObjectGuid casterGUID = default; + if (e.Action.removeAura.onlyOwnedAuras != 0) + { + if (_me == null) + break; + casterGUID = _me.GetGUID(); + } + + if (e.Action.removeAura.charges != 0) + { + Aura aur = target.ToUnit().GetAura(e.Action.removeAura.spell, casterGUID); + if (aur != null) + aur.ModCharges(-(int)e.Action.removeAura.charges, AuraRemoveMode.Expire); + } target.ToUnit().RemoveAurasDueToSpell(e.Action.removeAura.spell); + } + else + target.ToUnit().RemoveAllAuras(); Log.outDebug(LogFilter.ScriptsAi, "SmartScript.ProcessAction: SMART_ACTION_REMOVEAURASFROMSPELL: Unit {0}, spell {1}", target.GetGUID().ToString(), e.Action.removeAura.spell);