mirror of
https://github.com/brues-code/ClassicAPI.git
synced 2026-11-16 08:00:42 +00:00
UnitFacing(unit) returns the unit's facing in radians (0 = north, counter-clockwise, 0..2pi), or nothing when the token has no unit. The facing comes from the object's GetFacing virtual, vtable slot 6. The unit and player vtables (0x80C4F8 / 0x80AF78) both hold CGUnit_C::GetFacing (0x5F1F30) there, read from the binary: it loads the mover at +0x118, pushes its facing +0x1C and returns CMovement::TransportFacingToWorld (0x7C4AE0), which adds the transport's facing and wraps once into [0, 2pi]. Unit::Position::Facing wraps the call next to the shared position read. GetPlayerFacing moves to the same read. It used to load the float at +0x9C4 (the mover's +0x1C) directly, which is the facing relative to the transport, so on a boat or zeppelin it returned the wrong angle. The OFF_UNIT_FACING offset goes with it.