Corrected immunity checking after recent changes
Port From (https://github.com/TrinityCore/TrinityCore/commit/36a4e008d08b4a7ec9d80e261f282b94171fb90f)
This commit is contained in:
@@ -1588,22 +1588,26 @@ 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 schoolImmunityMask = 0;
|
uint schoolMask = (uint)spellInfo.GetSchoolMask();
|
||||||
var schoolList = m_spellImmune[(int)SpellImmunity.School];
|
if (schoolMask != 0)
|
||||||
foreach (var pair in schoolList)
|
|
||||||
{
|
{
|
||||||
if ((pair.Key & (uint)spellInfo.GetSchoolMask()) == 0)
|
uint schoolImmunityMask = 0;
|
||||||
continue;
|
var schoolList = m_spellImmune[(int)SpellImmunity.School];
|
||||||
|
foreach (var pair in schoolList)
|
||||||
|
{
|
||||||
|
if ((pair.Key & schoolMask) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
SpellInfo immuneSpellInfo = Global.SpellMgr.GetSpellInfo(pair.Value);
|
SpellInfo immuneSpellInfo = Global.SpellMgr.GetSpellInfo(pair.Value);
|
||||||
if (!(immuneSpellInfo != null && immuneSpellInfo.IsPositive() && spellInfo.IsPositive() && caster && IsFriendlyTo(caster)))
|
if (!(immuneSpellInfo != null && immuneSpellInfo.IsPositive() && spellInfo.IsPositive() && caster && IsFriendlyTo(caster)))
|
||||||
if (!spellInfo.CanPierceImmuneAura(immuneSpellInfo))
|
if (!spellInfo.CanPierceImmuneAura(immuneSpellInfo))
|
||||||
schoolImmunityMask |= pair.Key;
|
schoolImmunityMask |= pair.Key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((schoolImmunityMask & schoolMask) == schoolMask)
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((SpellSchoolMask)schoolImmunityMask & spellInfo.GetSchoolMask()) == spellInfo.GetSchoolMask())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public uint GetSchoolImmunityMask()
|
public uint GetSchoolImmunityMask()
|
||||||
@@ -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 m_immuneToSchool type contain this school type, IMMUNE damage.
|
if (schoolMask != 0)
|
||||||
var schoolList = m_spellImmune[(int)SpellImmunity.School];
|
{
|
||||||
foreach (var pair in schoolList)
|
// If m_immuneToSchool type contain this school type, IMMUNE damage.
|
||||||
if (Convert.ToBoolean(pair.Key & schoolMask) && !spellInfo.CanPierceImmuneAura(Global.SpellMgr.GetSpellInfo(pair.Value)))
|
uint schoolImmunityMask = 0;
|
||||||
|
var schoolList = m_spellImmune[(int)SpellImmunity.School];
|
||||||
|
foreach (var pair in schoolList)
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user