diff options
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 55b3e88c34f..df5ac7816af 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -7212,6 +7212,9 @@ int32 Unit::SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const bool Unit::IsImmunedToDamage(SpellSchoolMask schoolMask) const { + if (schoolMask == SPELL_SCHOOL_MASK_NONE) + return false; + // If m_immuneToSchool type contain this school type, IMMUNE damage. uint32 schoolImmunityMask = GetSchoolImmunityMask(); if ((schoolImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types @@ -7237,18 +7240,24 @@ bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const if (spellInfo->HasAttribute(SPELL_ATTR1_UNAFFECTED_BY_SCHOOL_IMMUNE) || spellInfo->HasAttribute(SPELL_ATTR2_UNAFFECTED_BY_AURA_SCHOOL_IMMUNE)) return false; - uint32 schoolMask = spellInfo->GetSchoolMask(); - // If m_immuneToSchool type contain this school type, IMMUNE damage. - SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; - for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr) - if ((itr->first & schoolMask) && !spellInfo->CanPierceImmuneAura(sSpellMgr->GetSpellInfo(itr->second))) + if (uint32 schoolMask = spellInfo->GetSchoolMask()) + { + // If m_immuneToSchool type contain this school type, IMMUNE damage. + uint32 schoolImmunityMask = 0; + SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; + for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr) + if ((itr->first & schoolMask) && !spellInfo->CanPierceImmuneAura(sSpellMgr->GetSpellInfo(itr->second))) + schoolImmunityMask |= itr->first; + + // // We need to be immune to all types + if ((schoolImmunityMask & schoolMask) == schoolMask) return true; - // If m_immuneToDamage type contain magic, IMMUNE damage. - SpellImmuneContainer const& damageList = m_spellImmune[IMMUNITY_DAMAGE]; - for (auto itr = damageList.begin(); itr != damageList.end(); ++itr) - if ((itr->first & schoolMask) != 0) + // If m_immuneToDamage type contain magic, IMMUNE damage. + uint32 damageImmunityMask = GetDamageImmunityMask(); + if ((damageImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types return true; + } return false; } @@ -7298,22 +7307,24 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const if (immuneToAllEffects) //Return immune only if the target is immune to all spell effects. return true; - uint32 schoolImmunityMask = 0; - SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; - for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr) + if (uint32 schoolMask = spellInfo->GetSchoolMask()) { - if ((itr->first & spellInfo->GetSchoolMask()) == 0) - continue; + uint32 schoolImmunityMask = 0; + SpellImmuneContainer const& schoolList = m_spellImmune[IMMUNITY_SCHOOL]; + for (auto itr = schoolList.begin(); itr != schoolList.end(); ++itr) + { + if ((itr->first & schoolMask) == 0) + continue; - SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->second); - if (!(immuneSpellInfo && immuneSpellInfo->IsPositive() && spellInfo->IsPositive() && caster && IsFriendlyTo(caster))) - if (!spellInfo->CanPierceImmuneAura(immuneSpellInfo)) - schoolImmunityMask |= itr->first; + SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->second); + if (!(immuneSpellInfo && immuneSpellInfo->IsPositive() && spellInfo->IsPositive() && caster && IsFriendlyTo(caster))) + if (!spellInfo->CanPierceImmuneAura(immuneSpellInfo)) + schoolImmunityMask |= itr->first; + } + if ((schoolImmunityMask & schoolMask) == schoolMask) + return true; } - if ((schoolImmunityMask & spellInfo->GetSchoolMask()) == spellInfo->GetSchoolMask()) - return true; - return false; } |