From d41cf026e0c714a4a74316f789d6d99c889336e5 Mon Sep 17 00:00:00 2001 From: UltraNix <80540499+UltraNix@users.noreply.github.com> Date: Sat, 18 Jun 2022 17:05:18 +0200 Subject: [PATCH] =?UTF-8?q?fix(Core/Spells):=20Fixed=20calculating=20LoS?= =?UTF-8?q?=20checks=20for=20spells=20casted=20by=20g=E2=80=A6=20(#12091)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix(Core/Spells): Fixed calculating LoS checks for spells casted by gameobjects. Fixed #12066 --- src/server/game/Spells/Spell.cpp | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 44df83ab6..8bcb30778 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5851,31 +5851,27 @@ SpellCastResult Spell::CheckCast(bool strict) if ((!m_caster->IsTotem() || !m_spellInfo->IsPositive()) && !m_spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT) && !m_spellInfo->HasAttribute(SPELL_ATTR5_ALWAYS_AOE_LINE_OF_SIGHT) && !(m_spellFlags & SPELL_FLAG_REDIRECTED)) { - WorldObject* losCenter = nullptr; + bool castedByGameobject = false; uint32 losChecks = LINEOFSIGHT_ALL_CHECKS; if (m_originalCasterGUID.IsGameObject()) { - losCenter = m_caster->GetMap()->GetGameObject(m_originalCasterGUID); + castedByGameobject = m_caster->GetMap()->GetGameObject(m_originalCasterGUID) != nullptr; } else if (m_caster->GetEntry() == WORLD_TRIGGER) { if (TempSummon* tempSummon = m_caster->ToTempSummon()) { - losCenter = tempSummon->GetSummonerGameObject(); + castedByGameobject = tempSummon->GetSummonerGameObject() != nullptr; } } - if (losCenter) + if (castedByGameobject) { // If spell casted by gameobject then ignore M2 models losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2; } - else - { - losCenter = m_caster; - } - if (!losCenter->IsWithinLOSInMap(target, VMAP::ModelIgnoreFlags::M2, LineOfSightChecks(losChecks))) + if (!m_caster->IsWithinLOSInMap(target, VMAP::ModelIgnoreFlags::M2, LineOfSightChecks(losChecks))) { return SPELL_FAILED_LINE_OF_SIGHT; } @@ -7968,7 +7964,6 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const } } - WorldObject* caster = nullptr; if (gobCaster) { if (gobCaster->GetGOInfo()->IsIgnoringLOSChecks()) @@ -7976,15 +7971,9 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const return true; } - caster = gobCaster; - // If spell casted by gameobject then ignore M2 models losChecks &= ~LINEOFSIGHT_CHECK_GOBJECT_M2; } - else - { - caster = m_caster; - } if (target != m_caster) { @@ -7999,7 +7988,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const return false; } } - else if (!target->IsWithinLOSInMap(caster, VMAP::ModelIgnoreFlags::M2, LineOfSightChecks(losChecks))) + else if (!m_caster->IsWithinLOSInMap(target, VMAP::ModelIgnoreFlags::M2, LineOfSightChecks(losChecks))) { return false; }