Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
carscript.c
Go to the documentation of this file.
2 {
6 }
7 
8 enum CarHeadlightBulbsState
9 {
10  NONE,
11  LEFT,
12  RIGHT,
13  BOTH
14 }
15 
16 enum CarRearLightType
17 {
18  NONE,
21  BRAKES_AND_REVERSE
22 }
23 
24 enum CarEngineSoundState
25 {
26  NONE,
27  STARTING,
28  START_OK,
32  STOP_OK,
33  STOP_NO_FUEL
34 }
35 
36 enum ECarHornState
37 {
38  OFF = 0,
39  SHORT = 1,
40  LONG = 2
41 }
42 
43 #ifdef DIAG_DEVELOPER
44 enum EVehicleDebugOutputType
45 {
46  NONE,
47  DAMAGE_APPLIED = 1,
48  DAMAGE_CONSIDERED = 2,
49  CONTACT = 4
50  //OTHER = 8
51  //OTHER = 16
52 }
53 
54 class CrashDebugData
55 {
56  static ref array<ref CrashDebugData> m_CrashData = new array<ref CrashDebugData>;
57  static ref CrashDebugData m_CrashDataPoint;
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
71  static void DumpDataArray(array<ref CrashDebugData> dataArray)
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");
74  foreach (CrashDebugData data:dataArray)
75  {
76  DumpData(data);
77  }
78  }
79 
80  static void DumpData(CrashDebugData data)
81  {
82  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;
83  output += ";"+data.m_SpeedWorld+";"+data.m_SpeedWorldPrev+";"+data.m_SpeedWorldDelta+";"+data.m_VelocityCur;
84  output += ";"+data.m_VelocityPrev+";"+data.m_VelocityDot+";"+data.m_Time+";"+data.m_CrewDamageBase+";"+data.m_ShockTemp+";"+data.m_DMGHealth+";"+data.m_DMGShock;
85  Print(output);
86  }
87 
88  string m_VehicleType;
89  string m_DamageType;
90  float m_Damage;
91  string m_Zone;
92  float m_MomentumCurr;
93  float m_MomentumPrev;
94  float m_MomentumDelta;
95  float m_Speedometer;
96  float m_SpeedWorld;
97  float m_SpeedWorldPrev;
98  float m_SpeedWorldDelta;
99  vector m_VelocityCur;
100  vector m_VelocityPrev;
101  float m_VelocityDot;
102  float m_Time;
103  float m_CrewDamageBase;
104  float m_ShockTemp;
105  float m_DMGHealth;
106  float m_DMGShock;
107 }
108 
109 #endif
110 class CarContactData
111 {
112  vector localPos;
113  IEntity other;
114  float impulse;
115 
116  void CarContactData(vector _localPos, IEntity _other, float _impulse)
117  {
118  localPos = _localPos;
119  other = _other;
120  impulse = _impulse;
121  }
122 }
123 
124 typedef map<string, ref array<ref CarContactData>> CarContactCache
125 
126 #ifdef DEVELOPER
127 CarScript _car;
128 #endif
129 
133 class CarScript extends Car
134 {
135  #ifdef DIAG_DEVELOPER
136  static EVehicleDebugOutputType DEBUG_OUTPUT_TYPE;
137  bool m_ContactCalled;
138  #endif
142  protected float m_MomentumPrevTick;
144  ref CarContactCache m_ContactCache;
145 
146  protected float m_Time;
147 
148  static float DROWN_ENGINE_THRESHOLD = 0.5;
149  static float DROWN_ENGINE_DAMAGE = 350.0;
150 
151  static const string MEMORY_POINT_NAME_CAR_HORN = "pos_carHorn";
152 
154  protected float m_FuelAmmount;
155  protected float m_CoolantAmmount;
156  protected float m_OilAmmount;
157  protected float m_BrakeAmmount;
158 
160  //protected float m_dmgContactCoef = 0.023;
161  protected float m_dmgContactCoef = 0.058;
163 
165  protected float m_DrownTime;
166  static vector m_DrownEnginePos;
167 
169  protected float m_EngineHealth;
170  protected float m_RadiatorHealth;
171  protected float m_FuelTankHealth;
172  protected float m_BatteryHealth;
173  protected float m_PlugHealth;
174 
175  protected EntityAI m_Radiator;
176 
177  protected float m_BatteryConsume = 15; //Battery energy consumption upon engine start
178  protected float m_BatteryContinuousConsume = 0.25; //Battery consumption with lights on and engine is off
179  protected float m_BatteryRecharge = 0.15; //Battery recharge rate when engine is on
180  private float m_BatteryTimer = 0; //Used to factor energy consumption / recharging
181  private const float BATTERY_UPDATE_DELAY = 100;
182  protected float m_BatteryEnergyStartMin = 5.0; // Minimal energy level of battery required for start
183 
188 
189  protected int m_enginePtcFx;
190  protected int m_coolantPtcFx;
191  protected int m_exhaustPtcFx;
192 
197 
198  protected vector m_fuelPos;
199 
200  protected vector m_enginePos;
201  protected vector m_frontPos;
202  protected vector m_backPos;
206  protected vector m_side_2_2Pos;
207 
209  string m_EngineStartOK = "";
210  string m_EngineStartBattery = "";
211  string m_EngineStartPlug = "";
212  string m_EngineStartFuel = "";
213  string m_EngineStopFuel = "";
214 
215  string m_CarDoorOpenSound = "";
216  string m_CarDoorCloseSound = "";
219 
222 
228 
230  protected ref NoiseParams m_NoisePar;
232 
233  protected bool m_PlayCrashSoundLight;
234  protected bool m_PlayCrashSoundHeavy;
235 
236  protected bool m_HeadlightsOn;
237  protected bool m_HeadlightsState;
238  protected bool m_BrakesArePressed;
239  protected bool m_RearLightType;
240 
241  protected bool m_ForceUpdateLights;
242  protected bool m_EngineStarted;
243  protected bool m_EngineDestroyed;
244 
245  protected int m_CarHornState;
246 
249 
250  // Memory points
251  static string m_ReverseLightPoint = "light_reverse";
252  static string m_LeftHeadlightPoint = "light_left";
253  static string m_RightHeadlightPoint = "light_right";
254  static string m_LeftHeadlightTargetPoint = "light_left_dir";
255  static string m_RightHeadlightTargetPoint = "light_right_dir";
256  static string m_DrownEnginePoint = "drown_engine";
257 
258  // Model selection IDs for texture/material changes
259  // If each car needs different IDs, then feel free to remove the 'static' flag and overwrite these numbers down the hierarchy
260  static const int SELECTION_ID_FRONT_LIGHT_L = 0;
261  static const int SELECTION_ID_FRONT_LIGHT_R = 1;
262  static const int SELECTION_ID_BRAKE_LIGHT_L = 2;
263  static const int SELECTION_ID_BRAKE_LIGHT_R = 3;
264  static const int SELECTION_ID_REVERSE_LIGHT_L = 4;
265  static const int SELECTION_ID_REVERSE_LIGHT_R = 5;
266  static const int SELECTION_ID_TAIL_LIGHT_L = 6;
267  static const int SELECTION_ID_TAIL_LIGHT_R = 7;
268  static const int SELECTION_ID_DASHBOARD_LIGHT = 8;
269 
270  protected bool m_EngineBeforeStart;
271  protected bool m_EngineStartDoOnce;
272 
273  protected bool m_EngineZoneReceivedHit;
274 
275  protected ref set<int> m_UnconsciousCrewMemberIndices;
276  protected ref set<int> m_DeadCrewMemberIndices;
277 
278  #ifdef DEVELOPER
279  private const int DEBUG_MESSAGE_CLEAN_TIME_SECONDS = 10;
280  private float m_DebugMessageCleanTime;
281  private string m_DebugContactDamageMessage;
282  #endif
283 
284  void CarScript()
285  {
286 #ifdef DEVELOPER
287  _car = this;
288 #endif
289 
290  SetEventMask(EntityEvent.POSTSIMULATE);
291 
292  m_ContactCache = new CarContactCache;
293 
294  m_Time = 0;
295  // sets max health for all components at init
296  m_EngineHealth = 1;
297  m_FuelTankHealth = 1;
298  m_RadiatorHealth = -1;
299  m_BatteryHealth = -1;
300  m_PlugHealth = -1;
301 
302  m_enginePtcFx = -1;
303  m_coolantPtcFx = -1;
304  m_exhaustPtcFx = -1;
305 
307 
308  m_PlayCrashSoundLight = false;
309  m_PlayCrashSoundHeavy = false;
310 
311  m_CarHornState = ECarHornState.OFF;
312 
313  m_UnconsciousCrewMemberIndices = new set<int>();
314  m_DeadCrewMemberIndices = new set<int>();
315 
316  RegisterNetSyncVariableBool("m_HeadlightsOn");
317  RegisterNetSyncVariableBool("m_BrakesArePressed");
318  RegisterNetSyncVariableBool("m_ForceUpdateLights");
319  RegisterNetSyncVariableBool("m_EngineZoneReceivedHit");
320  RegisterNetSyncVariableBoolSignal("m_PlayCrashSoundLight");
321  RegisterNetSyncVariableBoolSignal("m_PlayCrashSoundHeavy");
322  RegisterNetSyncVariableInt("m_CarHornState", ECarHornState.OFF, ECarHornState.LONG);
323 
324  if ( MemoryPointExists("ptcExhaust_end") )
325  {
326  m_exhaustPtcPos = GetMemoryPointPos("ptcExhaust_end");
327  if ( MemoryPointExists("ptcExhaust_start") )
328  {
329  vector exhaustStart = GetMemoryPointPos("ptcExhaust_start");
330  vector tempOri = vector.Direction( exhaustStart, m_exhaustPtcPos);
331 
332  m_exhaustPtcDir[0] = -tempOri[2];
333  m_exhaustPtcDir[1] = tempOri[1];
334  m_exhaustPtcDir[2] = tempOri[0];
335 
336  m_exhaustPtcDir = m_exhaustPtcDir.Normalized().VectorToAngles();
337  }
338  }
339  else
340  {
341  m_exhaustPtcPos = "0 0 0";
342  m_exhaustPtcDir = "1 1 1";
343  }
344 
345  if ( MemoryPointExists("ptcEnginePos") )
346  m_enginePtcPos = GetMemoryPointPos("ptcEnginePos");
347  else
348  m_enginePtcPos = "0 0 0";
349 
350  if ( MemoryPointExists("ptcCoolantPos") )
351  m_coolantPtcPos = GetMemoryPointPos("ptcCoolantPos");
352  else
353  m_coolantPtcPos = "0 0 0";
354 
355  if ( MemoryPointExists("refill") )
356  m_fuelPos = GetMemoryPointPos("refill");
357  else
358  m_fuelPos = "0 0 0";
359 
360  if ( MemoryPointExists("drown_engine") )
361  m_DrownEnginePos = GetMemoryPointPos("drown_engine");
362  else
363  m_DrownEnginePos = "0 0 0";
364 
365  if ( MemoryPointExists("dmgZone_engine") )
366  m_enginePos = GetMemoryPointPos("dmgZone_engine");
367  else
368  m_enginePos = "0 0 0";
369 
370  if ( MemoryPointExists("dmgZone_front") )
371  m_frontPos = GetMemoryPointPos("dmgZone_front");
372  else
373  m_frontPos = "0 0 0";
374 
375  if ( MemoryPointExists("dmgZone_back") )
376  m_backPos = GetMemoryPointPos("dmgZone_back");
377  else
378  m_backPos = "0 0 0";
379 
380  if ( MemoryPointExists("dmgZone_fender_1_1") )
381  m_side_1_1Pos = GetMemoryPointPos("dmgZone_fender_1_1");
382  else
383  m_side_1_1Pos = "0 0 0";
384 
385  if ( MemoryPointExists("dmgZone_fender_1_2") )
386  m_side_1_2Pos = GetMemoryPointPos("dmgZone_fender_1_2");
387  else
388  m_side_1_2Pos = "0 0 0";
389 
390  if ( MemoryPointExists("dmgZone_fender_2_1") )
391  m_side_2_1Pos = GetMemoryPointPos("dmgZone_fender_2_1");
392  else
393  m_side_2_1Pos = "0 0 0";
394 
395  if ( MemoryPointExists("dmgZone_fender_2_2") )
396  m_side_2_2Pos = GetMemoryPointPos("dmgZone_fender_2_2");
397  else
398  m_side_2_2Pos = "0 0 0";
399  }
400 
401  override void EEInit()
402  {
403  super.EEInit();
404 
405  if (GetGame().IsServer())
406  {
407  m_NoiseSystem = GetGame().GetNoiseSystem();
408  if (m_NoiseSystem && !m_NoisePar)
409  {
410  m_NoisePar = new NoiseParams();
411  m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseCarHorn");
412  }
413  }
414  }
415 
416  #ifdef DIAG_DEVELOPER
417 
418  override void FixEntity()
419  {
420  if (GetGame().IsServer())
421  {
422  FillUpCarFluids();
423  //server and single
424 
425  for (int i = 5; i > 0; i--)//there is a problem with wheels when performed only once, this solves it
426  super.FixEntity();
427  if (!GetGame().IsMultiplayer())
428  {
429  //single
430  SEffectManager.DestroyEffect(m_engineFx);
431  }
432  }
433  else
434  {
435  //MP client
436  SEffectManager.DestroyEffect(m_engineFx);
437  }
438  }
439  #endif
440 
441 
443  {
444  return ModelToWorld( m_DrownEnginePos );
445  }
446 
448  {
449  return ModelToWorld( m_coolantPtcPos );
450  }
451 
453  {
454  return ModelToWorld( m_fuelPos );
455  }
456 
458  {
459  return ModelToWorld( m_enginePos );
460  }
462  {
463  return ModelToWorld( m_frontPos );
464  }
466  {
467  return ModelToWorld( m_backPos );
468  }
470  {
471  return ModelToWorld( m_side_1_1Pos );
472  }
474  {
475  return ModelToWorld( m_side_1_2Pos );
476  }
478  {
479  return ModelToWorld( m_side_2_1Pos );
480  }
482  {
483  return ModelToWorld( m_side_2_2Pos );
484  }
485 
486  override float GetLiquidThroughputCoef()
487  {
489  }
490 
491  //here we should handle the damage dealt in OnContact event, but maybe we will react even in that event
492  override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
493  {
494  super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
495 
497  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(ForceUpdateLightsEnd, 100, false);
498 
499  SetEngineZoneReceivedHit(dmgZone == "Engine");
500  }
501 
502  override void EEDelete(EntityAI parent)
503  {
504  #ifndef SERVER
505  CleanupEffects();
506  #endif
507  }
508 
509  void ~CarScript()
510  {
511  #ifndef SERVER
512  CleanupEffects();
513  #endif
514  }
515 
517  {
518  SEffectManager.DestroyEffect(m_coolantFx);
519  SEffectManager.DestroyEffect(m_exhaustFx);
520  SEffectManager.DestroyEffect(m_engineFx);
521 
522  if (m_Headlight)
523  m_Headlight.Destroy();
524 
525  if (m_RearLight)
526  m_RearLight.Destroy();
527 
528  SEffectManager.DestroyEffect(m_CrashSoundLight);
529  SEffectManager.DestroyEffect(m_CrashSoundHeavy);
530  SEffectManager.DestroyEffect(m_WindowSmall);
531  SEffectManager.DestroyEffect(m_WindowLarge);
533  }
534 
536  {
537  SEffectManager.DestroyEffect(sound);
538  }
539 
540  override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
541  {
542  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_START_SHORT, "Car Horn Start Short", FadeColors.LIGHT_GREY));
543  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_START_LONG, "Car Horn Start Long", FadeColors.LIGHT_GREY));
544  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_STOP, "Car Horn Stop", FadeColors.LIGHT_GREY));
545 
546  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "Car Fuel", FadeColors.RED));
547  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_FULL, "Full", FadeColors.LIGHT_GREY));
548  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_EMPTY, "Empty", FadeColors.LIGHT_GREY));
549  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_INCREASE, "10% increase", FadeColors.LIGHT_GREY));
550  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_DECREASE, "10% decrease", FadeColors.LIGHT_GREY));
551  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
552  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "Car Cooler", FadeColors.RED));
553  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_FULL, "Full", FadeColors.LIGHT_GREY));
554  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_EMPTY, "Empty", FadeColors.LIGHT_GREY));
555  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_INCREASE, "10% increase", FadeColors.LIGHT_GREY));
556  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_DECREASE, "10% decrease", FadeColors.LIGHT_GREY));
557  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
558 
559  super.GetDebugActions(outputList);
560 
561  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
562  outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
563  }
564 
565  override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
566  {
567  if (super.OnAction(action_id, player, ctx))
568  return true;
569 
570  if (!GetGame().IsServer())
571  {
572  return false;
573  }
574 
575  switch (action_id)
576  {
577  case EActions.CAR_HORN_START_SHORT:
578  SetCarHornState(ECarHornState.SHORT);
579  return true;
580  case EActions.CAR_HORN_START_LONG:
581  SetCarHornState(ECarHornState.LONG);
582  return true;
583  case EActions.CAR_HORN_STOP:
584  SetCarHornState(ECarHornState.OFF);
585  return true;
586 
587  case EActions.CAR_FUEL_FULL:
588  Fill(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL));
589  return true;
590  case EActions.CAR_FUEL_EMPTY:
591  LeakAll(CarFluid.FUEL);
592  return true;
593  case EActions.CAR_FUEL_INCREASE:
594  Fill(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL) * 0.1);
595  return true;
596  case EActions.CAR_FUEL_DECREASE:
597  Leak(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL) * 0.1);
598  return true;
599 
600  case EActions.CAR_COOLANT_FULL:
601  Fill(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT));
602  return true;
603  case EActions.CAR_COOLANT_EMPTY:
604  LeakAll(CarFluid.COOLANT);
605  return true;
606  case EActions.CAR_COOLANT_INCREASE:
607  Fill(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT) * 0.1);
608  return true;
609  case EActions.CAR_COOLANT_DECREASE:
610  Leak(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT) * 0.1);
611  return true;
612  case EActions.DELETE:
613  Delete();
614  return true;
615  }
616 
617  return false;
618  }
619 
620  override void OnVariablesSynchronized()
621  {
622  super.OnVariablesSynchronized();
623 
624  if (GetCrashHeavySound())
625  {
627  }
628  else if (GetCrashLightSound())
629  {
631  }
632 
634 
635  UpdateLights();
636  }
637 
639  {
640  if ( !SEffectManager.IsEffectExist( m_enginePtcFx ) && GetGame().GetWaterDepth( GetEnginePosWS() ) <= 0 )
641  {
642  m_engineFx = new EffEngineSmoke();
643  m_engineFx.SetParticleStateHeavy();
644  m_enginePtcFx = SEffectManager.PlayOnObject( m_engineFx, this, m_enginePtcPos, Vector(0,0,0));
645  }
646  }
647 
648  override void EEItemAttached(EntityAI item, string slot_name)
649  {
650  super.EEItemAttached(item, slot_name);
651 
652  switch (slot_name)
653  {
654  case "Reflector_1_1":
655  if (GetGame().IsServer())
656  {
657  SetHealth("Reflector_1_1", "Health", item.GetHealth());
658  }
659  break;
660  case "Reflector_2_1":
661  if (GetGame().IsServer())
662  {
663  SetHealth("Reflector_2_1", "Health", item.GetHealth());
664  }
665  break;
666  case "CarBattery":
667  case "TruckBattery":
668  if (GetGame().IsServer())
669  {
670  m_BatteryHealth = item.GetHealth01();
671  }
672  break;
673  case "SparkPlug":
674  case "GlowPlug":
675  if (GetGame().IsServer())
676  {
677  m_PlugHealth = item.GetHealth01();
678  }
679  break;
680  case "CarRadiator":
681  if (GetGame().IsServer())
682  {
683  m_RadiatorHealth = item.GetHealth01();
684  }
685 
686  m_Radiator = item;
687  break;
688  }
689 
690  if (GetGame().IsServer())
691  {
692  Synchronize();
693  }
694 
696  UpdateLights();
697  }
698 
699  // Updates state of attached headlight bulbs for faster access
701  {
702  EntityAI bulb_L = FindAttachmentBySlotName("Reflector_1_1");
703  EntityAI bulb_R = FindAttachmentBySlotName("Reflector_2_1");
704 
705  if (bulb_L && !bulb_L.IsRuined() && bulb_R && !bulb_R.IsRuined())
706  {
707  m_HeadlightsState = CarHeadlightBulbsState.BOTH;
708  }
709  else if (bulb_L && !bulb_L.IsRuined())
710  {
711  m_HeadlightsState = CarHeadlightBulbsState.LEFT;
712  }
713  else if (bulb_R && !bulb_R.IsRuined())
714  {
715  m_HeadlightsState = CarHeadlightBulbsState.RIGHT;
716  }
717  else if ((!bulb_L || bulb_L.IsRuined()) && (!bulb_R || bulb_R.IsRuined()))
718  {
719  m_HeadlightsState = CarHeadlightBulbsState.NONE;
720  }
721  }
722 
723  override void EEItemDetached(EntityAI item, string slot_name)
724  {
725  switch (slot_name)
726  {
727  case "CarBattery":
728  case "TruckBattery":
729  m_BatteryHealth = -1;
730  if (GetGame().IsServer())
731  {
732  if (EngineIsOn())
733  {
734  EngineStop();
735  }
736 
737  if (IsScriptedLightsOn())
738  {
740  }
741  }
742  break;
743  case "SparkPlug":
744  case "GlowPlug":
745  m_PlugHealth = -1;
746  if (GetGame().IsServer() && EngineIsOn())
747  {
748  EngineStop();
749  }
750  break;
751  case "CarRadiator":
752  m_Radiator = null;
753  if (GetGame().IsServer())
754  {
755  LeakAll(CarFluid.COOLANT);
756 
757  if (m_DamageZoneMap.Contains("Radiator"))
758  {
759  SetHealth("Radiator", "Health", 0);
760  }
761  }
762  break;
763  }
764 
765  if (GetGame().IsServer())
766  {
767  Synchronize();
768  }
769 
771  UpdateLights();
772  }
773 
774  override void OnAttachmentRuined(EntityAI attachment)
775  {
776  super.OnAttachmentRuined(attachment);
777 
779  UpdateLights();
780  }
781 
782  override bool CanReceiveAttachment(EntityAI attachment, int slotId)
783  {
784  if (!super.CanReceiveAttachment(attachment, slotId))
785  return false;
786 
787  InventoryLocation attachmentInventoryLocation = new InventoryLocation();
788  attachment.GetInventory().GetCurrentInventoryLocation(attachmentInventoryLocation);
789  if (attachmentInventoryLocation.GetParent() == null)
790  {
791  return true;
792  }
793 
794  if (attachment && attachment.Type().IsInherited(CarWheel))
795  {
796  string slotSelectionName;
797  InventorySlots.GetSelectionForSlotId(slotId, slotSelectionName);
798 
799  switch (slotSelectionName)
800  {
801  case "wheel_spare_1":
802  case "wheel_spare_2":
803  return CanManipulateSpareWheel(slotSelectionName);
804  break;
805  }
806  }
807 
808  return true;
809  }
810 
811  override bool CanReleaseAttachment(EntityAI attachment)
812  {
813  if (!super.CanReleaseAttachment(attachment))
814  {
815  return false;
816  }
817 
818  if (EngineIsOn() && IsMoving())
819  {
820  return false;
821  }
822 
823  if (attachment && attachment.Type().IsInherited(CarWheel))
824  {
825  InventoryLocation attachmentInventoryLocation = new InventoryLocation();
826  attachment.GetInventory().GetCurrentInventoryLocation(attachmentInventoryLocation);
827 
828  string slotSelectionName;
829  InventorySlots.GetSelectionForSlotId(attachmentInventoryLocation.GetSlot(), slotSelectionName);
830 
831  switch (slotSelectionName)
832  {
833  case "wheel_spare_1":
834  case "wheel_spare_2":
835  return CanManipulateSpareWheel(slotSelectionName);
836  break;
837  }
838  }
839 
840  return true;
841  }
842 
843  protected bool CanManipulateSpareWheel(string slotSelectionName)
844  {
845  return false;
846  }
847 
848  override void EOnPostSimulate(IEntity other, float timeSlice)
849  {
850  m_Time += timeSlice;
851 
852  if (GetGame().IsServer())
853  {
856 
857  #ifdef DIAG_DEVELOPER
858  if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
859  {
860  if (m_ContactCalled)
861  {
862  Debug.Log("Momentum delta: " + (GetMomentum() - m_MomentumPrevTick));
863  Debug.Log("--------------------------------------------------------------------");
864  m_ContactCalled = false;
865  }
866  }
867  #endif
868 
869 
873  #ifdef DEVELOPER
874  m_DebugMessageCleanTime += timeSlice;
875  if (m_DebugMessageCleanTime >= DEBUG_MESSAGE_CLEAN_TIME_SECONDS)
876  {
877  m_DebugMessageCleanTime = 0;
878  m_DebugContactDamageMessage = "";
879  }
880  #endif
881  }
882 
883  if ( m_Time >= GameConstants.CARS_FLUIDS_TICK )
884  {
885  m_Time = 0;
886 
888 
889  //First of all check if the car should stop the engine
890  if (GetGame().IsServer() && EngineIsOn())
891  {
892  if ( GetFluidFraction(CarFluid.FUEL) <= 0 || m_EngineHealth <= 0 )
893  EngineStop();
894 
895  CheckVitalItem(IsVitalCarBattery(), "CarBattery");
896  CheckVitalItem(IsVitalTruckBattery(), "TruckBattery");
897  CheckVitalItem(IsVitalSparkPlug(), "SparkPlug");
898  CheckVitalItem(IsVitalGlowPlug(), "GlowPlug");
899  }
900 
901  if (GetGame().IsServer())
902  {
903  if (IsVitalFuelTank())
904  {
905  if (m_FuelTankHealth == GameConstants.DAMAGE_RUINED_VALUE && m_EngineHealth > GameConstants.DAMAGE_RUINED_VALUE)
906  {
907  SetHealth("Engine", "Health", GameConstants.DAMAGE_RUINED_VALUE);
908  }
909  }
910  }
911 
913  if ( EngineIsOn() )
914  {
915  if ( GetGame().IsServer() )
916  {
917  float dmg;
918 
919  if ( EngineGetRPM() >= EngineGetRPMRedline() )
920  {
921  if (EngineGetRPM() > EngineGetRPMMax())
922  AddHealth( "Engine", "Health", -GetMaxHealth("Engine", "") * 0.05 ); //CAR_RPM_DMG
923 
924  dmg = EngineGetRPM() * 0.001 * Math.RandomFloat( 0.02, 1.0 ); //CARS_TICK_DMG_MIN; //CARS_TICK_DMG_MAX
925  ProcessDirectDamage(DamageType.CUSTOM, null, "Engine", "EnviroDmg", vector.Zero, dmg);
927  }
928  else
929  {
931  }
932 
934  if ( IsVitalRadiator() )
935  {
936  if ( GetFluidFraction(CarFluid.COOLANT) > 0 && m_RadiatorHealth < 0.5 ) //CARS_LEAK_THRESHOLD
937  LeakFluid( CarFluid.COOLANT );
938  }
939 
940  if ( GetFluidFraction(CarFluid.FUEL) > 0 && m_FuelTankHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
941  LeakFluid( CarFluid.FUEL );
942 
943  if ( GetFluidFraction(CarFluid.BRAKE) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
944  LeakFluid( CarFluid.BRAKE );
945 
946  if ( GetFluidFraction(CarFluid.OIL) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
947  LeakFluid( CarFluid.OIL );
948 
949  if ( m_EngineHealth < 0.25 )
950  LeakFluid( CarFluid.OIL );
951 
952  if ( IsVitalRadiator() )
953  {
954  if ( GetFluidFraction( CarFluid.COOLANT ) < 0.5 && GetFluidFraction( CarFluid.COOLANT ) >= 0 )
955  {
956  dmg = ( 1 - GetFluidFraction(CarFluid.COOLANT) ) * Math.RandomFloat( 0.02, 10.00 ); //CARS_DMG_TICK_MIN_COOLANT; //CARS_DMG_TICK_MAX_COOLANT
957  AddHealth( "Engine", "Health", -dmg );
959  }
960  }
961  }
962 
963  //FX only on Client and in Single
964  if (!GetGame().IsDedicatedServer())
965  {
966  if (!SEffectManager.IsEffectExist(m_exhaustPtcFx))
967  {
970  m_exhaustFx.SetParticleStateLight();
971  }
972 
973  if (IsVitalRadiator() && GetFluidFraction(CarFluid.COOLANT) < 0.5)
974  {
975  if (!SEffectManager.IsEffectExist(m_coolantPtcFx))
976  {
978  m_coolantPtcFx = SEffectManager.PlayOnObject(m_coolantFx, this, m_coolantPtcPos, vector.Zero);
979  }
980 
981  if (m_coolantFx)
982  {
983  if (GetFluidFraction(CarFluid.COOLANT) > 0)
984  m_coolantFx.SetParticleStateLight();
985  else
986  m_coolantFx.SetParticleStateHeavy();
987  }
988  }
989  else
990  {
991  if (SEffectManager.IsEffectExist(m_coolantPtcFx))
993  }
994  }
995  }
996  else
997  {
998  //FX only on Client and in Single
999  if ( !GetGame().IsDedicatedServer() )
1000  {
1001  if (SEffectManager.IsEffectExist(m_exhaustPtcFx))
1002  {
1004  m_exhaustPtcFx = -1;
1005  }
1006 
1007  if (SEffectManager.IsEffectExist(m_coolantPtcFx))
1008  {
1010  m_coolantPtcFx = -1;
1011  }
1012  }
1013  }
1014  }
1015  }
1016 
1018  {
1019  UpdateLights();
1020  }
1021 
1023  {
1024  UpdateLights();
1025  }
1026 
1027  override void OnUpdate( float dt )
1028  {
1029  if ( GetGame().IsServer() )
1030  {
1031  ItemBase battery = GetBattery();
1032  if ( battery )
1033  {
1034  if ( EngineIsOn() )
1035  {
1036  m_BatteryTimer += dt;
1038  {
1039  battery.GetCompEM().ConsumeEnergy(GetBatteryRechargeRate() * m_BatteryTimer);
1040  m_BatteryTimer = 0;
1041  }
1042  }
1043  else if ( !EngineIsOn() && IsScriptedLightsOn() )
1044  {
1045  m_BatteryTimer += dt;
1047  {
1048  battery.GetCompEM().ConsumeEnergy(GetBatteryRuntimeConsumption() * m_BatteryTimer);
1049  m_BatteryTimer = 0;
1050 
1051  if ( battery.GetCompEM().GetEnergy() <= 0 )
1052  {
1053  ToggleHeadlights();
1054  }
1055  }
1056  }
1057  }
1058 
1059  if ( GetGame().GetWaterDepth( GetEnginePosWS() ) > 0 )
1060  {
1061  m_DrownTime += dt;
1062  if ( m_DrownTime > DROWN_ENGINE_THRESHOLD )
1063  {
1064  // *dt to get damage per second
1065  AddHealth( "Engine", "Health", -DROWN_ENGINE_DAMAGE * dt);
1067  }
1068  }
1069  else
1070  {
1071  m_DrownTime = 0;
1072  }
1073  }
1074 
1075  // For visualisation of brake lights for all players
1076  float brake_coef = GetBrake();
1077  if ( brake_coef > 0 )
1078  {
1079  if ( !m_BrakesArePressed )
1080  {
1081  m_BrakesArePressed = true;
1082  SetSynchDirty();
1083  OnBrakesPressed();
1084  }
1085  }
1086  else
1087  {
1088  if ( m_BrakesArePressed )
1089  {
1090  m_BrakesArePressed = false;
1091  SetSynchDirty();
1092  OnBrakesReleased();
1093  }
1094  }
1095 
1096  if ( (!GetGame().IsDedicatedServer()) && m_ForceUpdateLights )
1097  {
1098  UpdateLights();
1099  m_ForceUpdateLights = false;
1100  }
1101  }
1102 
1103  override void EEKilled(Object killer)
1104  {
1105  super.EEKilled(killer);
1106  m_EngineDestroyed = true;
1107  }
1108 
1110  override void OnContact( string zoneName, vector localPos, IEntity other, Contact data )
1111  {
1112  if (GetGame().IsServer())
1113  {
1114  #ifdef DIAG_DEVELOPER
1115  m_ContactCalled = true;
1116  if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
1117  {
1118  string output = "Zone: " + zoneName + " | Impulse:" + data.Impulse;
1119  Debug.Log(output);
1120  }
1121  #endif
1122  if (m_ContactCache.Count() == 0)
1123  {
1125  m_ContactCache.Insert(zoneName, ccd);
1126  float momentumDelta = GetMomentum() - m_MomentumPrevTick;
1127  float dot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1128  if (dot < 0)
1129  {
1130  momentumDelta = m_MomentumPrevTick;
1131  }
1132 
1133  ccd.Insert(new CarContactData(localPos, other, momentumDelta));
1134  }
1135  }
1136  }
1137 
1140  {
1141 
1142  int contactZonesCount = m_ContactCache.Count();
1143 
1144  if (contactZonesCount == 0)
1145  return;
1146 
1147 
1148  for (int i = 0; i < contactZonesCount; ++i)
1149  {
1150  string zoneName = m_ContactCache.GetKey(i);
1151  array<ref CarContactData> data = m_ContactCache[zoneName];
1152 
1153  float dmg = Math.AbsInt(data[0].impulse * m_dmgContactCoef);
1154  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
1155 
1156  #ifdef DIAG_DEVELOPER
1157  CrashDebugData.m_CrashDataPoint = new CrashDebugData();
1158  CrashDebugData.m_CrashDataPoint.m_VehicleType = GetDisplayName();
1159  CrashDebugData.m_CrashDataPoint.m_Damage = dmg;
1160  CrashDebugData.m_CrashDataPoint.m_Zone = zoneName;
1161  CrashDebugData.m_CrashDataPoint.m_MomentumCurr = GetMomentum();
1162  CrashDebugData.m_CrashDataPoint.m_MomentumPrev = m_MomentumPrevTick;
1163  CrashDebugData.m_CrashDataPoint.m_MomentumDelta = data[0].impulse;
1164  CrashDebugData.m_CrashDataPoint.m_SpeedWorld = GetVelocity(this).Length() * 3.6;
1165  CrashDebugData.m_CrashDataPoint.m_SpeedWorldPrev = m_VelocityPrevTick.Length() * 3.6;
1166  CrashDebugData.m_CrashDataPoint.m_SpeedWorldDelta = (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6;
1167  CrashDebugData.m_CrashDataPoint.m_VelocityCur = GetVelocity(this);
1168  CrashDebugData.m_CrashDataPoint.m_VelocityPrev = m_VelocityPrevTick;
1169  CrashDebugData.m_CrashDataPoint.m_VelocityDot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1170  CrashDebugData.m_CrashDataPoint.m_Time = GetGame().GetTime();
1171 
1172 
1173 
1174  if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1175  {
1176  Debug.Log("--------------------------------------------------");
1177  Debug.Log("Vehicle:" + GetDisplayName());
1178  Debug.Log("DMG: " + dmg);
1179  Debug.Log("zoneName : "+ zoneName);
1180  Debug.Log("momentumCurr : "+ GetMomentum());
1181  Debug.Log("momentumPrev : "+ m_MomentumPrevTick);
1182  Debug.Log("momentumDelta : "+ data[0].impulse);
1183  Debug.Log("speed(km/h): "+ GetVelocity(this).Length() * 3.6);
1184  Debug.Log("speedPrev(km/h): "+ m_VelocityPrevTick.Length() * 3.6);
1185  Debug.Log("speedDelta(km/h) : "+ (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6);
1186  Debug.Log("velocityCur.): "+ GetVelocity(this));
1187  Debug.Log("velocityPrev.): "+ m_VelocityPrevTick);
1188  Debug.Log("velocityDot): "+ vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized()));
1189  Debug.Log("GetGame().GetTime(): "+ GetGame().GetTime());
1190  Debug.Log("--------------------------------------------------");
1191  }
1192  #endif
1193  if ( dmg < GameConstants.CARS_CONTACT_DMG_MIN )
1194  continue;
1195 
1196  int pddfFlags;
1197  #ifdef DIAG_DEVELOPER
1198  CrashDebugData.m_CrashData.Insert(CrashDebugData.m_CrashDataPoint);
1199  CrashDebugData.m_CrashDataPoint.m_Speedometer = GetSpeedometer();
1200  //Print("Crash data recorded");
1201  #endif
1202  if (dmg < GameConstants.CARS_CONTACT_DMG_THRESHOLD)
1203  {
1204  #ifdef DIAG_DEVELOPER
1205  CrashDebugData.m_CrashDataPoint.m_DamageType = "Small";
1206  if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1207  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() ));
1208  #endif
1209  SynchCrashLightSound(true);
1210  pddfFlags = ProcessDirectDamageFlags.NO_TRANSFER;
1211  }
1212  else
1213  {
1214  #ifdef DIAG_DEVELOPER
1215  CrashDebugData.m_CrashDataPoint.m_DamageType = "Big";
1216  if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1217  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() ));
1218  #endif
1219  DamageCrew(crewDmgBase);
1220  SynchCrashHeavySound(true);
1221  pddfFlags = 0;
1222  }
1223 
1224  #ifdef DEVELOPER
1225  m_DebugContactDamageMessage += string.Format("%1: %2\n", zoneName, dmg);
1226  #endif
1227 
1228  ProcessDirectDamage(DT_CUSTOM, null, zoneName, "EnviroDmg", "0 0 0", dmg, pddfFlags);
1229  }
1230 
1232  UpdateLights();
1233 
1234  m_ContactCache.Clear();
1235 
1236  }
1237 
1239  void DamageCrew(float dmg)
1240  {
1241  for ( int c = 0; c < CrewSize(); ++c )
1242  {
1243  Human crew = CrewMember( c );
1244  if ( !crew )
1245  continue;
1246 
1247  PlayerBase player;
1248  if ( Class.CastTo(player, crew ) )
1249  {
1250  if ( dmg > GameConstants.CARS_CONTACT_DMG_KILLCREW )
1251  {
1252  #ifdef DIAG_DEVELOPER
1253  CrashDebugData.m_CrashDataPoint.m_CrewDamageBase = dmg;
1254  CrashDebugData.m_CrashDataPoint.m_DMGHealth = -100;
1255  if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1256  {
1257  Debug.Log("--------------------------------------------------");
1258  Debug.Log("Killing the player");
1259  Debug.Log("Crew DMG Base: " + dmg);
1260  Debug.Log("--------------------------------------------------");
1261 
1262  }
1263  #endif
1264  player.SetHealth(0.0);
1265  }
1266  else
1267  {
1268  float shockTemp = Math.InverseLerp(GameConstants.CARS_CONTACT_DMG_THRESHOLD, GameConstants.CARS_CONTACT_DMG_KILLCREW, dmg);
1269  shockTemp = Math.Clamp(shockTemp,0,1);
1270  float shock = Math.Lerp( 50, 150, shockTemp );
1271  float hp = Math.Lerp( 2, 100, shockTemp );
1272 
1273  #ifdef DIAG_DEVELOPER
1274  CrashDebugData.m_CrashDataPoint.m_CrewDamageBase = dmg;
1275  CrashDebugData.m_CrashDataPoint.m_ShockTemp = shockTemp;
1276  CrashDebugData.m_CrashDataPoint.m_DMGHealth = hp;
1277  CrashDebugData.m_CrashDataPoint.m_DMGShock = shock;
1278  if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1279  {
1280  Debug.Log("--------------------------------------------------");
1281  Debug.Log("Crew DMG Base: " + dmg);
1282  Debug.Log("Crew shockTemp: " + shockTemp);
1283  Debug.Log("Crew DMG Health: " + hp);
1284  Debug.Log("Crew DMG Shock: " + shock);
1285  Debug.Log("--------------------------------------------------");
1286  }
1287  #endif
1288 
1289  player.AddHealth("", "Shock", -shock );
1290  player.AddHealth("", "Health", -hp );
1291  }
1292  }
1293  }
1294  }
1295 
1301  override float OnSound( CarSoundCtrl ctrl, float oldValue )
1302  {
1303  switch (ctrl)
1304  {
1305  case CarSoundCtrl.ENGINE:
1306  if (!m_EngineStarted)
1307  {
1308  return 0.0;
1309  }
1310  break;
1311  }
1312 
1313  return oldValue;
1314  }
1315 
1316  override void OnAnimationPhaseStarted(string animSource, float phase)
1317  {
1318  #ifndef SERVER
1319  HandleDoorsSound(animSource, phase);
1320  HandleSeatAdjustmentSound(animSource, phase);
1321  #endif
1322  }
1323 
1324  protected void HandleDoorsSound(string animSource, float phase)
1325  {
1326  switch (animSource)
1327  {
1328  case "doorsdriver":
1329  case "doorscodriver":
1330  case "doorscargo1":
1331  case "doorscargo2":
1332  case "doorshood":
1333  case "doorstrunk":
1334  EffectSound sound;
1335  if (phase == 0)
1336  sound = SEffectManager.PlaySound(m_CarDoorOpenSound, GetPosition());
1337  else
1338  sound = SEffectManager.PlaySound(m_CarDoorCloseSound, GetPosition());
1339 
1340  if (sound)
1341  sound.SetAutodestroy(true);
1342 
1343  break;
1344  }
1345  }
1346 
1347  protected void HandleSeatAdjustmentSound(string animSource, float phase)
1348  {
1349  switch (animSource)
1350  {
1351  case "seatdriver":
1352  case "seatcodriver":
1353  EffectSound sound;
1354  if (phase == 0)
1355  sound = SEffectManager.PlaySound(m_CarSeatShiftInSound, GetPosition());
1356  else
1357  sound = SEffectManager.PlaySound(m_CarSeatShiftOutSound, GetPosition());
1358 
1359  if (sound)
1360  sound.SetAutodestroy(true);
1361 
1362  break;
1363  }
1364  }
1365 
1366 
1367  protected void HandleCarHornSound(ECarHornState pState)
1368  {
1369  switch (pState)
1370  {
1371  case ECarHornState.SHORT:
1372  PlaySoundSet(m_CarHornSoundEffect, m_CarHornShortSoundName, 0, 0, false);
1373  break;
1374  case ECarHornState.LONG:
1375  PlaySoundSet(m_CarHornSoundEffect, m_CarHornLongSoundName, 0, 0, true);
1376  break;
1377  default:
1379  break;
1380  }
1381  }
1382 
1383  void HandleEngineSound(CarEngineSoundState state)
1384  {
1385  #ifndef SERVER
1386  PlayerBase player = null;
1387  EffectSound sound = null;
1388  WaveKind waveKind = WaveKind.WAVEEFFECT;
1389 
1390  switch (state)
1391  {
1392  case CarEngineSoundState.STARTING:
1393  m_PreStartSound = SEffectManager.PlaySound("Offroad_02_Starting_SoundSet", ModelToWorld(GetEnginePos()));
1394  m_PreStartSound.SetSoundFadeOut(0.15);
1395  break;
1396  case CarEngineSoundState.START_OK:
1397  // play different sound based on selected camera
1398  if (Class.CastTo(player, CrewMember(0)))
1399  {
1400  if (!player.IsCameraInsideVehicle())
1401  {
1402  waveKind = WaveKind.WAVEEFFECTEX;
1403  }
1404 
1405  sound = SEffectManager.CreateSound(m_EngineStartOK, ModelToWorld(GetEnginePos()));
1406  if (sound)
1407  {
1408  sound.SetSoundWaveKind(waveKind);
1409  sound.SoundPlay();
1410  sound.SetAutodestroy(true);
1411  }
1412  }
1413 
1415  GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(SetEngineStarted, 1000, false, true);
1416  break;
1417 
1418  case CarEngineSoundState.START_NO_FUEL:
1419  sound = SEffectManager.PlaySound("offroad_engine_failed_start_fuel_SoundSet", ModelToWorld(GetEnginePos()));
1420  sound.SetAutodestroy(true);
1421  break;
1422 
1423  case CarEngineSoundState.START_NO_BATTERY:
1424  sound = SEffectManager.PlaySound("offroad_engine_failed_start_battery_SoundSet", ModelToWorld(GetEnginePos()));
1425  sound.SetAutodestroy(true);
1426  break;
1427 
1428  case CarEngineSoundState.START_NO_SPARKPLUG:
1429  sound = SEffectManager.PlaySound("offroad_engine_failed_start_sparkplugs_SoundSet", ModelToWorld(GetEnginePos()));
1430  sound.SetAutodestroy(true);
1431  break;
1432 
1433  case CarEngineSoundState.STOP_OK:
1434  case CarEngineSoundState.STOP_NO_FUEL:
1435  // play different sound based on selected camera
1436  if (Class.CastTo(player, CrewMember(0)))
1437  {
1438  if (!player.IsCameraInsideVehicle())
1439  {
1440  waveKind = WaveKind.WAVEEFFECTEX;
1441  }
1442 
1443  sound = SEffectManager.CreateSound(m_EngineStopFuel, ModelToWorld(GetEnginePos()));
1444  if (sound)
1445  {
1446  sound.SetSoundWaveKind(waveKind);
1447  sound.SoundPlay();
1448  sound.SetAutodestroy(true);
1449  }
1450  }
1451 
1452  SetEngineStarted(false);
1453  break;
1454  }
1455  #endif
1456  }
1457 
1458  override void MarkCrewMemberUnconscious(int crewMemberIndex)
1459  {
1460  set<int> crewMemberIndicesCopy = new set<int>();
1461  crewMemberIndicesCopy.Copy(m_UnconsciousCrewMemberIndices);
1462  crewMemberIndicesCopy.Insert(crewMemberIndex);
1463 
1464  m_UnconsciousCrewMemberIndices = crewMemberIndicesCopy;
1465  }
1466 
1467  override void MarkCrewMemberDead(int crewMemberIndex)
1468  {
1469  set<int> crewMemberIndicesCopy = new set<int>();
1470  crewMemberIndicesCopy.Copy(m_DeadCrewMemberIndices);
1471  crewMemberIndicesCopy.Insert(crewMemberIndex);
1472 
1473  m_DeadCrewMemberIndices = crewMemberIndicesCopy;
1474  }
1475 
1477  {
1478  switch (state)
1479  {
1480  case ECrewMemberState.UNCONSCIOUS:
1481  foreach (int unconsciousCrewMemberIndex : m_UnconsciousCrewMemberIndices)
1482  {
1483  if (unconsciousCrewMemberIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
1484  {
1485  EngineStop();
1486  SetBrake(0.5);
1487  }
1488 
1489  m_UnconsciousCrewMemberIndices.RemoveItem(unconsciousCrewMemberIndex);
1490  }
1491 
1492  break
1493 
1494  case ECrewMemberState.DEAD:
1495  foreach (int deadCrewMemberIndex : m_DeadCrewMemberIndices)
1496  {
1497  if (deadCrewMemberIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
1498  {
1499  EngineStop();
1500  SetBrake(0.5);
1501  }
1502 
1503  m_DeadCrewMemberIndices.RemoveItem(deadCrewMemberIndex);
1504  }
1505 
1506  break
1507  }
1508  }
1509 
1512 
1519  override void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
1520  {
1521  switch ( fluid )
1522  {
1523  case CarFluid.FUEL:
1524  m_FuelAmmount = newValue;
1525  break;
1526 
1527  case CarFluid.OIL:
1528  m_OilAmmount = newValue;
1529  break;
1530 
1531  case CarFluid.BRAKE:
1532  m_BrakeAmmount = newValue;
1533  break;
1534 
1535  case CarFluid.COOLANT:
1536  m_CoolantAmmount = newValue;
1537  break;
1538  }
1539  }
1540 
1547  override bool OnBeforeEngineStart()
1548  {
1549  EntityAI item = null;
1550 
1551  if (m_EngineStartDoOnce)
1552  {
1553  m_EngineStartDoOnce = false;
1554  return m_EngineBeforeStart;
1555  }
1556 
1557  if (GetFluidFraction(CarFluid.FUEL) <= 0)
1558  {
1559  HandleEngineSound(CarEngineSoundState.START_NO_FUEL);
1560  return false;
1561  }
1562 
1563  if (IsVitalCarBattery() || IsVitalTruckBattery())
1564  {
1565  item = GetBattery();
1566  if (!item || (item && (item.IsRuined() || item.GetCompEM().GetEnergy() < m_BatteryEnergyStartMin)))
1567  {
1568  m_EngineStartDoOnce = true;
1569  HandleEngineSound(CarEngineSoundState.START_NO_BATTERY);
1570  return false;
1571  }
1572  }
1573 
1574  if (IsVitalSparkPlug())
1575  {
1576  item = FindAttachmentBySlotName("SparkPlug");
1577  if (!item || (item && item.IsRuined()))
1578  {
1579  m_EngineStartDoOnce = true;
1580  HandleEngineSound(CarEngineSoundState.START_NO_SPARKPLUG);
1581  return false;
1582  }
1583  }
1584 
1585  if (IsVitalGlowPlug())
1586  {
1587  item = FindAttachmentBySlotName("GlowPlug");
1588  if (!item || (item && item.IsRuined()))
1589  {
1590  m_EngineStartDoOnce = true;
1591  HandleEngineSound(CarEngineSoundState.START_NO_SPARKPLUG);
1592  return false;
1593  }
1594  }
1595 
1596  if (!m_EngineBeforeStart)
1597  {
1598  m_EngineBeforeStart = true;
1599  HandleEngineSound(CarEngineSoundState.STARTING);
1600  }
1601 
1602  return true;
1603  }
1604 
1605  override void OnGearChanged(int newGear, int oldGear)
1606  {
1607  //Debug.Log(string.Format("OnGearChanged newGear=%1,oldGear=%2", newGear, oldGear));
1608  UpdateLights(newGear);
1609  }
1610 
1612  override void OnEngineStart()
1613  {
1614  ItemBase battery = GetBattery();
1615  if (GetGame().IsServer() && battery)
1616  {
1617  battery.GetCompEM().ConsumeEnergy(GetBatteryConsumption());
1618  }
1619 
1620  UpdateLights();
1621 
1622  HandleEngineSound(CarEngineSoundState.START_OK);
1623 
1624  m_EngineBeforeStart = false;
1625  }
1626 
1628  override void OnEngineStop()
1629  {
1630  UpdateLights();
1631 
1632  HandleEngineSound(CarEngineSoundState.STOP_OK);
1633  SetEngineZoneReceivedHit(false);
1634 
1635  m_EngineBeforeStart = false;
1636  }
1637 
1642  bool OnBeforeSwitchLights( bool toOn )
1643  {
1644  return true;
1645  }
1646 
1649  {
1650  return m_HeadlightsOn;
1651  }
1652 
1655  {
1657  SetSynchDirty();
1658  }
1659 
1660  void UpdateLights(int new_gear = -1)
1661  {
1662  #ifndef SERVER
1663  UpdateLightsClient(new_gear);
1664  #endif
1665  UpdateLightsServer(new_gear);
1666  }
1667 
1668  void UpdateLightsClient(int newGear = -1)
1669  {
1670  int gear;
1671 
1672  if (newGear == -1)
1673  {
1674  gear = GetGear();
1675  }
1676  else
1677  {
1678  gear = newGear;
1679  }
1680 
1681  if (m_HeadlightsOn)
1682  {
1683  if (!m_Headlight && m_HeadlightsState != CarHeadlightBulbsState.NONE)
1684  {
1685  m_Headlight = CreateFrontLight();
1686  }
1687 
1688  if (m_Headlight)
1689  {
1690  switch (m_HeadlightsState)
1691  {
1692  case CarHeadlightBulbsState.LEFT:
1693  m_Headlight.AttachOnMemoryPoint(this, m_LeftHeadlightPoint, m_LeftHeadlightTargetPoint);
1694  m_Headlight.SegregateLight();
1695  break;
1696  case CarHeadlightBulbsState.RIGHT:
1697  m_Headlight.AttachOnMemoryPoint(this, m_RightHeadlightPoint, m_RightHeadlightTargetPoint);
1698  m_Headlight.SegregateLight();
1699  break;
1700  case CarHeadlightBulbsState.BOTH:
1701  vector local_pos_left = GetMemoryPointPos(m_LeftHeadlightPoint);
1702  vector local_pos_right = GetMemoryPointPos(m_RightHeadlightPoint);
1703 
1704  vector local_pos_middle = (local_pos_left + local_pos_right) * 0.5;
1705  m_Headlight.AttachOnObject(this, local_pos_middle);
1706  m_Headlight.AggregateLight();
1707  break;
1708  default:
1709  m_Headlight.FadeOut();
1710  m_Headlight = null;
1711  }
1712  }
1713  }
1714  else
1715  {
1716  if (m_Headlight)
1717  {
1718  m_Headlight.FadeOut();
1719  m_Headlight = null;
1720  }
1721  }
1722 
1723  // brakes & reverse
1724  switch (gear)
1725  {
1726  case CarGear.REVERSE:
1727  case CarAutomaticGearboxMode.R:
1728  if (m_BrakesArePressed)
1729  m_RearLightType = CarRearLightType.BRAKES_AND_REVERSE;
1730  else
1731  m_RearLightType = CarRearLightType.REVERSE_ONLY;
1732  break;
1733  default:
1734  if (m_BrakesArePressed)
1735  m_RearLightType = CarRearLightType.BRAKES_ONLY;
1736  else
1737  m_RearLightType = CarRearLightType.NONE;
1738  }
1739 
1740  //Debug.Log(string.Format("m_BrakesArePressed=%1, m_RearLightType=%2", m_BrakesArePressed.ToString(), EnumTools.EnumToString(CarRearLightType, m_RearLightType)));
1741 
1742  if (!m_RearLight && m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
1743  {
1744  if (EngineIsOn() || m_RearLightType == CarRearLightType.BRAKES_ONLY || m_RearLightType == CarRearLightType.BRAKES_AND_REVERSE)
1745  {
1746  m_RearLight = CreateRearLight();
1747  vector localPos = GetMemoryPointPos(m_ReverseLightPoint);
1748  m_RearLight.AttachOnObject(this, localPos, "180 0 0");
1749  }
1750  }
1751 
1752  // rear lights
1753  if (m_RearLight && m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
1754  {
1755  switch (m_RearLightType)
1756  {
1757  case CarRearLightType.BRAKES_ONLY:
1758  BrakesRearLight();
1759  break;
1760  case CarRearLightType.REVERSE_ONLY:
1761  if (EngineIsOn())
1762  ReverseRearLight();
1763  else
1764  NoRearLight();
1765 
1766  break;
1767  case CarRearLightType.BRAKES_AND_REVERSE:
1768  if (EngineIsOn())
1770  else
1771  BrakesRearLight();
1772 
1773  break;
1774  default:
1775  NoRearLight();
1776  }
1777  }
1778  else
1779  {
1780  if (m_RearLight)
1781  {
1782  NoRearLight();
1783  }
1784  }
1785  }
1786 
1787  void UpdateLightsServer(int newGear = -1)
1788  {
1789  int gear;
1790 
1791  if (newGear == -1)
1792  {
1793  gear = GetGear();
1794  if (GearboxGetType() == CarGearboxType.AUTOMATIC)
1795  {
1796  gear = GearboxGetMode();
1797  }
1798  }
1799  else
1800  {
1801  gear = newGear;
1802  }
1803 
1804  if (m_HeadlightsOn)
1805  {
1806  DashboardShineOn();
1808 
1809  switch (m_HeadlightsState)
1810  {
1811  case CarHeadlightBulbsState.LEFT:
1814  break;
1815  case CarHeadlightBulbsState.RIGHT:
1818  break;
1819  case CarHeadlightBulbsState.BOTH:
1822  break;
1823  default:
1826  }
1827 
1828  //Debug.Log(string.Format("m_HeadlightsOn=%1, m_HeadlightsState=%2", m_HeadlightsOn.ToString(), EnumTools.EnumToString(CarHeadlightBulbsState, m_HeadlightsState)));
1829  }
1830  else
1831  {
1836  }
1837 
1838 
1839  // brakes & reverse
1840  switch (gear)
1841  {
1842  case CarGear.REVERSE:
1843  case CarAutomaticGearboxMode.R:
1844  if (m_BrakesArePressed)
1845  m_RearLightType = CarRearLightType.BRAKES_AND_REVERSE;
1846  else
1847  m_RearLightType = CarRearLightType.REVERSE_ONLY;
1848  break;
1849  default:
1850  if (m_BrakesArePressed)
1851  m_RearLightType = CarRearLightType.BRAKES_ONLY;
1852  else
1853  m_RearLightType = CarRearLightType.NONE;
1854  }
1855 
1856  //Debug.Log(string.Format("m_BrakesArePressed=%1, m_RearLightType=%2", m_BrakesArePressed.ToString(), EnumTools.EnumToString(CarRearLightType, m_RearLightType)));
1857 
1858 
1859  // rear lights
1860  if (m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
1861  {
1862  switch (m_RearLightType)
1863  {
1864  case CarRearLightType.BRAKES_ONLY:
1867  break;
1868  case CarRearLightType.REVERSE_ONLY:
1869  if (EngineIsOn())
1870  {
1873  }
1874  else
1875  {
1878  }
1879  break;
1880  case CarRearLightType.BRAKES_AND_REVERSE:
1881  if (EngineIsOn())
1882  {
1885  }
1886  else
1887  {
1890  }
1891  break;
1892  default:
1895  }
1896  }
1897  else
1898  {
1901  }
1902  }
1903 
1904  protected void BrakesRearLight()
1905  {
1906  m_RearLight.SetAsSegregatedBrakeLight();
1907  }
1908 
1909  protected void ReverseRearLight()
1910  {
1911  m_RearLight.SetAsSegregatedReverseLight();
1912  }
1913 
1914  protected void BrakeAndReverseRearLight()
1915  {
1916  m_RearLight.AggregateLight();
1917  m_RearLight.SetFadeOutTime(1);
1918  }
1919 
1920  protected void NoRearLight()
1921  {
1922  m_RearLight.FadeOut();
1923  m_RearLight = null;
1924  }
1925 
1926  protected void LeftFrontLightShineOn()
1927  {
1928  string material = ConfigGetString("frontReflectorMatOn");
1929 
1930  if (material)
1931  {
1932  SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_L, material);
1933  }
1934  }
1935 
1936  protected void RightFrontLightShineOn()
1937  {
1938  string material = ConfigGetString("frontReflectorMatOn");
1939 
1940  if (material)
1941  {
1942  SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_R, material);
1943  }
1944  }
1945 
1946  protected void LeftFrontLightShineOff()
1947  {
1948  string material = ConfigGetString("frontReflectorMatOff");
1949 
1950  if (material)
1951  {
1952  SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_L, material);
1953  }
1954  }
1955 
1956  protected void RightFrontLightShineOff()
1957  {
1958  string material = ConfigGetString("frontReflectorMatOff");
1959 
1960  if (material)
1961  {
1962  SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_R, material);
1963  }
1964  }
1965 
1966  protected void ReverseLightsShineOn()
1967  {
1968  string material = ConfigGetString("ReverseReflectorMatOn");
1969 
1970  if (material)
1971  {
1972  SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_L, material);
1973  SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_R, material);
1974  }
1975  }
1976 
1977  protected void ReverseLightsShineOff()
1978  {
1979  string material = ConfigGetString("ReverseReflectorMatOff");
1980 
1981  if (material)
1982  {
1983  SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_L, material);
1984  SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_R, material);
1985  }
1986  }
1987 
1988  protected void BrakeLightsShineOn()
1989  {
1990  string material = ConfigGetString("brakeReflectorMatOn");
1991 
1992  if (material)
1993  {
1994  SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_L, material);
1995  SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_R, material);
1996  }
1997  }
1998 
1999  protected void BrakeLightsShineOff()
2000  {
2001  string material = ConfigGetString("brakeReflectorMatOff");
2002 
2003  if (material)
2004  {
2005  SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_L, material);
2006  SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_R, material);
2007  }
2008  }
2009 
2010  protected void TailLightsShineOn()
2011  {
2012  string material = ConfigGetString("TailReflectorMatOn");
2013  string materialOff = ConfigGetString("TailReflectorMatOff");
2014 
2015  if (material && materialOff)
2016  {
2017  if (m_HeadlightsState == CarHeadlightBulbsState.LEFT)
2018  {
2019  SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2020  SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, materialOff);
2021  }
2022  else if (m_HeadlightsState == CarHeadlightBulbsState.RIGHT)
2023  {
2024  SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, materialOff);
2025  SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2026  }
2027  else if (m_HeadlightsState == CarHeadlightBulbsState.BOTH)
2028  {
2029  SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2030  SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2031  }
2032  }
2033  }
2034 
2035  protected void TailLightsShineOff()
2036  {
2037  string material = ConfigGetString("TailReflectorMatOff");
2038 
2039  if (material)
2040  {
2041  SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2042  SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2043  }
2044  }
2045 
2046  protected void DashboardShineOn()
2047  {
2048  string material = ConfigGetString("dashboardMatOn");
2049 
2050  if (material)
2051  {
2052  SetObjectMaterial(SELECTION_ID_DASHBOARD_LIGHT, material);
2053  }
2054  }
2055 
2056  protected void DashboardShineOff()
2057  {
2058  string material = ConfigGetString("dashboardMatOff");
2059 
2060  if (material)
2061  {
2062  SetObjectMaterial(SELECTION_ID_DASHBOARD_LIGHT, material);
2063  }
2064  }
2065 
2066  // Override this for a car-specific light type
2067  protected CarRearLightBase CreateRearLight()
2068  {
2069  return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
2070  }
2071 
2072  // Override this for a car-specific light type
2073  protected CarLightBase CreateFrontLight()
2074  {
2075  return CarLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
2076  }
2077 
2078  protected void CheckVitalItem( bool isVital, string itemName )
2079  {
2080  if ( !isVital )
2081  return;
2082 
2083  EntityAI item = FindAttachmentBySlotName(itemName);
2084 
2085  if ( !item )
2086  EngineStop();
2087  else if ( item.IsRuined() )
2088  EngineStop();
2089  }
2090 
2091  protected void LeakFluid(CarFluid fluid)
2092  {
2093  float ammount = 0;
2094 
2095  switch (fluid)
2096  {
2097  case CarFluid.COOLANT:
2098  ammount = (1- m_RadiatorHealth) * Math.RandomFloat(0.02, 0.05);//CARS_LEAK_TICK_MIN; CARS_LEAK_TICK_MAX
2099  Leak(fluid, ammount);
2100  break;
2101 
2102  case CarFluid.OIL:
2103  ammount = ( 1 - m_EngineHealth ) * Math.RandomFloat(0.02, 1.0);//CARS_LEAK_OIL_MIN; CARS_LEAK_OIL_MAX
2104  Leak(fluid, ammount);
2105  break;
2106 
2107  case CarFluid.FUEL:
2108  ammount = ( 1 - m_FuelTankHealth ) * Math.RandomFloat(0.02, 0.05);//CARS_LEAK_TICK_MIN; CARS_LEAK_TICK_MAX
2109  Leak(fluid, ammount);
2110  break;
2111  }
2112  }
2113 
2114  protected void CarPartsHealthCheck()
2115  {
2116  if (GetGame().IsServer())
2117  {
2118  if (HasRadiator())
2119  {
2120  m_RadiatorHealth = GetRadiator().GetHealth01("", "");
2121  }
2122  else
2123  {
2124  m_RadiatorHealth = 0;
2125  }
2126 
2127  m_EngineHealth = GetHealth01("Engine", "");
2128  m_FuelTankHealth = GetHealth01("FuelTank", "");
2129  }
2130  }
2131 
2133  {
2134  return m_PlayCrashSoundLight;
2135  }
2136 
2137  void SynchCrashLightSound(bool play)
2138  {
2139  if (m_PlayCrashSoundLight != play)
2140  {
2141  m_PlayCrashSoundLight = play;
2142  SetSynchDirty();
2143  }
2144  }
2145 
2147  {
2148  PlaySoundEx("offroad_hit_light_SoundSet", m_CrashSoundLight, m_PlayCrashSoundLight);
2149  }
2150 
2152  {
2153  return m_PlayCrashSoundHeavy;
2154  }
2155 
2156  void SynchCrashHeavySound(bool play)
2157  {
2158  if (m_PlayCrashSoundHeavy != play)
2159  {
2160  m_PlayCrashSoundHeavy = play;
2161  SetSynchDirty();
2162  }
2163  }
2164 
2166  {
2167  PlaySoundEx("offroad_hit_heavy_SoundSet", m_CrashSoundHeavy, m_PlayCrashSoundHeavy);
2168  }
2169 
2170  void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
2171  {
2172  #ifndef SERVER
2173  if (!sound)
2174  {
2175  sound = SEffectManager.PlaySoundCachedParams(soundset, GetPosition());
2176  if( sound )
2177  {
2178  sound.SetAutodestroy(true);
2179  }
2180  }
2181  else
2182  {
2183  if (!sound.IsSoundPlaying())
2184  {
2185  sound.SetPosition(GetPosition());
2186  sound.SoundPlay();
2187  }
2188  }
2189 
2190  soundbool = false;
2191  #endif
2192  }
2193 
2194  void PlaySound(string soundset, ref EffectSound sound, out bool soundbool)
2195  {
2196  PlaySoundEx(soundset, sound, soundbool);
2197  }
2198 
2199  string GetAnimSourceFromSelection( string selection )
2200  {
2201  return "";
2202  }
2203 
2204  string GetDoorConditionPointFromSelection( string selection )
2205  {
2206  switch( selection )
2207  {
2208  case "seat_driver":
2209  return "seat_con_1_1";
2210  break;
2211  case "seat_codriver":
2212  return "seat_con_2_1";
2213  break;
2214  case "seat_cargo1":
2215  return "seat_con_1_2";
2216  break;
2217  case "seat_cargo2":
2218  return "seat_con_2_2";
2219  break;
2220  }
2221 
2222  return "";
2223  }
2224 
2225  string GetDoorSelectionNameFromSeatPos(int posIdx)
2226  {
2227  return "";
2228  }
2229 
2230  string GetDoorInvSlotNameFromSeatPos(int posIdx)
2231  {
2232  return "";
2233  }
2234 
2235  int GetCrewIndex( string selection )
2236  {
2237  return -1;
2238  }
2239 
2240  override bool CanReachSeatFromDoors( string pSeatSelection, vector pFromPos, float pDistance = 1.0 )
2241  {
2242  string conPointName = GetDoorConditionPointFromSelection(pSeatSelection);
2243  if (conPointName.Length() > 0)
2244  {
2245  if ( MemoryPointExists(conPointName) )
2246  {
2247  vector conPointMS = GetMemoryPointPos(conPointName);
2248  vector conPointWS = ModelToWorld(conPointMS);
2249 
2251  conPointWS[1] = 0;
2252  pFromPos[1] = 0;
2253 
2254  if (vector.Distance(pFromPos, conPointWS) <= pDistance)
2255  {
2256  return true;
2257  }
2258  }
2259  }
2260 
2261  return false;
2262  }
2263 
2264  bool IsVitalCarBattery()
2265  {
2266  return true;
2267  }
2268 
2269  bool IsVitalTruckBattery()
2270  {
2271  return true;
2272  }
2273 
2274  bool IsVitalSparkPlug()
2275  {
2276  return true;
2277  }
2278 
2279  bool IsVitalGlowPlug()
2280  {
2281  return true;
2282  }
2283 
2284  bool IsVitalEngineBelt()
2285  {
2286  return true;
2287  }
2288 
2289  bool IsVitalRadiator()
2290  {
2291  return true;
2292  }
2293 
2295  {
2296  return true;
2297  }
2298 
2300  {
2301  return m_Radiator != null;
2302  }
2303 
2305  {
2306  return m_Radiator;
2307  }
2308 
2309  bool IsMoving()
2310  {
2311  return GetSpeedometerAbsolute() > 3.5;
2312  }
2313 
2315  {
2316  return GetHandbrake() > 0.0;
2317  }
2318 
2320  override int Get3rdPersonCameraType()
2321  {
2322  return DayZPlayerCameras.DAYZCAMERA_3RD_VEHICLE;
2323 
2324  }
2325 
2326  void SetEngineStarted(bool started)
2327  {
2328  m_EngineStarted = started;
2329  }
2330 
2331  int GetCarDoorsState(string slotType)
2332  {
2333  return -1;
2334  }
2335 
2337  {
2338  if (GetAnimationPhase(animation) > 0.5)
2339  {
2340  return CarDoorState.DOORS_OPEN;
2341  }
2342  else
2343  {
2344  return CarDoorState.DOORS_CLOSED;
2345  }
2346  }
2347 
2349  {
2350  return "radiator";
2351  }
2352 
2354  {
2355  return 2.0;
2356  }
2357 
2359  {
2360  return "refill";
2361  }
2362 
2364  {
2365  return 1.5;
2366  }
2367 
2369  {
2370  return "carradiator";
2371  }
2372 
2374  {
2375  return 2.0;
2376  }
2377 
2379  {
2380  return "carradiator";
2381  }
2382 
2384  {
2385  return 2.0;
2386  }
2387 
2389  {
2390  m_InputActionMap = m_CarTypeActionsMap.Get( this.Type() );
2391  if (!m_InputActionMap)
2392  {
2393  TInputActionMap iam = new TInputActionMap;
2394  m_InputActionMap = iam;
2395  SetActions();
2396  m_CarTypeActionsMap.Insert(this.Type(), m_InputActionMap);
2397  }
2398  }
2399 
2400  override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
2401  {
2402  if (!m_ActionsInitialize)
2403  {
2404  m_ActionsInitialize = true;
2406  }
2407 
2408  actions = m_InputActionMap.Get(action_input_type);
2409  }
2410 
2411  void SetActions()
2412  {
2420  }
2421 
2422  void AddAction(typename actionName)
2423  {
2424  ActionBase action = ActionManagerBase.GetAction(actionName);
2425 
2426  if (!action)
2427  {
2428  Debug.LogError("Action " + actionName + " dosn't exist!");
2429  return;
2430  }
2431 
2432  typename ai = action.GetInputType();
2433  if (!ai)
2434  {
2435  m_ActionsInitialize = false;
2436  return;
2437  }
2438  array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
2439 
2440  if (!action_array)
2441  {
2442  action_array = new array<ActionBase_Basic>;
2443  m_InputActionMap.Insert(ai, action_array);
2444  }
2445 
2446  if ( LogManager.IsActionLogEnable() )
2447  {
2448  Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action" );
2449  }
2450  action_array.Insert(action);
2451  }
2452 
2453  void RemoveAction(typename actionName)
2454  {
2455  PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
2456  ActionBase action = player.GetActionManager().GetAction(actionName);
2457  typename ai = action.GetInputType();
2458  array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
2459 
2460  if (action_array)
2461  {
2462  action_array.RemoveItem(action);
2463  }
2464  }
2465 
2466  override bool IsInventoryVisible()
2467  {
2468  return ( GetGame().GetPlayer() && ( !GetGame().GetPlayer().GetCommand_Vehicle() || GetGame().GetPlayer().GetCommand_Vehicle().GetTransport() == this ) );
2469  }
2470 
2471  override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
2472  {
2473  super.EEHealthLevelChanged(oldLevel,newLevel,zone);
2474 
2475  if (newLevel == GameConstants.STATE_RUINED && oldLevel != newLevel)
2476  {
2477  bool dummy;
2478  switch ( zone )
2479  {
2480  case "WindowLR":
2481  case "WindowRR":
2482  if (m_Initialized)
2483  {
2484  PlaySoundEx("offroad_hit_window_small_SoundSet", m_WindowSmall, dummy);
2485  }
2486  break;
2487 
2488  case "WindowFront":
2489  case "WindowBack":
2490  case "WindowFrontLeft":
2491  case "WindowFrontRight":
2492  if (m_Initialized)
2493  {
2494  PlaySoundEx("offroad_hit_window_large_SoundSet", m_WindowLarge, dummy);
2495  }
2496  break;
2497 
2498  case "Engine":
2499  #ifndef SERVER
2501  #endif
2502  break;
2503  }
2504  }
2505  }
2506 
2507  override void EEOnCECreate()
2508  {
2509 
2510  float maxVolume = GetFluidCapacity( CarFluid.FUEL );
2511  float amount = Math.RandomFloat(0.0, maxVolume * 0.35 );
2512 
2513  Fill( CarFluid.FUEL, amount );
2514  }
2515 
2517  {
2518  if (!m_ForceUpdateLights)
2519  {
2520  m_ForceUpdateLights = true;
2521  SetSynchDirty();
2522  }
2523  }
2524 
2526  {
2527  if (m_ForceUpdateLights)
2528  {
2529  m_ForceUpdateLights = false;
2530  SetSynchDirty();
2531  }
2532  }
2533 
2534  //Get the engine start battery consumption
2536  {
2537  return m_BatteryConsume;
2538  }
2539 
2541  {
2543  }
2544 
2546  {
2547  return -m_BatteryRecharge;
2548  }
2549 
2551  {
2552  if (IsVitalCarBattery())
2553  {
2554  return ItemBase.Cast(FindAttachmentBySlotName("CarBattery"));
2555  }
2556  else if (IsVitalTruckBattery())
2557  {
2558  return ItemBase.Cast(FindAttachmentBySlotName("TruckBattery"));
2559  }
2560 
2561  return null;
2562  }
2563 
2564  void SetCarHornState(int pState)
2565  {
2566  m_CarHornState = pState;
2567  SetSynchDirty();
2568 
2569  if (GetGame().IsServer())
2570  {
2571  GenerateCarHornAINoise(pState);
2572  }
2573  }
2574 
2575 
2576 
2577  protected void GenerateCarHornAINoise(int pState)
2578  {
2579  if (pState != ECarHornState.OFF)
2580  {
2581  if (m_NoiseSystem && m_NoisePar)
2582  {
2583  float noiseMultiplier = 1.0;
2584  if (pState == ECarHornState.LONG)
2585  noiseMultiplier = 2.0;
2586 
2587  m_NoiseSystem.AddNoiseTarget(GetPosition(), 5, m_NoisePar, noiseMultiplier);
2588  }
2589  }
2590  }
2591 
2593  {
2594  return vector.Zero;
2595  }
2596 
2597  void SetEngineZoneReceivedHit(bool pState)
2598  {
2599  m_EngineZoneReceivedHit = pState;
2600  SetSynchDirty();
2601  }
2602 
2604  {
2605  return m_EngineZoneReceivedHit;
2606  }
2607 
2608  float GetMomentum()
2609  {
2610  return GetVelocity(this).Length() * dBodyGetMass(this);
2611  }
2612 
2613  float GetPushForceCoefficientMultiplier()
2614  {
2615  return 1.0;
2616  }
2617 
2618 #ifdef DEVELOPER
2619  override protected string GetDebugText()
2620  {
2621  string debug_output = super.GetDebugText();
2622  if (GetGame().IsServer())
2623  {
2624  debug_output += m_DebugContactDamageMessage + "\n";
2625  }
2626  debug_output += "Entity momentum: " + GetMomentum();
2627 
2628  return debug_output;
2629  }
2630 #endif
2631 
2632  protected void SpawnUniversalParts()
2633  {
2634  GetInventory().CreateInInventory("HeadlightH7");
2635  GetInventory().CreateInInventory("HeadlightH7");
2636  GetInventory().CreateInInventory("HeadlightH7");
2637  GetInventory().CreateInInventory("HeadlightH7");
2638 
2639  if (IsVitalCarBattery())
2640  {
2641  GetInventory().CreateInInventory("CarBattery");
2642  GetInventory().CreateInInventory("CarBattery");
2643  }
2644 
2645  if (IsVitalTruckBattery())
2646  {
2647  GetInventory().CreateInInventory("TruckBattery");
2648  GetInventory().CreateInInventory("TruckBattery");
2649  }
2650 
2651  if (IsVitalRadiator())
2652  {
2653  GetInventory().CreateInInventory("CarRadiator");
2654  GetInventory().CreateInInventory("CarRadiator");
2655  }
2656 
2657  if (IsVitalSparkPlug())
2658  {
2659  GetInventory().CreateInInventory("SparkPlug");
2660  GetInventory().CreateInInventory("SparkPlug");
2661  }
2662 
2663  if (IsVitalGlowPlug())
2664  {
2665  GetInventory().CreateInInventory("GlowPlug");
2666  GetInventory().CreateInInventory("GlowPlug");
2667  }
2668  }
2669 
2670  protected void SpawnAdditionalItems()
2671  {
2672  GetInventory().CreateInInventory("Wrench");
2673  GetInventory().CreateInInventory("LugWrench");
2674  GetInventory().CreateInInventory("Screwdriver");
2675  GetInventory().CreateInInventory("EpoxyPutty");
2676 
2677  GetInventory().CreateInInventory("CanisterGasoline");
2678 
2679  EntityAI ent;
2680  ItemBase container;
2681  ent = GetInventory().CreateInInventory("CanisterGasoline");
2682  if (Class.CastTo(container, ent))
2683  {
2684  container.SetLiquidType(LIQUID_WATER, true);
2685  }
2686 
2687  ent = GetInventory().CreateInInventory("Blowtorch");
2688  if (ent)
2689  {
2690  ent.GetInventory().CreateInInventory("LargeGasCanister");
2691  }
2692 
2693  ent = GetInventory().CreateInInventory("Blowtorch");
2694  if (ent)
2695  {
2696  ent.GetInventory().CreateInInventory("LargeGasCanister");
2697  }
2698  }
2699 
2700  protected void FillUpCarFluids()
2701  {
2702  Fill(CarFluid.FUEL, 200.0);
2703  Fill(CarFluid.COOLANT, 200.0);
2704  Fill(CarFluid.OIL, 200.0);
2705  }
2706 }
ItemBase
Definition: inventoryitem.c:730
Get_1_2PointPosWS
vector Get_1_2PointPosWS()
Definition: carscript.c:473
GetActionCompNameFuel
string GetActionCompNameFuel()
Definition: carscript.c:2358
GetBatteryRuntimeConsumption
float GetBatteryRuntimeConsumption()
Definition: carscript.c:2540
OnFluidChanged
override void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
Definition: carscript.c:1519
GetGame
proto native CGame GetGame()
OnBrakesReleased
void OnBrakesReleased()
Definition: carscript.c:1022
UpdateLightsServer
void UpdateLightsServer(int newGear=-1)
Definition: carscript.c:1787
SynchCrashHeavySound
void SynchCrashHeavySound(bool play)
Definition: carscript.c:2156
m_Time
protected float m_Time
Definition: carscript.c:146
BrakeLightsShineOn
protected void BrakeLightsShineOn()
Definition: carscript.c:1988
m_backPos
protected vector m_backPos
Definition: carscript.c:202
Get_2_2PointPosWS
vector Get_2_2PointPosWS()
Definition: carscript.c:481
EffCoolantSteam
Definition: coolantsteam.c:1
m_coolantPtcPos
protected vector m_coolantPtcPos
Definition: carscript.c:196
EEItemAttached
override void EEItemAttached(EntityAI item, string slot_name)
Definition: carscript.c:648
ReverseRearLight
protected void ReverseRearLight()
Definition: carscript.c:1909
EffVehicleSmoke
Definition: vehiclesmoke.c:1
TailLightsShineOff
protected void TailLightsShineOff()
Definition: carscript.c:2035
m_exhaustFx
protected ref EffVehicleSmoke m_exhaustFx
Definition: carscript.c:187
m_Radiator
protected EntityAI m_Radiator
Definition: carscript.c:175
START_OK
enum CarDoorState START_OK
m_CarDoorCloseSound
string m_CarDoorCloseSound
Definition: carscript.c:216
m_BrakeAmmount
protected float m_BrakeAmmount
Definition: carscript.c:157
m_RearLight
CarRearLightBase m_RearLight
Definition: carscript.c:248
CALL_CATEGORY_GAMEPLAY
const int CALL_CATEGORY_GAMEPLAY
Definition: tools.c:10
GetActionCompNameCoolant
string GetActionCompNameCoolant()
Definition: carscript.c:2348
GetFrontPointPosWS
vector GetFrontPointPosWS()
Definition: carscript.c:461
LogManager
Definition: debug.c:734
m_Headlight
CarLightBase m_Headlight
Definition: carscript.c:247
InventorySlots
provides access to slot configuration
Definition: inventoryslots.c:5
OnAttachmentRuined
override void OnAttachmentRuined(EntityAI attachment)
Definition: carscript.c:774
m_coolantFx
protected ref EffVehicleSmoke m_coolantFx
Particles.
Definition: carscript.c:185
EEHitBy
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Definition: carscript.c:492
CleanupSound
void CleanupSound(EffectSound sound)
Definition: carscript.c:535
TailLightsShineOn
protected void TailLightsShineOn()
Definition: carscript.c:2010
SynchCrashLightSound
void SynchCrashLightSound(bool play)
Definition: carscript.c:2137
CarRearLightBase
Definition: civiliansedanrearlight.c:1
BRAKES_ONLY
enum CarDoorState BRAKES_ONLY
HandleEngineSound
void HandleEngineSound(CarEngineSoundState state)
Definition: carscript.c:1383
PlayCrashHeavySound
void PlayCrashHeavySound()
Definition: carscript.c:2165
GetDebugActions
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Definition: carscript.c:540
SpawnAdditionalItems
protected void SpawnAdditionalItems()
Definition: carscript.c:2670
BATTERY_UPDATE_DELAY
const private float BATTERY_UPDATE_DELAY
Definition: carscript.c:181
START_NO_BATTERY
enum CarDoorState START_NO_BATTERY
START_NO_FUEL
enum CarDoorState START_NO_FUEL
Synchronize
void Synchronize(eInjuryHandlerLevels level)
Definition: injuryhandler.c:173
IsHandbrakeActive
bool IsHandbrakeActive()
Definition: carscript.c:2314
BrakeAndReverseRearLight
protected void BrakeAndReverseRearLight()
Definition: carscript.c:1914
m_frontPos
protected vector m_frontPos
Definition: carscript.c:201
DashboardShineOn
protected void DashboardShineOn()
Definition: carscript.c:2046
OnVariablesSynchronized
override void OnVariablesSynchronized()
Definition: carscript.c:620
dBodyGetMass
proto native float dBodyGetMass(notnull IEntity ent)
GetActions
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Definition: carscript.c:2400
DamageCrew
void DamageCrew(float dmg)
Responsible for damaging crew in a car crash.
Definition: carscript.c:1239
m_CarHornLongSoundName
string m_CarHornLongSoundName
Definition: carscript.c:221
DOORS_OPEN
@ DOORS_OPEN
Definition: carscript.c:4
GetRadiator
EntityAI GetRadiator()
Definition: carscript.c:2304
m_EnviroHeatComfortOverride
protected float m_EnviroHeatComfortOverride
Definition: carscript.c:162
CarScript
Definition: civiliansedan.c:1
OnBeforeEngineStart
override bool OnBeforeEngineStart()
Definition: carscript.c:1547
m_EngineZoneReceivedHit
protected bool m_EngineZoneReceivedHit
Definition: carscript.c:273
GetActionDistanceCoolant
float GetActionDistanceCoolant()
Definition: carscript.c:2353
HasEngineZoneReceivedHit
bool HasEngineZoneReceivedHit()
Definition: carscript.c:2603
MarkCrewMemberUnconscious
override void MarkCrewMemberUnconscious(int crewMemberIndex)
Definition: carscript.c:1458
m_MomentumPrevTick
protected float m_MomentumPrevTick
Definition: carscript.c:142
m_BatteryConsume
protected float m_BatteryConsume
Definition: carscript.c:177
Print
proto void Print(void var)
Prints content of variable to console/log.
UpdateHeadlightState
void UpdateHeadlightState()
Definition: carscript.c:700
m_EngineStartDoOnce
protected bool m_EngineStartDoOnce
Definition: carscript.c:271
m_CarHornShortSoundName
string m_CarHornShortSoundName
Definition: carscript.c:220
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
Get_1_1PointPosWS
vector Get_1_1PointPosWS()
Definition: carscript.c:469
ECrewMemberState
ECrewMemberState
Definition: ecrewmemberstate.c:1
gear
< h scale="0.8">< image set="dayz_gui" name="icon_pin"/> Welcome to the DayZ Stress Test Branch</h >< h scale="0.6"> This branch serves for time limited development tests that are open to the community Our goal in each of these tests is to gather performance and stability data from servers under heavy load</h ></br >< h scale="0.8">< image set="dayz_gui" name="icon_pin"/> Stress test Schedule</h >< h scale="0.6"> We ll only run the Stress Tests when our development team needs data and or specific feedback Stress Tests will be announced on our Twitter and and will usually run for a couple of hours</h ></br >< h scale="0.8">< image set="dayz_gui" name="icon_pin"/> Current Stress Test</h >< h scale="0.6"> In the first bunch of Stress we ll mostly focus on watching server performance under heavy PvP gameplay load For detailed information about an ongoing Stress please visit dayz com dev hub</h ></br >< h scale="0.8">< image set="dayz_gui" name="icon_pin"/> Important Note</h >< h scale="0.6"> Stress Tests do not represent a typical DayZ gameplay experience Spawn starting gear
Definition: news_feed.txt:26
REVERSE_ONLY
enum CarDoorState REVERSE_ONLY
LIQUID_WATER
const int LIQUID_WATER
Definition: constants.c:505
ActionCarHornLong
Definition: actioncarhorn.c:208
DOORS_MISSING
@ DOORS_MISSING
Definition: carscript.c:3
OnContact
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:1110
CarPartsHealthCheck
protected void CarPartsHealthCheck()
Definition: carscript.c:2114
m_engineFx
protected ref EffVehicleSmoke m_engineFx
Definition: carscript.c:186
m_CarHornSoundEffect
protected ref EffectSound m_CarHornSoundEffect
Definition: carscript.c:229
m_dmgContactCoef
protected float m_dmgContactCoef
Definition: carscript.c:161
HasRadiator
bool HasRadiator()
Definition: carscript.c:2299
ReverseLightsShineOn
protected void ReverseLightsShineOn()
Definition: carscript.c:1966
EffEngineSmoke
Definition: enginesmoke.c:1
LEFT
enum CarDoorState LEFT
m_side_1_1Pos
protected vector m_side_1_1Pos
Definition: carscript.c:203
component
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
ActionManagerBase
void ActionManagerBase(PlayerBase player)
Definition: actionmanagerbase.c:62
GetMomentum
float GetMomentum()
Definition: carscript.c:2608
m_CarSeatShiftOutSound
string m_CarSeatShiftOutSound
Definition: carscript.c:218
m_CarDoorOpenSound
string m_CarDoorOpenSound
Definition: carscript.c:215
CONTACT
@ CONTACT
Definition: enentity.c:97
LeftFrontLightShineOn
protected void LeftFrontLightShineOn()
Definition: carscript.c:1926
m_exhaustPtcPos
protected vector m_exhaustPtcPos
Definition: carscript.c:193
PlaySound
void PlaySound(string soundset, ref EffectSound sound, out bool soundbool)
Definition: carscript.c:2194
IsInventoryVisible
override bool IsInventoryVisible()
Definition: carscript.c:2466
OFF
enum CarDoorState OFF
m_DrownTime
protected float m_DrownTime
Definition: carscript.c:165
m_EngineStarted
protected bool m_EngineStarted
Definition: carscript.c:242
RIGHT
enum CarDoorState RIGHT
BrakesRearLight
protected void BrakesRearLight()
Definition: carscript.c:1904
CarSoundCtrl
CarSoundCtrl
Car's sound controller list. (native, do not change or extend)
Definition: car.c:3
DayZPlayerCameras
Definition: dayzplayercameras.c:1
GetLiquidThroughputCoef
override float GetLiquidThroughputCoef()
Definition: carscript.c:486
ActionGetInTransport
Definition: actiongetintransport.c:1
IEntity
Definition: enentity.c:164
m_BatteryEnergyStartMin
protected float m_BatteryEnergyStartMin
Definition: carscript.c:182
m_EngineBeforeStart
protected bool m_EngineBeforeStart
Definition: carscript.c:270
m_FuelTankHealth
protected float m_FuelTankHealth
Definition: carscript.c:171
OnUpdate
override void OnUpdate(float dt)
Definition: carscript.c:1027
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
ForceUpdateLightsStart
void ForceUpdateLightsStart()
Definition: carscript.c:2516
m_EngineDestroyed
protected bool m_EngineDestroyed
Definition: carscript.c:243
m_HeadlightsState
protected bool m_HeadlightsState
Definition: carscript.c:237
SetEngineZoneReceivedHit
void SetEngineZoneReceivedHit(bool pState)
Definition: carscript.c:2597
GetRefillPointPosWS
vector GetRefillPointPosWS()
Definition: carscript.c:452
ActionOpenCarDoorsOutside
Definition: actionopencardoorsoutside.c:1
m_CrashSoundHeavy
ref EffectSound m_CrashSoundHeavy
Definition: carscript.c:224
OnBrakesPressed
void OnBrakesPressed()
Definition: carscript.c:1017
SHORT
enum CarDoorState SHORT
EEDelete
override void EEDelete(EntityAI parent)
Definition: carscript.c:502
GetPosition
class JsonUndergroundAreaTriggerData GetPosition
Definition: undergroundarealoader.c:9
EffectSound
Wrapper class for managing sound through SEffectManager.
Definition: effectsound.c:4
RemoveAction
void RemoveAction(typename actionName)
Definition: carscript.c:2453
DOORS_CLOSED
@ DOORS_CLOSED
Definition: carscript.c:5
BrakeLightsShineOff
protected void BrakeLightsShineOff()
Definition: carscript.c:1999
CarGearboxType
CarGearboxType
Enumerated gearbox types. (native, do not change or extend)
Definition: car.c:34
CarFluid
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Definition: car.c:18
PlayerBase
Definition: playerbaseclient.c:1
m_enginePos
protected vector m_enginePos
Definition: carscript.c:200
map
map
Definition: controlsxboxnew.c:3
HandleDoorsSound
protected void HandleDoorsSound(string animSource, float phase)
Definition: carscript.c:1324
vector
Definition: enconvert.c:105
HandleByCrewMemberState
override void HandleByCrewMemberState(ECrewMemberState state)
Definition: carscript.c:1476
~CarScript
void ~CarScript()
Definition: carscript.c:509
IsScriptedLightsOn
bool IsScriptedLightsOn()
Propper way to get if light is swiched on. Use instead of IsLightsOn().
Definition: carscript.c:1648
NoiseParams
class ObjectSpawnerHandler NoiseParams
m_side_2_1Pos
protected vector m_side_2_1Pos
Definition: carscript.c:205
m_ForceUpdateLights
protected bool m_ForceUpdateLights
Definition: carscript.c:241
OnBeforeSwitchLights
bool OnBeforeSwitchLights(bool toOn)
Definition: carscript.c:1642
PlayCrashLightSound
void PlayCrashLightSound()
Definition: carscript.c:2146
GetCrashLightSound
bool GetCrashLightSound()
Definition: carscript.c:2132
m_CrashSoundLight
ref EffectSound m_CrashSoundLight
Definition: carscript.c:223
TotalDamageResult
Definition: damagesystem.c:1
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
CarDoorState
CarDoorState
Definition: carscript.c:1
CreateCarDestroyedEffect
void CreateCarDestroyedEffect()
Definition: carscript.c:638
GetActionCompNameOil
string GetActionCompNameOil()
Definition: carscript.c:2368
m_WindowLarge
ref EffectSound m_WindowLarge
Definition: carscript.c:226
OnAction
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Definition: carscript.c:565
DamageType
DamageType
exposed from C++ (do not change)
Definition: damagesystem.c:10
m_VelocityPrevTick
protected vector m_VelocityPrevTick
Definition: carscript.c:143
STOP_OK
enum CarDoorState STOP_OK
AddAction
void AddAction(typename actionName)
Definition: carscript.c:2422
GetDebugText
string GetDebugText()
Definition: modifierbase.c:68
m_fuelPos
protected vector m_fuelPos
Definition: carscript.c:198
Object
Definition: objecttyped.c:1
EEOnCECreate
override void EEOnCECreate()
Definition: carscript.c:2507
CarWheel
Definition: inventoryitem.c:413
NONE
enum CarDoorState NONE
m_OilAmmount
protected float m_OilAmmount
Definition: carscript.c:156
ScriptedLightBase
Definition: pointlightbase.c:1
IsMoving
bool IsMoving()
Definition: carscript.c:2309
SetCarHornState
void SetCarHornState(int pState)
Definition: carscript.c:2564
m_HeadlightsOn
protected bool m_HeadlightsOn
Definition: carscript.c:236
WaveKind
WaveKind
Definition: sound.c:1
GetActionDistanceBrakes
float GetActionDistanceBrakes()
Definition: carscript.c:2383
OnGearChanged
override void OnGearChanged(int newGear, int oldGear)
Definition: carscript.c:1605
ActionSwitchLights
Definition: actionswitchlights.c:1
CleanupEffects
void CleanupEffects()
Definition: carscript.c:516
Contact
Definition: enphysics.c:300
START_NO_SPARKPLUG
enum CarDoorState START_NO_SPARKPLUG
GetCrashHeavySound
bool GetCrashHeavySound()
Definition: carscript.c:2151
EffExhaustSmoke
Definition: exhaustsmoke.c:1
HandleSeatAdjustmentSound
protected void HandleSeatAdjustmentSound(string animSource, float phase)
Definition: carscript.c:1347
m_BatteryRecharge
protected float m_BatteryRecharge
Definition: carscript.c:179
m_DeadCrewMemberIndices
protected ref set< int > m_DeadCrewMemberIndices
Definition: carscript.c:276
MarkCrewMemberDead
override void MarkCrewMemberDead(int crewMemberIndex)
Definition: carscript.c:1467
m_RadiatorHealth
protected float m_RadiatorHealth
Definition: carscript.c:170
m_exhaustPtcFx
protected int m_exhaustPtcFx
Definition: carscript.c:191
m_PreStartSound
private ref EffectSound m_PreStartSound
Definition: carscript.c:227
m_BatteryTimer
private float m_BatteryTimer
Definition: carscript.c:180
GetEnviroHeatComfortOverride
float GetEnviroHeatComfortOverride()
DEPRECATED
EActions
EActions
Definition: eactions.c:1
m_NoiseSystem
protected NoiseSystem m_NoiseSystem
Definition: carscript.c:231
SpawnUniversalParts
protected void SpawnUniversalParts()
Definition: carscript.c:2632
m_ActionsInitialize
bool m_ActionsInitialize
Definition: carscript.c:141
m_NoisePar
protected ref NoiseParams m_NoisePar
Definition: carscript.c:230
CheckContactCache
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
Definition: carscript.c:1139
m_EngineStopFuel
string m_EngineStopFuel
Definition: carscript.c:213
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
UpdateLights
void UpdateLights(int new_gear=-1)
Definition: carscript.c:1660
RightFrontLightShineOn
protected void RightFrontLightShineOn()
Definition: carscript.c:1936
m_PlayCrashSoundLight
protected bool m_PlayCrashSoundLight
Definition: carscript.c:233
GetDefaultHitPosition
override vector GetDefaultHitPosition()
Definition: carscript.c:2592
RightFrontLightShineOff
protected void RightFrontLightShineOff()
Definition: carscript.c:1956
Get3rdPersonCameraType
override int Get3rdPersonCameraType()
camera type
Definition: carscript.c:2320
CarLightBase
Definition: carrearlightbase.c:1
GetBatteryConsumption
float GetBatteryConsumption()
Definition: carscript.c:2535
NoiseSystem
Definition: noise.c:1
UpdateLightsClient
void UpdateLightsClient(int newGear=-1)
Definition: carscript.c:1668
m_side_1_2Pos
protected vector m_side_1_2Pos
Definition: carscript.c:204
m_PlayCrashSoundHeavy
protected bool m_PlayCrashSoundHeavy
Definition: carscript.c:234
m_BatteryContinuousConsume
protected float m_BatteryContinuousConsume
Definition: carscript.c:178
m_side_2_2Pos
protected vector m_side_2_2Pos
Definition: carscript.c:206
GetBatteryRechargeRate
float GetBatteryRechargeRate()
Definition: carscript.c:2545
ActionBase
void ActionBase()
Definition: actionbase.c:73
EEItemDetached
override void EEItemDetached(EntityAI item, string slot_name)
Definition: carscript.c:723
m_EngineStartBattery
string m_EngineStartBattery
Definition: carscript.c:210
FillUpCarFluids
protected void FillUpCarFluids()
Definition: carscript.c:2700
m_BrakesArePressed
protected bool m_BrakesArePressed
Definition: carscript.c:238
TranslateAnimationPhaseToCarDoorState
CarDoorState TranslateAnimationPhaseToCarDoorState(string animation)
Definition: carscript.c:2336
CanReceiveAttachment
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Definition: carscript.c:782
SetEngineStarted
void SetEngineStarted(bool started)
Definition: carscript.c:2326
GetBackPointPosWS
vector GetBackPointPosWS()
Definition: carscript.c:465
GetPlayer
protected void GetPlayer()
Definition: crosshairselector.c:127
TInputActionMap
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Definition: actionmanagerclient.c:1
EEHealthLevelChanged
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Definition: carscript.c:2471
GameConstants
Definition: constants.c:612
Debug
Definition: debug.c:13
GetCoolantPtcPosWS
vector GetCoolantPtcPosWS()
Definition: carscript.c:447
m_EngineHealth
protected float m_EngineHealth
Definition: carscript.c:169
LIQUID_THROUGHPUT_CAR_DEFAULT
const float LIQUID_THROUGHPUT_CAR_DEFAULT
Definition: constants.c:527
ToggleHeadlights
void ToggleHeadlights()
Switches headlights on/off, including the illumination of the control panel and synchronizes this cha...
Definition: carscript.c:1654
m_exhaustPtcDir
protected vector m_exhaustPtcDir
Definition: carscript.c:194
ActionCloseCarDoorsOutside
Definition: actionclosecardoorsoutside.c:1
Type
string Type
Definition: jsondatacontaminatedarea.c:11
ForceUpdateLightsEnd
void ForceUpdateLightsEnd()
Definition: carscript.c:2525
m_Initialized
protected bool m_Initialized
Definition: uihintpanel.c:23
ActionPushCar
Definition: actionpushcar.c:126
PlaySoundEx
void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
Definition: carscript.c:2170
GetActionCompNameBrakes
string GetActionCompNameBrakes()
Definition: carscript.c:2378
DashboardShineOff
protected void DashboardShineOff()
Definition: carscript.c:2056
GenerateCarHornAINoise
protected void GenerateCarHornAINoise(int pState)
Definition: carscript.c:2577
GetEnginePointPosWS
vector GetEnginePointPosWS()
Definition: carscript.c:457
ERPCs
ERPCs
Definition: erpcs.c:1
GetCommand_Vehicle
proto native HumanCommandVehicle GetCommand_Vehicle()
m_EngineStartPlug
string m_EngineStartPlug
Definition: carscript.c:211
GetTime
float GetTime()
Definition: notificationsystem.c:35
ActionCarHornShort
ActionFillBrakesCB ActionCarHornShort
m_InputActionMap
TInputActionMap m_InputActionMap
Definition: carscript.c:140
m_CarHornState
protected int m_CarHornState
Definition: carscript.c:245
m_WindowSmall
ref EffectSound m_WindowSmall
Definition: carscript.c:225
m_coolantPtcFx
protected int m_coolantPtcFx
Definition: carscript.c:190
NoRearLight
protected void NoRearLight()
Definition: carscript.c:1920
SAT_DEBUG_ACTION
const int SAT_DEBUG_ACTION
Definition: constants.c:424
LONG
enum CarDoorState LONG
CarScript
void CarScript()
Definition: carscript.c:284
m_CoolantAmmount
protected float m_CoolantAmmount
Definition: carscript.c:155
CheckVitalItem
protected void CheckVitalItem(bool isVital, string itemName)
Definition: carscript.c:2078
ProcessDirectDamageFlags
ProcessDirectDamageFlags
Definition: object.c:1
STARTING
enum CarDoorState STARTING
HandleCarHornSound
protected void HandleCarHornSound(ECarHornState pState)
Definition: carscript.c:1367
EEKilled
override void EEKilled(Object killer)
Definition: carscript.c:1103
Get_2_1PointPosWS
vector Get_2_1PointPosWS()
Definition: carscript.c:477
LeakFluid
protected void LeakFluid(CarFluid fluid)
Definition: carscript.c:2091
m_RearLightType
protected bool m_RearLightType
Definition: carscript.c:239
m_BatteryHealth
protected float m_BatteryHealth
Definition: carscript.c:172
Math
Definition: enmath.c:6
m_CarSeatShiftInSound
string m_CarSeatShiftInSound
Definition: carscript.c:217
EntityEvent
EntityEvent
Entity events for event-mask, or throwing event from code.
Definition: enentity.c:44
GetVelocity
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
GetBattery
ItemBase GetBattery()
Definition: carscript.c:2550
m_DamageType
int m_DamageType
Definition: areadamagecomponent.c:11
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_CarTypeActionsMap
enum CarDoorState m_CarTypeActionsMap
TSelectableActionInfoWithColor
Param4< int, int, string, int > TSelectableActionInfoWithColor
Definition: entityai.c:97
GetEnginePosWS
vector GetEnginePosWS()
Definition: carscript.c:442
m_EngineStartFuel
string m_EngineStartFuel
Definition: carscript.c:212
SEffectManager
Manager class for managing Effect (EffectParticle, EffectSound)
Definition: effectmanager.c:5
m_UnconsciousCrewMemberIndices
protected ref set< int > m_UnconsciousCrewMemberIndices
Definition: carscript.c:275
m_EngineStartOK
string m_EngineStartOK
Sounds.
Definition: carscript.c:209
Vector
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
GetActionDistanceFuel
float GetActionDistanceFuel()
Definition: carscript.c:2363
m_enginePtcFx
protected int m_enginePtcFx
Definition: carscript.c:189
GetActionDistanceOil
float GetActionDistanceOil()
Definition: carscript.c:2373
EntityAI
Definition: building.c:5
m_FuelAmmount
protected float m_FuelAmmount
keeps ammount of each fluid
Definition: carscript.c:154
GetType
override int GetType()
Definition: huddebugwincharagents.c:49
LeftFrontLightShineOff
protected void LeftFrontLightShineOff()
Definition: carscript.c:1946
ReverseLightsShineOff
protected void ReverseLightsShineOff()
Definition: carscript.c:1977
m_enginePtcPos
protected vector m_enginePtcPos
Definition: carscript.c:195
InitializeActions
void InitializeActions()
Definition: carscript.c:2388
CarAutomaticGearboxMode
CarAutomaticGearboxMode
Enumerated automatic gearbox modes. (native, do not change or extend)
Definition: car.c:68
IsVitalFuelTank
bool IsVitalFuelTank()
Definition: carscript.c:2294
m_ContactCache
ref CarContactCache m_ContactCache
Definition: carscript.c:144
CanReachSeatFromDoors
override bool CanReachSeatFromDoors(string pSeatSelection, vector pFromPos, float pDistance=1.0)
Definition: carscript.c:2240
BOTH
BOTH
Definition: pluginrecipesmanagerbase.c:4
m_PlugHealth
protected float m_PlugHealth
Definition: carscript.c:173