aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorthenecromancer <none@none>2010-01-13 10:20:00 +0100
committerthenecromancer <none@none>2010-01-13 10:20:00 +0100
commit8dd67e8bb31ef3740fcff936eb65223072a52729 (patch)
treefc4b3c57850014f9eeaf10f67c63f71167fcecaa /src
parent6b07806d0c034e6b88cf0426c753e620841181a5 (diff)
Allow state/effect immunities ignore whole spell when one effect is immuned
(Fixes getting part of CC auras with some immunities) --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Creature.cpp4
-rw-r--r--src/game/Creature.h2
-rw-r--r--src/game/Totem.cpp4
-rw-r--r--src/game/Totem.h2
-rw-r--r--src/game/Unit.cpp23
-rw-r--r--src/game/Unit.h2
6 files changed, 24 insertions, 13 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 0a74b64d320..384eec4ebdb 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -1598,12 +1598,12 @@ bool Creature::IsImmunedToSpell(SpellEntry const* spellInfo)
return Unit::IsImmunedToSpell(spellInfo);
}
-bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const
+bool Creature::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool checkMechanic) const
{
if (GetCreatureInfo()->MechanicImmuneMask & (1 << (spellInfo->EffectMechanic[index] - 1)))
return true;
- return Unit::IsImmunedToSpellEffect(spellInfo, index);
+ return Unit::IsImmunedToSpellEffect(spellInfo, index, checkMechanic);
}
SpellEntry const *Creature::reachWithSpellAttack(Unit *pVictim)
diff --git a/src/game/Creature.h b/src/game/Creature.h
index 6bad39de566..cd9f30f703a 100644
--- a/src/game/Creature.h
+++ b/src/game/Creature.h
@@ -448,7 +448,7 @@ class TRINITY_DLL_SPEC Creature : public Unit, public GridObject<Creature>
bool canCreatureAttack(Unit const *pVictim, bool force = true) const;
bool IsImmunedToSpell(SpellEntry const* spellInfo);
// redefine Unit::IsImmunedToSpell
- bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
+ bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool checkMechanic) const;
// redefine Unit::IsImmunedToSpellEffect
bool isElite() const
{
diff --git a/src/game/Totem.cpp b/src/game/Totem.cpp
index 282dc7678cb..a6e30ca09ae 100644
--- a/src/game/Totem.cpp
+++ b/src/game/Totem.cpp
@@ -145,7 +145,7 @@ void Totem::UnSummon()
AddObjectToRemoveList();
}
-bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const
+bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool checkMechanic) const
{
// TODO: possibly all negative auras immune?
if(GetEntry() == 5925)
@@ -160,5 +160,5 @@ bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) co
default:
break;
}
- return Creature::IsImmunedToSpellEffect(spellInfo, index);
+ return Creature::IsImmunedToSpellEffect(spellInfo, index, checkMechanic);
}
diff --git a/src/game/Totem.h b/src/game/Totem.h
index 6dbd699f1d2..535e39a58dd 100644
--- a/src/game/Totem.h
+++ b/src/game/Totem.h
@@ -54,7 +54,7 @@ class Totem : public Minion
void UpdateAttackPowerAndDamage(bool /*ranged*/ ) {}
void UpdateDamagePhysical(WeaponAttackType /*attType*/) {}
- bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
+ bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool checkMechanic) const;
protected:
TotemType m_type;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index f0c16365606..fdd2816d8c9 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -10653,6 +10653,14 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo)
if (itr->type == spellInfo->Mechanic)
return true;
}
+
+ for (int i=0;i<3;++i)
+ {
+ // State/effect immunities applied by aura expect full spell immunity
+ // However function also check for mechanic, so ignore that for now
+ if (IsImmunedToSpellEffect(spellInfo, i, false))
+ return true;
+ }
if (spellInfo->Id != 42292 && spellInfo->Id !=59752)
{
@@ -10667,7 +10675,7 @@ bool Unit::IsImmunedToSpell(SpellEntry const* spellInfo)
return false;
}
-bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const
+bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool checkMechanic) const
{
if (!spellInfo)
return false;
@@ -10678,12 +10686,15 @@ bool Unit::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) con
if (itr->type == effect)
return true;
- if (uint32 mechanic = spellInfo->EffectMechanic[index])
+ if (checkMechanic)
{
- SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
- for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
- if (itr->type == spellInfo->EffectMechanic[index])
- return true;
+ if (uint32 mechanic = spellInfo->EffectMechanic[index])
+ {
+ SpellImmuneList const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
+ for (SpellImmuneList::const_iterator itr = mechanicList.begin(); itr != mechanicList.end(); ++itr)
+ if (itr->type == spellInfo->EffectMechanic[index])
+ return true;
+ }
}
if (uint32 aura = spellInfo->EffectApplyAuraName[index])
diff --git a/src/game/Unit.h b/src/game/Unit.h
index dba30f176f5..cd15a902660 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1817,7 +1817,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
// redefined in Creature
bool IsImmunedToDamage(SpellSchoolMask meleeSchoolMask);
bool IsImmunedToDamage(SpellEntry const* spellInfo);
- virtual bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) const;
+ virtual bool IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index, bool checkMechanic=true) const;
// redefined in Creature
uint32 CalcNotIgnoreDamageRedunction( uint32 damage, SpellSchoolMask damageSchoolMask);
uint32 CalcArmorReducedDamage(Unit* pVictim, const uint32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType=MAX_ATTACK);