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.
This commit is contained in:
Kelsi 2026-03-21 03:38:17 -07:00
parent a63f980e02
commit 0d49cc8b94

View file

@ -18364,6 +18364,27 @@ void GameHandler::handleMonsterMove(network::Packet& packet) {
creatureMoveCallback_(data.guid, creatureMoveCallback_(data.guid,
posCanonical.x, posCanonical.y, posCanonical.z, 0); 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);
}
}
} }
} }