[saco] Implement/match CPlayerPed::PutDirectlyInVehicle(...)

This commit is contained in:
RD42 2024-10-31 17:22:38 +08:00
parent 7e8ea75194
commit aacad6daf2
3 changed files with 61 additions and 0 deletions

View File

@ -618,6 +618,7 @@ VEHICLE_TYPE * CPlayerPed::GetGtaVehicle()
} }
//----------------------------------------------------------- //-----------------------------------------------------------
//-----------------------------------------------------------
void CPlayerPed::GiveWeapon(int iWeaponID, int iAmmo) void CPlayerPed::GiveWeapon(int iWeaponID, int iAmmo)
{ {
@ -744,6 +745,7 @@ BOOL CPlayerPed::HasAmmoForCurrentWeapon()
} }
return TRUE; return TRUE;
} }
//----------------------------------------------------------- //-----------------------------------------------------------
float CPlayerPed::GetDistanceFromVehicle(CVehicle *pVehicle) float CPlayerPed::GetDistanceFromVehicle(CVehicle *pVehicle)
@ -782,6 +784,58 @@ int CPlayerPed::GetVehicleSeatID()
return (-1); 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 // Forceful removal

View File

@ -66,6 +66,7 @@ public:
void SetImmunities(BOOL bBullet, BOOL bFire, BOOL bExplosion, BOOL bDamage, BOOL bUnknown); 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); void RemoveFromVehicleAndPutAt(float fX, float fY, float fZ);
BOOL IsAPassenger(); BOOL IsAPassenger();

View File

@ -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 is_model_available = { 0x0248, "i" }; // #MODEL
const SCRIPT_COMMAND set_camera_behind_player = { 0x0373, "" }; // -/- 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 point_camera = { 0x0160, "fffi" }; // x, y, z, type
const SCRIPT_COMMAND restore_camera_jumpcut = { 0x02EB, "" }; // -/- const SCRIPT_COMMAND restore_camera_jumpcut = { 0x02EB, "" }; // -/-
const SCRIPT_COMMAND set_camera_position = { 0x015F, "ffffff" }; // x, y, z, vx, vy, vz 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 set_actor_armed_weapon = { 0x01b9, "ii" };
const SCRIPT_COMMAND get_actor_armed_weapon = { 0x0470, "iv" }; 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_immunities = { 0x02ab, "iiiiii" };
const SCRIPT_COMMAND set_actor_can_be_decapitated = { 0x0446, "ii" }; 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 lock_actor = { 0x04d7, "ii" };
const SCRIPT_COMMAND refresh_streaming_at = { 0x04E4, "ff" }; 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 kill_actor = { 0x0321, "i" };
const SCRIPT_COMMAND set_actor_animation_set = { 0x0245, "is" }; const SCRIPT_COMMAND set_actor_animation_set = { 0x0245, "is" };