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