[saco] Implement/match CEntity::Get2DDistanceFromLocalPlayerPed()

This commit is contained in:
RD42
2024-08-07 19:03:03 +08:00
parent fa0b2fb065
commit a0f164ed15
2 changed files with 33 additions and 0 deletions

View File

@ -280,6 +280,38 @@ float CEntity::GetDistanceFromCamera()
//-----------------------------------------------------------
float CEntity::Get2DDistanceFromLocalPlayerPed()
{
MATRIX4X4 matFromPlayer;
MATRIX4X4 matThis;
float fSX,fSY,fSZ;
CPlayerPed *pLocalPlayerPed = pGame->FindPlayerPed();
CLocalPlayer *pLocalPlayer=NULL;
if(!pLocalPlayerPed) return 10000.0f;
GetMatrix(&matThis);
if(pNetGame) {
pLocalPlayer = pNetGame->GetPlayerPool()->GetLocalPlayer();
if(pLocalPlayer && (pLocalPlayer->IsSpectating() || pLocalPlayer->IsInRCMode())) {
pGame->GetCamera()->GetMatrix(&matFromPlayer);
} else {
pLocalPlayerPed->GetMatrix(&matFromPlayer);
}
} else {
pLocalPlayerPed->GetMatrix(&matFromPlayer);
}
fSX = (matThis.pos.X - matFromPlayer.pos.X) * (matThis.pos.X - matFromPlayer.pos.X);
fSY = (matThis.pos.Y - matFromPlayer.pos.Y) * (matThis.pos.Y - matFromPlayer.pos.Y);
return (float)sqrt(fSX + fSY);
}
//-----------------------------------------------------------
float CEntity::GetDistanceFromPoint(float X, float Y, float Z)
{
MATRIX4X4 matThis;

View File

@ -27,6 +27,7 @@ public:
void TeleportTo(float x, float y, float z);
float GetDistanceFromLocalPlayerPed();
float GetDistanceFromCamera();
float Get2DDistanceFromLocalPlayerPed(); // unused
float GetDistanceFromPoint(float X, float Y, float Z);
BOOL IsStationary();