DayZ 1.24
Loading...
Searching...
No Matches
CarScript.c
Go to the documentation of this file.
7
9{
13 BOTH
14}
15
17{
18 NONE,
22}
23
25{
26 NONE,
34}
35
37{
38 OFF = 0,
39 SHORT = 1,
40 LONG = 2
41}
42
43#ifdef DIAG_DEVELOPER
45{
46 NONE,
49 CONTACT = 4
50 //OTHER = 8
51 //OTHER = 16
52}
53
55{
58 //data is recorded on server, upon request, sent to the client
59 static void SendData(PlayerBase player)
60 {
61 /*
62 m_CrashData.Clear();
63 CrashDebugData fakeData = new CrashDebugData();
64 fakeData.m_VehicleType = "FakeVehicle";
65 m_CrashData.Insert(fakeData);
66 */
67 GetGame().RPCSingleParam(player, ERPCs.DIAG_VEHICLES_DUMP_CRASH_DATA_CONTENTS, new Param1<array<ref CrashDebugData>>(m_CrashData), true, player.GetIdentity());
68 }
69
70 //this is client requesting to dump the data it previously received from the server
72 {
73 Print("Vehicle; DamageType; Damage; Zone; Momentum; Momentum Prev; Momentum Delta; Speedometer; SpeedWorld; SpeedWorld Prev; SpeedWorld Delta; Velocity; Velocity Prev; Velocity Dot; TimeStamp (ms); CrewDamageBase; ShockTemp; DMGHealth; DMGShock");
76 }
77
78 static void DumpData(CrashDebugData data)
79 {
80 string output = data.m_VehicleType + ";" + data.m_DamageType + ";" + data.m_Damage + ";" + data.m_Zone + ";" + data.m_MomentumCurr + ";" + data.m_MomentumPrev + ";" + data.m_MomentumDelta + ";" + data.m_Speedometer;
81 output += ";" + data.m_SpeedWorld + ";" + data.m_SpeedWorldPrev + ";" + data.m_SpeedWorldDelta + ";" + data.m_VelocityCur;
82 output += ";" + data.m_VelocityPrev + ";" + data.m_VelocityDot + ";" + data.m_Time + ";" + data.m_CrewDamageBase + ";" + data.m_ShockTemp + ";" + data.m_DMGHealth + ";" + data.m_DMGShock;
84 }
85
86 string m_VehicleType;
87 string m_DamageType;
88 float m_Damage;
89 string m_Zone;
90 float m_MomentumCurr;
91 float m_MomentumPrev;
92 float m_MomentumDelta;
93 float m_Speedometer;
94 float m_SpeedWorld;
95 float m_SpeedWorldPrev;
99 float m_VelocityDot;
100 float m_Time;
101 float m_CrewDamageBase;
102 float m_ShockTemp;
103 float m_DMGHealth;
104 float m_DMGShock;
105}
106
107#endif
108class CarContactData
109{
112 float impulse;
113
115 {
117 other = _other;
119 }
120}
121
123
124#ifdef DEVELOPER
126#endif
127
131class CarScript extends Car
132{
133#ifdef DIAG_DEVELOPER
135 bool m_ContactCalled;
136#endif
140 protected float m_MomentumPrevTick;
143
144 protected float m_Time;
145
146 static float DROWN_ENGINE_THRESHOLD = 0.5;
147 static float DROWN_ENGINE_DAMAGE = 350.0;
148
149 static const string MEMORY_POINT_NAME_CAR_HORN = "pos_carHorn";
150
152 protected float m_FuelAmmount;
153 protected float m_CoolantAmmount;
154 protected float m_OilAmmount;
155 protected float m_BrakeAmmount;
156
158 //protected float m_dmgContactCoef = 0.023;
159 protected float m_dmgContactCoef = 0.058;
161
163 protected float m_DrownTime;
165
167 protected float m_EngineHealth;
168 protected float m_RadiatorHealth;
169 protected float m_FuelTankHealth;
170 protected float m_BatteryHealth;
171 protected float m_PlugHealth;
172
174
175 protected float m_BatteryConsume = 15; //Battery energy consumption upon engine start
176 protected float m_BatteryContinuousConsume = 0.25; //Battery consumption with lights on and engine is off
177 protected float m_BatteryRecharge = 0.15; //Battery recharge rate when engine is on
178 private float m_BatteryTimer = 0; //Used to factor energy consumption / recharging
179 private const float BATTERY_UPDATE_DELAY = 100;
180 protected float m_BatteryEnergyStartMin = 5.0; // Minimal energy level of battery required for start
181
186
187 protected int m_enginePtcFx;
188 protected int m_coolantPtcFx;
189 protected int m_exhaustPtcFx;
190
195
196 protected vector m_fuelPos;
197
200 protected vector m_backPos;
205
207 string m_EngineStartOK = "";
209 string m_EngineStartPlug = "";
210 string m_EngineStartFuel = "";
211 string m_EngineStopFuel = "";
212
217
220
226
230
231 protected bool m_PlayCrashSoundLight;
232 protected bool m_PlayCrashSoundHeavy;
233
234 protected bool m_HeadlightsOn;
235 protected bool m_HeadlightsState;
236 protected bool m_BrakesArePressed;
237 protected bool m_RearLightType;
238
239 protected bool m_ForceUpdateLights;
240 protected bool m_EngineStarted;
241 protected bool m_EngineDestroyed;
242
243 protected int m_CarHornState;
244
247
248 // Memory points
249 static string m_ReverseLightPoint = "light_reverse";
250 static string m_LeftHeadlightPoint = "light_left";
251 static string m_RightHeadlightPoint = "light_right";
252 static string m_LeftHeadlightTargetPoint = "light_left_dir";
253 static string m_RightHeadlightTargetPoint = "light_right_dir";
254 static string m_DrownEnginePoint = "drown_engine";
255
256 // Model selection IDs for texture/material changes
257 // If each car needs different IDs, then feel free to remove the 'static' flag and overwrite these numbers down the hierarchy
258 static const int SELECTION_ID_FRONT_LIGHT_L = 0;
259 static const int SELECTION_ID_FRONT_LIGHT_R = 1;
260 static const int SELECTION_ID_BRAKE_LIGHT_L = 2;
261 static const int SELECTION_ID_BRAKE_LIGHT_R = 3;
262 static const int SELECTION_ID_REVERSE_LIGHT_L = 4;
263 static const int SELECTION_ID_REVERSE_LIGHT_R = 5;
264 static const int SELECTION_ID_TAIL_LIGHT_L = 6;
265 static const int SELECTION_ID_TAIL_LIGHT_R = 7;
266 static const int SELECTION_ID_DASHBOARD_LIGHT = 8;
267
268 protected bool m_EngineBeforeStart;
269 protected bool m_EngineStartDoOnce;
270
272
275
276#ifdef DEVELOPER
277 private const int DEBUG_MESSAGE_CLEAN_TIME_SECONDS = 10;
278 private float m_DebugMessageCleanTime;
279 private string m_DebugContactDamageMessage;
280#endif
281
283 {
284#ifdef DEVELOPER
285 _car = this;
286#endif
287
288 SetEventMask(EntityEvent.POSTSIMULATE);
289
291
292 m_Time = 0;
293 // sets max health for all components at init
294 m_EngineHealth = 1;
296 m_RadiatorHealth = -1;
297 m_BatteryHealth = -1;
298 m_PlugHealth = -1;
299
300 m_enginePtcFx = -1;
301 m_coolantPtcFx = -1;
302 m_exhaustPtcFx = -1;
303
305
306 m_PlayCrashSoundLight = false;
307 m_PlayCrashSoundHeavy = false;
308
310
313
314 RegisterNetSyncVariableBool("m_HeadlightsOn");
315 RegisterNetSyncVariableBool("m_BrakesArePressed");
316 RegisterNetSyncVariableBool("m_ForceUpdateLights");
317 RegisterNetSyncVariableBool("m_EngineZoneReceivedHit");
318 RegisterNetSyncVariableBoolSignal("m_PlayCrashSoundLight");
319 RegisterNetSyncVariableBoolSignal("m_PlayCrashSoundHeavy");
320 RegisterNetSyncVariableInt("m_CarHornState", ECarHornState.OFF, ECarHornState.LONG);
321
322 if (MemoryPointExists("ptcExhaust_end"))
323 {
324 m_exhaustPtcPos = GetMemoryPointPos("ptcExhaust_end");
325 if (MemoryPointExists("ptcExhaust_start"))
326 {
327 vector exhaustStart = GetMemoryPointPos("ptcExhaust_start");
329
330 m_exhaustPtcDir[0] = -tempOri[2];
331 m_exhaustPtcDir[1] = tempOri[1];
332 m_exhaustPtcDir[2] = tempOri[0];
333
334 m_exhaustPtcDir = m_exhaustPtcDir.Normalized().VectorToAngles();
335 }
336 }
337 else
338 {
339 m_exhaustPtcPos = "0 0 0";
340 m_exhaustPtcDir = "1 1 1";
341 }
342
343 if (MemoryPointExists("ptcEnginePos"))
344 m_enginePtcPos = GetMemoryPointPos("ptcEnginePos");
345 else
346 m_enginePtcPos = "0 0 0";
347
348 if (MemoryPointExists("ptcCoolantPos"))
349 m_coolantPtcPos = GetMemoryPointPos("ptcCoolantPos");
350 else
351 m_coolantPtcPos = "0 0 0";
352
353 if (MemoryPointExists("refill"))
354 m_fuelPos = GetMemoryPointPos("refill");
355 else
356 m_fuelPos = "0 0 0";
357
358 if (MemoryPointExists("drown_engine"))
359 m_DrownEnginePos = GetMemoryPointPos("drown_engine");
360 else
361 m_DrownEnginePos = "0 0 0";
362
363 if (MemoryPointExists("dmgZone_engine"))
364 m_enginePos = GetMemoryPointPos("dmgZone_engine");
365 else
366 m_enginePos = "0 0 0";
367
368 if (MemoryPointExists("dmgZone_front"))
369 m_frontPos = GetMemoryPointPos("dmgZone_front");
370 else
371 m_frontPos = "0 0 0";
372
373 if (MemoryPointExists("dmgZone_back"))
374 m_backPos = GetMemoryPointPos("dmgZone_back");
375 else
376 m_backPos = "0 0 0";
377
378 if (MemoryPointExists("dmgZone_fender_1_1"))
379 m_side_1_1Pos = GetMemoryPointPos("dmgZone_fender_1_1");
380 else
381 m_side_1_1Pos = "0 0 0";
382
383 if (MemoryPointExists("dmgZone_fender_1_2"))
384 m_side_1_2Pos = GetMemoryPointPos("dmgZone_fender_1_2");
385 else
386 m_side_1_2Pos = "0 0 0";
387
388 if (MemoryPointExists("dmgZone_fender_2_1"))
389 m_side_2_1Pos = GetMemoryPointPos("dmgZone_fender_2_1");
390 else
391 m_side_2_1Pos = "0 0 0";
392
393 if (MemoryPointExists("dmgZone_fender_2_2"))
394 m_side_2_2Pos = GetMemoryPointPos("dmgZone_fender_2_2");
395 else
396 m_side_2_2Pos = "0 0 0";
397 }
398
399 override void EEInit()
400 {
401 super.EEInit();
402
403 if (GetGame().IsServer())
404 {
405 m_NoiseSystem = GetGame().GetNoiseSystem();
407 {
408 m_NoisePar = new NoiseParams();
409 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseCarHorn");
410 }
411 }
412 }
413
414#ifdef DIAG_DEVELOPER
415
416 override void FixEntity()
417 {
418 if (GetGame().IsServer())
419 {
421 //server and single
422
423 for (int i = 5; i > 0; i--)//there is a problem with wheels when performed only once, this solves it
424 super.FixEntity();
425 if (!GetGame().IsMultiplayer())
426 {
427 //single
429 }
430 }
431 else
432 {
433 //MP client
435 }
436 }
437#endif
438
439
441 {
442 return ModelToWorld(m_DrownEnginePos);
443 }
444
446 {
447 return ModelToWorld(m_coolantPtcPos);
448 }
449
451 {
452 return ModelToWorld(m_fuelPos);
453 }
454
456 {
457 return ModelToWorld(m_enginePos);
458 }
460 {
461 return ModelToWorld(m_frontPos);
462 }
464 {
465 return ModelToWorld(m_backPos);
466 }
468 {
469 return ModelToWorld(m_side_1_1Pos);
470 }
472 {
473 return ModelToWorld(m_side_1_2Pos);
474 }
476 {
477 return ModelToWorld(m_side_2_1Pos);
478 }
480 {
481 return ModelToWorld(m_side_2_2Pos);
482 }
483
484 override float GetLiquidThroughputCoef()
485 {
487 }
488
489 //here we should handle the damage dealt in OnContact event, but maybe we will react even in that event
491 {
493
495 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(ForceUpdateLightsEnd, 100, false);
496
498 }
499
500 override void EEDelete(EntityAI parent)
501 {
502#ifndef SERVER
504#endif
505 }
506
508 {
509#ifndef SERVER
511#endif
512 }
513
532
537
539 {
540 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_START_SHORT, "Car Horn Start Short", FadeColors.LIGHT_GREY));
541 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_START_LONG, "Car Horn Start Long", FadeColors.LIGHT_GREY));
542 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_STOP, "Car Horn Stop", FadeColors.LIGHT_GREY));
543
544 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "Car Fuel", FadeColors.RED));
545 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_FULL, "Full", FadeColors.LIGHT_GREY));
546 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_EMPTY, "Empty", FadeColors.LIGHT_GREY));
547 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_INCREASE, "10% increase", FadeColors.LIGHT_GREY));
548 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_DECREASE, "10% decrease", FadeColors.LIGHT_GREY));
549 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
550 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "Car Cooler", FadeColors.RED));
551 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_FULL, "Full", FadeColors.LIGHT_GREY));
552 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_EMPTY, "Empty", FadeColors.LIGHT_GREY));
553 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_INCREASE, "10% increase", FadeColors.LIGHT_GREY));
554 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_DECREASE, "10% decrease", FadeColors.LIGHT_GREY));
555 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
556
557 super.GetDebugActions(outputList);
558
559 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
561 }
562
564 {
565 if (super.OnAction(action_id, player, ctx))
566 return true;
567
568 if (!GetGame().IsServer())
569 return false;
570
571 switch (action_id)
572 {
573 case EActions.CAR_HORN_START_SHORT:
575 return true;
576 case EActions.CAR_HORN_START_LONG:
578 return true;
579 case EActions.CAR_HORN_STOP:
581 return true;
582
583 case EActions.CAR_FUEL_FULL:
584 Fill(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL));
585 return true;
586 case EActions.CAR_FUEL_EMPTY:
587 LeakAll(CarFluid.FUEL);
588 return true;
589 case EActions.CAR_FUEL_INCREASE:
590 Fill(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL) * 0.1);
591 return true;
592 case EActions.CAR_FUEL_DECREASE:
593 Leak(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL) * 0.1);
594 return true;
595
596 case EActions.CAR_COOLANT_FULL:
597 Fill(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT));
598 return true;
599 case EActions.CAR_COOLANT_EMPTY:
600 LeakAll(CarFluid.COOLANT);
601 return true;
602 case EActions.CAR_COOLANT_INCREASE:
603 Fill(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT) * 0.1);
604 return true;
605 case EActions.CAR_COOLANT_DECREASE:
606 Leak(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT) * 0.1);
607 return true;
608 case EActions.DELETE:
609 Delete();
610 return true;
611 }
612
613 return false;
614 }
615
617 {
618 super.OnVariablesSynchronized();
619
620 if (GetCrashHeavySound())
622 else if (GetCrashLightSound())
624
626
627 UpdateLights();
628 }
629
631 {
632 if (!SEffectManager.IsEffectExist(m_enginePtcFx) && GetGame().GetWaterDepth(GetEnginePosWS()) <= 0)
633 {
635 m_engineFx.SetParticleStateHeavy();
637 }
638 }
639
640 override void EEItemAttached(EntityAI item, string slot_name)
641 {
642 super.EEItemAttached(item, slot_name);
643
644 switch (slot_name)
645 {
646 case "Reflector_1_1":
647 if (GetGame().IsServer())
648 SetHealth("Reflector_1_1", "Health", item.GetHealth());
649 break;
650 case "Reflector_2_1":
651 if (GetGame().IsServer())
652 SetHealth("Reflector_2_1", "Health", item.GetHealth());
653 break;
654 case "CarBattery":
655 case "TruckBattery":
656 if (GetGame().IsServer())
657 m_BatteryHealth = item.GetHealth01();
658 break;
659 case "SparkPlug":
660 case "GlowPlug":
661 if (GetGame().IsServer())
662 m_PlugHealth = item.GetHealth01();
663 break;
664 case "CarRadiator":
665 if (GetGame().IsServer())
666 m_RadiatorHealth = item.GetHealth01();
667
669 break;
670 }
671
672 if (GetGame().IsServer())
673 Synchronize();
674
676 UpdateLights();
677 }
678
679 // Updates state of attached headlight bulbs for faster access
681 {
682 EntityAI bulb_L = FindAttachmentBySlotName("Reflector_1_1");
683 EntityAI bulb_R = FindAttachmentBySlotName("Reflector_2_1");
684
685 if (bulb_L && !bulb_L.IsRuined() && bulb_R && !bulb_R.IsRuined())
687 else if (bulb_L && !bulb_L.IsRuined())
689 else if (bulb_R && !bulb_R.IsRuined())
691 else if ((!bulb_L || bulb_L.IsRuined()) && (!bulb_R || bulb_R.IsRuined()))
693 }
694
695 override void EEItemDetached(EntityAI item, string slot_name)
696 {
697 switch (slot_name)
698 {
699 case "CarBattery":
700 case "TruckBattery":
701 m_BatteryHealth = -1;
702 if (GetGame().IsServer())
703 {
704 if (EngineIsOn())
705 EngineStop();
706
707 if (IsScriptedLightsOn())
709 }
710 break;
711 case "SparkPlug":
712 case "GlowPlug":
713 m_PlugHealth = -1;
714 if (GetGame().IsServer() && EngineIsOn())
715 EngineStop();
716 break;
717 case "CarRadiator":
719 if (GetGame().IsServer())
720 {
721 LeakAll(CarFluid.COOLANT);
722
723 if (m_DamageZoneMap.Contains("Radiator"))
724 SetHealth("Radiator", "Health", 0);
725 }
726 break;
727 }
728
729 if (GetGame().IsServer())
730 Synchronize();
731
733 UpdateLights();
734 }
735
737 {
738 super.OnAttachmentRuined(attachment);
739
741 UpdateLights();
742 }
743
745 {
746 if (!super.CanReceiveAttachment(attachment, slotId))
747 return false;
748
750 attachment.GetInventory().GetCurrentInventoryLocation(attachmentInventoryLocation);
751 if (attachmentInventoryLocation.GetParent() == null)
752 return true;
753
754 if (attachment && attachment.Type().IsInherited(CarWheel))
755 {
756 string slotSelectionName;
758
759 switch (slotSelectionName)
760 {
761 case "wheel_spare_1":
762 case "wheel_spare_2":
764 break;
765 }
766 }
767
768 return true;
769 }
770
772 {
773 if (!super.CanReleaseAttachment(attachment))
774 return false;
775
776 if (EngineIsOn() && IsMoving())
777 return false;
778
779 if (attachment && attachment.Type().IsInherited(CarWheel))
780 {
782 attachment.GetInventory().GetCurrentInventoryLocation(attachmentInventoryLocation);
783
784 string slotSelectionName;
786
787 switch (slotSelectionName)
788 {
789 case "wheel_spare_1":
790 case "wheel_spare_2":
792 break;
793 }
794 }
795
796 return true;
797 }
798
800 {
801 return false;
802 }
803
805 {
806 m_Time += timeSlice;
807
808 if (GetGame().IsServer())
809 {
812
813#ifdef DIAG_DEVELOPER
815 {
816 if (m_ContactCalled)
817 {
818 Debug.Log("Momentum delta: " + (GetMomentum() - m_MomentumPrevTick));
819 Debug.Log("--------------------------------------------------------------------");
820 m_ContactCalled = false;
821 }
822 }
823#endif
824
825
829#ifdef DEVELOPER
832 {
835 }
836#endif
837 }
838
840 {
841 m_Time = 0;
842
844
845 //First of all check if the car should stop the engine
846 if (GetGame().IsServer() && EngineIsOn())
847 {
848 if (GetFluidFraction(CarFluid.FUEL) <= 0 || m_EngineHealth <= 0)
849 EngineStop();
850
851 CheckVitalItem(IsVitalCarBattery(), "CarBattery");
852 CheckVitalItem(IsVitalTruckBattery(), "TruckBattery");
853 CheckVitalItem(IsVitalSparkPlug(), "SparkPlug");
854 CheckVitalItem(IsVitalGlowPlug(), "GlowPlug");
855 }
856
857 if (GetGame().IsServer())
858 {
859 if (IsVitalFuelTank())
860 {
862 SetHealth("Engine", "Health", GameConstants.DAMAGE_RUINED_VALUE);
863 }
864 }
865
867 if (EngineIsOn())
868 {
869 if (GetGame().IsServer())
870 {
871 float dmg;
872
873 if (EngineGetRPM() >= EngineGetRPMRedline())
874 {
875 if (EngineGetRPM() > EngineGetRPMMax())
876 AddHealth("Engine", "Health", -GetMaxHealth("Engine", "") * 0.05); //CAR_RPM_DMG
877
878 dmg = EngineGetRPM() * 0.001 * Math.RandomFloat(0.02, 1.0); //CARS_TICK_DMG_MIN; //CARS_TICK_DMG_MAX
879 ProcessDirectDamage(DamageType.CUSTOM, null, "Engine", "EnviroDmg", vector.Zero, dmg);
881 }
882 else
884
886 if (IsVitalRadiator())
887 {
888 if (GetFluidFraction(CarFluid.COOLANT) > 0 && m_RadiatorHealth < 0.5) //CARS_LEAK_THRESHOLD
889 LeakFluid(CarFluid.COOLANT);
890 }
891
892 if (GetFluidFraction(CarFluid.FUEL) > 0 && m_FuelTankHealth < GameConstants.DAMAGE_DAMAGED_VALUE)
893 LeakFluid(CarFluid.FUEL);
894
895 if (GetFluidFraction(CarFluid.BRAKE) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE)
896 LeakFluid(CarFluid.BRAKE);
897
898 if (GetFluidFraction(CarFluid.OIL) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE)
899 LeakFluid(CarFluid.OIL);
900
901 if (m_EngineHealth < 0.25)
902 LeakFluid(CarFluid.OIL);
903
904 if (IsVitalRadiator())
905 {
906 if (GetFluidFraction(CarFluid.COOLANT) < 0.5 && GetFluidFraction(CarFluid.COOLANT) >= 0)
907 {
908 dmg = (1 - GetFluidFraction(CarFluid.COOLANT)) * Math.RandomFloat(0.02, 10.00); //CARS_DMG_TICK_MIN_COOLANT; //CARS_DMG_TICK_MAX_COOLANT
909 AddHealth("Engine", "Health", -dmg);
911 }
912 }
913 }
914
915 //FX only on Client and in Single
916 if (!GetGame().IsDedicatedServer())
917 {
919 {
922 m_exhaustFx.SetParticleStateLight();
923 }
924
925 if (IsVitalRadiator() && GetFluidFraction(CarFluid.COOLANT) < 0.5)
926 {
928 {
931 }
932
933 if (m_coolantFx)
934 {
935 if (GetFluidFraction(CarFluid.COOLANT) > 0)
936 m_coolantFx.SetParticleStateLight();
937 else
938 m_coolantFx.SetParticleStateHeavy();
939 }
940 }
941 else
942 {
945 }
946 }
947 }
948 else
949 {
950 //FX only on Client and in Single
951 if (!GetGame().IsDedicatedServer())
952 {
954 {
956 m_exhaustPtcFx = -1;
957 }
958
960 {
962 m_coolantPtcFx = -1;
963 }
964 }
965 }
966 }
967 }
968
970 {
971 UpdateLights();
972 }
973
975 {
976 UpdateLights();
977 }
978
979 override void OnUpdate(float dt)
980 {
981 if (GetGame().IsServer())
982 {
984 if (battery)
985 {
986 if (EngineIsOn())
987 {
990 {
991 battery.GetCompEM().ConsumeEnergy(GetBatteryRechargeRate() * m_BatteryTimer);
992 m_BatteryTimer = 0;
993 }
994 }
995 else if (!EngineIsOn() && IsScriptedLightsOn())
996 {
999 {
1000 battery.GetCompEM().ConsumeEnergy(GetBatteryRuntimeConsumption() * m_BatteryTimer);
1001 m_BatteryTimer = 0;
1002
1003 if (battery.GetCompEM().GetEnergy() <= 0)
1005 }
1006 }
1007 }
1008
1009 if (GetGame().GetWaterDepth(GetEnginePosWS()) > 0)
1010 {
1011 m_DrownTime += dt;
1013 {
1014 // *dt to get damage per second
1015 AddHealth("Engine", "Health", -DROWN_ENGINE_DAMAGE * dt);
1017 }
1018 }
1019 else
1020 m_DrownTime = 0;
1021 }
1022
1023 // For visualisation of brake lights for all players
1024 float brake_coef = GetBrake();
1025 if (brake_coef > 0)
1026 {
1027 if (!m_BrakesArePressed)
1028 {
1029 m_BrakesArePressed = true;
1030 SetSynchDirty();
1032 }
1033 }
1034 else
1035 {
1037 {
1038 m_BrakesArePressed = false;
1039 SetSynchDirty();
1041 }
1042 }
1043
1044 if ((!GetGame().IsDedicatedServer()) && m_ForceUpdateLights)
1045 {
1046 UpdateLights();
1047 m_ForceUpdateLights = false;
1048 }
1049 }
1050
1051 override void EEKilled(Object killer)
1052 {
1053 super.EEKilled(killer);
1054 m_EngineDestroyed = true;
1055 }
1056
1059 {
1060 if (GetGame().IsServer())
1061 {
1062#ifdef DIAG_DEVELOPER
1063 m_ContactCalled = true;
1065 {
1066 string output = "Zone: " + zoneName + " | Impulse:" + data.Impulse;
1067 Debug.Log(output);
1068 }
1069#endif
1070 if (m_ContactCache.Count() == 0)
1071 {
1073 m_ContactCache.Insert(zoneName, ccd);
1075 float dot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1076 if (dot < 0)
1078
1080 }
1081 }
1082 }
1083
1086 {
1087
1088 int contactZonesCount = m_ContactCache.Count();
1089
1090 if (contactZonesCount == 0)
1091 return;
1092
1093
1094 for (int i = 0; i < contactZonesCount; ++i)
1095 {
1096 string zoneName = m_ContactCache.GetKey(i);
1098
1100 float crewDmgBase = Math.AbsInt((data[0].impulse / dBodyGetMass(this)) * 1000 * m_dmgContactCoef);// calculates damage as if the object's weight was 1000kg instead of its actual weight
1101
1102#ifdef DIAG_DEVELOPER
1103 CrashDebugData.m_CrashDataPoint = new CrashDebugData();
1104 CrashDebugData.m_CrashDataPoint.m_VehicleType = GetDisplayName();
1105 CrashDebugData.m_CrashDataPoint.m_Damage = dmg;
1106 CrashDebugData.m_CrashDataPoint.m_Zone = zoneName;
1107 CrashDebugData.m_CrashDataPoint.m_MomentumCurr = GetMomentum();
1108 CrashDebugData.m_CrashDataPoint.m_MomentumPrev = m_MomentumPrevTick;
1109 CrashDebugData.m_CrashDataPoint.m_MomentumDelta = data[0].impulse;
1110 CrashDebugData.m_CrashDataPoint.m_SpeedWorld = GetVelocity(this).Length() * 3.6;
1111 CrashDebugData.m_CrashDataPoint.m_SpeedWorldPrev = m_VelocityPrevTick.Length() * 3.6;
1112 CrashDebugData.m_CrashDataPoint.m_SpeedWorldDelta = (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6;
1113 CrashDebugData.m_CrashDataPoint.m_VelocityCur = GetVelocity(this);
1114 CrashDebugData.m_CrashDataPoint.m_VelocityPrev = m_VelocityPrevTick;
1115 CrashDebugData.m_CrashDataPoint.m_VelocityDot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1116 CrashDebugData.m_CrashDataPoint.m_Time = GetGame().GetTime();
1117
1118
1119 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1120 {
1121 Debug.Log("--------------------------------------------------");
1122 Debug.Log("Vehicle:" + GetDisplayName());
1123 Debug.Log("DMG: " + dmg);
1124 Debug.Log("zoneName : " + zoneName);
1125 Debug.Log("momentumCurr : " + GetMomentum());
1126 Debug.Log("momentumPrev : " + m_MomentumPrevTick);
1127 Debug.Log("momentumDelta : " + data[0].impulse);
1128 Debug.Log("speed(km/h): " + GetVelocity(this).Length() * 3.6);
1129 Debug.Log("speedPrev(km/h): " + m_VelocityPrevTick.Length() * 3.6);
1130 Debug.Log("speedDelta(km/h) : " + (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6);
1131 Debug.Log("velocityCur.): " + GetVelocity(this));
1132 Debug.Log("velocityPrev.): " + m_VelocityPrevTick);
1133 Debug.Log("velocityDot): " + vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized()));
1134 Debug.Log("GetGame().GetTime(): " + GetGame().GetTime());
1135 Debug.Log("--------------------------------------------------");
1136 }
1137#endif
1139 continue;
1140
1141 int pddfFlags;
1142#ifdef DIAG_DEVELOPER
1143 CrashDebugData.m_CrashData.Insert(CrashDebugData.m_CrashDataPoint);
1144 CrashDebugData.m_CrashDataPoint.m_Speedometer = GetSpeedometer();
1145 //Print("Crash data recorded");
1146#endif
1148 {
1149#ifdef DIAG_DEVELOPER
1150 CrashDebugData.m_CrashDataPoint.m_DamageType = "Small";
1151 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1152 Debug.Log(string.Format("[Vehiles:Damage]:: DMG %1 to the %2 zone is SMALL (threshold: %3), SPEEDOMETER: %4, TIME: %5", dmg, zoneName, GameConstants.CARS_CONTACT_DMG_MIN, GetSpeedometer(), GetGame().GetTime()));
1153#endif
1155 pddfFlags = ProcessDirectDamageFlags.NO_TRANSFER;
1156 }
1157 else
1158 {
1159#ifdef DIAG_DEVELOPER
1160 CrashDebugData.m_CrashDataPoint.m_DamageType = "Big";
1161 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1162 Debug.Log(string.Format("[Vehiles:Damage]:: DMG %1 to the %2 zone is BIG (threshold: %3), SPEED: %4, TIME: %5", dmg, zoneName, GameConstants.CARS_CONTACT_DMG_THRESHOLD, GetSpeedometer(), GetGame().GetTime()));
1163#endif
1166 pddfFlags = 0;
1167 }
1168
1169#ifdef DEVELOPER
1170 m_DebugContactDamageMessage += string.Format("%1: %2\n", zoneName, dmg);
1171#endif
1172
1173 ProcessDirectDamage(DT_CUSTOM, null, zoneName, "EnviroDmg", "0 0 0", dmg, pddfFlags);
1174 }
1175
1177 UpdateLights();
1178
1179 m_ContactCache.Clear();
1180
1181 }
1182
1184 void DamageCrew(float dmg)
1185 {
1186 for (int c = 0; c < CrewSize(); ++c)
1187 {
1188 Human crew = CrewMember(c);
1189 if (!crew)
1190 continue;
1191
1193 if (Class.CastTo(player, crew))
1194 {
1196 {
1197#ifdef DIAG_DEVELOPER
1198 CrashDebugData.m_CrashDataPoint.m_CrewDamageBase = dmg;
1199 CrashDebugData.m_CrashDataPoint.m_DMGHealth = -100;
1200 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1201 {
1202 Debug.Log("--------------------------------------------------");
1203 Debug.Log("Killing the player");
1204 Debug.Log("Crew DMG Base: " + dmg);
1205 Debug.Log("--------------------------------------------------");
1206
1207 }
1208#endif
1209 player.SetHealth(0.0);
1210 }
1211 else
1212 {
1214 shockTemp = Math.Clamp(shockTemp, 0, 1);
1215 float shock = Math.Lerp(50, 150, shockTemp);
1216 float hp = Math.Lerp(2, 100, shockTemp);
1217
1218#ifdef DIAG_DEVELOPER
1219 CrashDebugData.m_CrashDataPoint.m_CrewDamageBase = dmg;
1220 CrashDebugData.m_CrashDataPoint.m_ShockTemp = shockTemp;
1221 CrashDebugData.m_CrashDataPoint.m_DMGHealth = hp;
1222 CrashDebugData.m_CrashDataPoint.m_DMGShock = shock;
1223 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1224 {
1225 Debug.Log("--------------------------------------------------");
1226 Debug.Log("Crew DMG Base: " + dmg);
1227 Debug.Log("Crew shockTemp: " + shockTemp);
1228 Debug.Log("Crew DMG Health: " + hp);
1229 Debug.Log("Crew DMG Shock: " + shock);
1230 Debug.Log("--------------------------------------------------");
1231 }
1232#endif
1233
1234 player.AddHealth("", "Shock", -shock);
1235 player.AddHealth("", "Health", -hp);
1236 }
1237 }
1238 }
1239 }
1240
1246 override float OnSound(CarSoundCtrl ctrl, float oldValue)
1247 {
1248 switch (ctrl)
1249 {
1250 case CarSoundCtrl.ENGINE:
1251 if (!m_EngineStarted)
1252 return 0.0;
1253 break;
1254 }
1255
1256 return oldValue;
1257 }
1258
1259 override void OnAnimationPhaseStarted(string animSource, float phase)
1260 {
1261#ifndef SERVER
1264#endif
1265 }
1266
1267 protected void HandleDoorsSound(string animSource, float phase)
1268 {
1269 switch (animSource)
1270 {
1271 case "doorsdriver":
1272 case "doorscodriver":
1273 case "doorscargo1":
1274 case "doorscargo2":
1275 case "doorshood":
1276 case "doorstrunk":
1278 if (phase == 0)
1280 else
1282
1283 if (sound)
1284 sound.SetAutodestroy(true);
1285
1286 break;
1287 }
1288 }
1289
1290 protected void HandleSeatAdjustmentSound(string animSource, float phase)
1291 {
1292 switch (animSource)
1293 {
1294 case "seatdriver":
1295 case "seatcodriver":
1297 if (phase == 0)
1299 else
1301
1302 if (sound)
1303 sound.SetAutodestroy(true);
1304
1305 break;
1306 }
1307 }
1308
1309
1311 {
1312 switch (pState)
1313 {
1314 case ECarHornState.SHORT:
1315 PlaySoundSet(m_CarHornSoundEffect, m_CarHornShortSoundName, 0, 0, false);
1316 break;
1317 case ECarHornState.LONG:
1318 PlaySoundSet(m_CarHornSoundEffect, m_CarHornLongSoundName, 0, 0, true);
1319 break;
1320 default:
1322 break;
1323 }
1324 }
1325
1327 {
1328#ifndef SERVER
1331 WaveKind waveKind = WaveKind.WAVEEFFECT;
1332
1333 switch (state)
1334 {
1335 case CarEngineSoundState.STARTING:
1336 m_PreStartSound = SEffectManager.PlaySound("Offroad_02_Starting_SoundSet", ModelToWorld(GetEnginePos()));
1337 m_PreStartSound.SetSoundFadeOut(0.15);
1338 break;
1339 case CarEngineSoundState.START_OK:
1340 // play different sound based on selected camera
1341 if (Class.CastTo(player, CrewMember(0)))
1342 {
1343 if (!player.IsCameraInsideVehicle())
1344 waveKind = WaveKind.WAVEEFFECTEX;
1345
1346 sound = SEffectManager.CreateSound(m_EngineStartOK, ModelToWorld(GetEnginePos()));
1347 if (sound)
1348 {
1349 sound.SetSoundWaveKind(waveKind);
1350 sound.SoundPlay();
1351 sound.SetAutodestroy(true);
1352 }
1353 }
1354
1356 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(SetEngineStarted, 1000, false, true);
1357 break;
1358
1359 case CarEngineSoundState.START_NO_FUEL:
1360 sound = SEffectManager.PlaySound("offroad_engine_failed_start_fuel_SoundSet", ModelToWorld(GetEnginePos()));
1361 sound.SetAutodestroy(true);
1362 break;
1363
1364 case CarEngineSoundState.START_NO_BATTERY:
1365 sound = SEffectManager.PlaySound("offroad_engine_failed_start_battery_SoundSet", ModelToWorld(GetEnginePos()));
1366 sound.SetAutodestroy(true);
1367 break;
1368
1369 case CarEngineSoundState.START_NO_SPARKPLUG:
1370 sound = SEffectManager.PlaySound("offroad_engine_failed_start_sparkplugs_SoundSet", ModelToWorld(GetEnginePos()));
1371 sound.SetAutodestroy(true);
1372 break;
1373
1374 case CarEngineSoundState.STOP_OK:
1375 case CarEngineSoundState.STOP_NO_FUEL:
1376 // play different sound based on selected camera
1377 if (Class.CastTo(player, CrewMember(0)))
1378 {
1379 if (!player.IsCameraInsideVehicle())
1380 waveKind = WaveKind.WAVEEFFECTEX;
1381
1382 sound = SEffectManager.CreateSound(m_EngineStopFuel, ModelToWorld(GetEnginePos()));
1383 if (sound)
1384 {
1385 sound.SetSoundWaveKind(waveKind);
1386 sound.SoundPlay();
1387 sound.SetAutodestroy(true);
1388 }
1389 }
1390
1391 SetEngineStarted(false);
1392 break;
1393 }
1394#endif
1395 }
1396
1405
1414
1416 {
1417 switch (state)
1418 {
1419 case ECrewMemberState.UNCONSCIOUS:
1421 {
1422 if (unconsciousCrewMemberIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
1423 {
1424 EngineStop();
1425 SetBrake(0.5);
1426 }
1427
1429 }
1430
1431 break
1432
1433 case ECrewMemberState.DEAD:
1435 {
1436 if (deadCrewMemberIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
1437 {
1438 EngineStop();
1439 SetBrake(0.5);
1440 }
1441
1443 }
1444
1445 break
1446 }
1447 }
1448
1451
1458 override void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
1459 {
1460 switch (fluid)
1461 {
1462 case CarFluid.FUEL:
1464 break;
1465
1466 case CarFluid.OIL:
1468 break;
1469
1470 case CarFluid.BRAKE:
1472 break;
1473
1474 case CarFluid.COOLANT:
1476 break;
1477 }
1478 }
1479
1486 override bool OnBeforeEngineStart()
1487 {
1488 EntityAI item = null;
1489
1491 {
1492 m_EngineStartDoOnce = false;
1493 return m_EngineBeforeStart;
1494 }
1495
1496 if (GetFluidFraction(CarFluid.FUEL) <= 0)
1497 {
1499 return false;
1500 }
1501
1503 {
1504 item = GetBattery();
1505 if (!item || (item && (item.IsRuined() || item.GetCompEM().GetEnergy() < m_BatteryEnergyStartMin)))
1506 {
1507 m_EngineStartDoOnce = true;
1508 HandleEngineSound(CarEngineSoundState.START_NO_BATTERY);
1509 return false;
1510 }
1511 }
1512
1513 if (IsVitalSparkPlug())
1514 {
1515 item = FindAttachmentBySlotName("SparkPlug");
1516 if (!item || (item && item.IsRuined()))
1517 {
1518 m_EngineStartDoOnce = true;
1519 HandleEngineSound(CarEngineSoundState.START_NO_SPARKPLUG);
1520 return false;
1521 }
1522 }
1523
1524 if (IsVitalGlowPlug())
1525 {
1526 item = FindAttachmentBySlotName("GlowPlug");
1527 if (!item || (item && item.IsRuined()))
1528 {
1529 m_EngineStartDoOnce = true;
1530 HandleEngineSound(CarEngineSoundState.START_NO_SPARKPLUG);
1531 return false;
1532 }
1533 }
1534
1536 {
1537 m_EngineBeforeStart = true;
1539 }
1540
1541 return true;
1542 }
1543
1544 override void OnGearChanged(int newGear, int oldGear)
1545 {
1546 //Debug.Log(string.Format("OnGearChanged newGear=%1,oldGear=%2", newGear, oldGear));
1548 }
1549
1551 override void OnEngineStart()
1552 {
1554 if (GetGame().IsServer() && battery)
1555 battery.GetCompEM().ConsumeEnergy(GetBatteryConsumption());
1556
1557 UpdateLights();
1558
1560
1561 m_EngineBeforeStart = false;
1562 }
1563
1565 override void OnEngineStop()
1566 {
1567 UpdateLights();
1568
1571
1572 m_EngineBeforeStart = false;
1573 }
1574
1580 {
1581 return true;
1582 }
1583
1586 {
1587 return m_HeadlightsOn;
1588 }
1589
1592 {
1594 SetSynchDirty();
1595 }
1596
1597 void UpdateLights(int new_gear = -1)
1598 {
1599#ifndef SERVER
1601#endif
1603 }
1604
1606 {
1607 int gear;
1608
1609 if (newGear == -1)
1610 gear = GetGear();
1611 else
1612 gear = newGear;
1613
1614 if (m_HeadlightsOn)
1615 {
1618
1619 if (m_Headlight)
1620 {
1621 switch (m_HeadlightsState)
1622 {
1623 case CarHeadlightBulbsState.LEFT:
1625 m_Headlight.SegregateLight();
1626 break;
1627 case CarHeadlightBulbsState.RIGHT:
1629 m_Headlight.SegregateLight();
1630 break;
1631 case CarHeadlightBulbsState.BOTH:
1632 vector local_pos_left = GetMemoryPointPos(m_LeftHeadlightPoint);
1633 vector local_pos_right = GetMemoryPointPos(m_RightHeadlightPoint);
1634
1636 m_Headlight.AttachOnObject(this, local_pos_middle);
1637 m_Headlight.AggregateLight();
1638 break;
1639 default:
1640 m_Headlight.FadeOut();
1641 m_Headlight = null;
1642 }
1643 }
1644 }
1645 else
1646 {
1647 if (m_Headlight)
1648 {
1649 m_Headlight.FadeOut();
1650 m_Headlight = null;
1651 }
1652 }
1653
1654 // brakes & reverse
1655 switch (gear)
1656 {
1657 case CarGear.REVERSE:
1660 m_RearLightType = CarRearLightType.BRAKES_AND_REVERSE;
1661 else
1662 m_RearLightType = CarRearLightType.REVERSE_ONLY;
1663 break;
1664 default:
1666 m_RearLightType = CarRearLightType.BRAKES_ONLY;
1667 else
1669 }
1670
1671 //Debug.Log(string.Format("m_BrakesArePressed=%1, m_RearLightType=%2", m_BrakesArePressed.ToString(), EnumTools.EnumToString(CarRearLightType, m_RearLightType)));
1672
1674 {
1675 if (EngineIsOn() || m_RearLightType == CarRearLightType.BRAKES_ONLY || m_RearLightType == CarRearLightType.BRAKES_AND_REVERSE)
1676 {
1678 vector localPos = GetMemoryPointPos(m_ReverseLightPoint);
1679 m_RearLight.AttachOnObject(this, localPos, "180 0 0");
1680 }
1681 }
1682
1683 // rear lights
1685 {
1686 switch (m_RearLightType)
1687 {
1688 case CarRearLightType.BRAKES_ONLY:
1690 break;
1691 case CarRearLightType.REVERSE_ONLY:
1692 if (EngineIsOn())
1694 else
1695 NoRearLight();
1696
1697 break;
1698 case CarRearLightType.BRAKES_AND_REVERSE:
1699 if (EngineIsOn())
1701 else
1703
1704 break;
1705 default:
1706 NoRearLight();
1707 }
1708 }
1709 else
1710 {
1711 if (m_RearLight)
1712 NoRearLight();
1713 }
1714 }
1715
1717 {
1718 int gear;
1719
1720 if (newGear == -1)
1721 {
1722 gear = GetGear();
1723 if (GearboxGetType() == CarGearboxType.AUTOMATIC)
1724 gear = GearboxGetMode();
1725 }
1726 else
1727 gear = newGear;
1728
1729 if (m_HeadlightsOn)
1730 {
1733
1734 switch (m_HeadlightsState)
1735 {
1736 case CarHeadlightBulbsState.LEFT:
1739 break;
1740 case CarHeadlightBulbsState.RIGHT:
1743 break;
1744 case CarHeadlightBulbsState.BOTH:
1747 break;
1748 default:
1751 }
1752
1753 //Debug.Log(string.Format("m_HeadlightsOn=%1, m_HeadlightsState=%2", m_HeadlightsOn.ToString(), EnumTools.EnumToString(CarHeadlightBulbsState, m_HeadlightsState)));
1754 }
1755 else
1756 {
1761 }
1762
1763
1764 // brakes & reverse
1765 switch (gear)
1766 {
1767 case CarGear.REVERSE:
1770 m_RearLightType = CarRearLightType.BRAKES_AND_REVERSE;
1771 else
1772 m_RearLightType = CarRearLightType.REVERSE_ONLY;
1773 break;
1774 default:
1776 m_RearLightType = CarRearLightType.BRAKES_ONLY;
1777 else
1779 }
1780
1781 //Debug.Log(string.Format("m_BrakesArePressed=%1, m_RearLightType=%2", m_BrakesArePressed.ToString(), EnumTools.EnumToString(CarRearLightType, m_RearLightType)));
1782
1783
1784 // rear lights
1786 {
1787 switch (m_RearLightType)
1788 {
1789 case CarRearLightType.BRAKES_ONLY:
1792 break;
1793 case CarRearLightType.REVERSE_ONLY:
1794 if (EngineIsOn())
1795 {
1798 }
1799 else
1800 {
1803 }
1804 break;
1805 case CarRearLightType.BRAKES_AND_REVERSE:
1806 if (EngineIsOn())
1807 {
1810 }
1811 else
1812 {
1815 }
1816 break;
1817 default:
1820 }
1821 }
1822 else
1823 {
1826 }
1827 }
1828
1829 protected void BrakesRearLight()
1830 {
1831 m_RearLight.SetAsSegregatedBrakeLight();
1832 }
1833
1834 protected void ReverseRearLight()
1835 {
1836 m_RearLight.SetAsSegregatedReverseLight();
1837 }
1838
1840 {
1841 m_RearLight.AggregateLight();
1842 m_RearLight.SetFadeOutTime(1);
1843 }
1844
1845 protected void NoRearLight()
1846 {
1847 m_RearLight.FadeOut();
1848 m_RearLight = null;
1849 }
1850
1851 protected void LeftFrontLightShineOn()
1852 {
1853 string material = ConfigGetString("frontReflectorMatOn");
1854
1855 if (material)
1856 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_L, material);
1857 }
1858
1859 protected void RightFrontLightShineOn()
1860 {
1861 string material = ConfigGetString("frontReflectorMatOn");
1862
1863 if (material)
1864 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_R, material);
1865 }
1866
1867 protected void LeftFrontLightShineOff()
1868 {
1869 string material = ConfigGetString("frontReflectorMatOff");
1870
1871 if (material)
1872 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_L, material);
1873 }
1874
1876 {
1877 string material = ConfigGetString("frontReflectorMatOff");
1878
1879 if (material)
1880 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_R, material);
1881 }
1882
1883 protected void ReverseLightsShineOn()
1884 {
1885 string material = ConfigGetString("ReverseReflectorMatOn");
1886
1887 if (material)
1888 {
1889 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_L, material);
1890 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_R, material);
1891 }
1892 }
1893
1894 protected void ReverseLightsShineOff()
1895 {
1896 string material = ConfigGetString("ReverseReflectorMatOff");
1897
1898 if (material)
1899 {
1900 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_L, material);
1901 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_R, material);
1902 }
1903 }
1904
1905 protected void BrakeLightsShineOn()
1906 {
1907 string material = ConfigGetString("brakeReflectorMatOn");
1908
1909 if (material)
1910 {
1911 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_L, material);
1912 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_R, material);
1913 }
1914 }
1915
1916 protected void BrakeLightsShineOff()
1917 {
1918 string material = ConfigGetString("brakeReflectorMatOff");
1919
1920 if (material)
1921 {
1922 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_L, material);
1923 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_R, material);
1924 }
1925 }
1926
1927 protected void TailLightsShineOn()
1928 {
1929 string material = ConfigGetString("TailReflectorMatOn");
1930 string materialOff = ConfigGetString("TailReflectorMatOff");
1931
1932 if (material && materialOff)
1933 {
1935 {
1936 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
1937 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, materialOff);
1938 }
1939 else if (m_HeadlightsState == CarHeadlightBulbsState.RIGHT)
1940 {
1941 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, materialOff);
1942 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
1943 }
1945 {
1946 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
1947 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
1948 }
1949 }
1950 }
1951
1952 protected void TailLightsShineOff()
1953 {
1954 string material = ConfigGetString("TailReflectorMatOff");
1955
1956 if (material)
1957 {
1958 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
1959 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
1960 }
1961 }
1962
1963 protected void DashboardShineOn()
1964 {
1965 string material = ConfigGetString("dashboardMatOn");
1966
1967 if (material)
1968 SetObjectMaterial(SELECTION_ID_DASHBOARD_LIGHT, material);
1969 }
1970
1971 protected void DashboardShineOff()
1972 {
1973 string material = ConfigGetString("dashboardMatOff");
1974
1975 if (material)
1976 SetObjectMaterial(SELECTION_ID_DASHBOARD_LIGHT, material);
1977 }
1978
1979 // Override this for a car-specific light type
1981 {
1982 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
1983 }
1984
1985 // Override this for a car-specific light type
1987 {
1988 return CarLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
1989 }
1990
1991 protected void CheckVitalItem(bool isVital, string itemName)
1992 {
1993 if (!isVital)
1994 return;
1995
1996 EntityAI item = FindAttachmentBySlotName(itemName);
1997
1998 if (!item)
1999 EngineStop();
2000 else if (item.IsRuined())
2001 EngineStop();
2002 }
2003
2004 protected void LeakFluid(CarFluid fluid)
2005 {
2006 float ammount = 0;
2007
2008 switch (fluid)
2009 {
2010 case CarFluid.COOLANT:
2011 ammount = (1 - m_RadiatorHealth) * Math.RandomFloat(0.02, 0.05); //CARS_LEAK_TICK_MIN; CARS_LEAK_TICK_MAX
2012 Leak(fluid, ammount);
2013 break;
2014
2015 case CarFluid.OIL:
2016 ammount = (1 - m_EngineHealth) * Math.RandomFloat(0.02, 1.0); //CARS_LEAK_OIL_MIN; CARS_LEAK_OIL_MAX
2017 Leak(fluid, ammount);
2018 break;
2019
2020 case CarFluid.FUEL:
2021 ammount = (1 - m_FuelTankHealth) * Math.RandomFloat(0.02, 0.05); //CARS_LEAK_TICK_MIN; CARS_LEAK_TICK_MAX
2022 Leak(fluid, ammount);
2023 break;
2024 }
2025 }
2026
2027 protected void CarPartsHealthCheck()
2028 {
2029 if (GetGame().IsServer())
2030 {
2031 if (HasRadiator())
2032 m_RadiatorHealth = GetRadiator().GetHealth01("", "");
2033 else
2034 m_RadiatorHealth = 0;
2035
2036 m_EngineHealth = GetHealth01("Engine", "");
2037 m_FuelTankHealth = GetHealth01("FuelTank", "");
2038 }
2039 }
2040
2042 {
2043 return m_PlayCrashSoundLight;
2044 }
2045
2047 {
2049 {
2051 SetSynchDirty();
2052 }
2053 }
2054
2056 {
2057 PlaySoundEx("offroad_hit_light_SoundSet", m_CrashSoundLight, m_PlayCrashSoundLight);
2058 }
2059
2061 {
2062 return m_PlayCrashSoundHeavy;
2063 }
2064
2066 {
2068 {
2070 SetSynchDirty();
2071 }
2072 }
2073
2075 {
2076 PlaySoundEx("offroad_hit_heavy_SoundSet", m_CrashSoundHeavy, m_PlayCrashSoundHeavy);
2077 }
2078
2080 {
2081#ifndef SERVER
2082 if (!sound)
2083 {
2085 if (sound)
2086 sound.SetAutodestroy(true);
2087 }
2088 else
2089 {
2090 if (!sound.IsSoundPlaying())
2091 {
2092 sound.SetPosition(GetPosition());
2093 sound.SoundPlay();
2094 }
2095 }
2096
2097 soundbool = false;
2098#endif
2099 }
2100
2105
2106 string GetAnimSourceFromSelection(string selection)
2107 {
2108 return "";
2109 }
2110
2111 string GetDoorConditionPointFromSelection(string selection)
2112 {
2113 switch (selection)
2114 {
2115 case "seat_driver":
2116 return "seat_con_1_1";
2117 break;
2118 case "seat_codriver":
2119 return "seat_con_2_1";
2120 break;
2121 case "seat_cargo1":
2122 return "seat_con_1_2";
2123 break;
2124 case "seat_cargo2":
2125 return "seat_con_2_2";
2126 break;
2127 }
2128
2129 return "";
2130 }
2131
2133 {
2134 return "";
2135 }
2136
2138 {
2139 return "";
2140 }
2141
2142 int GetCrewIndex(string selection)
2143 {
2144 return -1;
2145 }
2146
2148 {
2150 if (conPointName.Length() > 0)
2151 {
2152 if (MemoryPointExists(conPointName))
2153 {
2154 vector conPointMS = GetMemoryPointPos(conPointName);
2155 vector conPointWS = ModelToWorld(conPointMS);
2156
2158 conPointWS[1] = 0;
2159 pFromPos[1] = 0;
2160
2162 return true;
2163 }
2164 }
2165
2166 return false;
2167 }
2168
2170 {
2171 return true;
2172 }
2173
2175 {
2176 return true;
2177 }
2178
2180 {
2181 return true;
2182 }
2183
2185 {
2186 return true;
2187 }
2188
2190 {
2191 return true;
2192 }
2193
2195 {
2196 return true;
2197 }
2198
2200 {
2201 return true;
2202 }
2203
2205 {
2206 return m_Radiator != null;
2207 }
2208
2210 {
2211 return m_Radiator;
2212 }
2213
2215 {
2216 return GetSpeedometerAbsolute() > 3.5;
2217 }
2218
2220 {
2221 return GetHandbrake() > 0.0;
2222 }
2223
2226 {
2228
2229 }
2230
2232 {
2234 }
2235
2237 {
2238 return -1;
2239 }
2240
2242 {
2243 if (GetAnimationPhase(animation) > 0.5)
2244 return CarDoorState.DOORS_OPEN;
2245 else
2246 return CarDoorState.DOORS_CLOSED;
2247 }
2248
2250 {
2251 return "radiator";
2252 }
2253
2255 {
2256 return 2.0;
2257 }
2258
2260 {
2261 return "refill";
2262 }
2263
2265 {
2266 return 1.5;
2267 }
2268
2270 {
2271 return "carradiator";
2272 }
2273
2275 {
2276 return 2.0;
2277 }
2278
2280 {
2281 return "carradiator";
2282 }
2283
2285 {
2286 return 2.0;
2287 }
2288
2290 {
2292 if (!m_InputActionMap)
2293 {
2296 SetActions();
2297 m_CarTypeActionsMap.Insert(this.Type(), m_InputActionMap);
2298 }
2299 }
2300
2302 {
2304 {
2305 m_ActionsInitialize = true;
2307 }
2308
2310 }
2311
2322
2323 void AddAction(typename actionName)
2324 {
2325 ActionBase action = ActionManagerBase.GetAction(actionName);
2326
2327 if (!action)
2328 {
2329 Debug.LogError("Action " + actionName + " dosn't exist!");
2330 return;
2331 }
2332
2333 typename ai = action.GetInputType();
2334 if (!ai)
2335 {
2336 m_ActionsInitialize = false;
2337 return;
2338 }
2340
2341 if (!action_array)
2342 {
2345 }
2346
2348 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString(), "n/a", "Add action");
2349 action_array.Insert(action);
2350 }
2351
2353 {
2355 ActionBase action = player.GetActionManager().GetAction(actionName);
2356 typename ai = action.GetInputType();
2358
2359 if (action_array)
2360 action_array.RemoveItem(action);
2361 }
2362
2363 override bool IsInventoryVisible()
2364 {
2365 return (GetGame().GetPlayer() && (!GetGame().GetPlayer().GetCommand_Vehicle() || GetGame().GetPlayer().GetCommand_Vehicle().GetTransport() == this));
2366 }
2367
2368 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
2369 {
2370 super.EEHealthLevelChanged(oldLevel, newLevel, zone);
2371
2373 {
2374 bool dummy;
2375 switch (zone)
2376 {
2377 case "WindowLR":
2378 case "WindowRR":
2379 if (m_Initialized)
2380 PlaySoundEx("offroad_hit_window_small_SoundSet", m_WindowSmall, dummy);
2381 break;
2382
2383 case "WindowFront":
2384 case "WindowBack":
2385 case "WindowFrontLeft":
2386 case "WindowFrontRight":
2387 if (m_Initialized)
2388 PlaySoundEx("offroad_hit_window_large_SoundSet", m_WindowLarge, dummy);
2389 break;
2390
2391 case "Engine":
2392#ifndef SERVER
2394#endif
2395 break;
2396 }
2397 }
2398 }
2399
2400 override void EEOnCECreate()
2401 {
2402
2403 float maxVolume = GetFluidCapacity(CarFluid.FUEL);
2404 float amount = Math.RandomFloat(0.0, maxVolume * 0.35);
2405
2406 Fill(CarFluid.FUEL, amount);
2407 }
2408
2410 {
2412 {
2413 m_ForceUpdateLights = true;
2414 SetSynchDirty();
2415 }
2416 }
2417
2419 {
2421 {
2422 m_ForceUpdateLights = false;
2423 SetSynchDirty();
2424 }
2425 }
2426
2427 //Get the engine start battery consumption
2429 {
2430 return m_BatteryConsume;
2431 }
2432
2437
2439 {
2440 return -m_BatteryRecharge;
2441 }
2442
2444 {
2445 if (IsVitalCarBattery())
2446 return ItemBase.Cast(FindAttachmentBySlotName("CarBattery"));
2447 else if (IsVitalTruckBattery())
2448 return ItemBase.Cast(FindAttachmentBySlotName("TruckBattery"));
2449
2450 return null;
2451 }
2452
2454 {
2456 SetSynchDirty();
2457
2458 if (GetGame().IsServer())
2460 }
2461
2462
2463 protected void GenerateCarHornAINoise(int pState)
2464 {
2465 if (pState != ECarHornState.OFF)
2466 {
2468 {
2469 float noiseMultiplier = 1.0;
2470 if (pState == ECarHornState.LONG)
2471 noiseMultiplier = 2.0;
2472
2474 }
2475 }
2476 }
2477
2479 {
2480 return vector.Zero;
2481 }
2482
2484 {
2486 SetSynchDirty();
2487 }
2488
2490 {
2492 }
2493
2495 {
2496 return GetVelocity(this).Length() * dBodyGetMass(this);
2497 }
2498
2500 {
2501 return 1.0;
2502 }
2503
2504#ifdef DEVELOPER
2505 override protected string GetDebugText()
2506 {
2507 string debug_output = super.GetDebugText();
2508 if (GetGame().IsServer())
2510 debug_output += "Entity momentum: " + GetMomentum();
2511
2512 return debug_output;
2513 }
2514#endif
2515
2516 protected void SpawnUniversalParts()
2517 {
2518 GetInventory().CreateInInventory("HeadlightH7");
2519 GetInventory().CreateInInventory("HeadlightH7");
2520 GetInventory().CreateInInventory("HeadlightH7");
2521 GetInventory().CreateInInventory("HeadlightH7");
2522
2523 if (IsVitalCarBattery())
2524 {
2525 GetInventory().CreateInInventory("CarBattery");
2526 GetInventory().CreateInInventory("CarBattery");
2527 }
2528
2529 if (IsVitalTruckBattery())
2530 {
2531 GetInventory().CreateInInventory("TruckBattery");
2532 GetInventory().CreateInInventory("TruckBattery");
2533 }
2534
2535 if (IsVitalRadiator())
2536 {
2537 GetInventory().CreateInInventory("CarRadiator");
2538 GetInventory().CreateInInventory("CarRadiator");
2539 }
2540
2541 if (IsVitalSparkPlug())
2542 {
2543 GetInventory().CreateInInventory("SparkPlug");
2544 GetInventory().CreateInInventory("SparkPlug");
2545 }
2546
2547 if (IsVitalGlowPlug())
2548 {
2549 GetInventory().CreateInInventory("GlowPlug");
2550 GetInventory().CreateInInventory("GlowPlug");
2551 }
2552 }
2553
2554 protected void SpawnAdditionalItems()
2555 {
2556 GetInventory().CreateInInventory("Wrench");
2557 GetInventory().CreateInInventory("LugWrench");
2558 GetInventory().CreateInInventory("Screwdriver");
2559 GetInventory().CreateInInventory("EpoxyPutty");
2560
2561 GetInventory().CreateInInventory("CanisterGasoline");
2562
2563 EntityAI ent;
2565 ent = GetInventory().CreateInInventory("CanisterGasoline");
2566 if (Class.CastTo(container, ent))
2567 container.SetLiquidType(LIQUID_WATER, true);
2568
2569 ent = GetInventory().CreateInInventory("Blowtorch");
2570 if (ent)
2571 ent.GetInventory().CreateInInventory("LargeGasCanister");
2572
2573 ent = GetInventory().CreateInInventory("Blowtorch");
2574 if (ent)
2575 ent.GetInventory().CreateInInventory("LargeGasCanister");
2576 }
2577
2578 protected void FillUpCarFluids()
2579 {
2580 Fill(CarFluid.FUEL, 200.0);
2581 Fill(CarFluid.COOLANT, 200.0);
2582 Fill(CarFluid.OIL, 200.0);
2583 }
2584}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition EntityAI.c:97
eBleedingSourceType GetType()
CarHornActionData ActionData ActionCarHornShort()
map< typename, ref array< ActionBase_Basic > > TInputActionMap
ref NoiseParams m_NoisePar
void AddAction(typename actionName)
void RemoveAction(typename actionName)
TInputActionMap m_InputActionMap
bool m_ActionsInitialize
class PASBroadcaster extends AdvancedCommunication IsInventoryVisible
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
void InitializeActions()
override void OnVariablesSynchronized()
int m_DamageType
override void EEItemDetached(EntityAI item, string slot_name)
override void EEItemAttached(EntityAI item, string slot_name)
CarAutomaticGearboxMode
Enumerated automatic gearbox modes. (native, do not change or extend)
Definition Car.c:65
CarSoundCtrl
Car's sound controller list. (native, do not change or extend)
Definition Car.c:4
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Definition Car.c:18
CarGearboxType
Enumerated gearbox types. (native, do not change or extend)
Definition Car.c:33
bool m_HeadlightsOn
Definition CarScript.c:234
void CreateCarDestroyedEffect()
Definition CarScript.c:630
void SetEngineStarted(bool started)
Definition CarScript.c:2231
bool m_EngineZoneReceivedHit
Definition CarScript.c:271
void OnBrakesPressed()
Definition CarScript.c:969
static const int SELECTION_ID_TAIL_LIGHT_R
Definition CarScript.c:265
ref set< int > m_DeadCrewMemberIndices
Definition CarScript.c:274
override void MarkCrewMemberUnconscious(int crewMemberIndex)
Definition CarScript.c:1397
void SpawnUniversalParts()
Definition CarScript.c:2516
string m_CarSeatShiftInSound
Definition CarScript.c:215
void ReverseLightsShineOn()
Definition CarScript.c:1883
enum CarDoorState START_NO_BATTERY
void TailLightsShineOn()
Definition CarScript.c:1927
vector m_VelocityPrevTick
Definition CarScript.c:141
enum CarDoorState START_NO_FUEL
CarDoorState TranslateAnimationPhaseToCarDoorState(string animation)
Definition CarScript.c:2241
float GetEnviroHeatComfortOverride()
DEPRECATED.
ItemBase GetBattery()
Definition CarScript.c:2443
CarDoorState
Definition CarScript.c:2
@ DOORS_CLOSED
Definition CarScript.c:5
@ DOORS_MISSING
Definition CarScript.c:3
@ DOORS_OPEN
Definition CarScript.c:4
void SpawnAdditionalItems()
Definition CarScript.c:2554
void BrakeLightsShineOff()
Definition CarScript.c:1916
override void MarkCrewMemberDead(int crewMemberIndex)
Definition CarScript.c:1406
float GetActionDistanceBrakes()
Definition CarScript.c:2284
ref EffVehicleSmoke m_coolantFx
Particles.
Definition CarScript.c:183
string m_EngineStartOK
Sounds.
Definition CarScript.c:207
void PlayCrashHeavySound()
Definition CarScript.c:2074
float m_FuelTankHealth
Definition CarScript.c:169
vector GetEnginePosWS()
Definition CarScript.c:440
static string m_RightHeadlightPoint
Definition CarScript.c:251
void DashboardShineOff()
Definition CarScript.c:1971
float m_Time
Definition CarScript.c:144
enum CarDoorState m_CarTypeActionsMap
override int Get3rdPersonCameraType()
camera type
Definition CarScript.c:2225
float GetBatteryRuntimeConsumption()
Definition CarScript.c:2433
enum CarDoorState NONE
float GetBatteryConsumption()
Definition CarScript.c:2428
void UpdateLightsServer(int newGear=-1)
Definition CarScript.c:1716
float m_BatteryHealth
Definition CarScript.c:170
void BrakeLightsShineOn()
Definition CarScript.c:1905
void CheckVitalItem(bool isVital, string itemName)
Definition CarScript.c:1991
static string m_DrownEnginePoint
Definition CarScript.c:254
void ReverseLightsShineOff()
Definition CarScript.c:1894
override bool OnBeforeEngineStart()
Definition CarScript.c:1486
bool m_EngineStartDoOnce
Definition CarScript.c:269
vector m_exhaustPtcPos
Definition CarScript.c:191
int m_CarHornState
Definition CarScript.c:243
void GenerateCarHornAINoise(int pState)
Definition CarScript.c:2463
string m_CarDoorCloseSound
Definition CarScript.c:214
void ~CarScript()
Definition CarScript.c:507
void SetEngineZoneReceivedHit(bool pState)
Definition CarScript.c:2483
int m_coolantPtcFx
Definition CarScript.c:188
vector m_enginePos
Definition CarScript.c:198
ref EffectSound m_WindowLarge
Definition CarScript.c:224
enum CarDoorState LONG
static string m_LeftHeadlightPoint
Definition CarScript.c:250
void RightFrontLightShineOn()
Definition CarScript.c:1859
vector m_backPos
Definition CarScript.c:200
void ForceUpdateLightsStart()
Definition CarScript.c:2409
void PlayCrashLightSound()
Definition CarScript.c:2055
static string m_ReverseLightPoint
Definition CarScript.c:249
int m_enginePtcFx
Definition CarScript.c:187
void DamageCrew(float dmg)
Responsible for damaging crew in a car crash.
Definition CarScript.c:1184
static const int SELECTION_ID_BRAKE_LIGHT_R
Definition CarScript.c:261
void ForceUpdateLightsEnd()
Definition CarScript.c:2418
void CleanupSound(EffectSound sound)
Definition CarScript.c:533
ref EffectSound m_WindowSmall
Definition CarScript.c:223
static const int SELECTION_ID_REVERSE_LIGHT_L
Definition CarScript.c:262
string m_EngineStartBattery
Definition CarScript.c:208
ref EffVehicleSmoke m_engineFx
Definition CarScript.c:184
float m_EngineHealth
Definition CarScript.c:167
void BrakesRearLight()
Definition CarScript.c:1829
ref set< int > m_UnconsciousCrewMemberIndices
Definition CarScript.c:273
enum CarDoorState STOP_OK
float m_BatteryEnergyStartMin
Definition CarScript.c:180
static string m_LeftHeadlightTargetPoint
Definition CarScript.c:252
float m_DrownTime
Definition CarScript.c:163
enum CarDoorState SHORT
enum CarDoorState LEFT
vector GetRefillPointPosWS()
Definition CarScript.c:450
float m_EnviroHeatComfortOverride
Definition CarScript.c:160
float m_BrakeAmmount
Definition CarScript.c:155
bool GetCrashHeavySound()
Definition CarScript.c:2060
string GetActionCompNameCoolant()
Definition CarScript.c:2249
float m_CoolantAmmount
Definition CarScript.c:153
vector m_fuelPos
Definition CarScript.c:196
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
Definition CarScript.c:1085
static float DROWN_ENGINE_DAMAGE
Definition CarScript.c:147
float m_BatteryContinuousConsume
Definition CarScript.c:176
string GetActionCompNameBrakes()
Definition CarScript.c:2279
string m_EngineStartPlug
Definition CarScript.c:209
bool m_ForceUpdateLights
Definition CarScript.c:239
bool m_EngineStarted
Definition CarScript.c:240
EntityAI m_Radiator
Definition CarScript.c:173
ref EffectSound m_PreStartSound
Definition CarScript.c:225
bool m_PlayCrashSoundLight
Definition CarScript.c:231
bool m_BrakesArePressed
Definition CarScript.c:236
ref EffectSound m_CrashSoundHeavy
Definition CarScript.c:222
float m_OilAmmount
Definition CarScript.c:154
void SetCarHornState(int pState)
Definition CarScript.c:2453
static const int SELECTION_ID_BRAKE_LIGHT_L
Definition CarScript.c:260
override void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
Definition CarScript.c:1458
override vector GetDefaultHitPosition()
Definition CarScript.c:2478
bool IsHandbrakeActive()
Definition CarScript.c:2219
int m_exhaustPtcFx
Definition CarScript.c:189
void HandleCarHornSound(ECarHornState pState)
Definition CarScript.c:1310
void UpdateLightsClient(int newGear=-1)
Definition CarScript.c:1605
float m_BatteryTimer
Definition CarScript.c:178
bool IsMoving()
Definition CarScript.c:2214
override void HandleByCrewMemberState(ECrewMemberState state)
Definition CarScript.c:1415
vector Get_1_2PointPosWS()
Definition CarScript.c:471
void NoRearLight()
Definition CarScript.c:1845
string m_EngineStartFuel
Definition CarScript.c:210
void CleanupEffects()
Definition CarScript.c:514
void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
Definition CarScript.c:2079
void LeakFluid(CarFluid fluid)
Definition CarScript.c:2004
string m_CarHornShortSoundName
Definition CarScript.c:218
NoiseSystem m_NoiseSystem
Definition CarScript.c:229
float m_MomentumPrevTick
Definition CarScript.c:140
static const int SELECTION_ID_FRONT_LIGHT_R
Definition CarScript.c:259
vector Get_2_2PointPosWS()
Definition CarScript.c:479
void BrakeAndReverseRearLight()
Definition CarScript.c:1839
void UpdateLights(int new_gear=-1)
Definition CarScript.c:1597
bool HasRadiator()
Definition CarScript.c:2204
static float DROWN_ENGINE_THRESHOLD
Definition CarScript.c:146
static const int SELECTION_ID_FRONT_LIGHT_L
Definition CarScript.c:258
float GetMomentum()
Definition CarScript.c:2494
void DashboardShineOn()
Definition CarScript.c:1963
static string m_RightHeadlightTargetPoint
Definition CarScript.c:253
vector Get_1_1PointPosWS()
Definition CarScript.c:467
const float BATTERY_UPDATE_DELAY
Definition CarScript.c:179
enum CarDoorState STARTING
void FillUpCarFluids()
Definition CarScript.c:2578
float GetActionDistanceFuel()
Definition CarScript.c:2264
vector m_coolantPtcPos
Definition CarScript.c:194
vector m_frontPos
Definition CarScript.c:199
override void OnGearChanged(int newGear, int oldGear)
Definition CarScript.c:1544
float GetActionDistanceOil()
Definition CarScript.c:2274
vector m_side_1_2Pos
Definition CarScript.c:202
string GetActionCompNameOil()
Definition CarScript.c:2269
bool HasEngineZoneReceivedHit()
Definition CarScript.c:2489
void ReverseRearLight()
Definition CarScript.c:1834
float GetActionDistanceCoolant()
Definition CarScript.c:2254
static const string MEMORY_POINT_NAME_CAR_HORN
Definition CarScript.c:149
vector GetEnginePointPosWS()
Definition CarScript.c:455
vector GetCoolantPtcPosWS()
Definition CarScript.c:445
float m_BatteryRecharge
Definition CarScript.c:177
static const int SELECTION_ID_TAIL_LIGHT_L
Definition CarScript.c:264
enum CarDoorState OFF
vector GetFrontPointPosWS()
Definition CarScript.c:459
void ToggleHeadlights()
Switches headlights on/off, including the illumination of the control panel and synchronizes this cha...
Definition CarScript.c:1591
enum CarDoorState REVERSE_ONLY
float m_BatteryConsume
Definition CarScript.c:175
float GetBatteryRechargeRate()
Definition CarScript.c:2438
float m_FuelAmmount
keeps ammount of each fluid
Definition CarScript.c:152
void LeftFrontLightShineOn()
Definition CarScript.c:1851
vector m_enginePtcPos
Definition CarScript.c:193
void HandleDoorsSound(string animSource, float phase)
Definition CarScript.c:1267
enum CarDoorState START_OK
vector m_exhaustPtcDir
Definition CarScript.c:192
bool m_EngineBeforeStart
Definition CarScript.c:268
bool m_EngineDestroyed
Definition CarScript.c:241
override bool CanReachSeatFromDoors(string pSeatSelection, vector pFromPos, float pDistance=1.0)
Definition CarScript.c:2147
void LeftFrontLightShineOff()
Definition CarScript.c:1867
string m_CarHornLongSoundName
Definition CarScript.c:219
override void OnContact(string zoneName, vector localPos, IEntity other, Contact data)
WARNING: Can be called very frequently in one frame, use with caution.
Definition CarScript.c:1058
ref EffVehicleSmoke m_exhaustFx
Definition CarScript.c:185
vector GetBackPointPosWS()
Definition CarScript.c:463
enum CarDoorState RIGHT
vector m_side_1_1Pos
Definition CarScript.c:201
CarRearLightBase m_RearLight
Definition CarScript.c:246
enum CarDoorState BRAKES_ONLY
ref EffectSound m_CrashSoundLight
Definition CarScript.c:221
string m_EngineStopFuel
Definition CarScript.c:211
bool OnBeforeSwitchLights(bool toOn)
Definition CarScript.c:1579
string GetActionCompNameFuel()
Definition CarScript.c:2259
void SynchCrashHeavySound(bool play)
Definition CarScript.c:2065
vector m_side_2_2Pos
Definition CarScript.c:204
void RightFrontLightShineOff()
Definition CarScript.c:1875
void OnBrakesReleased()
Definition CarScript.c:974
ref EffectSound m_CarHornSoundEffect
Definition CarScript.c:227
void TailLightsShineOff()
Definition CarScript.c:1952
float m_PlugHealth
Definition CarScript.c:171
EntityAI GetRadiator()
Definition CarScript.c:2209
void UpdateHeadlightState()
Definition CarScript.c:680
float m_dmgContactCoef
Definition CarScript.c:159
void CarScript()
Definition CarScript.c:282
vector m_side_2_1Pos
Definition CarScript.c:203
bool m_RearLightType
Definition CarScript.c:237
void SynchCrashLightSound(bool play)
Definition CarScript.c:2046
bool GetCrashLightSound()
Definition CarScript.c:2041
vector Get_2_1PointPosWS()
Definition CarScript.c:475
override float GetLiquidThroughputCoef()
Definition CarScript.c:484
string m_CarSeatShiftOutSound
Definition CarScript.c:216
static const int SELECTION_ID_DASHBOARD_LIGHT
Definition CarScript.c:266
void HandleSeatAdjustmentSound(string animSource, float phase)
Definition CarScript.c:1290
void HandleEngineSound(CarEngineSoundState state)
Definition CarScript.c:1326
void CarPartsHealthCheck()
Definition CarScript.c:2027
enum CarDoorState START_NO_SPARKPLUG
static const int SELECTION_ID_REVERSE_LIGHT_R
Definition CarScript.c:263
bool m_PlayCrashSoundHeavy
Definition CarScript.c:232
bool IsScriptedLightsOn()
Propper way to get if light is swiched on. Use instead of IsLightsOn().
Definition CarScript.c:1585
float m_RadiatorHealth
Definition CarScript.c:168
string m_CarDoorOpenSound
Definition CarScript.c:213
bool IsVitalFuelTank()
Definition CarScript.c:2199
static vector m_DrownEnginePos
Definition CarScript.c:164
bool m_HeadlightsState
Definition CarScript.c:235
ref CarContactCache m_ContactCache
Definition CarScript.c:142
CarLightBase m_Headlight
Definition CarScript.c:245
void Synchronize()
override void EEDelete(EntityAI parent)
DamageType
exposed from C++ (do not change)
EActions
Definition EActions.c:2
ECrewMemberState
ERPCs
Definition ERPCs.c:2
override void EEKilled(Object killer)
override void OnAttachmentRuined(EntityAI attachment)
void PlaySound()
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition ItemBase.c:6834
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition ItemBase.c:8724
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition ItemBase.c:6792
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition ItemBase.c:6535
override void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Definition ItemBase.c:8656
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition ItemBase.c:6103
string Type
PlayerBase GetPlayer()
string GetDebugText()
class NoiseSystem NoiseParams()
Definition Noise.c:15
float GetTime()
ProcessDirectDamageFlags
Definition Object.c:2
WaveKind
Definition Sound.c:2
bool m_Initialized
class JsonUndergroundAreaTriggerData GetPosition
override float OnSound(CarSoundCtrl ctrl, float oldValue)
override bool IsVitalEngineBelt()
override string GetDoorSelectionNameFromSeatPos(int posIdx)
override int GetCrewIndex(string selection)
override CarRearLightBase CreateRearLight()
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
override string GetDoorConditionPointFromSelection(string selection)
override CarLightBase CreateFrontLight()
override bool IsVitalGlowPlug()
override int GetCarDoorsState(string slotType)
override bool IsVitalTruckBattery()
override void OnAnimationPhaseStarted(string animSource, float phase)
override string GetAnimSourceFromSelection(string selection)
override void EOnPostSimulate(IEntity other, float timeSlice)
override void OnEngineStart()
override bool CanReleaseAttachment(EntityAI attachment)
override void SetActions()
override void EEInit()
override bool IsVitalRadiator()
Definition Offroad_02.c:359
override bool IsVitalCarBattery()
override bool IsVitalSparkPlug()
Definition Offroad_02.c:354
bool CanManipulateSpareWheel(string slotSelectionName)
override float GetPushForceCoefficientMultiplier()
override void OnEngineStop()
Super root of all classes in Enforce script.
Definition EnScript.c:11
static const int DAYZCAMERA_3RD_VEHICLE
generic vehicle 3rd person
Definition Debug.c:14
static void LogError(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message as error message.
Definition Debug.c:341
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition Debug.c:133
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:143
Wrapper class for managing sound through SEffectManager.
Definition EffectSound.c:5
InventoryLocation.
provides access to slot configuration
static proto bool GetSelectionForSlotId(int slot_Id, out string selection)
static bool IsActionLogEnable()
Definition Debug.c:719
Definition EnMath.c:7
proto void AddNoiseTarget(vector pos, float lifetime, NoiseParams noise_params, float external_strength_multiplier=1.0)
Will make a noise at that position which the AI will "see" for the duration of 'lifetime'.
Manager class for managing Effect (EffectParticle, EffectSound)
static EffectSound PlaySoundCachedParams(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound, using or creating cached SoundParams.
static int PlayOnObject(notnull Effect eff, Object obj, vector local_pos="0 0 0", vector local_ori="0 0 0", bool force_rotation_relative_to_world=false)
Play an Effect.
static void Stop(int effect_id)
Stops the Effect.
static EffectSound PlaySound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false)
Create and play an EffectSound.
static bool IsEffectExist(int effect_id)
Checks whether an Effect ID is registered in SEffectManager.
static EffectSound CreateSound(string sound_set, vector position, float play_fade_in=0, float stop_fade_out=0, bool loop=false, bool enviroment=false)
Create an EffectSound.
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
proto vector Normalized()
return normalized vector (keeps orginal vector untouched)
proto native float Length()
Returns length of vector (magnitude)
static float Dot(vector v1, vector v2)
Returns Dot product of vector v1 and vector v2.
Definition EnConvert.c:271
static const vector Zero
Definition EnConvert.c:110
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Definition EnConvert.c:220
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
proto native CGame GetGame()
const float CARS_CONTACT_DMG_THRESHOLD
Definition constants.c:747
const float CARS_CONTACT_DMG_MIN
Definition constants.c:748
const float CARS_CONTACT_DMG_KILLCREW
Definition constants.c:749
const int CARS_FLUIDS_TICK
Definition constants.c:736
proto void Print(void var)
Prints content of variable to console/log.
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition EnEntity.c:44
@ CONTACT
Definition EnEntity.c:96
const float DAMAGE_RUINED_VALUE
Definition constants.c:773
const float DAMAGE_DAMAGED_VALUE
Definition constants.c:771
const int STATE_RUINED
Definition constants.c:757
const float LIQUID_THROUGHPUT_CAR_DEFAULT
Definition constants.c:526
const int LIQUID_WATER
Definition constants.c:504
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
static proto float Lerp(float a, float b, float time)
Linearly interpolates between 'a' and 'b' given 'time'.
static proto int AbsInt(int i)
Returns absolute value.
static proto float RandomFloat(float min, float max)
Returns a random float number between and min[inclusive] and max[exclusive].
static proto float Clamp(float value, float min, float max)
Clamps 'value' to 'min' if it is lower than 'min', or to 'max' if it is higher than 'max'.
static proto float InverseLerp(float a, float b, float value)
Calculates the linear value that produces the interpolant value within the range [a,...
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native float dBodyGetMass(notnull IEntity ent)
const int SAT_DEBUG_ACTION
Definition constants.c:424
const int CALL_CATEGORY_GAMEPLAY
Definition tools.c:10
proto native void OnUpdate()
Definition tools.c:333
proto native HumanCommandVehicle GetCommand_Vehicle()