Core/Spell: improved immunity logic for dispels
This commit is contained in:
1 parent
307b736768
commit
6e62130e96
10 files changed
+36
-36
No files matched your search
@@ -1873,7 +1873,7 @@ void Creature::LoadMechanicTemplateImmunity()
|
||||
}
|
||||
}
|
||||
|
||||
bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
|
||||
bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
|
||||
{
|
||||
if (!spellInfo)
|
||||
return false;
|
||||
@@ -1883,7 +1883,7 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
|
||||
{
|
||||
if (!spellInfo->Effects[i].IsEffect())
|
||||
continue;
|
||||
if (!IsImmunedToSpellEffect(spellInfo, i))
|
||||
if (!IsImmunedToSpellEffect(spellInfo, i, caster))
|
||||
{
|
||||
immunedToAllEffects = false;
|
||||
break;
|
||||
@@ -1892,15 +1892,15 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
|
||||
if (immunedToAllEffects)
|
||||
return true;
|
||||
|
||||
return Unit::IsImmunedToSpell(spellInfo);
|
||||
return Unit::IsImmunedToSpell(spellInfo, caster);
|
||||
}
|
||||
|
||||
bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
|
||||
bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const
|
||||
{
|
||||
if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && spellInfo->Effects[index].Effect == SPELL_EFFECT_HEAL)
|
||||
return true;
|
||||
|
||||
return Unit::IsImmunedToSpellEffect(spellInfo, index);
|
||||
return Unit::IsImmunedToSpellEffect(spellInfo, index, caster);
|
||||
}
|
||||
|
||||
bool Creature::isElite() const
|
||||
|
||||
@@ -497,8 +497,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
bool isCanTrainingAndResetTalentsOf(Player* player) const;
|
||||
bool CanCreatureAttack(Unit const* victim, bool force = true) const;
|
||||
void LoadMechanicTemplateImmunity();
|
||||
bool IsImmunedToSpell(SpellInfo const* spellInfo) const override; // override Unit::IsImmunedToSpell
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override; // override Unit::IsImmunedToSpellEffect
|
||||
bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const override;
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
|
||||
bool isElite() const;
|
||||
bool isWorldBoss() const;
|
||||
|
||||
|
||||
@@ -2225,7 +2225,7 @@ void Player::SetObjectScale(float scale)
|
||||
SendMovementSetCollisionHeight(scale * GetCollisionHeight(IsMounted()));
|
||||
}
|
||||
|
||||
bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
|
||||
bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const
|
||||
{
|
||||
// players are immune to taunt (the aura and the spell effect)
|
||||
if (spellInfo->Effects[index].IsAura(SPELL_AURA_MOD_TAUNT))
|
||||
@@ -2233,7 +2233,7 @@ bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) co
|
||||
if (spellInfo->Effects[index].IsEffect(SPELL_EFFECT_ATTACK_ME))
|
||||
return true;
|
||||
|
||||
return Unit::IsImmunedToSpellEffect(spellInfo, index);
|
||||
return Unit::IsImmunedToSpellEffect(spellInfo, index, caster);
|
||||
}
|
||||
|
||||
void Player::RegenerateAll()
|
||||
|
||||
@@ -1243,7 +1243,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
|
||||
|
||||
static bool BuildEnumData(PreparedQueryResult result, ByteBuffer* dataBuffer, ByteBuffer* bitBuffer);
|
||||
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
|
||||
|
||||
void SetInWater(bool apply);
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ void Totem::UnSummon(uint32 msTime)
|
||||
AddObjectToRemoveList();
|
||||
}
|
||||
|
||||
bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
|
||||
bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const
|
||||
{
|
||||
/// @todo possibly all negative auras immune?
|
||||
if (GetEntry() == 5925)
|
||||
@@ -160,5 +160,5 @@ bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) con
|
||||
break;
|
||||
}
|
||||
|
||||
return Creature::IsImmunedToSpellEffect(spellInfo, index);
|
||||
return Creature::IsImmunedToSpellEffect(spellInfo, index, caster);
|
||||
}
|
||||
@@ -58,7 +58,7 @@ class TC_GAME_API Totem : public Minion
|
||||
void UpdateAttackPowerAndDamage(bool /*ranged*/) override { }
|
||||
void UpdateDamagePhysical(WeaponAttackType /*attType*/) override { }
|
||||
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override;
|
||||
bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
|
||||
|
||||
protected:
|
||||
TotemType m_type;
|
||||
|
||||
@@ -2589,13 +2589,13 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo
|
||||
// Parry
|
||||
// For spells
|
||||
// Resist
|
||||
SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool CanReflect)
|
||||
SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool canReflect /*= false*/)
|
||||
{
|
||||
if (spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT))
|
||||
return SPELL_MISS_NONE;
|
||||
|
||||
// Check for immune
|
||||
if (victim->IsImmunedToSpell(spellInfo))
|
||||
if (victim->IsImmunedToSpell(spellInfo, this))
|
||||
return SPELL_MISS_IMMUNE;
|
||||
|
||||
// Damage immunity is only checked if the spell has damage effects, this immunity must not prevent aura apply
|
||||
@@ -2616,7 +2616,7 @@ SpellMissInfo Unit::SpellHitResult(Unit* victim, SpellInfo const* spellInfo, boo
|
||||
return SPELL_MISS_EVADE;
|
||||
|
||||
// Try victim reflect spell
|
||||
if (CanReflect)
|
||||
if (canReflect)
|
||||
{
|
||||
int32 reflectchance = victim->GetTotalAuraModifier(SPELL_AURA_REFLECT_SPELLS);
|
||||
Unit::AuraEffectList const& mReflectSpellsSchool = victim->GetAuraEffectsByType(SPELL_AURA_REFLECT_SPELLS_SCHOOL);
|
||||
@@ -7665,7 +7665,7 @@ bool Unit::IsImmunedToDamage(SpellInfo const* spellInfo) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
|
||||
bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
|
||||
{
|
||||
if (!spellInfo)
|
||||
return false;
|
||||
@@ -7698,7 +7698,7 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
|
||||
{
|
||||
// State/effect immunities applied by aura expect full spell immunity
|
||||
// Ignore effects with mechanic, they are supposed to be checked separately
|
||||
if (!IsImmunedToSpellEffect(spellInfo, i))
|
||||
if (!IsImmunedToSpellEffect(spellInfo, i, caster))
|
||||
{
|
||||
immuneToAllEffects = false;
|
||||
break;
|
||||
@@ -7715,7 +7715,7 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
|
||||
{
|
||||
SpellInfo const* immuneSpellInfo = sSpellMgr->GetSpellInfo(itr->second);
|
||||
if ((itr->first & spellInfo->GetSchoolMask())
|
||||
&& !(immuneSpellInfo && immuneSpellInfo->IsPositive() && spellInfo->IsPositive())
|
||||
&& !(immuneSpellInfo && immuneSpellInfo->IsPositive() && spellInfo->IsPositive() && IsFriendlyTo(caster))
|
||||
&& !spellInfo->CanPierceImmuneAura(immuneSpellInfo))
|
||||
return true;
|
||||
}
|
||||
@@ -7744,7 +7744,7 @@ uint32 Unit::GetMechanicImmunityMask() const
|
||||
return mask;
|
||||
}
|
||||
|
||||
bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
|
||||
bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const
|
||||
{
|
||||
if (!spellInfo || !spellInfo->Effects[index].IsEffect())
|
||||
return false;
|
||||
@@ -7754,13 +7754,13 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
|
||||
|
||||
// If m_immuneToEffect type contain this effect type, IMMUNE effect.
|
||||
uint32 effect = spellInfo->Effects[index].Effect;
|
||||
auto const& effectList = m_spellImmune[IMMUNITY_EFFECT];
|
||||
SpellImmuneContainer const& effectList = m_spellImmune[IMMUNITY_EFFECT];
|
||||
if (effectList.count(effect) > 0)
|
||||
return true;
|
||||
|
||||
if (uint32 mechanic = spellInfo->Effects[index].Mechanic)
|
||||
{
|
||||
auto const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
|
||||
SpellImmuneContainer const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
|
||||
if (mechanicList.count(mechanic) > 0)
|
||||
return true;
|
||||
}
|
||||
@@ -7778,8 +7778,8 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
|
||||
// Check for immune to application of harmful magical effects
|
||||
AuraEffectList const& immuneAuraApply = GetAuraEffectsByType(SPELL_AURA_MOD_IMMUNE_AURA_APPLY_SCHOOL);
|
||||
for (AuraEffectList::const_iterator iter = immuneAuraApply.begin(); iter != immuneAuraApply.end(); ++iter)
|
||||
if (((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school
|
||||
!spellInfo->IsPositiveEffect(index)) // Harmful
|
||||
if (((*iter)->GetMiscValue() & spellInfo->GetSchoolMask()) && // Check school
|
||||
(!IsFriendlyTo(caster) || !spellInfo->IsPositiveEffect(index))) // Harmful
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -12353,15 +12353,15 @@ Aura* Unit::AddAura(SpellInfo const* spellInfo, uint8 effMask, Unit* target)
|
||||
if (!spellInfo)
|
||||
return NULL;
|
||||
|
||||
if (target->IsImmunedToSpell(spellInfo))
|
||||
if (target->IsImmunedToSpell(spellInfo, this))
|
||||
return NULL;
|
||||
|
||||
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
if (!(effMask & (1<<i)))
|
||||
if (!(effMask & (1 << i)))
|
||||
continue;
|
||||
if (target->IsImmunedToSpellEffect(spellInfo, i))
|
||||
effMask &= ~(1<<i);
|
||||
if (target->IsImmunedToSpellEffect(spellInfo, i, this))
|
||||
effMask &= ~(1 << i);
|
||||
}
|
||||
|
||||
if (Aura* aura = Aura::TryRefreshStackOrCreate(spellInfo, effMask, target, this))
|
||||
|
||||
@@ -2054,13 +2054,13 @@ class TC_GAME_API Unit : public WorldObject
|
||||
uint32 GetRemainingPeriodicAmount(ObjectGuid caster, uint32 spellId, AuraType auraType, uint8 effectIndex = 0) const;
|
||||
|
||||
void ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply);
|
||||
virtual bool IsImmunedToSpell(SpellInfo const* spellInfo) const; // redefined in Creature
|
||||
virtual bool IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const; // redefined in Creature
|
||||
uint32 GetSchoolImmunityMask() const;
|
||||
uint32 GetMechanicImmunityMask() const;
|
||||
|
||||
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask) const;
|
||||
bool IsImmunedToDamage(SpellInfo const* spellInfo) const;
|
||||
virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const; // redefined in Creature
|
||||
virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const; // redefined in Creature
|
||||
|
||||
static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = NULL, uint8 effIndex = MAX_SPELL_EFFECTS);
|
||||
uint32 CalcArmorReducedDamage(Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK);
|
||||
|
||||
@@ -550,11 +550,11 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
|
||||
// check target immunities
|
||||
for (uint8 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
|
||||
{
|
||||
if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex))
|
||||
if (itr->first->IsImmunedToSpellEffect(GetSpellInfo(), effIndex, caster))
|
||||
itr->second &= ~(1 << effIndex);
|
||||
}
|
||||
if (!itr->second
|
||||
|| itr->first->IsImmunedToSpell(GetSpellInfo())
|
||||
|| itr->first->IsImmunedToSpell(GetSpellInfo(), caster)
|
||||
|| !CanBeAppliedOn(itr->first))
|
||||
addUnit = false;
|
||||
|
||||
|
||||
@@ -1178,7 +1178,7 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
|
||||
// find last added target for this effect
|
||||
for (std::list<TargetInfo>::reverse_iterator ihit = m_UniqueTargetInfo.rbegin(); ihit != m_UniqueTargetInfo.rend(); ++ihit)
|
||||
{
|
||||
if (ihit->effectMask & (1<<effIndex))
|
||||
if (ihit->effectMask & (1 << effIndex))
|
||||
{
|
||||
referer = ObjectAccessor::GetUnit(*m_caster, ihit->targetGUID);
|
||||
break;
|
||||
@@ -2077,7 +2077,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
|
||||
|
||||
// Check for effect immune skip if immuned
|
||||
for (uint32 effIndex = 0; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
|
||||
if (target->IsImmunedToSpellEffect(m_spellInfo, effIndex))
|
||||
if (target->IsImmunedToSpellEffect(m_spellInfo, effIndex, m_caster))
|
||||
effectMask &= ~(1 << effIndex);
|
||||
|
||||
ObjectGuid targetGUID = target->GetGUID();
|
||||
@@ -2557,14 +2557,14 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
|
||||
return SPELL_MISS_EVADE;
|
||||
|
||||
// For delayed spells immunity may be applied between missile launch and hit - check immunity for that case
|
||||
if (m_spellInfo->Speed && unit->IsImmunedToSpell(m_spellInfo))
|
||||
if (m_spellInfo->Speed && unit->IsImmunedToSpell(m_spellInfo, m_caster))
|
||||
return SPELL_MISS_IMMUNE;
|
||||
|
||||
// disable effects to which unit is immune
|
||||
SpellMissInfo returnVal = SPELL_MISS_IMMUNE;
|
||||
for (uint32 effectNumber = 0; effectNumber < MAX_SPELL_EFFECTS; ++effectNumber)
|
||||
if (effectMask & (1 << effectNumber))
|
||||
if (unit->IsImmunedToSpellEffect(m_spellInfo, effectNumber))
|
||||
if (unit->IsImmunedToSpellEffect(m_spellInfo, effectNumber, m_caster))
|
||||
effectMask &= ~(1 << effectNumber);
|
||||
|
||||
if (!effectMask)
|
||||
|
||||
Reference in new issue
Block a user