From aacad6daf2fb7f3ffb2f53f697b751b1e8bbad89 Mon Sep 17 00:00:00 2001 From: RD42 <42702181+dashr9230@users.noreply.github.com> Date: Thu, 31 Oct 2024 17:22:38 +0800 Subject: [PATCH] [saco] Implement/match `CPlayerPed::PutDirectlyInVehicle(...)` --- saco/game/playerped.cpp | 54 +++++++++++++++++++++++++++++++++++++++++ saco/game/playerped.h | 1 + saco/game/scripting.h | 6 +++++ 3 files changed, 61 insertions(+) diff --git a/saco/game/playerped.cpp b/saco/game/playerped.cpp index 584bf03..9916b1f 100644 --- a/saco/game/playerped.cpp +++ b/saco/game/playerped.cpp @@ -618,6 +618,7 @@ VEHICLE_TYPE * CPlayerPed::GetGtaVehicle() } //----------------------------------------------------------- +//----------------------------------------------------------- void CPlayerPed::GiveWeapon(int iWeaponID, int iAmmo) { @@ -744,6 +745,7 @@ BOOL CPlayerPed::HasAmmoForCurrentWeapon() } return TRUE; } + //----------------------------------------------------------- float CPlayerPed::GetDistanceFromVehicle(CVehicle *pVehicle) @@ -782,6 +784,58 @@ int CPlayerPed::GetVehicleSeatID() return (-1); } +//----------------------------------------------------------- + +void CPlayerPed::PutDirectlyInVehicle(int iVehicleID, int iSeat) +{ + if(!m_pPed) return; + if(!GamePool_Vehicle_GetAt(iVehicleID)) return; + if(!GamePool_Ped_GetAt(m_dwGTAId)) return; + + if(GetCurrentWeapon() == WEAPON_PARACHUTE) { + SetArmedWeapon(0); + } + + VEHICLE_TYPE *pVehicle = GamePool_Vehicle_GetAt(iVehicleID); + + if(pVehicle->fHealth == 0.0f) return; + + // Check to make sure internal data structure of the vehicle hasn't been deleted + // by checking if the vtbl points to CPlaceable_vtbl + if (pVehicle->entity.vtable == 0x863C40) return; + + if ((GetVehicleSubtypeFromVehiclePtr(pVehicle) == VEHICLE_SUBTYPE_CAR || + GetVehicleSubtypeFromVehiclePtr(pVehicle) == VEHICLE_SUBTYPE_BIKE) && + iSeat > pVehicle->byteMaxPassengers) + { + return; + } + + if(iSeat==0) { + if(pVehicle->pDriver && IN_VEHICLE(pVehicle->pDriver)) return; + ScriptCommand(&put_actor_in_car,m_dwGTAId,iVehicleID); + } else { + iSeat--; + ScriptCommand(&put_actor_in_car2,m_dwGTAId,iVehicleID,iSeat); + } + if(m_pPed == GamePool_FindPlayerPed() && IN_VEHICLE(m_pPed)) { + pGame->GetCamera()->SetBehindPlayer(); + } + + if(pNetGame) { + CVehiclePool* pVehiclePool = pNetGame->GetVehiclePool(); + VEHICLEID TrainVehicleId = pVehiclePool->FindIDFromGtaPtr(pVehicle); + if(TrainVehicleId == INVALID_VEHICLE_ID || TrainVehicleId > MAX_VEHICLES) return; + + CVehicle* pTrain = pVehiclePool->GetAt(TrainVehicleId); + if ( pTrain && pTrain->IsATrainPart() && m_pPed == GamePool_FindPlayerPed() ) { + ScriptCommand(&camera_on_vehicle, pTrain->m_dwGTAId, 3, 2); + } + } +} + +//----------------------------------------------------------- + //----------------------------------------------------------- // Forceful removal diff --git a/saco/game/playerped.h b/saco/game/playerped.h index 0b0cfb6..aa41dd0 100644 --- a/saco/game/playerped.h +++ b/saco/game/playerped.h @@ -66,6 +66,7 @@ public: void SetImmunities(BOOL bBullet, BOOL bFire, BOOL bExplosion, BOOL bDamage, BOOL bUnknown); + void PutDirectlyInVehicle(int iVehicleID, int iSeat); void RemoveFromVehicleAndPutAt(float fX, float fY, float fZ); BOOL IsAPassenger(); diff --git a/saco/game/scripting.h b/saco/game/scripting.h index dce79e4..4932e69 100644 --- a/saco/game/scripting.h +++ b/saco/game/scripting.h @@ -41,6 +41,9 @@ const SCRIPT_COMMAND set_current_time = { 0x00C0, "ii" }; // Hours, Minutes const SCRIPT_COMMAND is_model_available = { 0x0248, "i" }; // #MODEL const SCRIPT_COMMAND set_camera_behind_player = { 0x0373, "" }; // -/- + +const SCRIPT_COMMAND camera_on_vehicle = { 0x0158, "iii" }; // var_car, ukn, ukn + const SCRIPT_COMMAND point_camera = { 0x0160, "fffi" }; // x, y, z, type const SCRIPT_COMMAND restore_camera_jumpcut = { 0x02EB, "" }; // -/- const SCRIPT_COMMAND set_camera_position = { 0x015F, "ffffff" }; // x, y, z, vx, vy, vz @@ -66,6 +69,7 @@ const SCRIPT_COMMAND toggle_player_controllable = { 0x01B4, "ii" }; const SCRIPT_COMMAND set_actor_armed_weapon = { 0x01b9, "ii" }; const SCRIPT_COMMAND get_actor_armed_weapon = { 0x0470, "iv" }; +const SCRIPT_COMMAND put_actor_in_car = { 0x036A, "ii" }; const SCRIPT_COMMAND set_actor_immunities = { 0x02ab, "iiiiii" }; const SCRIPT_COMMAND set_actor_can_be_decapitated = { 0x0446, "ii" }; @@ -83,6 +87,8 @@ const SCRIPT_COMMAND set_actor_z_angle = { 0x0173, "if" }; const SCRIPT_COMMAND lock_actor = { 0x04d7, "ii" }; const SCRIPT_COMMAND refresh_streaming_at = { 0x04E4, "ff" }; +const SCRIPT_COMMAND put_actor_in_car2 = { 0x0430, "iii" }; + const SCRIPT_COMMAND kill_actor = { 0x0321, "i" }; const SCRIPT_COMMAND set_actor_animation_set = { 0x0245, "is" };