DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
Car.c
Go to the documentation of this file.
1
4{
5 // simulation
9
10 // miscellaneous
12 PLAYER
13};
14
15
16
19{
24
28 USER4
29};
30
31
32
35{
39
40
41
43enum CarGear
44{
47 FIRST,
48 SECOND,
63};
64
65
66
69{
70 P,
71 R,
72 N,
73 D
74};
75
76
77
79class Car extends Transport
80{
83
85 proto native float GetSpeedometer();
86
89 {
91 }
92
93 override bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
94 {
95 vector transform[4];
96
97 vector extents;
98
99 extents[0] = horizontalExtents;
100 extents[1] = playerHeight;
101 extents[2] = horizontalExtents;
102
103 float speed = GetSpeedometerAbsolute();
104 if (speed > 8)
105 extents[2] = extents[2] * 6;
106 if (speed > 8)
107 extents[0] = 2;
108
109 return IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform );
110 }
111
112 override Shape DebugFreeAreaAtDoor( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
113 {
114 int color = ARGB(20, 0, 255, 0);
115
116 vector transform[4];
117
118 vector extents;
119
120 extents[0] = horizontalExtents;
121 extents[1] = playerHeight;
122 extents[2] = horizontalExtents;
123
124 float speed = GetSpeedometerAbsolute();
125 if (speed > 8)
126 extents[2] = extents[2] * 6;
127 if (speed > 8)
128 extents[0] = 2;
129
130 if (!IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform ))
131 {
132 color = ARGB(20, 255, 0, 0);
133 }
134
135 Shape shape = Debug.DrawBox(-extents * 0.5, extents * 0.5, color);
136 shape.SetMatrix(transform);
137 return shape;
138 }
139
140 override int GetHideIconMask()
141 {
142 return EInventoryIconVisibility.HIDE_VICINITY;
143 }
144
145//-----------------------------------------------------------------------------
146// controls
147
149 proto native float GetSteering();
156 proto native void SetSteering( float in, bool analog = false );
157
159 proto native float GetThrustTurbo();
161 proto native float GetThrustGentle();
163 proto native float GetThrust();
171 proto native void SetThrust( float in, float gentle = 0, float turbo = 0 );
172
174 proto native float GetBrake();
181 proto native void SetBrake( float in, float panic = 0, bool gentle = false );
182
184 proto native float GetHandbrake();
190 proto native void SetHandbrake( float in );
191
195 proto native void SetBrakesActivateWithoutDriver( bool activate = true );
196
198 proto native float GetClutch();
202 proto native void SetClutchState( bool in );
203
205 proto native int GetGear();
206
207 proto native void ShiftUp();
208 proto native void ShiftTo( CarGear gear );
209 proto native void ShiftDown();
210
211//-----------------------------------------------------------------------------
212
213//-----------------------------------------------------------------------------
214// fluids
215
221 proto native float GetFluidCapacity( CarFluid fluid );
222
229 proto native float GetFluidFraction( CarFluid fluid );
230
232 proto native void Leak( CarFluid fluid, float amount );
233
235 proto native void LeakAll( CarFluid fluid );
236
238 proto native void Fill( CarFluid fluid, float amount );
239
248 void OnFluidChanged( CarFluid fluid, float newValue, float oldValue ) {}
249//-----------------------------------------------------------------------------
250
251
252//-----------------------------------------------------------------------------
253// engine
254
256 proto native float EngineGetRPMMin();
257
259 proto native float EngineGetRPMIdle();
260
262 proto native float EngineGetRPMMax();
263
265 proto native float EngineGetRPMRedline();
266
268 proto native float EngineGetRPM();
269
271 proto native bool EngineIsOn();
272
274 proto native void EngineStart();
275
282 {
283 // engine can start by default
284 return true;
285 }
286
289
291 proto native void EngineStop();
292
294 void OnEngineStop() {}
295
297 proto native vector GetEnginePos();
299 proto native void SetEnginePos(vector pos);
300
301//-----------------------------------------------------------------------------
302
303
304//-----------------------------------------------------------------------------
305// gearbox
306
308 proto native int GetGearsCount();
309
312
315
322 void OnGearChanged( int newGear, int oldGear )
323 {
324 }
325//-----------------------------------------------------------------------------
326
327
328//-----------------------------------------------------------------------------
329// wheels
330
332 proto native bool WheelIsAnyLocked();
338 proto native bool WheelIsLocked( int wheelIdx );
339
340//-----------------------------------------------------------------------------
341
342
343//-----------------------------------------------------------------------------
344// events
345
354 void OnContact( string zoneName, vector localPos, IEntity other, Contact data ) {}
355
364 float OnSound( CarSoundCtrl ctrl, float oldValue )
365 {
366 // just use the computed value by the game code
367 return oldValue;
368 }
369
378 void OnInput( float dt ) {}
379
384 void OnUpdate( float dt ) {}
385//-----------------------------------------------------------------------------
386
387
388 // implemented only in internal configuration
389 proto native void ForcePosition( vector pos );
390 // implemented only in internal configuration
391 proto native void ForceDirection( vector dir );
392};
393
394
395
398{
399 private void CarController() {}
400 private void ~CarController() {}
401
403 proto float GetSteering();
410 proto void SetSteering( float in, bool analog = false );
411
413 proto float GetThrustTurbo();
415 proto float GetThrustGentle();
417 proto float GetThrust();
425 proto void SetThrust( float in, float gentle = 0, float turbo = 0 );
426
428 proto float GetBrake();
435 proto void SetBrake( float in, float panic = 0 );
436
438 proto int GetGear();
439
440 proto void ShiftUp();
441 proto void ShiftTo( CarGear gear );
442 proto void ShiftDown();
443};
enum CarGearboxType ELEVENTH
CarAutomaticGearboxMode
Enumerated automatic gearbox modes. (native, do not change or extend)
Definition Car.c:69
@ R
reverse
Definition Car.c:71
@ N
neutral
Definition Car.c:72
@ D
drive
Definition Car.c:73
@ P
park
Definition Car.c:70
enum CarGearboxType THIRTEENTH
enum CarGearboxType EIGTH
enum CarGearboxType SECOND
enum CarGearboxType FOURTH
enum CarGearboxType NINTH
enum CarGearboxType SIXTEENTH
enum CarGearboxType FIFTH
enum CarGearboxType FIFTEENTH
CarSoundCtrl
Car's sound controller list. (native, do not change or extend)
Definition Car.c:4
@ SPEED
speed of the car in km/h
Definition Car.c:8
@ RPM
engine's RPM
Definition Car.c:7
@ DOORS
indicates if doors are open
Definition Car.c:11
@ ENGINE
indicates if engine is ON
Definition Car.c:6
@ PLAYER
indicates if driver is controlled by player
Definition Car.c:12
enum CarGearboxType SEVENTH
enum CarGearboxType SIXTH
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Definition Car.c:19
@ USER4
reserved for user / modding support
Definition Car.c:28
@ OIL
Definition Car.c:21
@ USER1
reserved for user / modding support
Definition Car.c:25
@ USER2
reserved for user / modding support
Definition Car.c:26
@ BRAKE
Definition Car.c:22
@ FUEL
Definition Car.c:20
@ COOLANT
Definition Car.c:23
@ USER3
reserved for user / modding support
Definition Car.c:27
enum CarGearboxType THIRD
enum CarGearboxType REVERSE
Enumerated vehicle's gears. (native, do not change or extend)
CarGearboxType
Enumerated gearbox types. (native, do not change or extend)
Definition Car.c:35
@ AUTOMATIC
automatic transmission with torque converter between engine and gearbox
Definition Car.c:37
@ MANUAL
classic manual transmission with friction plates between engine and gearbox
Definition Car.c:36
enum CarGearboxType FIRST
enum CarGearboxType TENTH
enum CarGearboxType TWELFTH
enum CarGearboxType FOURTEENTH
enum CarGearboxType NEUTRAL
DEPRECATED class left for backwards compatibility, methods are available on car itself now.
Definition Car.c:398
proto int GetGear()
Returns index of the current gear.
proto float GetBrake()
Returns the current brake value in range <0, 1>.
proto void SetThrust(float in, float gentle=0, float turbo=0)
proto float GetThrustGentle()
Returns the current thrust gentle modifier value in range <0, 1>.
proto void SetSteering(float in, bool analog=false)
proto void SetBrake(float in, float panic=0)
proto void ShiftUp()
proto float GetThrust()
Returns the current thrust value in range <0, 1>.
proto void ShiftTo(CarGear gear)
proto float GetSteering()
Returns the current steering value in range <-1, 1>.
proto void ShiftDown()
private void ~CarController()
Definition Car.c:400
proto float GetThrustTurbo()
Returns the current thrust turbo modifier value in range <0, 1>.
private void CarController()
Definition Car.c:399
Definition Debug.c:14
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
Definition Debug.c:273
Definition EnMath.c:7
Base native class for all motorized wheeled vehicles.
Definition Car.c:80
proto native float GetHandbrake()
Returns the current handbrake value in range <0, 1>.
proto native CarController GetController()
DEPRECATED, left for backwards compatibility, the methods of this class are now directly accessible o...
proto native bool WheelIsLocked(int wheelIdx)
proto native float GetFluidFraction(CarFluid fluid)
proto native vector GetEnginePos()
Get actual position of engine (model space)
proto native void ForceDirection(vector dir)
proto native float EngineGetRPMRedline()
Returns engine's maximal working rpm without damaging the engine.
proto native float GetSteering()
Returns the current steering value in range <-1, 1>.
override bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Definition Car.c:93
proto native void SetBrake(float in, float panic=0, bool gentle=false)
proto native void Leak(CarFluid fluid, float amount)
Removes from the specified fluid the specified amount.
proto native void SetClutchState(bool in)
proto native CarGearboxType GearboxGetType()
Returns gearbox type. See CarGearboxType enum for more info.
proto native void SetThrust(float in, float gentle=0, float turbo=0)
proto native void EngineStop()
Stops the engine.
proto native CarAutomaticGearboxMode GearboxGetMode()
Returns gearbox mode. This is useful when car has automatic gearbox.
proto native float GetSpeedometer()
Returns the current speed of the vehicle in km/h.
proto native float GetClutch()
Returns the current clutch value in range <0, 1>.
void OnGearChanged(int newGear, int oldGear)
Definition Car.c:322
proto native void SetHandbrake(float in)
proto native float GetThrustGentle()
Returns the current thrust gentle modifier value in range <0, 1>.
override Shape DebugFreeAreaAtDoor(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Definition Car.c:112
proto native float GetThrust()
Returns the current thrust value in range <0, 1>.
proto native void SetEnginePos(vector pos)
Override the position of engine (model space)
proto native bool EngineIsOn()
Returns true when engine is running, false otherwise.
proto native float EngineGetRPMIdle()
Returns engine's idle rpm before engine stalls.
proto native void SetBrakesActivateWithoutDriver(bool activate=true)
proto native void ShiftDown()
proto native void ShiftUp()
proto native void LeakAll(CarFluid fluid)
Removes all the specified fluid from vehicle.
bool OnBeforeEngineStart()
Definition Car.c:281
void OnInput(float dt)
Definition Car.c:378
proto native void EngineStart()
Starts the engine.
proto native float EngineGetRPM()
Returns engine's rpm value.
void OnEngineStart()
Is called every time the engine starts.
Definition Car.c:288
proto native bool WheelIsAnyLocked()
Returns true if any of the wheels are locked in terms of its movement.
override int GetHideIconMask()
Definition Car.c:140
proto native float GetFluidCapacity(CarFluid fluid)
proto native float EngineGetRPMMin()
Returns engine's min operating rpm.
proto native float GetThrustTurbo()
Returns the current thrust turbo modifier value in range <0, 1>.
proto native void ShiftTo(CarGear gear)
void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
Definition Car.c:248
void OnEngineStop()
Is called every time the engine stops.
Definition Car.c:294
proto native int GetGear()
Returns index of the current gear.
void OnContact(string zoneName, vector localPos, IEntity other, Contact data)
Definition Car.c:354
void OnUpdate(float dt)
Definition Car.c:384
proto native void SetSteering(float in, bool analog=false)
float GetSpeedometerAbsolute()
Returns the current speed of the vehicle in km/h. Value is absolute.
Definition Car.c:88
proto native int GetGearsCount()
Returns total number of gears.
proto native void Fill(CarFluid fluid, float amount)
Adds to the specified fluid the specified amount.
float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition Car.c:364
proto native float GetBrake()
Returns the current brake value in range <0, 1>.
proto native void ForcePosition(vector pos)
proto native float EngineGetRPMMax()
Returns engine's max rpm before engine blows up.
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
static proto float AbsFloat(float f)
Returns absolute value.
int ARGB(int a, int r, int g, int b)
Definition proto.c:322