From 65b857eb2756c745b0aa709c77f2d050fbb406f2 Mon Sep 17 00:00:00 2001 From: Mykhailo Redko Date: Fri, 9 Feb 2024 21:28:54 +0200 Subject: [PATCH] Core/Spells: Immune a reflected spell if the original caster cannot be it's target. (#29645) (cherry picked from commit 86551ba71669712cadf82f2dc1f0c5481f0fba1b) --- src/server/game/Spells/Spell.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 31b7e412d5..3e06b1f890 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2516,11 +2516,15 @@ void Spell::AddUnitTarget(Unit* target, uint32 effectMask, bool checkIfValid /*= // If target reflect spell back to caster if (targetInfo.MissCondition == SPELL_MISS_REFLECT) { - // Calculate reflected spell result on caster (shouldn't be able to reflect gameobject spells) + // Shouldn't be able to reflect gameobject spells Unit* unitCaster = ASSERT_NOTNULL(m_caster->ToUnit()); - targetInfo.ReflectResult = unitCaster->SpellHitResult(unitCaster, m_spellInfo, - false /*can't reflect twice*/, - false /*immunity will be checked after complete EffectMask is known*/); + + // Calculate reflected spell result on caster + targetInfo.ReflectResult = m_spellInfo->CheckTarget(target, unitCaster, implicit) == SPELL_CAST_OK + ? unitCaster->SpellHitResult(unitCaster, m_spellInfo, + false /*can't reflect twice*/, + false /*immunity will be checked after complete EffectMask is known*/) + : SPELL_MISS_IMMUNE; if (targetInfo.ReflectResult == SPELL_MISS_MISS && target->HasAuraType(SPELL_AURA_REFLECT_SPELLS)) targetInfo.ReflectingSpellId = target->GetAuraEffectsByType(SPELL_AURA_REFLECT_SPELLS).front()->GetId();