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();