2019-05-15 10:52:37 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Physical.h"
|
2019-07-05 18:44:49 -04:00
|
|
|
#include "AutoPilot.h"
|
2019-12-31 18:35:54 -05:00
|
|
|
#include "ModelIndices.h"
|
2020-02-29 20:43:30 -05:00
|
|
|
#include "AnimManager.h"
|
2020-03-31 18:58:40 -04:00
|
|
|
#include "Weapon.h"
|
2019-05-15 10:52:37 -04:00
|
|
|
|
|
|
|
class CPed;
|
2019-06-24 10:57:54 -04:00
|
|
|
class CFire;
|
|
|
|
struct tHandlingData;
|
|
|
|
|
2019-07-05 08:23:39 -04:00
|
|
|
enum {
|
|
|
|
RANDOM_VEHICLE = 1,
|
|
|
|
MISSION_VEHICLE = 2,
|
|
|
|
PARKED_VEHICLE = 3,
|
|
|
|
PERMANENT_VEHICLE = 4,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum eCarLock {
|
2019-06-24 10:57:54 -04:00
|
|
|
CARLOCK_NOT_USED,
|
|
|
|
CARLOCK_UNLOCKED,
|
|
|
|
CARLOCK_LOCKED,
|
|
|
|
CARLOCK_LOCKOUT_PLAYER_ONLY,
|
|
|
|
CARLOCK_LOCKED_PLAYER_INSIDE,
|
2019-07-14 05:49:03 -04:00
|
|
|
CARLOCK_LOCKED_INITIALLY,
|
2019-06-24 10:57:54 -04:00
|
|
|
CARLOCK_FORCE_SHUT_DOORS,
|
|
|
|
CARLOCK_SKIP_SHUT_DOORS
|
|
|
|
};
|
2019-05-15 10:52:37 -04:00
|
|
|
|
2019-07-06 13:44:00 -04:00
|
|
|
|
2019-07-26 12:48:14 -04:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
BOAT_POS_FRONTSEAT
|
|
|
|
};
|
|
|
|
|
2019-07-06 13:44:00 -04:00
|
|
|
enum eDoors
|
2019-07-02 14:35:47 -04:00
|
|
|
{
|
2019-07-06 13:44:00 -04:00
|
|
|
DOOR_BONNET = 0,
|
|
|
|
DOOR_BOOT,
|
|
|
|
DOOR_FRONT_LEFT,
|
|
|
|
DOOR_FRONT_RIGHT,
|
|
|
|
DOOR_REAR_LEFT,
|
|
|
|
DOOR_REAR_RIGHT
|
2019-07-02 14:35:47 -04:00
|
|
|
};
|
|
|
|
|
2019-07-08 02:46:42 -04:00
|
|
|
enum ePanels
|
|
|
|
{
|
|
|
|
VEHPANEL_FRONT_LEFT,
|
|
|
|
VEHPANEL_FRONT_RIGHT,
|
|
|
|
VEHPANEL_REAR_LEFT,
|
|
|
|
VEHPANEL_REAR_RIGHT,
|
|
|
|
VEHPANEL_WINDSCREEN,
|
|
|
|
VEHBUMPER_FRONT,
|
|
|
|
VEHBUMPER_REAR,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum eLights
|
|
|
|
{
|
|
|
|
VEHLIGHT_FRONT_LEFT,
|
|
|
|
VEHLIGHT_FRONT_RIGHT,
|
|
|
|
VEHLIGHT_REAR_LEFT,
|
|
|
|
VEHLIGHT_REAR_RIGHT,
|
|
|
|
};
|
|
|
|
|
2019-07-08 15:37:47 -04:00
|
|
|
enum eWheels
|
|
|
|
{
|
|
|
|
VEHWHEEL_FRONT_LEFT,
|
|
|
|
VEHWHEEL_FRONT_RIGHT,
|
|
|
|
VEHWHEEL_REAR_LEFT,
|
|
|
|
VEHWHEEL_REAR_RIGHT,
|
|
|
|
};
|
|
|
|
|
2019-07-08 11:07:34 -04:00
|
|
|
enum
|
|
|
|
{
|
2019-07-18 15:41:20 -04:00
|
|
|
CAR_PIECE_BONNET = 1,
|
|
|
|
CAR_PIECE_BOOT,
|
|
|
|
CAR_PIECE_BUMP_FRONT,
|
|
|
|
CAR_PIECE_BUMP_REAR,
|
|
|
|
CAR_PIECE_DOOR_LF,
|
|
|
|
CAR_PIECE_DOOR_RF,
|
|
|
|
CAR_PIECE_DOOR_LR,
|
|
|
|
CAR_PIECE_DOOR_RR,
|
|
|
|
CAR_PIECE_WING_LF,
|
|
|
|
CAR_PIECE_WING_RF,
|
|
|
|
CAR_PIECE_WING_LR,
|
|
|
|
CAR_PIECE_WING_RR,
|
|
|
|
CAR_PIECE_WHEEL_LF,
|
2019-07-08 11:07:34 -04:00
|
|
|
CAR_PIECE_WHEEL_LR,
|
|
|
|
CAR_PIECE_WHEEL_RF,
|
|
|
|
CAR_PIECE_WHEEL_RR,
|
2019-07-18 15:41:20 -04:00
|
|
|
CAR_PIECE_WINDSCREEN,
|
2019-07-08 11:07:34 -04:00
|
|
|
};
|
|
|
|
|
2019-07-09 17:49:44 -04:00
|
|
|
enum tWheelState
|
|
|
|
{
|
2019-07-28 07:14:08 -04:00
|
|
|
WHEEL_STATE_NORMAL, // standing still or rolling normally
|
|
|
|
WHEEL_STATE_SPINNING, // rotating but not moving
|
|
|
|
WHEEL_STATE_SKIDDING,
|
|
|
|
WHEEL_STATE_FIXED, // not rotating
|
2019-07-09 17:49:44 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum eFlightModel
|
|
|
|
{
|
|
|
|
FLIGHT_MODEL_DODO,
|
|
|
|
// not used in III
|
|
|
|
FLIGHT_MODEL_RCPLANE,
|
|
|
|
FLIGHT_MODEL_HELI,
|
|
|
|
FLIGHT_MODEL_SEAPLANE
|
|
|
|
};
|
|
|
|
|
2019-08-03 18:31:00 -04:00
|
|
|
// Or Weapon.h?
|
|
|
|
void FireOneInstantHitRound(CVector *shotSource, CVector *shotTarget, int32 damage);
|
|
|
|
|
2019-05-15 10:52:37 -04:00
|
|
|
class CVehicle : public CPhysical
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// 0x128
|
2019-07-17 07:19:20 -04:00
|
|
|
tHandlingData *pHandling;
|
2019-07-16 13:48:50 -04:00
|
|
|
CAutoPilot AutoPilot;
|
2019-05-28 15:17:47 -04:00
|
|
|
uint8 m_currentColour1;
|
|
|
|
uint8 m_currentColour2;
|
2019-07-05 08:23:39 -04:00
|
|
|
uint8 m_aExtras[2];
|
2019-07-18 09:41:09 -04:00
|
|
|
int16 m_nAlarmState;
|
2019-06-24 10:57:54 -04:00
|
|
|
int16 m_nMissionValue;
|
2019-05-15 10:52:37 -04:00
|
|
|
CPed *pDriver;
|
|
|
|
CPed *pPassengers[8];
|
2019-06-24 10:57:54 -04:00
|
|
|
uint8 m_nNumPassengers;
|
|
|
|
int8 m_nNumGettingIn;
|
|
|
|
int8 m_nGettingInFlags;
|
|
|
|
int8 m_nGettingOutFlags;
|
|
|
|
uint8 m_nNumMaxPassengers;
|
2020-04-11 14:01:39 -04:00
|
|
|
char field_1CD[3];
|
|
|
|
float field_1D0[4];
|
2019-07-09 03:57:44 -04:00
|
|
|
CEntity *m_pCurGroundEntity;
|
2019-06-24 10:57:54 -04:00
|
|
|
CFire *m_pCarFire;
|
|
|
|
float m_fSteerAngle;
|
|
|
|
float m_fGasPedal;
|
2019-07-11 06:48:49 -04:00
|
|
|
float m_fBrakePedal;
|
2019-07-05 08:23:39 -04:00
|
|
|
uint8 VehicleCreatedBy;
|
|
|
|
|
|
|
|
// cf. https://github.com/DK22Pac/plugin-sdk/blob/master/plugin_sa/game_sa/CVehicle.h from R*
|
|
|
|
uint8 bIsLawEnforcer: 1; // Is this guy chasing the player at the moment
|
|
|
|
uint8 bIsAmbulanceOnDuty: 1; // Ambulance trying to get to an accident
|
|
|
|
uint8 bIsFireTruckOnDuty: 1; // Firetruck trying to get to a fire
|
|
|
|
uint8 bIsLocked: 1; // Is this guy locked by the script (cannot be removed)
|
|
|
|
uint8 bEngineOn: 1; // For sound purposes. Parked cars have their engines switched off (so do destroyed cars)
|
|
|
|
uint8 bIsHandbrakeOn: 1; // How's the handbrake doing ?
|
|
|
|
uint8 bLightsOn: 1; // Are the lights switched on ?
|
|
|
|
uint8 bFreebies: 1; // Any freebies left in this vehicle ?
|
|
|
|
|
|
|
|
uint8 bIsVan: 1; // Is this vehicle a van (doors at back of vehicle)
|
|
|
|
uint8 bIsBus: 1; // Is this vehicle a bus
|
|
|
|
uint8 bIsBig: 1; // Is this vehicle a bus
|
|
|
|
uint8 bLowVehicle: 1; // Need this for sporty type cars to use low getting-in/out anims
|
2019-07-11 06:48:49 -04:00
|
|
|
uint8 bComedyControls : 1; // Will make the car hard to control (hopefully in a funny way)
|
2019-07-16 13:48:50 -04:00
|
|
|
uint8 bWarnedPeds : 1; // Has scan and warn peds of danger been processed?
|
2019-07-27 14:28:18 -04:00
|
|
|
uint8 bCraneMessageDone : 1; // A crane message has been printed for this car allready
|
|
|
|
uint8 bExtendedRange : 1; // This vehicle needs to be a bit further away to get deleted
|
2019-07-05 08:23:39 -04:00
|
|
|
|
2019-07-18 15:41:20 -04:00
|
|
|
uint8 bTakeLessDamage : 1; // This vehicle is stronger (takes about 1/4 of damage)
|
2019-07-09 12:50:35 -04:00
|
|
|
uint8 bIsDamaged : 1; // This vehicle has been damaged and is displaying all its components
|
2019-07-16 13:48:50 -04:00
|
|
|
uint8 bHasBeenOwnedByPlayer : 1;// To work out whether stealing it is a crime
|
|
|
|
uint8 bFadeOut : 1; // Fade vehicle out
|
2019-10-10 17:02:55 -04:00
|
|
|
uint8 bIsBeingCarJacked : 1; // Fade vehicle out
|
2019-08-11 13:11:54 -04:00
|
|
|
uint8 bCreateRoadBlockPeds : 1; // If this vehicle gets close enough we will create peds (coppers or gang members) round it
|
2019-07-09 12:50:35 -04:00
|
|
|
uint8 bCanBeDamaged : 1; // Set to FALSE during cut scenes to avoid explosions
|
2019-07-27 07:02:49 -04:00
|
|
|
uint8 bUsingSpecialColModel : 1;// Is player vehicle using special collision model, stored in player strucure
|
2019-07-05 08:23:39 -04:00
|
|
|
|
2019-10-10 17:02:55 -04:00
|
|
|
uint8 bOccupantsHaveBeenGenerated : 1; // Is true if the occupants have already been generated. (Shouldn't happen again)
|
|
|
|
uint8 bGunSwitchedOff : 1; // Level designers can use this to switch off guns on boats
|
2019-07-09 12:50:35 -04:00
|
|
|
uint8 bVehicleColProcessed : 1;// Has ProcessEntityCollision been processed for this car?
|
|
|
|
uint8 bIsCarParkVehicle : 1; // Car has been created using the special CAR_PARK script command
|
|
|
|
uint8 bHasAlreadyBeenRecorded : 1; // Used for replays
|
2019-07-05 08:23:39 -04:00
|
|
|
|
2019-08-01 18:04:30 -04:00
|
|
|
int8 m_numPedsUseItAsCover;
|
2019-07-05 08:23:39 -04:00
|
|
|
uint8 m_nAmmoInClip; // Used to make the guns on boat do a reload (20 by default)
|
2019-08-11 13:11:54 -04:00
|
|
|
int8 m_nPacManPickupsCarried;
|
|
|
|
uint8 m_nRoadblockType;
|
|
|
|
int16 m_nRoadblockNode;
|
2019-07-18 09:41:09 -04:00
|
|
|
float m_fHealth; // 1000.0f = full health. 250.0f = fire. 0 -> explode
|
2019-06-24 10:57:54 -04:00
|
|
|
uint8 m_nCurrentGear;
|
|
|
|
int8 field_205[3];
|
2019-07-17 17:58:06 -04:00
|
|
|
float m_fChangeGearTime;
|
2019-06-24 10:57:54 -04:00
|
|
|
uint32 m_nGunFiringTime; // last time when gun on vehicle was fired (used on boats)
|
|
|
|
uint32 m_nTimeOfDeath;
|
2019-09-14 13:53:04 -04:00
|
|
|
uint16 m_nTimeBlocked;
|
2019-06-24 10:57:54 -04:00
|
|
|
int16 m_nBombTimer; // goes down with each frame
|
2019-07-16 13:48:50 -04:00
|
|
|
CEntity *m_pBlowUpEntity;
|
2019-09-12 06:11:13 -04:00
|
|
|
float m_fMapObjectHeightAhead; // front Z?
|
|
|
|
float m_fMapObjectHeightBehind; // rear Z?
|
2019-06-24 10:57:54 -04:00
|
|
|
eCarLock m_nDoorLock;
|
|
|
|
int8 m_nLastWeaponDamage; // see eWeaponType, -1 if no damage
|
|
|
|
int8 m_nRadioStation;
|
2019-08-02 11:43:40 -04:00
|
|
|
uint8 m_bRainAudioCounter;
|
|
|
|
uint8 m_bRainSamplesCounter;
|
2019-06-24 10:57:54 -04:00
|
|
|
uint8 m_nCarHornTimer;
|
2019-09-24 07:33:16 -04:00
|
|
|
int8 field_22D; // last horn?
|
2019-07-09 12:50:35 -04:00
|
|
|
bool m_bSirenOrAlarm;
|
2019-07-11 06:48:49 -04:00
|
|
|
int8 m_comedyControlState;
|
2019-07-09 17:49:44 -04:00
|
|
|
CStoredCollPoly m_aCollPolys[2]; // poly which is under front/rear part of car
|
2019-06-24 10:57:54 -04:00
|
|
|
float m_fSteerRatio;
|
|
|
|
eVehicleType m_vehType;
|
2019-05-17 08:08:18 -04:00
|
|
|
|
2019-06-02 11:13:56 -04:00
|
|
|
static void *operator new(size_t);
|
2019-06-30 06:59:55 -04:00
|
|
|
static void *operator new(size_t sz, int slot);
|
2019-06-02 11:13:56 -04:00
|
|
|
static void operator delete(void*, size_t);
|
2019-06-30 09:20:11 -04:00
|
|
|
static void operator delete(void*, int);
|
2019-06-02 11:13:56 -04:00
|
|
|
|
2019-07-09 17:49:44 -04:00
|
|
|
CVehicle(void) {} // FAKE
|
|
|
|
CVehicle(uint8 CreatedBy);
|
2019-06-30 06:59:55 -04:00
|
|
|
~CVehicle(void);
|
2019-07-05 08:23:39 -04:00
|
|
|
// from CEntity
|
2019-07-08 02:46:42 -04:00
|
|
|
void SetModelIndex(uint32 id);
|
2019-07-05 08:23:39 -04:00
|
|
|
bool SetupLighting(void);
|
|
|
|
void RemoveLighting(bool);
|
|
|
|
void FlagToDestroyWhenNextProcessed(void) {}
|
2019-06-30 06:59:55 -04:00
|
|
|
|
2019-07-05 08:23:39 -04:00
|
|
|
virtual void ProcessControlInputs(uint8) {}
|
|
|
|
virtual void GetComponentWorldPosition(int32 component, CVector &pos) {}
|
|
|
|
virtual bool IsComponentPresent(int32 component) { return false; }
|
|
|
|
virtual void SetComponentRotation(int32 component, CVector rotation) {}
|
|
|
|
virtual void OpenDoor(int32, eDoors door, float) {}
|
|
|
|
virtual void ProcessOpenDoor(uint32, uint32, float) {}
|
|
|
|
virtual bool IsDoorReady(eDoors door) { return false; }
|
|
|
|
virtual bool IsDoorFullyOpen(eDoors door) { return false; }
|
|
|
|
virtual bool IsDoorClosed(eDoors door) { return false; }
|
|
|
|
virtual bool IsDoorMissing(eDoors door) { return false; }
|
|
|
|
virtual void RemoveRefsToVehicle(CEntity *ent) {}
|
|
|
|
virtual void BlowUpCar(CEntity *ent) {}
|
|
|
|
virtual bool SetUpWheelColModel(CColModel *colModel) { return false; }
|
|
|
|
virtual void BurstTyre(uint8 tyre) {}
|
2019-07-26 12:48:14 -04:00
|
|
|
virtual bool IsRoomForPedToLeaveCar(uint32 component, CVector *forcedDoorPos) { return false;}
|
2019-07-05 08:23:39 -04:00
|
|
|
virtual float GetHeightAboveRoad(void);
|
|
|
|
virtual void PlayCarHorn(void) {}
|
2019-06-30 06:59:55 -04:00
|
|
|
|
2019-10-25 12:39:26 -04:00
|
|
|
bool IsCar(void) { return m_vehType == VEHICLE_TYPE_CAR; }
|
2019-05-17 08:08:18 -04:00
|
|
|
bool IsBoat(void) { return m_vehType == VEHICLE_TYPE_BOAT; }
|
|
|
|
bool IsTrain(void) { return m_vehType == VEHICLE_TYPE_TRAIN; }
|
|
|
|
bool IsHeli(void) { return m_vehType == VEHICLE_TYPE_HELI; }
|
|
|
|
bool IsPlane(void) { return m_vehType == VEHICLE_TYPE_PLANE; }
|
2020-04-08 15:29:02 -04:00
|
|
|
bool IsBike(void) { return m_vehType == VEHICLE_TYPE_BIKE; }
|
2019-07-09 17:49:44 -04:00
|
|
|
|
|
|
|
void FlyingControl(eFlightModel flightModel);
|
2019-07-10 05:05:49 -04:00
|
|
|
void ProcessWheel(CVector &wheelFwd, CVector &wheelRight, CVector &wheelContactSpeed, CVector &wheelContactPoint,
|
|
|
|
int32 wheelsOnGround, float thrust, float brake, float adhesion, int8 wheelId, float *wheelSpeed, tWheelState *wheelState, uint16 wheelStatus);
|
2019-07-09 17:49:44 -04:00
|
|
|
void ExtinguishCarFire(void);
|
|
|
|
void ProcessDelayedExplosion(void);
|
|
|
|
float ProcessWheelRotation(tWheelState state, const CVector &fwd, const CVector &speed, float radius);
|
2019-06-24 10:57:54 -04:00
|
|
|
bool IsLawEnforcementVehicle(void);
|
2019-07-05 08:23:39 -04:00
|
|
|
void ChangeLawEnforcerState(uint8 enable);
|
|
|
|
bool UsesSiren(uint32 id);
|
|
|
|
bool IsVehicleNormal(void);
|
|
|
|
bool CarHasRoof(void);
|
2019-06-24 10:57:54 -04:00
|
|
|
bool IsUpsideDown(void);
|
2019-07-05 08:23:39 -04:00
|
|
|
bool IsOnItsSide(void);
|
|
|
|
bool CanBeDeleted(void);
|
|
|
|
bool CanPedOpenLocks(CPed *ped);
|
|
|
|
bool CanPedEnterCar(void);
|
|
|
|
bool CanPedExitCar(void);
|
|
|
|
// do these two actually return something?
|
|
|
|
CPed *SetUpDriver(void);
|
|
|
|
CPed *SetupPassenger(int n);
|
|
|
|
void SetDriver(CPed *driver);
|
|
|
|
bool AddPassenger(CPed *passenger);
|
|
|
|
bool AddPassenger(CPed *passenger, uint8 n);
|
|
|
|
void RemovePassenger(CPed *passenger);
|
|
|
|
void RemoveDriver(void);
|
|
|
|
void ProcessCarAlarm(void);
|
|
|
|
bool IsSphereTouchingVehicle(float sx, float sy, float sz, float radius);
|
2019-08-12 18:30:31 -04:00
|
|
|
bool ShufflePassengersToMakeSpace(void);
|
2020-03-31 18:58:40 -04:00
|
|
|
void InflictDamage(CEntity *damagedBy, eWeaponType weaponType, float damage);
|
2020-04-12 18:02:11 -04:00
|
|
|
void DoFixedMachineGuns(void);
|
2019-07-18 09:41:09 -04:00
|
|
|
|
|
|
|
bool IsAlarmOn(void) { return m_nAlarmState != 0 && m_nAlarmState != -1; }
|
2019-08-17 08:44:25 -04:00
|
|
|
CVehicleModelInfo* GetModelInfo() { return (CVehicleModelInfo*)CModelInfo::GetModelInfo(GetModelIndex()); }
|
2019-12-31 18:35:54 -05:00
|
|
|
bool IsTaxi(void) { return GetModelIndex() == MI_TAXI || GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_BORGNINE; }
|
2020-02-29 20:43:30 -05:00
|
|
|
AnimationId GetDriverAnim(void) { return IsCar() && bLowVehicle ? ANIM_CAR_LSIT : (IsBoat() && GetModelIndex() != MI_SPEEDER ? ANIM_DRIVE_BOAT : ANIM_CAR_SIT); }
|
|
|
|
|
2019-06-16 18:16:38 -04:00
|
|
|
static bool &bWheelsOnlyCheat;
|
|
|
|
static bool &bAllDodosCheat;
|
|
|
|
static bool &bCheat3;
|
|
|
|
static bool &bCheat4;
|
|
|
|
static bool &bCheat5;
|
2019-07-03 11:26:15 -04:00
|
|
|
static bool &m_bDisableMouseSteering;
|
2019-05-15 10:52:37 -04:00
|
|
|
};
|
2019-06-24 10:57:54 -04:00
|
|
|
|
2019-05-15 10:52:37 -04:00
|
|
|
static_assert(sizeof(CVehicle) == 0x288, "CVehicle: error");
|
2019-07-09 03:57:44 -04:00
|
|
|
static_assert(offsetof(CVehicle, m_pCurGroundEntity) == 0x1E0, "CVehicle: error");
|
2019-06-24 10:57:54 -04:00
|
|
|
static_assert(offsetof(CVehicle, m_nAlarmState) == 0x1A0, "CVehicle: error");
|
2019-07-05 08:23:39 -04:00
|
|
|
static_assert(offsetof(CVehicle, m_nLastWeaponDamage) == 0x228, "CVehicle: error");
|
2019-07-08 11:07:34 -04:00
|
|
|
|
2019-07-08 15:44:32 -04:00
|
|
|
class cTransmission;
|
|
|
|
|
|
|
|
class cVehicleParams
|
|
|
|
{
|
|
|
|
public:
|
2019-11-29 10:30:04 -05:00
|
|
|
bool m_bDistanceCalculated;
|
2019-07-08 15:44:32 -04:00
|
|
|
char gap_1[3];
|
|
|
|
float m_fDistance;
|
|
|
|
CVehicle *m_pVehicle;
|
|
|
|
cTransmission *m_pTransmission;
|
|
|
|
int m_nIndex;
|
|
|
|
float m_fVelocityChange;
|
|
|
|
};
|
|
|
|
|
2019-11-29 10:30:04 -05:00
|
|
|
static_assert(sizeof(cVehicleParams) == 0x18, "cVehicleParams: error");
|
2020-03-28 08:24:13 -04:00
|
|
|
|
|
|
|
void DestroyVehicleAndDriverAndPassengers(CVehicle* pVehicle);
|