Corrected immunity checking after recent changes

Port From (https://github.com/TrinityCore/TrinityCore/commit/36a4e008d08b4a7ec9d80e261f282b94171fb90f)
This commit is contained in:
hondacrx
2019-08-17 10:52:40 -04:00
parent d3cbe70f56
commit a44224564c
+19 -5
View File
@@ -1588,11 +1588,14 @@ namespace Game.Entities
if (immuneToAllEffects) //Return immune only if the target is immune to all spell effects. if (immuneToAllEffects) //Return immune only if the target is immune to all spell effects.
return true; return true;
uint schoolMask = (uint)spellInfo.GetSchoolMask();
if (schoolMask != 0)
{
uint schoolImmunityMask = 0; uint schoolImmunityMask = 0;
var schoolList = m_spellImmune[(int)SpellImmunity.School]; var schoolList = m_spellImmune[(int)SpellImmunity.School];
foreach (var pair in schoolList) foreach (var pair in schoolList)
{ {
if ((pair.Key & (uint)spellInfo.GetSchoolMask()) == 0) if ((pair.Key & schoolMask) == 0)
continue; continue;
SpellInfo immuneSpellInfo = Global.SpellMgr.GetSpellInfo(pair.Value); SpellInfo immuneSpellInfo = Global.SpellMgr.GetSpellInfo(pair.Value);
@@ -1601,8 +1604,9 @@ namespace Game.Entities
schoolImmunityMask |= pair.Key; schoolImmunityMask |= pair.Key;
} }
if (((SpellSchoolMask)schoolImmunityMask & spellInfo.GetSchoolMask()) == spellInfo.GetSchoolMask()) if ((schoolImmunityMask & schoolMask) == schoolMask)
return true; return true;
}
return false; return false;
} }
@@ -1681,6 +1685,9 @@ namespace Game.Entities
} }
public bool IsImmunedToDamage(SpellSchoolMask schoolMask) public bool IsImmunedToDamage(SpellSchoolMask schoolMask)
{ {
if (schoolMask == SpellSchoolMask.None)
return false;
// If m_immuneToSchool type contain this school type, IMMUNE damage. // If m_immuneToSchool type contain this school type, IMMUNE damage.
uint schoolImmunityMask = GetSchoolImmunityMask(); uint schoolImmunityMask = GetSchoolImmunityMask();
if (((SpellSchoolMask)schoolImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types if (((SpellSchoolMask)schoolImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
@@ -1706,17 +1713,24 @@ namespace Game.Entities
return false; return false;
uint schoolMask = (uint)spellInfo.GetSchoolMask(); uint schoolMask = (uint)spellInfo.GetSchoolMask();
if (schoolMask != 0)
{
// If m_immuneToSchool type contain this school type, IMMUNE damage. // If m_immuneToSchool type contain this school type, IMMUNE damage.
uint schoolImmunityMask = 0;
var schoolList = m_spellImmune[(int)SpellImmunity.School]; var schoolList = m_spellImmune[(int)SpellImmunity.School];
foreach (var pair in schoolList) foreach (var pair in schoolList)
if (Convert.ToBoolean(pair.Key & schoolMask) && !spellInfo.CanPierceImmuneAura(Global.SpellMgr.GetSpellInfo(pair.Value))) if (Convert.ToBoolean(pair.Key & schoolMask) && !spellInfo.CanPierceImmuneAura(Global.SpellMgr.GetSpellInfo(pair.Value)))
schoolImmunityMask |= pair.Key;
// // We need to be immune to all types
if ((schoolImmunityMask & schoolMask) == schoolMask)
return true; return true;
// If m_immuneToDamage type contain magic, IMMUNE damage. // If m_immuneToDamage type contain magic, IMMUNE damage.
var damageList = m_spellImmune[(int)SpellImmunity.Damage]; uint damageImmunityMask = GetDamageImmunityMask();
foreach (var immune in damageList) if ((damageImmunityMask & schoolMask) == schoolMask) // We need to be immune to all types
if (Convert.ToBoolean(immune.Key & schoolMask))
return true; return true;
}
return false; return false;
} }