Core/Spells: Fixed spell with SPELL_AURA_MECHANIC_IMMUNITY_MASK failing to cast if they were supposed to purge effect they are granting immunity to (CreatureImmunities was not checked)

This commit is contained in:
Shauren
2024-06-20 16:22:11 +02:00
parent 1479bb4607
commit e1e4aa7980
3 changed files with 62 additions and 79 deletions

View File

@@ -3608,11 +3608,9 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
continue;
if (!auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
{
if (uint32 schoolImmunity = immuneInfo->SchoolImmuneMask)
if ((auraSpellInfo->SchoolMask & schoolImmunity) != 0)
return true;
}
if (uint64 mechanicImmunity = immuneInfo->MechanicImmuneMask)
if ((mechanicImmunity & (UI64LIT(1) << auraSpellInfo->Mechanic)) != 0)
@@ -3625,48 +3623,25 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
bool immuneToAllEffects = true;
for (SpellEffectInfo const& auraSpellEffectInfo : auraSpellInfo->GetEffects())
{
if (!auraSpellEffectInfo.IsEffect())
if (!auraSpellEffectInfo.IsAura())
continue;
auto spellImmuneItr = immuneInfo->SpellEffectImmune.find(auraSpellEffectInfo.Effect);
if (spellImmuneItr == immuneInfo->SpellEffectImmune.end())
if (uint64 mechanicImmunity = immuneInfo->MechanicImmuneMask)
if ((mechanicImmunity & (UI64LIT(1) << auraSpellEffectInfo.Mechanic)) != 0)
continue;
if (AuraType auraName = auraSpellEffectInfo.ApplyAuraName)
{
immuneToAllEffects = false;
break;
if (immuneInfo->AuraTypeImmune.find(auraName) != immuneInfo->AuraTypeImmune.end())
continue;
if (!auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES) && !auraSpellInfo->IsPositiveEffect(auraSpellEffectInfo.EffectIndex))
if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
continue;
}
if (uint32 mechanic = auraSpellEffectInfo.Mechanic)
{
if (!(immuneInfo->MechanicImmuneMask & (UI64LIT(1) << mechanic)))
{
immuneToAllEffects = false;
break;
}
}
if (!auraSpellInfo->HasAttribute(SPELL_ATTR3_ALWAYS_HIT))
{
if (AuraType auraName = auraSpellEffectInfo.ApplyAuraName)
{
bool isImmuneToAuraEffectApply = false;
auto auraImmuneItr = immuneInfo->AuraTypeImmune.find(auraName);
if (auraImmuneItr != immuneInfo->AuraTypeImmune.end())
isImmuneToAuraEffectApply = true;
if (!isImmuneToAuraEffectApply && !auraSpellInfo->IsPositiveEffect(auraSpellEffectInfo.EffectIndex) && !auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
{
if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
isImmuneToAuraEffectApply = true;
}
if (!isImmuneToAuraEffectApply)
{
immuneToAllEffects = false;
break;
}
}
}
immuneToAllEffects = false;
}
if (immuneToAllEffects)
@@ -3676,6 +3651,41 @@ bool SpellInfo::CanSpellProvideImmunityAgainstAura(SpellInfo const* auraSpellInf
return false;
}
bool SpellInfo::CanSpellEffectProvideImmunityAgainstAuraEffect(SpellEffectInfo const& immunityEffectInfo, SpellInfo const* auraSpellInfo, SpellEffectInfo const& auraEffectInfo) const
{
SpellEffectInfo::ImmunityInfo const* immuneInfo = immunityEffectInfo.GetImmunityInfo();
if (!immuneInfo)
return false;
if (!auraSpellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
{
if (uint32 schoolImmunity = immuneInfo->SchoolImmuneMask)
if ((auraSpellInfo->SchoolMask & schoolImmunity) != 0)
return true;
if (uint32 applyHarmfulAuraImmunityMask = immuneInfo->ApplyHarmfulAuraImmuneMask)
if ((auraSpellInfo->GetSchoolMask() & applyHarmfulAuraImmunityMask) != 0)
return true;
}
if (uint64 mechanicImmunity = immuneInfo->MechanicImmuneMask)
{
if ((mechanicImmunity & (UI64LIT(1) << auraSpellInfo->Mechanic)) != 0)
return true;
if ((mechanicImmunity & (UI64LIT(1) << auraEffectInfo.Mechanic)) != 0)
return true;
}
if (uint32 dispelImmunity = immuneInfo->DispelImmuneMask)
if (auraSpellInfo->Dispel == dispelImmunity)
return true;
if (immuneInfo->AuraTypeImmune.find(auraEffectInfo.ApplyAuraName) != immuneInfo->AuraTypeImmune.end())
return true;
return false;
}
// based on client Spell_C::CancelsAuraEffect
bool SpellInfo::SpellCancelsAuraEffect(AuraEffect const* aurEff) const
{
@@ -3685,40 +3695,12 @@ bool SpellInfo::SpellCancelsAuraEffect(AuraEffect const* aurEff) const
if (aurEff->GetSpellInfo()->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
return false;
if (aurEff->GetSpellEffectInfo().EffectAttributes.HasFlag(SpellEffectAttributes::NoImmunity))
return false;
for (SpellEffectInfo const& effect : GetEffects())
{
if (!effect.IsEffect(SPELL_EFFECT_APPLY_AURA))
continue;
uint32 const miscValue = static_cast<uint32>(effect.MiscValue);
switch (effect.ApplyAuraName)
{
case SPELL_AURA_STATE_IMMUNITY:
if (miscValue != aurEff->GetAuraType())
continue;
break;
case SPELL_AURA_SCHOOL_IMMUNITY:
case SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL:
if (aurEff->GetSpellInfo()->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES) || !(aurEff->GetSpellInfo()->SchoolMask & miscValue))
continue;
break;
case SPELL_AURA_DISPEL_IMMUNITY:
if (miscValue != aurEff->GetSpellInfo()->Dispel)
continue;
break;
case SPELL_AURA_MECHANIC_IMMUNITY:
if (miscValue != aurEff->GetSpellInfo()->Mechanic)
{
if (miscValue != aurEff->GetSpellEffectInfo().Mechanic)
continue;
}
break;
default:
continue;
}
return true;
}
if (CanSpellEffectProvideImmunityAgainstAuraEffect(effect, aurEff->GetSpellInfo(), aurEff->GetSpellEffectInfo()))
return true;
return false;
}