-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathtdw_vdamage.inc
362 lines (309 loc) · 10.5 KB
/
tdw_vdamage.inc
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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
/* ========================================================================== *\
Damage status
| Description:
Change the visual appearance of the vehicle. It interacts with all parts of
the vehicles.
| License:
Copyright (c) 2016-2017 Double V
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgement in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
| Metadata:
[Functions]:
Stock:
- GetVehicleDoorsStatus
- GetVehicleLightsStatus
- GetVehiclePanelsStatus
- GetVehicleTiresStatus
- SetVehicleDoorsStatus
- SetVehicleLightsStatus
- SetVehiclePanelsStatus
- SetVehicleTiresStatus
Static:
-
Public:
-
Hooks:
-
[Callbacks]:
-
[Definitions]:
-
[Enumerations]:
-
[Macros]:
-
[Tags]:
-
[Variables]:
Global scope:
-
Static scope:
- TDW_g_sNullStorage
[Natives]:
-
[Operators]:
-
| Dependencies:
-
\* ========================================================================== */
#if defined _inc_tdw_vdamage
// I remove this constant because the compiler automatically generates it.
// github.com/Zeex/pawn/issues/107
#undef _inc_tdw_vdamage
#endif
#if defined _TDW_VH_DAMAGE_STATUS
#endinput
#endif
#define _TDW_VH_DAMAGE_STATUS
#include "tdw_vehicle"
// -----------------------------------------------------------------------------
// Static scope:
static stock
TDW_g_sNullStorage = 0; // We use this to reduce the size of the stack.
// -----------------------------------------------------------------------------
// Functions:
/** ------------------------------------------------------------------------ **\
<summary>GetVehicleLightsStatus</summary>
<param name="vehicleid">The ID of the vehicle</param>
<param name="&front_left_light">The state of the front left light</param>
<param name="&front_right_light">The state of the front right light</param>
<param name="&back_lights">The state of the back lights</param>
<returns>
-
</returns>
<remarks>
</remarks>
\** ------------------------------------------------------------------------ **/
stock GetVehicleLightsStatus(vehicleid, &front_left_light, &front_right_light,
&back_lights)
{
new
lights;
// Check availability of the vehicle in the game and get the flag of
// the headlights.
if (0 == GetVehicleDamageStatus(vehicleid, TDW_g_sNullStorage,
TDW_g_sNullStorage, lights, TDW_g_sNullStorage))
return 0;
front_left_light = lights & 1;
front_right_light = (lights >>> 2) & 1;
back_lights = (lights >>> 6) & 1;
return 1;
}
/** ------------------------------------------------------------------------ **\
<summary>SetVehicleLightsStatus</summary>
<param name="vehicleid">The ID of the vehicle</param>
<param name="front_left_light">The state of the front left light</param>
<param name="front_right_light">The state of the front right light</param>
<param name="back_lights">The state of the back lights</param>
<returns>
-
</returns>
<remarks>
</remarks>
\** ------------------------------------------------------------------------ **/
stock SetVehicleLightsStatus(vehicleid, front_left_light, front_right_light,
back_lights)
{
new
panels,
doors,
tires;
// Check availability of the vehicle in the game and get the flags of
// other statuses.
if (0 == GetVehicleDamageStatus(vehicleid, panels, doors,
TDW_g_sNullStorage, tires))
return 0;
UpdateVehicleDamageStatus(vehicleid, panels, doors,
((back_lights & 1) << 6) | ((front_right_light & 1) << 2) |
(front_left_light & 1), tires);
return 1;
}
/** ------------------------------------------------------------------------ **\
<summary>GetVehicleTiresStatus</summary>
<param name="vehicleid">The ID of the vehicle</param>
<param name="&rear_right_tire">The state of the rear right tire</param>
<param name="&front_right_tire">The state of the front right tire</param>
<param name="&rear_left_tire">The state of the rear left tire</param>
<param name="&front_left_tire">The state of the front left tire</param>
<returns>
-
</returns>
<remarks>
</remarks>
\** ------------------------------------------------------------------------ **/
stock GetVehicleTiresStatus(vehicleid, &rear_right_tire, &front_right_tire,
&rear_left_tire, &front_left_tire)
{
new
tires;
if (0 == GetVehicleDamageStatus(vehicleid, TDW_g_sNullStorage,
TDW_g_sNullStorage, TDW_g_sNullStorage, tires))
return 0;
rear_right_tire = tires & 1;
front_right_tire = (tires >>> 1) & 1;
rear_left_tire = (tires >>> 2) & 1;
front_left_tire = (tires >>> 3) & 1;
return 1;
}
/** ------------------------------------------------------------------------ **\
<summary>SetVehicleTiresStatus</summary>
<param name="vehicleid">The ID of the vehicle</param>
<param name="rear_right_tire">The state of the rear right tire</param>
<param name="front_right_tire">The state of the front right tire</param>
<param name="rear_left_tire">The state of the rear left tire</param>
<param name="front_left_tire">The state of the front left tire</param>
<returns>
-
</returns>
<remarks>
</remarks>
\** ------------------------------------------------------------------------ **/
stock SetVehicleTiresStatus(vehicleid, rear_right_tire, front_right_tire,
rear_left_tire, front_left_tire)
{
new
panels,
doors,
lights;
if (0 == GetVehicleDamageStatus(vehicleid, panels, doors, lights,
TDW_g_sNullStorage))
return 0;
UpdateVehicleDamageStatus(vehicleid, panels, doors, lights,
rear_right_tire | (front_right_tire << 1) | (rear_left_tire << 2) |
(front_left_tire << 3)
);
return 1;
}
/** ------------------------------------------------------------------------ **\
<summary>GetVehiclePanelsStatus</summary>
<param name="vehicleid">The ID of the vehicle</param>
<param name="&front_left_panel">The state of the front left panel</param>
<param name="&front_right_panel">The state of the front right panel</param>
<param name="&rear_left_panel">The state of the rear left panel</param>
<param name="&rear_right_panel">The state of the rear right panel</param>
<param name="&windshield">The state of the windshield</param>
<param name="&front_bumper">The state of the front bumper</param>
<param name="&rear_bumper">The state of the rear bumper</param>
<returns>
-
</returns>
<remarks>
</remarks>
\** ------------------------------------------------------------------------ **/
stock GetVehiclePanelsStatus(vehicleid, &front_left_panel, &front_right_panel,
&rear_left_panel, &rear_right_panel, &windshield, &front_bumper,
&rear_bumper)
{
new
panels;
if (0 == GetVehicleDamageStatus(vehicleid, panels, TDW_g_sNullStorage,
TDW_g_sNullStorage, TDW_g_sNullStorage))
return 0;
front_left_panel = panels & 0xF;
front_right_panel = (panels >> 4) & 0xF;
rear_left_panel = (panels >> 8) & 0xF;
rear_right_panel = (panels >> 12) & 0xF;
windshield = (panels >> 16) & 0xF;
front_bumper = (panels >> 20) & 0xF;
rear_bumper = (panels >> 24) & 0xF;
return 1;
}
/** ------------------------------------------------------------------------ **\
<summary>SetVehiclePanelsStatus</summary>
<param name="vehicleid">The ID of the vehicle</param>
<param name="front_left_panel">The state of the front left panel</param>
<param name="front_right_panel">The state of the front right panel</param>
<param name="rear_left_panel">The state of the rear left panel</param>
<param name="rear_right_panel">The state of the rear right panel</param>
<param name="windshield">The state of the windshield</param>
<param name="front_bumper">The state of the front bumper</param>
<param name="rear_bumper">The state of the rear bumper</param>
<returns>
-
</returns>
<remarks>
</remarks>
\** ------------------------------------------------------------------------ **/
stock SetVehiclePanelsStatus(vehicleid, front_left_panel, front_right_panel,
rear_left_panel, rear_right_panel, windshield, front_bumper,
rear_bumper)
{
new
doors,
lights,
tires;
if (0 == GetVehicleDamageStatus(vehicleid, TDW_g_sNullStorage, doors,
lights, tires))
return 0;
UpdateVehicleDamageStatus(vehicleid, (front_left_panel |
(front_right_panel << 4) | (rear_left_panel << 8) |
(rear_right_panel << 12) | (windshield << 16) | (front_bumper << 20) |
(rear_bumper << 24)), doors, lights, tires
);
return 1;
}
/** ------------------------------------------------------------------------ **\
<summary>GetVehicleDoorsStatus</summary>
<param name="vehicleid">The ID of the vehicle</param>
<param name="&bonnet">The state of the bonnet</param>
<param name="&boot">The state of the rear boot</param>
<param name="&driver_door">The state of the driver door</param>
<param name="&passenger_door">The state of the passenger door</param>
<returns>
-
</returns>
<remarks>
</remarks>
\** ------------------------------------------------------------------------ **/
stock GetVehicleDoorsStatus(vehicleid, &bonnet, &boot, &driver_door,
&passenger_door)
{
new
doors;
if (0 == GetVehicleDamageStatus(vehicleid, TDW_g_sNullStorage, doors,
TDW_g_sNullStorage, TDW_g_sNullStorage))
return 0;
bonnet = doors & 7;
boot = (doors >>> 8) & 7;
driver_door = (doors >>> 16) & 7;
passenger_door = (doors >>> 24) & 7;
return 1;
}
/** ------------------------------------------------------------------------ **\
<summary>SetVehicleDoorsStatus</summary>
<param name="bonnet">The state of the bonnet</param>
<param name="boot">The state of the rear boot</param>
<param name="driver_door">The state of the driver door</param>
<param name="passenger_door">The state of the passenger door</param>
<returns>
-
</returns>
<remarks>
</remarks>
\** ------------------------------------------------------------------------ **/
stock SetVehicleDoorsStatus(vehicleid, bonnet, boot, driver_door,
passenger_door)
{
new
panels,
lights,
tires;
if (0 == GetVehicleDamageStatus(vehicleid, panels, TDW_g_sNullStorage,
lights, tires))
return 0;
UpdateVehicleDamageStatus(vehicleid, panels, bonnet | (boot << 8) |
(driver_door << 16) | (passenger_door << 24), lights, tires
);
return 1;
}