mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
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:
parent
a63f980e02
commit
0d49cc8b94
1 changed files with 21 additions and 0 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue