From 9cb6c596d59a7400a46ab18d0da75ad2b92123a5 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 28 Mar 2026 16:23:27 -0700 Subject: [PATCH] fix: face target before casting any targeted spell (not just melee) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only melee abilities sent MSG_MOVE_SET_FACING before the cast packet. Ranged spells like Smite used whatever orientation was in movementInfo from the last movement, causing "target not in front" server rejection. Now sends a facing update toward the target entity before ANY targeted spell cast. The server checks a ~180° frontal arc for most spells. --- src/game/spell_handler.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/game/spell_handler.cpp b/src/game/spell_handler.cpp index 204c79ff..98a6c671 100644 --- a/src/game/spell_handler.cpp +++ b/src/game/spell_handler.cpp @@ -300,6 +300,20 @@ void SpellHandler::castSpell(uint32_t spellId, uint64_t targetGuid) { } } + // Face the target before casting any targeted spell (server checks facing arc) + if (target != 0) { + auto entity = owner_.entityManager.getEntity(target); + if (entity) { + float dx = entity->getX() - owner_.movementInfo.x; + float dy = entity->getY() - owner_.movementInfo.y; + float lenSq = dx * dx + dy * dy; + if (lenSq > 0.01f) { + owner_.movementInfo.orientation = std::atan2(dy, dx); + owner_.sendMovement(Opcode::MSG_MOVE_SET_FACING); + } + } + } + auto packet = owner_.packetParsers_ ? owner_.packetParsers_->buildCastSpell(spellId, target, ++castCount_) : CastSpellPacket::build(spellId, target, ++castCount_);