Core/Auras: Allow some whitelisted spells to update effect values of non-passive auras when adding spell mods

This commit is contained in:
Shauren
2025-01-04 20:44:05 +01:00
parent c9099c8756
commit 3a19b8160d
3 changed files with 41 additions and 24 deletions

View File

@@ -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;
if (!triggeredBy)
triggeredBy = this;
ObjectGuid guid = target->GetGUID();
Unit::AuraApplicationMap& auras = target->GetAppliedAuras();
for (auto iter = auras.begin(); iter != auras.end(); ++iter)
ObjectGuid guid = target->GetGUID();
for (auto& [_, aurApp] : target->GetAppliedAuras())
{
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)
{
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);
}
}

View File

@@ -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

View File

@@ -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;