internal bool IsImmuneToSpellSchool(SpellSchoolMask schoolMask, SpellInfo spellInfo, Unit caster) { if (schoolMask != 0) { SpellSchoolMask immunedSchools = 0; foreach (var schoolImmunityEntry in schoolImmunities) { if (!schoolImmunityEntry.Key.HasAnyFlag(spellInfo.SchoolMask)) { continue; } foreach (SpellInfo immunitySpells in schoolImmunityEntry.Value) { if (!immunitySpells.IsPositive || !spellInfo.IsPositive || caster != null && !unit.IsFriendlyTo(caster)) { if (!spellInfo.CanPierceImmuneAura(immunitySpells)) { immunedSchools |= schoolImmunityEntry.Key; } } } } if (immunedSchools.HasTargetFlag(spellInfo.SchoolMask)) { return(true); } } return(false); }
internal bool IsImmuneToSpell(SpellInfo spellInfo, Unit caster) { if (spellInfo.HasAttribute(SpellAttributes.UnaffectedByInvulnerability)) { return(false); } if (spellInfo.SchoolMask != 0) { SpellSchoolMask immunedSchools = 0; foreach (var schoolImmunityEntry in schoolImmunities) { if (!schoolImmunityEntry.Key.HasAnyFlag(spellInfo.SchoolMask)) { continue; } foreach (SpellInfo immunitySpells in schoolImmunityEntry.Value) { if (!immunitySpells.IsPositive || !spellInfo.IsPositive || !unit.IsFriendlyTo(caster)) { if (!spellInfo.CanPierceImmuneAura(immunitySpells)) { immunedSchools |= schoolImmunityEntry.Key; } } } } if (immunedSchools.HasTargetFlag(spellInfo.SchoolMask)) { return(true); } } bool isImmuneToAllEffects = true; foreach (SpellEffectInfo spellEffectInfo in spellInfo.Effects) { if (!IsImmuneToSpellEffect(spellEffectInfo, caster)) { isImmuneToAllEffects = false; break; } } if (isImmuneToAllEffects) { return(true); } return(false); }