From 0d49cc8b9424b9b2b22024f01a99a6a7af1b431e Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sat, 21 Mar 2026 03:38:17 -0700 Subject: [PATCH] fix: handle NPC facing-only rotation in SMSG_MONSTER_MOVE Fix bug where NPCs receiving moveType=4 (FacingAngle) or moveType=3 (FacingTarget) monster move packets with zero waypoints would not rotate in place. The handler only processed orientation when hasDest was true, but facing-only updates have no destination waypoints. Now NPCs properly rotate when: - moveType=4: server specifies an exact facing angle (e.g., NPC turns to face the player during dialogue or scripted events) - moveType=3: NPC should face a specific target entity This fixes NPCs appearing frozen/unresponsive during scripted events, quest interactions, and patrol waypoint facing changes. --- src/game/game_handler.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/game/game_handler.cpp b/src/game/game_handler.cpp index 7971a6c2..60706f69 100644 --- a/src/game/game_handler.cpp +++ b/src/game/game_handler.cpp @@ -18364,6 +18364,27 @@ void GameHandler::handleMonsterMove(network::Packet& packet) { creatureMoveCallback_(data.guid, posCanonical.x, posCanonical.y, posCanonical.z, 0); } + } else if (data.moveType == 4) { + // FacingAngle without movement — rotate NPC in place + float orientation = core::coords::serverToCanonicalYaw(data.facingAngle); + glm::vec3 posCanonical = core::coords::serverToCanonical( + glm::vec3(data.x, data.y, data.z)); + entity->setPosition(posCanonical.x, posCanonical.y, posCanonical.z, orientation); + if (creatureMoveCallback_) { + creatureMoveCallback_(data.guid, + posCanonical.x, posCanonical.y, posCanonical.z, 0); + } + } else if (data.moveType == 3 && data.facingTarget != 0) { + // FacingTarget without movement — rotate NPC to face a target + auto target = entityManager.getEntity(data.facingTarget); + if (target) { + float dx = target->getX() - entity->getX(); + float dy = target->getY() - entity->getY(); + if (std::abs(dx) > 0.01f || std::abs(dy) > 0.01f) { + float orientation = std::atan2(-dy, dx); + entity->setOrientation(orientation); + } + } } }