mirror of
https://github.com/dashr9230/SA-MP.git
synced 2024-12-22 14:37:29 +08:00
[bot] Implement/match n_GetMyFacingAngle(...)
* Rename `unnamed_9` to `byteState` * Implement/match `CNetGame::GetMyZAngle()` * Update `CNetGame::Init(...)`
This commit is contained in:
parent
148efc2fa6
commit
831b304f20
@ -29,8 +29,8 @@ typedef struct _TRAILER_SYNC_DATA // size: 54
|
||||
|
||||
char unnamed_2[63];
|
||||
PASSENGER_SYNC_DATA unnamed_5[MAX_PLAYERS];
|
||||
char unnamed_9;
|
||||
BOOL bPlayerSlotState[MAX_PLAYERS];
|
||||
BYTE byteState;
|
||||
ONFOOT_SYNC_DATA ofSync;
|
||||
ONFOOT_SYNC_DATA unnamed_3[MAX_PLAYERS];
|
||||
BYTE bytePlayerState[MAX_PLAYERS];
|
||||
@ -237,6 +237,40 @@ BOOL CNetGame::IsVehicleAdded(VEHICLEID VehicleID)
|
||||
return bVehicleSlotState[VehicleID] != FALSE;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
float CNetGame::GetMyZAngle()
|
||||
{
|
||||
MATRIX4X4 mat;
|
||||
|
||||
if(byteState == PLAYER_STATE_ONFOOT)
|
||||
{
|
||||
QuaternionToMatrix(&ofSync.quatRotation, &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;
|
||||
}
|
||||
else if(byteState == PLAYER_STATE_DRIVER)
|
||||
{
|
||||
QuaternionToMatrix(&icSync.quatRotation, &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;
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
//----------------------------------------------------
|
||||
// MATCH
|
||||
void CNetGame::SetMyZAngle(float fAngle)
|
||||
@ -402,7 +436,7 @@ void CNetGame::Init(PCHAR szHostOrIp, int iPort,
|
||||
field_1DE = 0;
|
||||
field_1E2 = 0;
|
||||
field_1F2 = GetTickCount();
|
||||
unnamed_9 = 0;
|
||||
byteState = PLAYER_STATE_NONE;
|
||||
field_1FA = -1;
|
||||
field_1FE = -1;
|
||||
srand(0);
|
||||
|
@ -115,6 +115,7 @@ public:
|
||||
BYTE GetPlayerArmour(PLAYERID playerId);
|
||||
BOOL GetPlayerKeys(PLAYERID playerId, WORD *udAnalog, WORD *lrAnalog, WORD *wKeys);
|
||||
BOOL IsVehicleAdded(VEHICLEID VehicleID);
|
||||
float GetMyZAngle();
|
||||
|
||||
void StopRecordingPlayback();
|
||||
void PauseRecordingPlayback();
|
||||
|
@ -266,8 +266,11 @@ static cell AMX_NATIVE_CALL n_SetMyPos(AMX *amx, cell *params)
|
||||
// native GetMyFacingAngle(&Float:ang)
|
||||
static cell AMX_NATIVE_CALL n_GetMyFacingAngle(AMX *amx, cell *params)
|
||||
{
|
||||
// TODO: n_GetMyFacingAngle
|
||||
return 0;
|
||||
cell* cptr;
|
||||
amx_GetAddr(amx, params[1], &cptr);
|
||||
float fResult = pNetGame->GetMyZAngle();
|
||||
*cptr = amx_ftoc(fResult);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// native SetMyFacingAngle(Float:ang)
|
||||
|
Loading…
Reference in New Issue
Block a user