cmangos / issues

This repository is used as a centralized point for all issues regarding CMaNGOS.
179 stars 47 forks source link

🐛 [Bug Report] Unit::SetFacingToObject() sets orientation to 0 instead of facing the target #3590

Open Karth-Xyver opened 10 months ago

Karth-Xyver commented 10 months ago

Bug Details

Verified on TBC and WotLK.

When an escort script calls SetFacingToObject() on the creature, its orientation should be changed so that it faces the target. Instead, it's set to 0 both client-side and server-side.

I've noticed this happening within the first minute of an escort quest that is available in TBC but removed in WotLK. To make it available in WotLK (not Blizzlike, though):

DELETE FROM `creature_questrelation` WHERE `quest`=4322;
INSERT INTO `creature_questrelation` (`id`, `quest`) VALUES
(9023, 4322);

DELETE FROM `creature_involvedrelation` WHERE `quest`=4282;
INSERT INTO `creature_involvedrelation` (`id`, `quest`) VALUES
(9023, 4282);

WoWScrnShot_102923_130102

Steps to Reproduce

  1. Be at level 60.
  2. .set hp 999999
  3. Prepare a ".die" macro because there are a few groups of enemies around.
  4. .add 11140 (you need this key to open the door near the questgiver).
  5. .quest add 4282
  6. .quest complete 4282
  7. .go creature id 9023
  8. Turn the quest in, take Jail Break!, open the door, follow the NPC for a minute until it reaches the first door.
  9. Notice how, when it stops movement, it does not face the door as the script tells it to.
  10. .gps says orientation: 0.

Expected behavior

SetFacingToObject() should face the target, not set orientation to 0.

Suggested Workaround

No response

Crash Log

No response

Core SHA1 Commit Hash

030f1373f0b6dd301c27fd48689c382d5026051c

Database SHA1 Commit Hash

a5697bad928239af0a7884dfcda7c701030237ce

Operating System

Windows 10 x64

Client Version

3.3.5a (Wrath of the Lich King)

Exxenoz commented 1 month ago

I was able to reproduce this issue. The moving unit is flagged with UNIT_STAT_ROAMING and UNIT_STAT_ROAMING_MOVE when WaypointReached is called. Unit::IsStopped (checks if UNIT_STAT_ROAMING_MOVE is not set) returns false and Unit::SetFacingToObject fails due to this condition:

// never face when already moving
if (!IsStopped())
{
    return;
}

To me, that sounds like the behavior one would expect. If any intermediate waypoint is reached, then the unit is still in motion unless explicitly paused or stopped, which in Windsor's case happens through SetEscortPaused(true), but only after SetFacingToObject is called. For SetFacingToObject to work as expected, SetEscortPaused(true); must be called first.