DayZ 1.24
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
29
30
37
38
40enum CarGear
41{
44 FIRST,
45 SECOND,
60};
61
62
71
72
74class Car extends Transport
75{
78
81
84 {
85 return Math.AbsFloat(GetSpeedometer());
86 }
87
88 override bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7)
89 {
91
93
97
98 float speed = GetSpeedometerAbsolute();
99 if (speed > 8)
100 extents[2] = extents[2] * 6;
101 if (speed > 8)
102 extents[0] = 2;
103
104 return IsAreaAtDoorFree(currentSeat, maxAllowedObjHeight, extents, transform);
105 }
106
107 override Shape DebugFreeAreaAtDoor(int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7)
108 {
109 int color = ARGB(20, 0, 255, 0);
110
111 vector transform[4];
112
114
118
119 float speed = GetSpeedometerAbsolute();
120 if (speed > 8)
121 extents[2] = extents[2] * 6;
122 if (speed > 8)
123 extents[0] = 2;
124
125 if (!IsAreaAtDoorFree(currentSeat, maxAllowedObjHeight, extents, transform))
126 color = ARGB(20, 255, 0, 0);
127
128 Shape shape = Debug.DrawBox(-extents * 0.5, extents * 0.5, color);
129 shape.SetMatrix(transform);
130 return shape;
131 }
132
133 override int GetHideIconMask()
134 {
135 return EInventoryIconVisibility.HIDE_VICINITY;
136 }
137
138 //-----------------------------------------------------------------------------
139 // controls
140
149 proto native void SetSteering(float in, bool analog = false);
150
164 proto native void SetThrust(float in, float gentle = 0, float turbo = 0);
165
174 proto native void SetBrake(float in, float panic = 0, bool gentle = false);
175
184
189
196
199
203
204 //-----------------------------------------------------------------------------
205
206 //-----------------------------------------------------------------------------
207 // fluids
208
215
223
225 proto native void Leak(CarFluid fluid, float amount);
226
229
231 proto native void Fill(CarFluid fluid, float amount);
232
242 //-----------------------------------------------------------------------------
243
244
245 //-----------------------------------------------------------------------------
246 // engine
247
250
253
256
259
262
265
268
275 {
276 // engine can start by default
277 return true;
278 }
279
282
285
287 void OnEngineStop() {}
288
293
294 //-----------------------------------------------------------------------------
295
296
297 //-----------------------------------------------------------------------------
298 // gearbox
299
302
305
308
316 {
317 }
318 //-----------------------------------------------------------------------------
319
320
321 //-----------------------------------------------------------------------------
322 // wheels
323
332
335
338
339 //-----------------------------------------------------------------------------
340
341
342 //-----------------------------------------------------------------------------
343 // events
344
354
364 {
365 // just use the computed value by the game code
366 return oldValue;
367 }
368
377 void OnInput(float dt) {}
378
383 void OnUpdate(float dt) {}
384 //-----------------------------------------------------------------------------
385
386
387 // implemented only in internal configuration
389 // implemented only in internal configuration
391};
392
393
396{
397 private void CarController() {}
398 private void ~CarController() {}
399
408 proto void SetSteering(float in, bool analog = false);
409
423 proto void SetThrust(float in, float gentle = 0, float turbo = 0);
424
433 proto void SetBrake(float in, float panic = 0);
434
437
441};
enum CarGearboxType ELEVENTH
CarAutomaticGearboxMode
Enumerated automatic gearbox modes. (native, do not change or extend)
Definition Car.c:65
@ R
reverse
Definition Car.c:67
@ N
neutral
Definition Car.c:68
@ D
drive
Definition Car.c:69
@ P
park
Definition Car.c:66
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:18
@ USER4
reserved for user / modding support
Definition Car.c:27
@ OIL
Definition Car.c:20
@ USER1
reserved for user / modding support
Definition Car.c:24
@ USER2
reserved for user / modding support
Definition Car.c:25
@ BRAKE
Definition Car.c:21
@ FUEL
Definition Car.c:19
@ COOLANT
Definition Car.c:22
@ USER3
reserved for user / modding support
Definition Car.c:26
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:33
@ AUTOMATIC
automatic transmission with torque converter between engine and gearbox
Definition Car.c:35
@ MANUAL
classic manual transmission with friction plates between engine and gearbox
Definition Car.c:34
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:396
proto float GetThrust()
Returns the current thrust value in range <0, 1>.
proto float GetSteering()
Returns the current steering value in range <-1, 1>.
proto void ShiftUp()
proto void ShiftDown()
proto float GetThrustTurbo()
Returns the current thrust turbo modifier value in range <0, 1>.
proto void SetSteering(float in, bool analog=false)
void ~CarController()
Definition Car.c:398
proto float GetBrake()
Returns the current brake value in range <0, 1>.
proto void SetThrust(float in, float gentle=0, float turbo=0)
proto void ShiftTo(CarGear gear)
proto float GetThrustGentle()
Returns the current thrust gentle modifier value in range <0, 1>.
proto int GetGear()
Returns index of the current gear.
proto void SetBrake(float in, float panic=0)
void CarController()
Definition Car.c:397
Definition Debug.c:14
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
Definition Debug.c:401
Definition EnMath.c:7
Base native class for all motorized wheeled vehicles.
Definition Car.c:75
proto native void SetThrust(float in, float gentle=0, float turbo=0)
float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition Car.c:363
proto native float GetHandbrake()
Returns the current handbrake value in range <0, 1>.
void OnInput(float dt)
Definition Car.c:377
proto native void ShiftTo(CarGear gear)
proto native void ShiftUp()
void OnUpdate(float dt)
Definition Car.c:383
proto native void SetEnginePos(vector pos)
Override the position of engine (model space)
void OnEngineStop()
Is called every time the engine stops.
Definition Car.c:287
proto native void Fill(CarFluid fluid, float amount)
Adds to the specified fluid the specified amount.
proto native float GetThrustTurbo()
Returns the current thrust turbo modifier value in range <0, 1>.
proto native float GetThrustGentle()
Returns the current thrust gentle modifier value in range <0, 1>.
proto native float EngineGetRPM()
Returns engine's rpm value.
proto native void ShiftDown()
float GetSpeedometerAbsolute()
Returns the current speed of the vehicle in km/h. Value is absolute.
Definition Car.c:83
proto native void Leak(CarFluid fluid, float amount)
Removes from the specified fluid the specified amount.
proto native float EngineGetRPMIdle()
Returns engine's idle rpm before engine stalls.
proto native int WheelCountPresent()
Number of actually attached wheels (hubs only)
proto native void SetHandbrake(float in)
proto native bool EngineIsOn()
Returns true when engine is running, false otherwise.
proto native void SetBrake(float in, float panic=0, bool gentle=false)
proto native CarAutomaticGearboxMode GearboxGetMode()
Returns gearbox mode. This is useful when car has automatic gearbox.
proto native int WheelCount()
How many wheel can be attached to a car (hubs only)
proto native void EngineStart()
Starts the engine.
proto native float EngineGetRPMMin()
Returns engine's min operating rpm.
proto native bool WheelIsAnyLocked()
Returns true if any of the wheels are locked in terms of its movement.
proto native CarController GetController()
DEPRECATED, left for backwards compatibility, the methods of this class are now directly accessible o...
proto native void ForceDirection(vector dir)
proto native void EngineStop()
Stops the engine.
proto native float GetBrake()
Returns the current brake value in range <0, 1>.
proto native void SetSteering(float in, bool analog=false)
proto native float GetThrust()
Returns the current thrust value in range <0, 1>.
proto native float GetClutch()
Returns the current clutch value in range <0, 1>.
proto native bool WheelIsLocked(int wheelIdx)
override bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Definition Car.c:88
void OnContact(string zoneName, vector localPos, IEntity other, Contact data)
Definition Car.c:353
proto native void LeakAll(CarFluid fluid)
Removes all the specified fluid from vehicle.
proto native float GetSpeedometer()
Returns the current speed of the vehicle in km/h.
proto native float GetFluidFraction(CarFluid fluid)
proto native int GetGear()
Returns index of the current gear.
proto native CarGearboxType GearboxGetType()
Returns gearbox type. See CarGearboxType enum for more info.
proto native float GetFluidCapacity(CarFluid fluid)
proto native float EngineGetRPMMax()
Returns engine's max rpm before engine blows up.
override int GetHideIconMask()
Definition Car.c:133
proto native void ForcePosition(vector pos)
proto native void SetBrakesActivateWithoutDriver(bool activate=true)
void OnGearChanged(int newGear, int oldGear)
Definition Car.c:315
override Shape DebugFreeAreaAtDoor(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Definition Car.c:107
bool OnBeforeEngineStart()
Definition Car.c:274
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>.
void OnEngineStart()
Is called every time the engine starts.
Definition Car.c:281
proto native vector GetEnginePos()
Get actual position of engine (model space)
proto native int GetGearsCount()
Returns total number of gears.
proto native void SetClutchState(bool in)
void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
Definition Car.c:241
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