2024-08-13 23:29:34 +08:00
|
|
|
|
|
|
|
#include "../main.h"
|
2024-08-20 22:44:22 +08:00
|
|
|
#include "util.h"
|
2024-08-13 23:29:34 +08:00
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
// CONSTRUCTOR
|
|
|
|
|
|
|
|
CVehicle::CVehicle(int iType, float fPosX, float fPosY,
|
|
|
|
float fPosZ, float fRotation, BOOL bKeepModelLoaded,
|
|
|
|
int a8)
|
|
|
|
{
|
2024-08-20 22:44:22 +08:00
|
|
|
// TODO: CVehicle::CVehicle .text:100B88F0
|
2024-08-13 23:29:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 22:44:22 +08:00
|
|
|
void CVehicle::LinkToInterior(int iInterior)
|
|
|
|
{
|
|
|
|
if(GamePool_Vehicle_GetAt(m_dwGTAId)) {
|
|
|
|
ScriptCommand(&link_vehicle_to_interior, m_dwGTAId, iInterior);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
2024-08-20 22:48:22 +08:00
|
|
|
// If the game has internally destroyed the vehicle
|
|
|
|
// during this frame, the vehicle pointer should become 0
|
|
|
|
|
|
|
|
void CVehicle::ResetPointers()
|
|
|
|
{
|
|
|
|
if(!m_pVehicle) return;
|
|
|
|
|
|
|
|
m_pVehicle = GamePool_Vehicle_GetAt(m_dwGTAId);
|
|
|
|
m_pEntity = (ENTITY_TYPE *)m_pVehicle;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 22:51:36 +08:00
|
|
|
BOOL CVehicle::HasADriver()
|
|
|
|
{
|
|
|
|
if(!m_pVehicle) return FALSE;
|
|
|
|
if(!GamePool_Vehicle_GetAt(m_dwGTAId)) return FALSE;
|
|
|
|
|
|
|
|
if(m_pVehicle) {
|
|
|
|
if(m_pVehicle->pDriver && IN_VEHICLE(m_pVehicle->pDriver) && m_pVehicle->pDriver->dwPedType == 0)
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 22:52:44 +08:00
|
|
|
BOOL CVehicle::IsOccupied()
|
|
|
|
{
|
|
|
|
if(m_pVehicle) {
|
|
|
|
if(m_pVehicle->pDriver) return TRUE;
|
|
|
|
if(m_pVehicle->pPassengers[0]) return TRUE;
|
|
|
|
if(m_pVehicle->pPassengers[1]) return TRUE;
|
|
|
|
if(m_pVehicle->pPassengers[2]) return TRUE;
|
|
|
|
if(m_pVehicle->pPassengers[3]) return TRUE;
|
|
|
|
if(m_pVehicle->pPassengers[4]) return TRUE;
|
|
|
|
if(m_pVehicle->pPassengers[5]) return TRUE;
|
|
|
|
if(m_pVehicle->pPassengers[6]) return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 22:55:12 +08:00
|
|
|
void CVehicle::SetLockedState(int iLocked)
|
|
|
|
{
|
|
|
|
if(!m_pVehicle) return;
|
|
|
|
|
|
|
|
if(iLocked) {
|
|
|
|
ScriptCommand(&lock_car,m_dwGTAId,1);
|
|
|
|
} else {
|
|
|
|
ScriptCommand(&lock_car,m_dwGTAId,0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 22:58:42 +08:00
|
|
|
void CVehicle::SetEngineState(BOOL bState)
|
|
|
|
{
|
|
|
|
if(!m_pVehicle) return;
|
|
|
|
|
|
|
|
if(!bState) {
|
|
|
|
m_pVehicle->byteFlags &= 0xDF;
|
|
|
|
} else {
|
|
|
|
m_pVehicle->byteFlags |= 0x20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:00:33 +08:00
|
|
|
float CVehicle::GetHealth()
|
|
|
|
{
|
|
|
|
if(m_pVehicle) return m_pVehicle->fHealth;
|
|
|
|
else return 0.0f;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:01:30 +08:00
|
|
|
void CVehicle::SetHealth(float fHealth)
|
|
|
|
{
|
|
|
|
if(m_pVehicle) {
|
|
|
|
m_pVehicle->fHealth = fHealth;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:11:27 +08:00
|
|
|
void CVehicle::SetColor(BYTE byteColor1, BYTE byteColor2)
|
|
|
|
{
|
|
|
|
if(m_pVehicle && GamePool_Vehicle_GetAt(m_dwGTAId)) {
|
|
|
|
m_pVehicle->byteColor1 = byteColor1;
|
|
|
|
m_pVehicle->byteColor2 = byteColor2;
|
|
|
|
}
|
|
|
|
m_byteColor2 = byteColor2;
|
|
|
|
m_byteColor1 = byteColor1;
|
|
|
|
m_bHasNewColor = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:14:44 +08:00
|
|
|
void CVehicle::UpdateColor()
|
|
|
|
{
|
|
|
|
if(!m_pVehicle) return;
|
|
|
|
if(!GamePool_Vehicle_GetAt(m_dwGTAId)) return;
|
|
|
|
|
|
|
|
if(m_bHasNewColor) {
|
|
|
|
if(!field_71) {
|
|
|
|
if(m_byteColor1 != m_pVehicle->byteColor1 || m_byteColor2 != m_pVehicle->byteColor2) {
|
|
|
|
m_pVehicle->byteColor1 = m_byteColor1;
|
|
|
|
m_pVehicle->byteColor2 = m_byteColor2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:03:15 +08:00
|
|
|
BOOL CVehicle::HasSunk()
|
|
|
|
{
|
|
|
|
if(!m_pVehicle) return FALSE;
|
|
|
|
|
|
|
|
return ScriptCommand(&has_car_sunk,m_dwGTAId);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:04:18 +08:00
|
|
|
BOOL CVehicle::IsWrecked()
|
|
|
|
{
|
|
|
|
if(!m_pVehicle) return FALSE;
|
|
|
|
|
|
|
|
return ScriptCommand(&is_car_wrecked,m_dwGTAId);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:05:14 +08:00
|
|
|
BOOL CVehicle::IsDriverLocalPlayer()
|
|
|
|
{
|
|
|
|
if(m_pVehicle) {
|
|
|
|
if((PED_TYPE *)m_pVehicle->pDriver == GamePool_FindPlayerPed()) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:16:18 +08:00
|
|
|
BOOL CVehicle::IsATrainPart()
|
|
|
|
{
|
|
|
|
int nModel;
|
|
|
|
if(m_pVehicle) {
|
|
|
|
nModel = m_pVehicle->entity.nModelIndex;
|
|
|
|
if(nModel == TRAIN_PASSENGER_LOCO) return TRUE;
|
|
|
|
if(nModel == TRAIN_PASSENGER) return TRUE;
|
|
|
|
if(nModel == TRAIN_FREIGHT_LOCO) return TRUE;
|
|
|
|
if(nModel == TRAIN_FREIGHT) return TRUE;
|
|
|
|
if(nModel == TRAIN_TRAM) return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:18:41 +08:00
|
|
|
BOOL CVehicle::HasTurret()
|
|
|
|
{
|
|
|
|
int nModel = GetModelIndex();
|
|
|
|
return (nModel == 432 || // Tank
|
|
|
|
nModel == 564 || // RC Tank
|
|
|
|
nModel == 407 || // Firetruck
|
|
|
|
nModel == 601 // Swatvan
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:20:09 +08:00
|
|
|
void CVehicle::SetSirenOn(BYTE byteState)
|
|
|
|
{
|
|
|
|
m_pVehicle->bSirenOn = byteState;
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:20:41 +08:00
|
|
|
BOOL CVehicle::IsSirenOn()
|
|
|
|
{
|
|
|
|
return (m_pVehicle->bSirenOn == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------------------------
|
|
|
|
|
2024-08-20 23:20:09 +08:00
|
|
|
//-----------------------------------------------------------
|
|
|
|
|