summaryrefslogtreecommitdiff
path: root/src/vehicles/HandlingMgr.h
blob: 2d49761cfbe4efe4b84958c9f2d9235e8e305656 (plain)
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
#pragma once

#include "Transmission.h"

enum tVehicleType
{
	HANDLING_LANDSTAL,
	HANDLING_IDAHO,
	HANDLING_STINGER,
	HANDLING_LINERUN,
	HANDLING_PEREN,
	HANDLING_SENTINEL,
	HANDLING_PATRIOT,
	HANDLING_FIRETRUK,
	HANDLING_TRASH,
	HANDLING_STRETCH,
	HANDLING_MANANA,
	HANDLING_INFERNUS,
	HANDLING_PONY,
	HANDLING_MULE,
	HANDLING_CHEETAH,
	HANDLING_AMBULAN,
	HANDLING_FBICAR,
	HANDLING_MOONBEAM,
	HANDLING_ESPERANT,
	HANDLING_TAXI,
	HANDLING_KURUMA,
	HANDLING_BOBCAT,
	HANDLING_MRWHOOP,
	HANDLING_BFINJECT,
	HANDLING_POLICE,
	HANDLING_ENFORCER,
	HANDLING_SECURICA,
	HANDLING_BANSHEE,
	HANDLING_BUS,
	HANDLING_RHINO,
	HANDLING_BARRACKS,
	HANDLING_TRAIN,
	HANDLING_FERRY,
	HANDLING_HELI,
	HANDLING_DODO,
	HANDLING_COACH,
	HANDLING_CABBIE,
	HANDLING_STALLION,
	HANDLING_RUMPO,
	HANDLING_RCBANDIT,
	HANDLING_MAFIA,
	HANDLING_AIRTRAIN,
	HANDLING_DEADDODO,
	HANDLING_FLATBED,
	HANDLING_YANKEE,
	HANDLING_BLISTA,
	HANDLING_BELLYUP,
	HANDLING_MRWONGS,
	HANDLING_YARDIE,
	HANDLING_YAKUZA,
	HANDLING_DIABLOS,
	HANDLING_COLUMB,
	HANDLING_HOODS,
	HANDLING_PANLANT,
	HANDLING_BORGNINE,
	HANDLING_CAMPVAN,
	HANDLING_BALLOT,
	HANDLING_SPIDER,
	HANDLING_SHELBY,
	HANDLING_PONTIAC,
	HANDLING_ESPRIT,
	HANDLING_MINI,
	HANDLING_HOTROD,
	HANDLING_SINDACCO,
	HANDLING_FORELLI,

	HANDLING_BIKE,
	HANDLING_MOPED,
	HANDLING_DIRTBIKE,
	HANDLING_ANGEL,
	HANDLING_DIRTBIK2,
	HANDLING_ANGE2,
	HANDLING_FREEWAY,

	HANDLING_PREDATOR,
	HANDLING_SPEEDER,
	HANDLING_REEFER,

	HANDLING_MAVERICK,
	HANDLING_COASTMAV,
	HANDLING_POLMAV,
	HANDLING_HUNTER,
	HANDLING_RCGOBLIN,
	HANDLING_RCCOPTER,

	NUMHANDLINGS,

	NUMBIKEHANDLINGS = HANDLING_FREEWAY+1 - HANDLING_BIKE,
	NUMFLYINGHANDLINGS = HANDLING_RCCOPTER+1 - HANDLING_MAVERICK,
	NUMBOATHANDLINGS = HANDLING_REEFER+1 - HANDLING_PREDATOR,
};

enum tField // most likely a handling field enum, never used so :shrug:
{

};

enum
{
	HANDLING_1G_BOOST = 1,
	HANDLING_2G_BOOST = 2,
	HANDLING_REV_BONNET = 4,
	HANDLING_HANGING_BOOT = 8,
	HANDLING_NO_DOORS = 0x10,
	HANDLING_IS_VAN = 0x20,
	HANDLING_IS_BUS = 0x40,
	HANDLING_IS_LOW = 0x80,
	HANDLING_DBL_EXHAUST = 0x100,
	HANDLING_TAILGATE_BOOT = 0x200,
	HANDLING_NOSWING_BOOT = 0x400,
	HANDLING_NONPLAYER_STABILISER = 0x800,
	HANDLING_NEUTRALHANDLING = 0x1000,
	HANDLING_HAS_NO_ROOF = 0x2000,
	HANDLING_IS_BIG = 0x4000,
	HANDLING_HALOGEN_LIGHTS = 0x8000,
	HANDLING_IS_BIKE = 0x10000,
	HANDLING_IS_HELI = 0x20000,
	HANDLING_IS_PLANE = 0x40000,
	HANDLING_IS_BOAT = 0x80000,
	HANDLING_NO_EXHAUST = 0x100000,
	HANDLING_REARWHEEL_1ST = 0x200000,
	HANDLING_HANDBRAKE_TYRE = 0x400000,
	HANDLING_SIT_IN_BOAT = 0x800000,
	HANDLING_FAT_REARW = 0x1000000,
	HANDLING_NARROW_FRONTW = 0x2000000,
	HANDLING_GOOD_INSAND = 0x4000000,
	HANDLING_UNKNOWN = 0x8000000,	// something for helis and planes
	HANDLING_FORCE_GRND_CLR = 0x10000000
};

struct tHandlingData
{
	float fMass;
	float fTurnMass;
	float fTractionMultiplier;
	float fCollisionDamageMultiplier;
	tVehicleType nIdentifier;
	float fInvMass;
	float fDragMult;
	CVector CentreOfMass;
	int8 nPercentSubmerged;
	float fBuoyancy;
	cTransmission Transmission;
	float fBrakeDeceleration;
	float fBrakeBias;
	int8 bABS;
	float fSteeringLock;
	float fTractionLoss;
	float fTractionBias;
	float fUnused;
	float fSuspensionForceLevel;
	float fSuspensionDampingLevel;
	float fSuspensionUpperLimit;
	float fSuspensionLowerLimit;
	float fSuspensionBias;
	float fSuspensionAntidiveMultiplier;
	uint32 Flags;
	float fSeatOffsetDistance;
	int32 nMonetaryValue;
	int8 FrontLights;
	int8 RearLights;
	int unk[4];

	float GetMass(void) const { return fMass; }
	float GetTurnMass(void) const { return fTurnMass; }
	float GetTractionMultiplier(void) const { return fTractionMultiplier; }
	float GetCollisionDamageMultiplier(void) const { return fCollisionDamageMultiplier; }
};

struct tBikeHandlingData
{
	tVehicleType nIdentifier;
	float fLeanFwdCOM;
	float fLeanFwdForce;
	float fLeanBakCOM;
	float fLeanBackForce;
	float fMaxLean;
	float fFullAnimLean;
	float fDesLean;
	float fSpeedSteer;
	float fSlipSteer;
	float fNoPlayerCOMz;
	float fWheelieAng;
	float fStoppieAng;
	float fWheelieSteer;
	float fWheelieStabMult;
	float fStoppieStabMult;
};

struct tBoatHandlingData
{
	tVehicleType nIdentifier;
	float fThrustY;
	float fThrustZ;
	float fThrustAppZ;
	float fAqPlaneForce;
	float fAqPlaneLimit;
	float fAqPlaneOffset;
	float fWaveAudioMult;
	float fLook_L_R_BehindCamHeight;
	CVector vecMoveRes;
	CVector vecTurnRes;
};

struct  tFlyingHandlingData
{
	tVehicleType nIdentifier;
	float fThrust;
	float fThrustFallOff;
	float fYaw;
	float fYawStab;
	float fSideSlip;
	float fRoll;
	float fRollStab;
	float fPitch;
	float fPitchStab;
	float fFormLift;
	float fAttackLift;
	float fMoveRes;
	CVector vecTurnRes;
	CVector vecSpeedRes;
};

class CVehicle;

class cHandlingDataMgr
{
	float field_0;	// unused it seems
public:
	float fWheelFriction;	// wheel related
private:
	float field_8;	//
	float field_C;	// unused it seems
	float field_10;	//
	tHandlingData HandlingData[NUMHANDLINGS];
	tBikeHandlingData BikeHandlingData[NUMBIKEHANDLINGS];
	tFlyingHandlingData FlyingHandlingData[NUMFLYINGHANDLINGS];
	tBoatHandlingData BoatHandlingData[NUMBOATHANDLINGS];

public:
	cHandlingDataMgr(void);
	void Initialise(void);
	void LoadHandlingData(void);
	int FindExactWord(const char *word, const char *words, int wordLen, int numWords);
	void ConvertDataToWorldUnits(tHandlingData *handling);
	void ConvertDataToGameUnits(tHandlingData *handling);
	void ConvertBikeDataToGameUnits(tBikeHandlingData *handling);
	int32 GetHandlingId(const char *name);
	tHandlingData *GetHandlingData(tVehicleType id) { return &HandlingData[id]; }
	tBikeHandlingData *GetBikePointer(uint8 id) { return &BikeHandlingData[id-HANDLING_BIKE]; }
	tFlyingHandlingData *GetFlyingPointer(uint8 id);
	tBoatHandlingData *GetBoatPointer(uint8 id);
	bool HasRearWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType != 'F'; }
	bool HasFrontWheelDrive(tVehicleType id) { return HandlingData[id].Transmission.nDriveType != 'R'; }
};
extern cHandlingDataMgr mod_HandlingManager;