From 2c418701fd72831c91fc284df22fa7adf2dabde1 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Tue, 13 Aug 2024 23:29:34 +0800 Subject: [PATCH] [saco] Implement/match `CPlayerPed::GetDistanceFromVehicle(...)` * Add CVehicle constructor stub --- saco/game/playerped.cpp | 17 +++++++++++++++++ saco/game/playerped.h | 2 ++ saco/game/vehicle.cpp | 15 +++++++++++++++ saco/game/vehicle.h | 17 +++++++++++++++++ 4 files changed, 51 insertions(+) create mode 100644 saco/game/vehicle.cpp create mode 100644 saco/game/vehicle.h diff --git a/saco/game/playerped.cpp b/saco/game/playerped.cpp index 1b1214c..80eddd2 100644 --- a/saco/game/playerped.cpp +++ b/saco/game/playerped.cpp @@ -438,6 +438,23 @@ BOOL CPlayerPed::HasAmmoForCurrentWeapon() } return TRUE; } +//----------------------------------------------------------- + +float CPlayerPed::GetDistanceFromVehicle(CVehicle *pVehicle) +{ + MATRIX4X4 matFromPlayer; + MATRIX4X4 matThis; + float fSX,fSY,fSZ; + + GetMatrix(&matThis); + pVehicle->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); + fSZ = (matThis.pos.Z - matFromPlayer.pos.Z) * (matThis.pos.Z - matFromPlayer.pos.Z); + + return (float)sqrt(fSX + fSY + fSZ); +} //----------------------------------------------------------- diff --git a/saco/game/playerped.h b/saco/game/playerped.h index f15c287..f779b03 100644 --- a/saco/game/playerped.h +++ b/saco/game/playerped.h @@ -59,6 +59,8 @@ public: VEHICLE_TYPE * GetGtaVehicle(); + float GetDistanceFromVehicle(CVehicle *pVehicle); + void StartJetpack(); void StopJetpack(); BOOL IsInJetpackMode(); diff --git a/saco/game/vehicle.cpp b/saco/game/vehicle.cpp new file mode 100644 index 0000000..7bc5ae3 --- /dev/null +++ b/saco/game/vehicle.cpp @@ -0,0 +1,15 @@ + +#include "../main.h" + +//----------------------------------------------------------- +// CONSTRUCTOR + +CVehicle::CVehicle(int iType, float fPosX, float fPosY, + float fPosZ, float fRotation, BOOL bKeepModelLoaded, + int a8) +{ + // TODO: CVehicle::CVehicle +} + +//----------------------------------------------------------- + diff --git a/saco/game/vehicle.h b/saco/game/vehicle.h new file mode 100644 index 0000000..d589b5e --- /dev/null +++ b/saco/game/vehicle.h @@ -0,0 +1,17 @@ + +#pragma once + +#include "game.h" +#include "entity.h" + +//----------------------------------------------------------- + +class CVehicle : public CEntity +{ +public: + + CVehicle( int iType, float fPosX, float fPosY, float fPosZ, float fRotation = 0.0f, BOOL bKeepModelLoaded = FALSE, int a8 = 0); + +}; + +//-----------------------------------------------------------