Core/Auras: Improve aura interactions with immunities on spell effect level

Port From (https://github.com/TrinityCore/TrinityCore/commit/66b03acc47665cd79646096e13aa8c6b513675aa)
This commit is contained in:
hondacrx
2022-09-07 15:22:28 -04:00
parent 9abe7f8ad6
commit 7357a98adc
7 changed files with 140 additions and 89 deletions
+14 -4
View File
@@ -2439,13 +2439,23 @@ namespace Game.Spells
if (Convert.ToBoolean(mechanicImmunity & (1 << (int)i)))
target.ApplySpellImmune(Id, SpellImmunity.Mechanic, i, apply);
if (apply && HasAttribute(SpellAttr1.ImmunityPurgesEffect))
if (HasAttribute(SpellAttr1.ImmunityPurgesEffect))
{
// exception for purely snare mechanic (eg. hands of freedom)!
if (mechanicImmunity == (1 << (int)Mechanics.Snare))
target.RemoveMovementImpairingAuras(false);
else
if (apply)
target.RemoveAurasWithMechanic(mechanicImmunity, AuraRemoveMode.Default, Id);
else
{
target.RemoveAppliedAuras(aurApp =>
{
Aura aura = aurApp.GetBase();
if ((aura.GetSpellInfo().GetAllEffectsMechanicMask() & mechanicImmunity) != 0)
aura.UpdateTargetMap(aura.GetCaster());
// only update targets, don't remove anything
return false;
});
}
}
}