diff options
author | xinef1 <w.szyszko2@gmail.com> | 2017-02-05 16:36:42 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2019-07-21 21:06:54 +0200 |
commit | 36a4e008d08b4a7ec9d80e261f282b94171fb90f (patch) | |
tree | 0be58695de35adab2f3a25b14660577e36eb1dac | |
parent | fe63cd3dbb66f4fda743858db4284a24bc2bd400 (diff) |
Corrected immunity checking after recent changes (#19049)
- Shouldn't compare immunity to spells without schoolmask
(cherrypicked from 78a729b6a4f1643eea7120da87a5a10f268dd3c3)
-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; } |