1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
#pragma once
#include "Vehicle.h"
#include "DamageManager.h"
#include "Door.h"
class CObject;
enum eCarNodes
{
CAR_WHEEL_RF = 1,
CAR_WHEEL_RM,
CAR_WHEEL_RB,
CAR_WHEEL_LF,
CAR_WHEEL_LM,
CAR_WHEEL_LB,
CAR_BUMP_FRONT,
CAR_BUMP_REAR,
CAR_WING_RF,
CAR_WING_RR,
CAR_DOOR_RF,
CAR_DOOR_RR,
CAR_WING_LF,
CAR_WING_LR,
CAR_DOOR_LF,
CAR_DOOR_LR,
CAR_BONNET,
CAR_BOOT,
CAR_WINDSCREEN,
NUM_CAR_NODES,
};
enum eCarPositions
{
CAR_POS_HEADLIGHTS,
CAR_POS_TAILLIGHTS,
CAR_POS_FRONTSEAT,
CAR_POS_BACKSEAT,
CAR_POS_EXHAUST = 9,
};
// These are used for all the wheel arrays
// DON'T confuse with VEHWHEEL, which are vehicle components
enum {
CARWHEEL_FRONT_LEFT,
CARWHEEL_REAR_LEFT,
CARWHEEL_FRONT_RIGHT,
CARWHEEL_REAR_RIGHT
};
enum eBombType
{
CARBOMB_NONE,
CARBOMB_TIMED,
CARBOMB_ONIGNITION,
CARBOMB_REMOTE,
CARBOMB_TIMEDACTIVE,
CARBOMB_ONIGNITIONACTIVE,
};
enum {
CAR_DOOR_FLAG_UNKNOWN = 0x0,
CAR_DOOR_FLAG_LF = 0x1,
CAR_DOOR_FLAG_LR = 0x2,
CAR_DOOR_FLAG_RF = 0x4,
CAR_DOOR_FLAG_RR = 0x8
};
class CAutomobile : public CVehicle
{
public:
// 0x288
CDamageManager Damage;
CDoor Doors[6];
RwFrame *m_aCarNodes[NUM_CAR_NODES];
CColPoint m_aWheelColPoints[4];
float m_aSuspensionSpringRatio[4];
float m_aSuspensionSpringRatioPrev[4];
float m_aWheelTimer[4]; // set to 4.0 when wheel is touching ground, then decremented
float field_49C;
bool m_aWheelSkidmarkMuddy[4];
bool m_aWheelSkidmarkBloody[4];
float m_aWheelRotation[4];
float m_aWheelPosition[4];
float m_aWheelSpeed[4];
uint8 field_4D8;
uint8 m_bombType : 3;
uint8 bTaxiLight : 1;
uint8 bHadDriver : 1; // for bombs
uint8 bFixedColour : 1;
uint8 bBigWheels : 1;
uint8 bWaterTight : 1; // no damage for non-player peds
uint8 bNotDamagedUpsideDown : 1;
uint8 bMoreResistantToDamage : 1;
CEntity *m_pBombRigger;
int16 field_4E0;
uint16 m_hydraulicState;
uint32 m_nBusDoorTimerEnd;
uint32 m_nBusDoorTimerStart;
float m_aSuspensionSpringLength[4];
float m_aSuspensionLineLength[4];
float m_fHeightAboveRoad;
float m_fTraction;
float m_fVelocityChangeForAudio;
float m_randomValues[6]; // used for what?
float m_fFireBlowUpTimer;
CPhysical *m_aGroundPhysical[4]; // physicals touching wheels
CVector m_aGroundOffset[4]; // from ground object to colpoint
CEntity *m_pSetOnFireEntity;
float m_weaponDoorTimerLeft; // still don't know what exactly this is
float m_weaponDoorTimerRight;
float m_fCarGunLR;
float m_fCarGunUD;
float m_fPropellerRotation;
uint8 stuff4[4];
uint8 m_nWheelsOnGround;
uint8 m_nDriveWheelsOnGround;
uint8 m_nDriveWheelsOnGroundPrev;
float m_fGasPedalAudio;
tWheelState m_aWheelState[4];
static bool m_sAllTaxiLights;
CAutomobile(int32 id, uint8 CreatedBy);
// from CEntity
void SetModelIndex(uint32 id);
void ProcessControl(void);
void Teleport(CVector v);
void PreRender(void);
void Render(void);
// from CPhysical
int32 ProcessEntityCollision(CEntity *ent, CColPoint *colpoints);
// from CVehicle
void ProcessControlInputs(uint8);
void GetComponentWorldPosition(int32 component, CVector &pos);
bool IsComponentPresent(int32 component);
void SetComponentRotation(int32 component, CVector rotation);
void OpenDoor(int32 component, eDoors door, float openRatio);
void ProcessOpenDoor(uint32, uint32, float);
bool IsDoorReady(eDoors door);
bool IsDoorFullyOpen(eDoors door);
bool IsDoorClosed(eDoors door);
bool IsDoorMissing(eDoors door);
void RemoveRefsToVehicle(CEntity *ent);
void BlowUpCar(CEntity *ent);
bool SetUpWheelColModel(CColModel *colModel);
void BurstTyre(uint8 tyre);
bool IsRoomForPedToLeaveCar(uint32 component, CVector *doorOffset);
float GetHeightAboveRoad(void);
void PlayCarHorn(void);
void FireTruckControl(void);
void TankControl(void);
void HydraulicControl(void);
void VehicleDamage(float impulse, uint16 damagedPiece);
void ProcessBuoyancy(void);
void DoDriveByShootings(void);
int32 RcbanditCheckHitWheels(void);
int32 RcbanditCheck1CarWheels(CPtrList &list);
void PlaceOnRoadProperly(void);
void dmgDrawCarCollidingParticles(const CVector &pos, float amount);
void AddDamagedVehicleParticles(void);
int32 AddWheelDirtAndWater(CColPoint *colpoint, uint32 belowEffectSpeed);
void PlayHornIfNecessary(void);
void ResetSuspension(void);
void SetupSuspensionLines(void);
void ScanForCrimes(void);
void BlowUpCarsInPath(void);
bool HasCarStoppedBecauseOfLight(void);
void SetBusDoorTimer(uint32 timer, uint8 type);
void ProcessAutoBusDoors(void);
void ProcessSwingingDoor(int32 component, eDoors door);
void SetupDamageAfterLoad(void);
CObject *SpawnFlyingComponent(int32 component, uint32 type);
CObject *RemoveBonnetInPedCollision(void);
void SetPanelDamage(int32 component, ePanels panel, bool noFlyingComponents = false);
void SetBumperDamage(int32 component, ePanels panel, bool noFlyingComponents = false);
void SetDoorDamage(int32 component, eDoors door, bool noFlyingComponents = false);
void Fix(void);
void SetComponentVisibility(RwFrame *frame, uint32 flags);
void SetupModelNodes(void);
void SetTaxiLight(bool light);
bool GetAllWheelsOffGround(void);
void HideAllComps(void);
void ShowAllComps(void);
void ReduceHornCounter(void);
static void SetAllTaxiLights(bool set);
};
static_assert(sizeof(CAutomobile) == 0x5A8, "CAutomobile: error");
inline uint8 GetCarDoorFlag(int32 carnode) {
switch (carnode) {
case CAR_DOOR_LF:
return CAR_DOOR_FLAG_LF;
case CAR_DOOR_LR:
return CAR_DOOR_FLAG_LR;
case CAR_DOOR_RF:
return CAR_DOOR_FLAG_RF;
case CAR_DOOR_RR:
return CAR_DOOR_FLAG_RR;
default:
return CAR_DOOR_FLAG_UNKNOWN;
}
}
|