Core/Spell: improved immunity logic for dispels

This commit is contained in:
hondacrx
2018-03-12 13:31:19 -04:00
parent 060bc0b7a8
commit 9af60df765
6 changed files with 24 additions and 24 deletions
+5 -5
View File
@@ -1709,7 +1709,7 @@ namespace Game.Entities
ForcedDespawn(msTimeToDespawn, forceRespawnTimer);
}
public override bool IsImmunedToSpell(SpellInfo spellInfo)
public override bool IsImmunedToSpell(SpellInfo spellInfo, Unit caster)
{
if (spellInfo == null)
return false;
@@ -1726,7 +1726,7 @@ namespace Game.Entities
if (effect == null || !effect.IsEffect())
continue;
if (!IsImmunedToSpellEffect(spellInfo, effect.EffectIndex))
if (!IsImmunedToSpellEffect(spellInfo, effect.EffectIndex, caster))
{
immunedToAllEffects = false;
break;
@@ -1735,10 +1735,10 @@ namespace Game.Entities
if (immunedToAllEffects)
return true;
return base.IsImmunedToSpell(spellInfo);
return base.IsImmunedToSpell(spellInfo, caster);
}
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index)
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index, Unit caster)
{
SpellEffectInfo effect = spellInfo.GetEffect(GetMap().GetDifficultyID(), index);
if (effect == null)
@@ -1749,7 +1749,7 @@ namespace Game.Entities
if (GetCreatureTemplate().CreatureType == CreatureType.Mechanical && effect.Effect == SpellEffectName.Heal)
return true;
return base.IsImmunedToSpellEffect(spellInfo, index);
return base.IsImmunedToSpellEffect(spellInfo, index, caster);
}
public bool isElite()
+2 -2
View File
@@ -3675,7 +3675,7 @@ namespace Game.Entities
return false;
}
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index)
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index, Unit caster)
{
SpellEffectInfo effect = spellInfo.GetEffect(GetMap().GetDifficultyID(), index);
if (effect == null || !effect.IsEffect())
@@ -3687,7 +3687,7 @@ namespace Game.Entities
if (effect.IsEffect(SpellEffectName.AttackMe))
return true;
return base.IsImmunedToSpellEffect(spellInfo, index);
return base.IsImmunedToSpellEffect(spellInfo, index, caster);
}
void RegenerateAll()
+2 -2
View File
@@ -153,7 +153,7 @@ namespace Game.Entities
AddObjectToRemoveList();
}
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index)
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index, Unit caster)
{
// @todo possibly all negative auras immune?
if (GetEntry() == 5925)
@@ -174,7 +174,7 @@ namespace Game.Entities
break;
}
return base.IsImmunedToSpellEffect(spellInfo, index);
return base.IsImmunedToSpellEffect(spellInfo, index, caster);
}
public uint GetSpell(byte slot = 0) { return m_spells[slot]; }
+10 -10
View File
@@ -747,13 +747,13 @@ namespace Game.Entities
// Parry
// For spells
// Resist
public SpellMissInfo SpellHitResult(Unit victim, SpellInfo spellInfo, bool CanReflect)
public SpellMissInfo SpellHitResult(Unit victim, SpellInfo spellInfo, bool canReflect = false)
{
if (spellInfo.HasAttribute(SpellAttr3.IgnoreHitResult))
return SpellMissInfo.None;
// Check for immune
if (victim.IsImmunedToSpell(spellInfo))
if (victim.IsImmunedToSpell(spellInfo, this))
return SpellMissInfo.Immune;
// Damage immunity is only checked if the spell has damage effects, this immunity must not prevent aura apply
@@ -775,7 +775,7 @@ namespace Game.Entities
return SpellMissInfo.Evade;
// Try victim reflect spell
if (CanReflect)
if (canReflect)
{
int reflectchance = victim.GetTotalAuraModifier(AuraType.ReflectSpells);
var mReflectSpellsSchool = victim.GetAuraEffectsByType(AuraType.ReflectSpellsSchool);
@@ -1546,7 +1546,7 @@ namespace Game.Entities
}
}
}
public virtual bool IsImmunedToSpell(SpellInfo spellInfo)
public virtual bool IsImmunedToSpell(SpellInfo spellInfo, Unit caster)
{
if (spellInfo == null)
return false;
@@ -1584,7 +1584,7 @@ namespace Game.Entities
if (effect == null)
continue;
if (!IsImmunedToSpellEffect(spellInfo, effect.EffectIndex))
if (!IsImmunedToSpellEffect(spellInfo, effect.EffectIndex, caster))
{
immuneToAllEffects = false;
break;
@@ -1601,7 +1601,7 @@ namespace Game.Entities
{
SpellInfo immuneSpellInfo = Global.SpellMgr.GetSpellInfo(pair.Value);
if (Convert.ToBoolean(pair.Key & (uint)spellInfo.GetSchoolMask())
&& !(immuneSpellInfo != null && immuneSpellInfo.IsPositive() && spellInfo.IsPositive())
&& !(immuneSpellInfo != null && immuneSpellInfo.IsPositive() && spellInfo.IsPositive() && IsFriendlyTo(caster))
&& !spellInfo.CanPierceImmuneAura(immuneSpellInfo))
return true;
}
@@ -1627,7 +1627,7 @@ namespace Game.Entities
return mask;
}
public virtual bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index)
public virtual bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index, Unit caster)
{
if (spellInfo == null)
return false;
@@ -1665,7 +1665,7 @@ namespace Game.Entities
var immuneAuraApply = GetAuraEffectsByType(AuraType.ModImmuneAuraApplySchool);
foreach (var auraEffect in immuneAuraApply)
if (Convert.ToBoolean(auraEffect.GetMiscValue() & (int)spellInfo.GetSchoolMask()) && // Check school
!spellInfo.IsPositiveEffect(index)) // Harmful
(!IsFriendlyTo(caster) || !spellInfo.IsPositiveEffect(index))) // Harmful
return true;
}
}
@@ -2904,14 +2904,14 @@ namespace Game.Entities
if (spellInfo == null)
return null;
if (target.IsImmunedToSpell(spellInfo))
if (target.IsImmunedToSpell(spellInfo, this))
return null;
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
{
if (!Convert.ToBoolean(effMask & (1 << i)))
continue;
if (target.IsImmunedToSpellEffect(spellInfo, i))
if (target.IsImmunedToSpellEffect(spellInfo, i, this))
effMask &= ~(uint)(1 << i);
}
+2 -2
View File
@@ -492,10 +492,10 @@ namespace Game.Spells
// check target immunities
for (byte effIndex = 0; effIndex < SpellConst.MaxEffects; ++effIndex)
{
if (unit.IsImmunedToSpellEffect(GetSpellInfo(), effIndex))
if (unit.IsImmunedToSpellEffect(GetSpellInfo(), effIndex, caster))
value &= (byte)~(1 << effIndex);
}
if (value == 0 || unit.IsImmunedToSpell(GetSpellInfo())
if (value == 0 || unit.IsImmunedToSpell(GetSpellInfo(), caster)
|| !CanBeAppliedOn(unit))
addUnit = false;
+3 -3
View File
@@ -1628,7 +1628,7 @@ namespace Game.Spells
// Check for effect immune skip if immuned
foreach (SpellEffectInfo effect in GetEffects())
if (effect != null && target.IsImmunedToSpellEffect(m_spellInfo, effect.EffectIndex))
if (effect != null && target.IsImmunedToSpellEffect(m_spellInfo, effect.EffectIndex, m_caster))
effectMask &= ~(uint)(1 << (int)effect.EffectIndex);
ObjectGuid targetGUID = target.GetGUID();
@@ -2102,14 +2102,14 @@ namespace Game.Spells
return SpellMissInfo.Evade;
// For delayed spells immunity may be applied between missile launch and hit - check immunity for that case
if (m_spellInfo.Speed != 0.0f && unit.IsImmunedToSpell(m_spellInfo))
if (m_spellInfo.Speed != 0.0f && unit.IsImmunedToSpell(m_spellInfo, m_caster))
return SpellMissInfo.Immune;
// disable effects to which unit is immune
SpellMissInfo returnVal = SpellMissInfo.Immune;
foreach (SpellEffectInfo effect in GetEffects())
if (effect != null && Convert.ToBoolean(effectMask & (1 << (int)effect.EffectIndex)))
if (unit.IsImmunedToSpellEffect(m_spellInfo, effect.EffectIndex))
if (unit.IsImmunedToSpellEffect(m_spellInfo, effect.EffectIndex, m_caster))
effectMask &= (uint)~(1 << (int)effect.EffectIndex);
if (effectMask == 0)