fix(Core/Spell): Make use of SPELL_ATTR2_NO_SCHOOL_IMMUNITIES (#5880)

This commit is contained in:
Kitzunu
2021-07-31 15:31:00 +02:00
committed by GitHub
parent 19bbe2cd79
commit 87b2cd1299
2 changed files with 50 additions and 21 deletions
+28 -9
View File
@@ -12147,8 +12147,20 @@ bool Unit::IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const
bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const
{ {
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) if (!spellInfo)
{
return false; return false;
}
if (spellInfo->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && !HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
{
return false;
}
if (spellInfo->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS) || spellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
{
return false;
}
uint32 schoolMask = spellInfo->GetSchoolMask(); uint32 schoolMask = spellInfo->GetSchoolMask();
// If m_immuneToDamage type contain magic, IMMUNE damage. // If m_immuneToDamage type contain magic, IMMUNE damage.
@@ -12314,14 +12326,21 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
if (itr->blockType == SPELL_BLOCK_TYPE_ALL || spellInfo->IsPositive()) // xinef: added for pet scaling if (itr->blockType == SPELL_BLOCK_TYPE_ALL || spellInfo->IsPositive()) // xinef: added for pet scaling
return true; return true;
// Check for immune to application of harmful magical effects if (!spellInfo->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
AuraEffectList const& immuneAuraApply = GetAuraEffectsByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL); {
for (AuraEffectList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter) // Check for immune to application of harmful magical effects
if (/*(spellInfo->Dispel == DISPEL_MAGIC || spellInfo->Dispel == DISPEL_CURSE || spellInfo->Dispel == DISPEL_DISEASE) &&*/ // Magic debuff, xinef: all kinds? AuraEffectList const& immuneAuraApply = GetAuraEffectsByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL);
((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school for (AuraEffectList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter)
!spellInfo->IsPositiveEffect(index) && // Harmful {
spellInfo->Effects[index].Effect != SPELL_EFFECT_PERSISTENT_AREA_AURA) // Not Persistent area auras if (/*(spellInfo->Dispel == DISPEL_MAGIC || spellInfo->Dispel == DISPEL_CURSE || spellInfo->Dispel == DISPEL_DISEASE) &&*/ // Magic debuff, xinef: all kinds?
return true; ((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school
!spellInfo->IsPositiveEffect(index) && // Harmful
spellInfo->Effects[index].Effect != SPELL_EFFECT_PERSISTENT_AREA_AURA) // Not Persistent area auras
{
return true;
}
}
}
} }
return false; return false;
+22 -12
View File
@@ -1289,15 +1289,27 @@ bool SpellInfo::IsAffectedBySpellMod(SpellModifier const* mod) const
bool SpellInfo::CanPierceImmuneAura(SpellInfo const* aura) const bool SpellInfo::CanPierceImmuneAura(SpellInfo const* aura) const
{ {
// aura can't be pierced
if (!aura || aura->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
{
return false;
}
// these spells pierce all avalible spells (Resurrection Sickness for example) // these spells pierce all avalible spells (Resurrection Sickness for example)
if (HasAttribute(SPELL_ATTR0_NO_IMMUNITIES)) if (HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
return true; return true;
// these spells (Cyclone for example) can pierce all... // these spells (Cyclone for example) can pierce all...
if ((AttributesEx & SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS) if (HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS) || HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
// ...but not these (Divine shield for example) // xinef: banish exception, banish can override banish to cancel itself {
&& !(aura && (aura->Mechanic == MECHANIC_IMMUNE_SHIELD || aura->Mechanic == MECHANIC_INVULNERABILITY || (aura->Mechanic == MECHANIC_BANISH && (Mechanic != MECHANIC_BANISH || !(AttributesEx2 & SPELL_ATTR2_CANNOT_CAST_ON_TAPPED)))))) if (aura->Mechanic != MECHANIC_IMMUNE_SHIELD &&
return true; aura->Mechanic != MECHANIC_INVULNERABILITY &&
aura->Mechanic != MECHANIC_BANISH)
{
return true;
}
}
return false; return false;
} }
@@ -1308,22 +1320,20 @@ bool SpellInfo::CanDispelAura(SpellInfo const* aura) const
if (aura->IsPassive()) if (aura->IsPassive())
return false; return false;
// Xinef: At frist we check non-player auras, that should be never dispellable // These auras (like Divine Shield) can't be dispelled
// Xinef: Eg. Mark of the Fallen Champion if (aura->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
if (aura->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES) && aura->SpellFamilyName == SPELLFAMILY_GENERIC)
return false; return false;
// These spells (like Mass Dispel) can dispell all auras // These spells (like Mass Dispel) can dispell all auras
if (HasAttribute(SPELL_ATTR0_NO_IMMUNITIES)) if (HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
return true; return true;
// These auras (like Divine Shield) can't be dispelled
if (aura->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES))
return false;
// These auras (Cyclone for example) are not dispelable // These auras (Cyclone for example) are not dispelable
if (aura->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS)) if ((aura->HasAttribute(SPELL_ATTR1_IMMUNITY_TO_HOSTILE_AND_FRIENDLY_EFFECTS) && aura->Mechanic != MECHANIC_NONE)
|| aura->HasAttribute(SPELL_ATTR2_NO_SCHOOL_IMMUNITIES))
{
return false; return false;
}
return true; return true;
} }