diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-01-04 20:44:05 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-01-04 20:44:05 +0100 |
commit | 3a19b8160d8e2c8f2c2b10380fcd3fe7468810e2 (patch) | |
tree | ad88ca442be895eb808ebcf42fdc2f6debf2128e | |
parent | c9099c87567ead635811ef71b990ae7f19103509 (diff) |
Core/Auras: Allow some whitelisted spells to update effect values of non-passive auras when adding spell mods
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 49 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 13 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.h | 1 |
3 files changed, 40 insertions, 23 deletions
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 7a245e77d1a..5425afe4bc3 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -1168,50 +1168,53 @@ void AuraEffect::ApplySpellMod(Unit* target, bool apply, AuraEffect const* trigg // reapply some passive spells after add/remove related spellmods // Warning: it is a dead loop if 2 auras each other amount-shouldn't happen - std::bitset<MAX_SPELL_EFFECTS> recalculateEffectMask; + Optional<SpellEffIndex> recalculateEffectIndex; switch (SpellModOp(GetMiscValue())) { case SpellModOp::Points: - recalculateEffectMask.set(); break; case SpellModOp::PointsIndex0: - recalculateEffectMask.set(EFFECT_0); + recalculateEffectIndex = EFFECT_0; break; case SpellModOp::PointsIndex1: - recalculateEffectMask.set(EFFECT_1); + recalculateEffectIndex = EFFECT_1; break; case SpellModOp::PointsIndex2: - recalculateEffectMask.set(EFFECT_2); + recalculateEffectIndex = EFFECT_2; break; case SpellModOp::PointsIndex3: - recalculateEffectMask.set(EFFECT_3); + recalculateEffectIndex = EFFECT_3; break; case SpellModOp::PointsIndex4: - recalculateEffectMask.set(EFFECT_4); + recalculateEffectIndex = EFFECT_4; break; default: - break; + return; } - if (recalculateEffectMask.any()) + if (!triggeredBy) + triggeredBy = this; + + ObjectGuid guid = target->GetGUID(); + for (auto& [_, aurApp] : target->GetAppliedAuras()) { - if (!triggeredBy) - triggeredBy = this; + 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; - ObjectGuid guid = target->GetGUID(); - Unit::AuraApplicationMap& auras = target->GetAppliedAuras(); - for (auto iter = auras.begin(); iter != auras.end(); ++iter) + if (recalculateEffectIndex) { - Aura* aura = iter->second->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 (size_t i = 0; i < recalculateEffectMask.size(); ++i) - if (recalculateEffectMask[i]) - if (AuraEffect* aurEff = aura->GetEffect(i)) - if (aurEff != triggeredBy) - aurEff->RecalculateAmount(triggeredBy); + if (AuraEffect* aurEff = aura->GetEffect(*recalculateEffectIndex)) + if (aurEff != triggeredBy) + aurEff->RecalculateAmount(triggeredBy); } + else + for (AuraEffect* aurEff : aura->GetAuraEffects()) + if (aurEff != triggeredBy) + aurEff->RecalculateAmount(triggeredBy); } } diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 7b93cce27e1..8cc089c5ee7 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1881,6 +1881,19 @@ bool SpellInfo::IsAffectedBySpellMod(SpellModifier const* mod) const return false; } +bool SpellInfo::IsUpdatingTemporaryAuraValuesBySpellMod() const +{ + switch (Id) + { + case 384669: // Overflowing Maelstrom + return true; + default: + break; + } + + return false; +} + bool SpellInfo::CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const { // Dispels other auras on immunity, check if this spell makes the unit immune to aura diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 6dc47a1902d..8ecbd0b7ca5 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -516,6 +516,7 @@ class TC_GAME_API SpellInfo bool IsAffectedBySpellMods() const; bool IsAffectedBySpellMod(SpellModifier const* mod) const; + bool IsUpdatingTemporaryAuraValuesBySpellMod() const; bool CanPierceImmuneAura(SpellInfo const* auraSpellInfo) const; bool CanDispelAura(SpellInfo const* auraSpellInfo) const; |