Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
car.c
Go to the documentation of this file.
1
4{
5 // simulation
9
10 // miscellaneous
13};
14
15
16
30
31
32
39
40
41
43enum CarGear
44{
47 FIRST,
48 SECOND,
63};
64
65
66
75
76
84
86{
87};
88
89class CarOwnerState : TransportOwnerState
90{
91};
92
93class CarMove : TransportMove
94{
95};
96
98class Car extends Transport
99{
101 protected override event typename GetOwnerStateType()
102 {
103 return CarOwnerState;
104 }
105
107 protected override event typename GetMoveType()
108 {
109 return CarMove;
110 }
111
113 proto native float GetSpeedometer();
114
117 {
118 return Math.AbsFloat(GetSpeedometer());
119 }
120
121 override bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
122 {
123 vector transform[4];
124
125 vector extents;
126
127 extents[0] = horizontalExtents;
128 extents[1] = playerHeight;
129 extents[2] = horizontalExtents;
130
131 float speed = GetSpeedometerAbsolute();
132 if (speed > 8)
133 extents[2] = extents[2] * 6;
134 if (speed > 8)
135 extents[0] = 2;
136
137 return IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform );
138 }
139
140 override Shape DebugFreeAreaAtDoor( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
141 {
142 int color = ARGB(20, 0, 255, 0);
143
144 vector transform[4];
145
146 vector extents;
147
148 extents[0] = horizontalExtents;
149 extents[1] = playerHeight;
150 extents[2] = horizontalExtents;
151
152 float speed = GetSpeedometerAbsolute();
153 if (speed > 8)
154 extents[2] = extents[2] * 6;
155 if (speed > 8)
156 extents[0] = 2;
157
158 if (!IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform ))
159 {
160 color = ARGB(20, 255, 0, 0);
161 }
162
163 Shape shape = Debug.DrawBox(-extents * 0.5, extents * 0.5, color);
164 shape.SetMatrix(transform);
165 return shape;
166 }
167
168 protected bool DetectFlippedUsingWheels(VehicleFlippedContext ctx, bool disallowSide)
169 {
170 if (disallowSide && (vector.Dot(GetDirectionUp(), vector.Up) < 0.7))
171 {
172 // return as "flipped", vehicle isn't pointing enough up to be reasonably certain
173 return true;
174 }
175
176 int wheelCount = WheelCount();
177
178 for (int wheelIdx = 0; wheelIdx < wheelCount; wheelIdx++)
179 {
180 if (!WheelHasContact(wheelIdx))
181 {
182 // wheel not in contact, then we could be flipped, we assume there exist other predicates
183 return true;
184 }
185 }
186
187 // all wheels in contact (or zero registered wheels), then we are in contact
188 return false;
189 }
190
191
193 proto native float GetSteering();
194
196 proto native void SetSteering(float value, bool unused0 = false);
197
199 proto native float GetThrottle();
200
202 proto native void SetThrottle(float value);
203
205 proto native int GetClutch();
206
208 proto native void SetClutch(float value);
209
211 proto native float GetBrake();
212
214 proto native void SetBrake(float value, float unused0 = 0, bool unused1 = false);
215
217 proto native float GetHandbrake();
218
220 proto native void SetHandbrake(float value);
221
223 proto native void SetBrakesActivateWithoutDriver(bool activate = true);
224
226 proto native float EngineGetRPMMin();
227
229 proto native float EngineGetRPMIdle();
230
232 proto native float EngineGetRPMMax();
233
235 proto native float EngineGetRPMRedline();
236
238 proto native float EngineGetRPM();
239
241 proto native bool EngineIsOn();
242
244 proto native void EngineStart();
245
247 proto native void EngineStop();
248
250 proto native vector GetEnginePos();
251
253 proto native void SetEnginePos(vector pos);
254
256 proto native int GetCurrentGear();
257
259 proto native int GetGear();
260
262 proto native int GetNeutralGear();
263
265 proto native int GetGearCount();
266
268 proto native void ShiftUp();
269
271 proto native void ShiftTo(int gear);
272
274 proto native void ShiftDown();
275
278
281
283 proto native bool WheelIsAnyLocked();
284
290 proto native float WheelGetAngularVelocity( int wheelIdx );
291
297 proto native bool WheelHasContact( int wheelIdx );
298
304 proto native vector WheelGetContactPosition( int wheelIdx );
305
311 proto native vector WheelGetContactNormal( int wheelIdx );
312
318 proto native vector WheelGetDirection( int wheelIdx );
319
325 proto native SurfaceInfo WheelGetSurface( int wheelIdx );
326
332 proto native CarWheelWaterState WheelGetWaterState( int wheelIdx );
333
339 proto native EntityAI WheelGetEntity( int wheelIdx );
340
346 proto native bool WheelIsLocked( int wheelIdx );
347
349 proto native int WheelCount();
350
352 proto native int WheelCountPresent();
353
359 proto native float GetFluidCapacity(CarFluid fluid);
360
367 proto native float GetFluidFraction(CarFluid fluid);
368
370 proto native void Leak(CarFluid fluid, float amount);
371
373 proto native void LeakAll(CarFluid fluid);
374
376 proto native void Fill(CarFluid fluid, float amount);
377
384 {
385 // engine can start by default
386 return true;
387 }
388
393
397 void OnEngineStop() {}
398
405 void OnGearChanged(int newGear, int oldGear)
406 {
407 }
408
417 void OnFluidChanged(CarFluid fluid, float newValue, float oldValue) {}
418
427 float OnSound(CarSoundCtrl ctrl, float oldValue)
428 {
429 // just use the computed value by the game code
430 return oldValue;
431 }
432
433 [Obsolete("no replacement")]
434 proto native void ForcePosition(vector pos);
435
436 [Obsolete("no replacement")]
437 proto native void ForceDirection(vector dir);
438
439 [Obsolete("Use methods directly on Car")]
441
442 [Obsolete("Use Car.IsTurbo")]
443 proto native float GetThrustTurbo();
444
445 [Obsolete("Use Car.IsGentle")]
446 proto native float GetThrustGentle();
447
448 [Obsolete("Use Car.GetThrottle")]
449 proto native float GetThrust();
450
451 [Obsolete("Use Car.SetThrottle/Car.SetTurbo/Car.SetGentle")]
452 proto native void SetThrust(float in, float gentle = 0, float turbo = 0);
453
454 [Obsolete("no replacement")];
455 proto native void SetClutchState(bool in);
456
457 [Obsolete("Use Car.GetGearCount")]
458 proto native int GetGearsCount();
459
460};
461
462
463
465class CarController
466{
467 private void CarController() {}
468 private void ~CarController() {}
469
471 proto float GetSteering();
478 proto void SetSteering( float in, bool analog = false );
479
481 proto float GetThrustTurbo();
483 proto float GetThrustGentle();
485 proto float GetThrust();
493 proto void SetThrust( float in, float gentle = 0, float turbo = 0 );
494
496 proto float GetBrake();
503 proto void SetBrake( float in, float panic = 0 );
504
506 proto int GetGear();
507
508 proto void ShiftUp();
509 proto void ShiftTo( CarGear gear );
510 proto void ShiftDown();
511};
@ SPEED
speed of the boat in km/h
Definition boat.c:6
@ ENGINE
indicates if engine is ON
Definition boat.c:5
@ PLAYER
indicates if driver is controlled by player
Definition boat.c:9
@ FUEL
Definition boat.c:15
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
@ RPM
engine's RPM
Definition car.c:7
@ DOORS
indicates if doors are open
Definition car.c:11
CarWheelWaterState
Enumerated car wheel water state. (native, do not change or extend).
Definition car.c:79
@ ON_LAND
if the wheel is on or above land
Definition car.c:80
@ UNDER_WATER
if the wheel is under a water plane
Definition car.c:82
@ IN_WATER
if the wheel is partially within some water plane
Definition car.c:81
enum CarGearboxType SEVENTH
enum CarGearboxType SIXTH
CarFluid
Type of vehicle's fluid. (native, do not change or extend).
Definition car.c:19
@ OIL
Definition car.c:21
@ BRAKE
Definition car.c:22
@ COOLANT
Definition car.c:23
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:466
Definition car.c:94
Definition car.c:86
Definition debug.c:2
Definition enmath.c:7
Native class for boats - handles physics simulation.
Definition boat.c:32
proto native void SetThrust(float in, float gentle=0, float turbo=0)
float OnSound(CarSoundCtrl ctrl, float oldValue)
Definition car.c:427
proto native float GetHandbrake()
Returns the current handbrake value in range <0, 1>.
proto native vector WheelGetContactNormal(int wheelIdx)
proto native void ShiftUp()
Shifts the future gear up, triggering gearbox simulation.
proto native bool WheelHasContact(int wheelIdx)
proto native void SetEnginePos(vector pos)
Override the position of engine (model space).
proto native int GetCurrentGear()
Returns the index of the current gear, -1 if there is no engine.
proto native void SetSteering(float value, bool unused0=false)
Sets the future steering value.
void OnEngineStop()
Definition car.c:397
proto native void Fill(CarFluid fluid, float amount)
Adds to the specified fluid the specified amount.
proto native float GetThrustTurbo()
proto native float GetThrustGentle()
proto native float EngineGetRPM()
Returns engine's rpm value.
proto native void ShiftDown()
Shifts the future gear down, triggering gearbox simulation.
proto native float WheelGetAngularVelocity(int wheelIdx)
proto native CarWheelWaterState WheelGetWaterState(int wheelIdx)
float GetSpeedometerAbsolute()
Returns the current speed of the vehicle in km/h. Value is absolute.
Definition car.c:116
override event GetMoveType()
Definition car.c:107
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 bool EngineIsOn()
Returns true when engine is running, false otherwise.
proto native int GetClutch()
Returns the value of how much the clutch is disengaged.
proto native int GetNeutralGear()
Returns the index of the neutral gear.
proto native void SetThrottle(float value)
Sets the future throttle value.
proto native EntityAI WheelGetEntity(int wheelIdx)
proto native void SetClutch(float value)
Sets the future clutch value.
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 void ShiftTo(int gear)
Shifts the future gear to selected gear, triggering gearbox simulation.
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()
proto native void ForceDirection(vector dir)
proto native void EngineStop()
Stops the engine.
override event GetOwnerStateType()
Definition car.c:101
proto native float GetThrottle()
Returns the actual throttle value in range <0, 1>.
proto native float GetBrake()
Returns the current brake value in range <0, 1>.
proto native float GetThrust()
proto native vector WheelGetDirection(int wheelIdx)
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:121
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 vector WheelGetContactPosition(int wheelIdx)
proto native SurfaceInfo WheelGetSurface(int wheelIdx)
proto native int GetGear()
Returns the index of the future gear, -1 if there is no engine.
proto native CarGearboxType GearboxGetType()
Returns gearbox type. See CarGearboxType enum for more info.
proto native void SetHandbrake(float value)
Sets the future handbrake value.
bool DetectFlippedUsingWheels(VehicleFlippedContext ctx, bool disallowSide)
Definition car.c:168
proto native float GetFluidCapacity(CarFluid fluid)
proto native float EngineGetRPMMax()
Returns engine's max rpm before engine blows up.
proto native void ForcePosition(vector pos)
proto native void SetBrakesActivateWithoutDriver(bool activate=true)
Sets if brakes should activate without a driver present.
void OnGearChanged(int newGear, int oldGear)
Definition car.c:405
override Shape DebugFreeAreaAtDoor(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Definition car.c:140
bool OnBeforeEngineStart()
Definition car.c:383
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()
Definition car.c:392
proto native vector GetEnginePos()
Get actual position of engine (model space).
proto native int GetGearsCount()
proto native void SetClutchState(bool in)
proto native int GetGearCount()
Returns the number of gears.
proto native void SetBrake(float value, float unused0=0, bool unused1=false)
Sets the future brake value.
void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
Definition car.c:417
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
void Obsolete(string msg="")
Definition enscript.c:371
@ USER4
Definition enentity.c:156
@ USER1
Flags for custom usage and filterings.
Definition enentity.c:153
@ USER2
Definition enentity.c:154
@ USER3
Definition enentity.c:155
int ARGB(int a, int r, int g, int b)
Definition proto.c:322