From 195f63f62e5d7b16dfe6953dcdb64ee90bbbea3e Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Mon, 5 Aug 2024 18:11:12 +0800 Subject: [PATCH] [saco] Implement/match `CPlayerPed::GetTargetRotation()` --- saco/game/playerped.cpp | 19 +++++++++++++++++++ saco/game/playerped.h | 1 + 2 files changed, 20 insertions(+) diff --git a/saco/game/playerped.cpp b/saco/game/playerped.cpp index 27ed163..48eeee9 100644 --- a/saco/game/playerped.cpp +++ b/saco/game/playerped.cpp @@ -260,6 +260,25 @@ BOOL CPlayerPed::IsInVehicle() return FALSE; } +//----------------------------------------------------------- + +float CPlayerPed::GetTargetRotation() +{ + if(!m_pPed) return 0.0f; + if(GamePool_Ped_GetAt(m_dwGTAId) == 0) return 0.0f; + + MATRIX4X4 mat; + GetMatrix(&mat); + + float fZAngle = atan2(-mat.up.X, mat.up.Y) * 180.0f / PI; + // Bound it to [0, 360) + if ( fZAngle < 0.0f ) + fZAngle += 360.0f; + else if ( fZAngle >= 360.0f ) + fZAngle -= 360.0f; + return fZAngle; +} + //----------------------------------------------------------- void CPlayerPed::GiveWeapon(int iWeaponID, int iAmmo) diff --git a/saco/game/playerped.h b/saco/game/playerped.h index e4268c5..fcb1139 100644 --- a/saco/game/playerped.h +++ b/saco/game/playerped.h @@ -41,6 +41,7 @@ public: WORD GetAmmo(); + float GetTargetRotation(); void GiveWeapon(int iWeaponID, int iAmmo); void SetArmedWeapon(int iWeaponType, bool bUnk); WEAPON_SLOT_TYPE * GetCurrentWeaponSlot();