fix: face target before casting any targeted spell (not just melee)

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.
This commit is contained in:
Kelsi 2026-03-28 16:23:27 -07:00
parent c58537e2b8
commit 9cb6c596d5

View file

@ -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_);