aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp10
-rw-r--r--src/server/game/Entities/Creature/Creature.h4
-rw-r--r--src/server/game/Entities/Player/Player.cpp4
-rw-r--r--src/server/game/Entities/Player/Player.h2
-rw-r--r--src/server/game/Entities/Totem/Totem.cpp4
-rw-r--r--src/server/game/Entities/Totem/Totem.h2
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp28
-rw-r--r--src/server/game/Entities/Unit/Unit.h4
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp4
-rw-r--r--src/server/game/Spells/Spell.cpp8
10 files changed, 35 insertions, 35 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index 1c8bafc43ec..4bc7b7c9d27 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -1915,7 +1915,7 @@ void Creature::DespawnOrUnsummon(uint32 msTimeToDespawn /*= 0*/, Seconds const&
ForcedDespawn(msTimeToDespawn, forceRespawnTimer);
}
-bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
+bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo, Unit* caster) const
{
if (!spellInfo)
return false;
@@ -1931,7 +1931,7 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
{
if (!effect || !effect->IsEffect())
continue;
- if (!IsImmunedToSpellEffect(spellInfo, effect->EffectIndex))
+ if (!IsImmunedToSpellEffect(spellInfo, effect->EffectIndex, caster))
{
immunedToAllEffects = false;
break;
@@ -1940,10 +1940,10 @@ 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
{
SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficultyID(), index);
if (!effect)
@@ -1954,7 +1954,7 @@ bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index)
if (GetCreatureTemplate()->type == CREATURE_TYPE_MECHANICAL && effect->Effect == SPELL_EFFECT_HEAL)
return true;
- return Unit::IsImmunedToSpellEffect(spellInfo, index);
+ return Unit::IsImmunedToSpellEffect(spellInfo, index, caster);
}
bool Creature::isElite() const
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index ace1bba8734..0470a4cc41f 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -108,8 +108,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
bool isCanInteractWithBattleMaster(Player* player, bool msg) const;
bool CanResetTalents(Player* player) const;
bool CanCreatureAttack(Unit const* victim, bool force = true) const;
- 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;
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index e612d5ec7c0..ca8376646a2 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -1776,7 +1776,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
{
SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficultyID(), index);
if (!effect || !effect->IsEffect())
@@ -1788,7 +1788,7 @@ bool Player::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) co
if (effect->IsEffect(SPELL_EFFECT_ATTACK_ME))
return true;
- return Unit::IsImmunedToSpellEffect(spellInfo, index);
+ return Unit::IsImmunedToSpellEffect(spellInfo, index, caster);
}
void Player::RegenerateAll()
diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h
index e77aa588fa1..b7438477072 100644
--- a/src/server/game/Entities/Player/Player.h
+++ b/src/server/game/Entities/Player/Player.h
@@ -1068,7 +1068,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player>
void Update(uint32 time) override;
- bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const override; // override Unit::IsImmunedToSpellEffect
+ bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, Unit* caster) const override;
void SetInWater(bool apply);
diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp
index 55476c74b63..5c505a20482 100644
--- a/src/server/game/Entities/Totem/Totem.cpp
+++ b/src/server/game/Entities/Totem/Totem.cpp
@@ -147,7 +147,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)
@@ -168,5 +168,5 @@ bool Totem::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) con
else
return true;
- return Creature::IsImmunedToSpellEffect(spellInfo, index);
+ return Creature::IsImmunedToSpellEffect(spellInfo, index, caster);
}
diff --git a/src/server/game/Entities/Totem/Totem.h b/src/server/game/Entities/Totem/Totem.h
index b6841ce2b0e..aa673719a6e 100644
--- a/src/server/game/Entities/Totem/Totem.h
+++ b/src/server/game/Entities/Totem/Totem.h
@@ -51,7 +51,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;
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index a466ef6d4b8..a39c25327c0 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -2514,13 +2514,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
@@ -2541,7 +2541,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);
@@ -7193,7 +7193,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;
@@ -7228,7 +7228,7 @@ bool Unit::IsImmunedToSpell(SpellInfo const* spellInfo) const
// Ignore effects with mechanic, they are supposed to be checked separately
if (!effect)
continue;
- if (!IsImmunedToSpellEffect(spellInfo, effect->EffectIndex))
+ if (!IsImmunedToSpellEffect(spellInfo, effect->EffectIndex, caster))
{
immuneToAllEffects = false;
break;
@@ -7245,7 +7245,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;
}
@@ -7274,7 +7274,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)
return false;
@@ -7294,7 +7294,7 @@ bool Unit::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) cons
if (uint32 mechanic = effect->Mechanic)
{
- auto const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
+ SpellImmuneContainer const& mechanicList = m_spellImmune[IMMUNITY_MECHANIC];
if (mechanicList.count(mechanic) > 0)
return true;
}
@@ -7312,8 +7312,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;
}
}
@@ -11882,15 +11882,15 @@ Aura* Unit::AddAura(SpellInfo const* spellInfo, uint32 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);
}
ObjectGuid castId = ObjectGuid::Create<HighGuid::Cast>(SPELL_CAST_SOURCE_NORMAL, GetMapId(), spellInfo->Id, GetMap()->GenerateLowGuid<HighGuid::Cast>());
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index ef8fb3d97a9..2dcfb7094b3 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1720,13 +1720,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
bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr, int8 effIndex = -1);
uint32 CalcArmorReducedDamage(Unit* attacker, Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK);
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 676702d5d1b..64643964169 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -569,11 +569,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;
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 9cf3e557581..0234b16fec0 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -1223,7 +1223,7 @@ void Spell::SelectImplicitAreaTargets(SpellEffIndex effIndex, SpellImplicitTarge
// find last added target for this effect
for (std::vector<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;
@@ -2135,7 +2135,7 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*=
// Check for effect immune skip if immuned
for (SpellEffectInfo const* effect : GetEffects())
- if (effect && target->IsImmunedToSpellEffect(m_spellInfo, effect->EffectIndex))
+ if (effect && target->IsImmunedToSpellEffect(m_spellInfo, effect->EffectIndex, m_caster))
effectMask &= ~(1 << effect->EffectIndex);
ObjectGuid targetGUID = target->GetGUID();
@@ -2611,14 +2611,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 (SpellEffectInfo const* effect : GetEffects())
if (effect && (effectMask & (1 << effect->EffectIndex)))
- if (unit->IsImmunedToSpellEffect(m_spellInfo, effect->EffectIndex))
+ if (unit->IsImmunedToSpellEffect(m_spellInfo, effect->EffectIndex, m_caster))
effectMask &= ~(1 << effect->EffectIndex);
if (!effectMask)