From 7b0433c028b47d2af9692910b542253ca452882f Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 2 Jun 2025 14:03:36 -0400 Subject: [PATCH] Core/Auras: Allow some whitelisted spells to update effect values of non-passive auras when adding spell mods Port From (https://github.com/TrinityCore/TrinityCore/commit/3a19b8160d8e2c8f2c2b10380fcd3fe7468810e2) --- Source/Game/Spells/Auras/AuraEffect.cs | 61 +++++++++++++------------- Source/Game/Spells/SpellInfo.cs | 13 ++++++ 2 files changed, 43 insertions(+), 31 deletions(-) diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index f4c658cde..4631a1c52 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -461,56 +461,55 @@ namespace Game.Spells return; // reapply some passive spells after add/remove related spellmods // Warning: it is a dead loop if 2 auras each other amount-shouldn't happen - BitSet recalculateEffectMask = new(SpellConst.MaxEffects); + uint? recalculateEffectIndex = null; switch ((SpellModOp)GetMiscValue()) { case SpellModOp.Points: - recalculateEffectMask.SetAll(true); break; case SpellModOp.PointsIndex0: - recalculateEffectMask.Set(0, true); + recalculateEffectIndex = 0; break; case SpellModOp.PointsIndex1: - recalculateEffectMask.Set(1, true); + recalculateEffectIndex = 1; break; case SpellModOp.PointsIndex2: - recalculateEffectMask.Set(2, true); + recalculateEffectIndex = 2; break; case SpellModOp.PointsIndex3: - recalculateEffectMask.Set(3, true); + recalculateEffectIndex = 3; break; case SpellModOp.PointsIndex4: - recalculateEffectMask.Set(4, true); + recalculateEffectIndex = 4; break; default: - break; + return; } - if (recalculateEffectMask.Any()) - { - if (triggeredBy == null) - triggeredBy = this; + if (triggeredBy == null) + triggeredBy = this; - ObjectGuid guid = target.GetGUID(); - var auras = target.GetAppliedAuras(); - foreach (var iter in auras) + ObjectGuid guid = target.GetGUID(); + var auras = target.GetAppliedAuras(); + foreach (var (_, aurApp) in auras) + { + Aura aura = aurApp.GetBase(); + // only passive and permament auras-active auras should have amount set on spellcast and not be affected + // if aura is cast by others, it will not be affected + if ((!aura.IsPassive() && !aura.IsPermanent() && !GetSpellInfo().IsUpdatingTemporaryAuraValuesBySpellMod()) + || aura.GetCasterGUID() != guid || !aura.GetSpellInfo().IsAffectedBySpellMod(m_spellmod)) + continue; + + if (recalculateEffectIndex.HasValue) { - Aura aura = iter.Value.GetBase(); - // only passive and permament auras-active auras should have amount set on spellcast and not be affected - // if aura is cast by others, it will not be affected - if ((aura.IsPassive() || aura.IsPermanent()) && aura.GetCasterGUID() == guid && aura.GetSpellInfo().IsAffectedBySpellMod(m_spellmod)) - { - for (uint i = 0; i < recalculateEffectMask.Count; ++i) - { - if (recalculateEffectMask[(int)i]) - { - AuraEffect aurEff = aura.GetEffect(i); - if (aurEff != null) - if (aurEff != triggeredBy) - aurEff.RecalculateAmount(triggeredBy); - } - } - } + AuraEffect aurEff = aura.GetEffect(recalculateEffectIndex.Value); + if (aurEff != null && aurEff != triggeredBy) + aurEff.RecalculateAmount(triggeredBy); + } + else + { + foreach (AuraEffect aurEff in aura.GetAuraEffects()) + if (aurEff != triggeredBy) + aurEff.RecalculateAmount(triggeredBy); } } } diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index daacff3ca..511dace5c 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -677,6 +677,19 @@ namespace Game.Spells return false; } + public bool IsUpdatingTemporaryAuraValuesBySpellMod() + { + switch (Id) + { + case 384669: // Overflowing Maelstrom + return true; + default: + break; + } + + return false; + } + public bool CanPierceImmuneAura(SpellInfo auraSpellInfo) { // Dispels other auras on immunity, check if this spell makes the unit immune to aura