Fix immunity system for many spells.
This commit is contained in:
@@ -1643,7 +1643,20 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo)
|
|||||||
if (!spellInfo)
|
if (!spellInfo)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))
|
// Spells that don't have effectMechanics.
|
||||||
|
if (!spellInfo->HasAnyEffectMechanic() && GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// This check must be done instead of 'if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))' for not break
|
||||||
|
// the check of mechanic immunity on DB (tested) because GetCreatureInfo()->MechanicImmuneMask and m_spellImmune[IMMUNITY_MECHANIC] don't have same data.
|
||||||
|
bool immunedToAllEffects = true;
|
||||||
|
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||||
|
if (!IsImmunedToSpellEffect(spellInfo, i))
|
||||||
|
{
|
||||||
|
immunedToAllEffects = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (immunedToAllEffects)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return Unit::IsImmunedToSpell(spellInfo);
|
return Unit::IsImmunedToSpell(spellInfo);
|
||||||
|
|||||||
@@ -11448,7 +11448,8 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spellInfo->Mechanic)
|
// Spells that don't have effectMechanics.
|
||||||
|
if (!spellInfo->HasAnyEffectMechanic() && spellInfo->Mechanic)
|
||||||
{
|
{
|
||||||
SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
|
SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
|
||||||
for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
|
for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
|
||||||
@@ -11456,14 +11457,19 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
bool immuneToAllEffects = true;
|
||||||
|
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||||
{
|
{
|
||||||
// State/effect immunities applied by aura expect full spell immunity
|
// State/effect immunities applied by aura expect full spell immunity
|
||||||
// Ignore effects with mechanic, they are supposed to be checked separately
|
// Ignore effects with mechanic, they are supposed to be checked separately
|
||||||
if (!spellInfo->Effects[i].Mechanic)
|
if (spellInfo->Effects[i].Mechanic || !IsImmunedToSpellEffect(spellInfo, i))
|
||||||
if (IsImmunedToSpellEffect(spellInfo, i))
|
{
|
||||||
return true;
|
immuneToAllEffects = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (immuneToAllEffects) //Return immune only if the target is immune to all spell effects.
|
||||||
|
return true;
|
||||||
|
|
||||||
if (spellInfo->Id != 42292 && spellInfo->Id !=59752)
|
if (spellInfo->Id != 42292 && spellInfo->Id !=59752)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1562,7 +1562,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, const uint32 effectMask, bool
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
|
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
|
||||||
if (effectMask & (1 << effectNumber))
|
if (effectMask & (1 << effectNumber) && !unit->IsImmunedToSpellEffect(m_spellInfo, effectNumber)) //Handle effect only if the target isn't immune.
|
||||||
HandleEffects(unit, NULL, NULL, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
|
HandleEffects(unit, NULL, NULL, effectNumber, SPELL_EFFECT_HANDLE_HIT_TARGET);
|
||||||
|
|
||||||
return SPELL_MISS_NONE;
|
return SPELL_MISS_NONE;
|
||||||
|
|||||||
@@ -1755,6 +1755,14 @@ Mechanics SpellInfo::GetEffectMechanic(uint8 effIndex) const
|
|||||||
return MECHANIC_NONE;
|
return MECHANIC_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SpellInfo::HasAnyEffectMechanic() const
|
||||||
|
{
|
||||||
|
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||||
|
if (Effects[i].Mechanic)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
uint32 SpellInfo::GetDispelMask() const
|
uint32 SpellInfo::GetDispelMask() const
|
||||||
{
|
{
|
||||||
return GetDispelMask(DispelType(Dispel));
|
return GetDispelMask(DispelType(Dispel));
|
||||||
|
|||||||
@@ -446,6 +446,7 @@ public:
|
|||||||
uint32 GetEffectMechanicMask(uint8 effIndex) const;
|
uint32 GetEffectMechanicMask(uint8 effIndex) const;
|
||||||
uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const;
|
uint32 GetSpellMechanicMaskByEffectMask(uint32 effectMask) const;
|
||||||
Mechanics GetEffectMechanic(uint8 effIndex) const;
|
Mechanics GetEffectMechanic(uint8 effIndex) const;
|
||||||
|
bool HasAnyEffectMechanic() const;
|
||||||
uint32 GetDispelMask() const;
|
uint32 GetDispelMask() const;
|
||||||
static uint32 GetDispelMask(DispelType type);
|
static uint32 GetDispelMask(DispelType type);
|
||||||
uint32 GetExplicitTargetMask() const;
|
uint32 GetExplicitTargetMask() const;
|
||||||
|
|||||||
Reference in New Issue
Block a user