DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
CarScript.c
См. документацию.
7
8enum CarHeadlightBulbsState
9{
13 BOTH
14}
15
16enum CarRearLightType
17{
18 NONE,
21 BRAKES_AND_REVERSE
22}
23
24enum CarEngineSoundState
25{
26 NONE,
33 STOP_NO_FUEL
34}
35
36enum ECarHornState
37{
38 OFF = 0,
39 SHORT = 1,
40 LONG = 2
41}
42
43#ifdef DIAG_DEVELOPER
44enum EVehicleDebugOutputType
45{
46 NONE,
47 DAMAGE_APPLIED = 1,
48 DAMAGE_CONSIDERED = 2,
49 CONTACT = 4
50 //OTHER = 8
51 //OTHER = 16
52}
53
54class 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
110class 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
125
126#ifdef DIAG_DEVELOPER
127CarScript _car;
128#endif
129
133class 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;
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
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
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
228 protected ref NoiseParams m_NoisePar;
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;
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
272
273
274 #ifdef DEVELOPER
275 private const int DEBUG_MESSAGE_CLEAN_TIME_SECONDS = 10;
276 private float m_DebugMessageCleanTime;
277 private string m_DebugContactDamageMessage;
278 #endif
279
281 {
282#ifdef DIAG_DEVELOPER
283 _car = this;
284#endif
285
286 SetEventMask(EntityEvent.POSTSIMULATE);
287 SetEventMask(EntityEvent.POSTFRAME);
288
289 m_ContactCache = new CarContactCache;
290
291 m_Time = 0;
292 // sets max health for all components at init
293 m_EngineHealth = 1;
295 m_RadiatorHealth = -1;
296 m_BatteryHealth = -1;
297 m_PlugHealth = -1;
298
299 m_enginePtcFx = -1;
300 m_coolantPtcFx = -1;
301 m_exhaustPtcFx = -1;
302
304
305 m_PlayCrashSoundLight = false;
306 m_PlayCrashSoundHeavy = false;
307
308 m_CarHornState = ECarHornState.OFF;
309 m_CarEngineSoundState = CarEngineSoundState.NONE;
310
311 RegisterNetSyncVariableBool("m_HeadlightsOn");
312 RegisterNetSyncVariableBool("m_BrakesArePressed");
313 RegisterNetSyncVariableBool("m_ForceUpdateLights");
314 RegisterNetSyncVariableBoolSignal("m_PlayCrashSoundLight");
315 RegisterNetSyncVariableBoolSignal("m_PlayCrashSoundHeavy");
316 RegisterNetSyncVariableInt("m_CarHornState", ECarHornState.OFF, ECarHornState.LONG);
317 RegisterNetSyncVariableInt("m_CarEngineSoundState", CarEngineSoundState.NONE, CarEngineSoundState.STOP_NO_FUEL);
318
319 if ( MemoryPointExists("ptcExhaust_end") )
320 {
321 m_exhaustPtcPos = GetMemoryPointPos("ptcExhaust_end");
322 if ( MemoryPointExists("ptcExhaust_start") )
323 {
324 vector exhaustStart = GetMemoryPointPos("ptcExhaust_start");
325 vector tempOri = vector.Direction( exhaustStart, m_exhaustPtcPos);
326
327 m_exhaustPtcDir[0] = -tempOri[2];
328 m_exhaustPtcDir[1] = tempOri[1];
329 m_exhaustPtcDir[2] = tempOri[0];
330
331 m_exhaustPtcDir = m_exhaustPtcDir.Normalized().VectorToAngles();
332 }
333 }
334 else
335 {
336 m_exhaustPtcPos = "0 0 0";
337 m_exhaustPtcDir = "1 1 1";
338 }
339
340 if ( MemoryPointExists("ptcEnginePos") )
341 m_enginePtcPos = GetMemoryPointPos("ptcEnginePos");
342 else
343 m_enginePtcPos = "0 0 0";
344
345 if ( MemoryPointExists("ptcCoolantPos") )
346 m_coolantPtcPos = GetMemoryPointPos("ptcCoolantPos");
347 else
348 m_coolantPtcPos = "0 0 0";
349
350 if ( MemoryPointExists("drown_engine") )
351 m_DrownEnginePos = GetMemoryPointPos("drown_engine");
352 else
353 m_DrownEnginePos = "0 0 0";
354
355 if ( MemoryPointExists("dmgZone_engine") )
356 m_enginePos = GetMemoryPointPos("dmgZone_engine");
357 else
358 m_enginePos = "0 0 0";
359
360 if ( MemoryPointExists("dmgZone_front") )
361 m_frontPos = GetMemoryPointPos("dmgZone_front");
362 else
363 m_frontPos = "0 0 0";
364
365 if ( MemoryPointExists("dmgZone_back") )
366 m_backPos = GetMemoryPointPos("dmgZone_back");
367 else
368 m_backPos = "0 0 0";
369
370 if ( MemoryPointExists("dmgZone_fender_1_1") )
371 m_side_1_1Pos = GetMemoryPointPos("dmgZone_fender_1_1");
372 else
373 m_side_1_1Pos = "0 0 0";
374
375 if ( MemoryPointExists("dmgZone_fender_1_2") )
376 m_side_1_2Pos = GetMemoryPointPos("dmgZone_fender_1_2");
377 else
378 m_side_1_2Pos = "0 0 0";
379
380 if ( MemoryPointExists("dmgZone_fender_2_1") )
381 m_side_2_1Pos = GetMemoryPointPos("dmgZone_fender_2_1");
382 else
383 m_side_2_1Pos = "0 0 0";
384
385 if ( MemoryPointExists("dmgZone_fender_2_2") )
386 m_side_2_2Pos = GetMemoryPointPos("dmgZone_fender_2_2");
387 else
388 m_side_2_2Pos = "0 0 0";
389
390 if (!GetGame().IsDedicatedServer())
391 {
393 m_WheelSmokeFx.Resize(WheelCount());
395 m_WheelSmokePtcFx.Resize(WheelCount());
396 for (int i = 0; i < m_WheelSmokePtcFx.Count(); i++)
397 {
398 m_WheelSmokePtcFx.Set(i, -1);
399 }
400 }
401 }
402
403 override void EEInit()
404 {
405 super.EEInit();
406
407 if (GetGame().IsServer())
408 {
411 {
412 m_NoisePar = new NoiseParams();
413 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseCarHorn");
414 }
415 }
416 }
417
418 #ifdef DIAG_DEVELOPER
419
420 override void FixEntity()
421 {
422 if (GetGame().IsServer())
423 {
425 //server and single
426
427 for (int i = 5; i > 0; i--)//there is a problem with wheels when performed only once, this solves it
428 super.FixEntity();
429 if (!GetGame().IsMultiplayer())
430 {
431 //single
432 SEffectManager.DestroyEffect(m_engineFx);
433 }
434 }
435 else
436 {
437 //MP client
438 SEffectManager.DestroyEffect(m_engineFx);
439 }
440 }
441 #endif
442
443 override string GetVehicleType()
444 {
445 return "VehicleTypeCar";
446 }
447
449 {
450 return ModelToWorld( m_DrownEnginePos );
451 }
452
454 {
455 return ModelToWorld( m_coolantPtcPos );
456 }
457
459 {
460 return ModelToWorld( m_enginePos );
461 }
463 {
464 return ModelToWorld( m_frontPos );
465 }
467 {
468 return ModelToWorld( m_backPos );
469 }
471 {
472 return ModelToWorld( m_side_1_1Pos );
473 }
475 {
476 return ModelToWorld( m_side_1_2Pos );
477 }
479 {
480 return ModelToWorld( m_side_2_1Pos );
481 }
483 {
484 return ModelToWorld( m_side_2_2Pos );
485 }
486
487 override float GetLiquidThroughputCoef()
488 {
490 }
491
492 //here we should handle the damage dealt in OnContact event, but maybe we will react even in that event
493 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
494 {
495 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
496
499 }
500
501 override void EEDelete(EntityAI parent)
502 {
503 #ifndef SERVER
505 #endif
506 }
507
509 {
510 #ifndef SERVER
512 #endif
513 }
514
545
547 {
549 }
550
551 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
552 {
553 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_START_SHORT, "Car Horn Start Short", FadeColors.LIGHT_GREY));
554 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_START_LONG, "Car Horn Start Long", FadeColors.LIGHT_GREY));
555 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_STOP, "Car Horn Stop", FadeColors.LIGHT_GREY));
556
557 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "Car Fuel", FadeColors.RED));
558 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_FULL, "Full", FadeColors.LIGHT_GREY));
559 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_EMPTY, "Empty", FadeColors.LIGHT_GREY));
560 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_INCREASE, "10% increase", FadeColors.LIGHT_GREY));
561 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_DECREASE, "10% decrease", FadeColors.LIGHT_GREY));
562 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
563 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "Car Cooler", FadeColors.RED));
564 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_FULL, "Full", FadeColors.LIGHT_GREY));
565 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_EMPTY, "Empty", FadeColors.LIGHT_GREY));
566 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_INCREASE, "10% increase", FadeColors.LIGHT_GREY));
567 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_DECREASE, "10% decrease", FadeColors.LIGHT_GREY));
568 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
569
570 super.GetDebugActions(outputList);
571
572 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
573 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
574 }
575
576 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
577 {
578 if (super.OnAction(action_id, player, ctx))
579 return true;
580
581 if (!GetGame().IsServer())
582 {
583 return false;
584 }
585
586 switch (action_id)
587 {
588 case EActions.CAR_HORN_START_SHORT:
589 SetCarHornState(ECarHornState.SHORT);
590 return true;
591 case EActions.CAR_HORN_START_LONG:
592 SetCarHornState(ECarHornState.LONG);
593 return true;
594 case EActions.CAR_HORN_STOP:
595 SetCarHornState(ECarHornState.OFF);
596 return true;
597
598 case EActions.CAR_FUEL_FULL:
599 Fill(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL));
600 return true;
601 case EActions.CAR_FUEL_EMPTY:
602 LeakAll(CarFluid.FUEL);
603 return true;
604 case EActions.CAR_FUEL_INCREASE:
605 Fill(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL) * 0.1);
606 return true;
607 case EActions.CAR_FUEL_DECREASE:
608 Leak(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL) * 0.1);
609 return true;
610
611 case EActions.CAR_COOLANT_FULL:
612 Fill(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT));
613 return true;
614 case EActions.CAR_COOLANT_EMPTY:
615 LeakAll(CarFluid.COOLANT);
616 return true;
617 case EActions.CAR_COOLANT_INCREASE:
618 Fill(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT) * 0.1);
619 return true;
620 case EActions.CAR_COOLANT_DECREASE:
621 Leak(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT) * 0.1);
622 return true;
623 case EActions.DELETE:
624 Delete();
625 return true;
626 }
627
628 return false;
629 }
630
632 {
633 super.OnVariablesSynchronized();
634
635 if (GetCrashHeavySound())
636 {
638 }
639 else if (GetCrashLightSound())
640 {
642 }
643
645
648
649 UpdateLights();
650 }
651
653 {
654 if ( !SEffectManager.IsEffectExist( m_enginePtcFx ) && GetGame().GetWaterDepth( GetEnginePosWS() ) <= 0 )
655 {
657 m_engineFx.SetParticleStateHeavy();
659 }
660 }
661
662 override void EEItemAttached(EntityAI item, string slot_name)
663 {
664 super.EEItemAttached(item, slot_name);
665
666 switch (slot_name)
667 {
668 case "Reflector_1_1":
669 if (GetGame().IsServer())
670 {
671 SetHealth("Reflector_1_1", "Health", item.GetHealth());
672 }
673 break;
674 case "Reflector_2_1":
675 if (GetGame().IsServer())
676 {
677 SetHealth("Reflector_2_1", "Health", item.GetHealth());
678 }
679 break;
680 case "CarBattery":
681 case "TruckBattery":
682 if (GetGame().IsServer())
683 {
684 m_BatteryHealth = item.GetHealth01();
685 }
686 break;
687 case "SparkPlug":
688 case "GlowPlug":
689 if (GetGame().IsServer())
690 {
691 m_PlugHealth = item.GetHealth01();
692 }
693 break;
694 case "CarRadiator":
695 if (GetGame().IsServer())
696 {
697 m_RadiatorHealth = item.GetHealth01();
698 }
699
700 m_Radiator = item;
701 break;
702 }
703
704 if (GetGame().IsServer())
705 {
706 Synchronize();
707 }
708
710 UpdateLights();
711 }
712
713 // Updates state of attached headlight bulbs for faster access
715 {
716 EntityAI bulb_L = FindAttachmentBySlotName("Reflector_1_1");
717 EntityAI bulb_R = FindAttachmentBySlotName("Reflector_2_1");
718
719 if (bulb_L && !bulb_L.IsRuined() && bulb_R && !bulb_R.IsRuined())
720 {
721 m_HeadlightsState = CarHeadlightBulbsState.BOTH;
722 }
723 else if (bulb_L && !bulb_L.IsRuined())
724 {
725 m_HeadlightsState = CarHeadlightBulbsState.LEFT;
726 }
727 else if (bulb_R && !bulb_R.IsRuined())
728 {
729 m_HeadlightsState = CarHeadlightBulbsState.RIGHT;
730 }
731 else if ((!bulb_L || bulb_L.IsRuined()) && (!bulb_R || bulb_R.IsRuined()))
732 {
733 m_HeadlightsState = CarHeadlightBulbsState.NONE;
734 }
735 }
736
737 override void EEItemDetached(EntityAI item, string slot_name)
738 {
739 switch (slot_name)
740 {
741 case "CarBattery":
742 case "TruckBattery":
743 m_BatteryHealth = -1;
744 if (GetGame().IsServer())
745 {
746 if (EngineIsOn())
747 {
748 EngineStop();
749 }
750
751 if (IsScriptedLightsOn())
752 {
754 }
755 }
756 break;
757 case "SparkPlug":
758 case "GlowPlug":
759 m_PlugHealth = -1;
760 if (GetGame().IsServer() && EngineIsOn())
761 {
762 EngineStop();
763 }
764 break;
765 case "CarRadiator":
766 m_Radiator = null;
767 if (GetGame().IsServer())
768 {
769 LeakAll(CarFluid.COOLANT);
770
771 if (m_DamageZoneMap.Contains("Radiator"))
772 {
773 SetHealth("Radiator", "Health", 0);
774 }
775 }
776 break;
777 }
778
779 if (GetGame().IsServer())
780 {
781 Synchronize();
782 }
783
785 UpdateLights();
786 }
787
788 override void OnAttachmentRuined(EntityAI attachment)
789 {
790 super.OnAttachmentRuined(attachment);
791
793 UpdateLights();
794 }
795
796 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
797 {
798 if (!super.CanReceiveAttachment(attachment, slotId))
799 return false;
800
801 InventoryLocation attachmentInventoryLocation = new InventoryLocation();
802 attachment.GetInventory().GetCurrentInventoryLocation(attachmentInventoryLocation);
803 if (attachmentInventoryLocation.GetParent() == null)
804 {
805 return true;
806 }
807
808 if (attachment && attachment.Type().IsInherited(CarWheel))
809 {
810 string slotSelectionName;
811 InventorySlots.GetSelectionForSlotId(slotId, slotSelectionName);
812
813 switch (slotSelectionName)
814 {
815 case "wheel_spare_1":
816 case "wheel_spare_2":
817 return CanManipulateSpareWheel(slotSelectionName);
818 break;
819 }
820 }
821
822 return true;
823 }
824
825 override bool CanReleaseAttachment(EntityAI attachment)
826 {
827 if (!super.CanReleaseAttachment(attachment))
828 {
829 return false;
830 }
831
832 if (EngineIsOn() && IsMoving())
833 {
834 return false;
835 }
836
837 if (attachment && attachment.Type().IsInherited(CarWheel))
838 {
839 InventoryLocation attachmentInventoryLocation = new InventoryLocation();
840 attachment.GetInventory().GetCurrentInventoryLocation(attachmentInventoryLocation);
841
842 string slotSelectionName;
843 InventorySlots.GetSelectionForSlotId(attachmentInventoryLocation.GetSlot(), slotSelectionName);
844
845 switch (slotSelectionName)
846 {
847 case "wheel_spare_1":
848 case "wheel_spare_2":
849 return CanManipulateSpareWheel(slotSelectionName);
850 break;
851 }
852 }
853
854 return true;
855 }
856
857 protected bool CanManipulateSpareWheel(string slotSelectionName)
858 {
859 return false;
860 }
861
862 override void EOnPostSimulate(IEntity other, float timeSlice)
863 {
864 m_Time += timeSlice;
865
866 if (GetGame().IsServer())
867 {
870
871 #ifdef DIAG_DEVELOPER
872 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
873 {
874 if (m_ContactCalled)
875 {
876 Debug.Log("Momentum delta: " + (GetMomentum() - m_MomentumPrevTick));
877 Debug.Log("--------------------------------------------------------------------");
878 m_ContactCalled = false;
879 }
880 }
881 #endif
882
883
886 m_MomentumPrevTick = GetMomentum();
887 #ifdef DEVELOPER
888 m_DebugMessageCleanTime += timeSlice;
889 if (m_DebugMessageCleanTime >= DEBUG_MESSAGE_CLEAN_TIME_SECONDS)
890 {
891 m_DebugMessageCleanTime = 0;
892 m_DebugContactDamageMessage = "";
893 }
894 #endif
895 }
896
898 {
899 m_Time = 0;
900
902
903 //First of all check if the car should stop the engine
904 if (GetGame().IsServer() && EngineIsOn())
905 {
906 if ( GetFluidFraction(CarFluid.FUEL) <= 0 || m_EngineHealth <= 0 )
907 EngineStop();
908
909 CheckVitalItem(IsVitalCarBattery(), "CarBattery");
910 CheckVitalItem(IsVitalTruckBattery(), "TruckBattery");
911 CheckVitalItem(IsVitalSparkPlug(), "SparkPlug");
912 CheckVitalItem(IsVitalGlowPlug(), "GlowPlug");
913 }
914
915 if (GetGame().IsServer())
916 {
917 if (IsVitalFuelTank())
918 {
920 {
921 SetHealth("Engine", "Health", GameConstants.DAMAGE_RUINED_VALUE);
922 }
923 }
924 }
925
927 if ( EngineIsOn() )
928 {
929 if ( GetGame().IsServer() )
930 {
931 float dmg;
932
933 if ( EngineGetRPM() >= EngineGetRPMRedline() )
934 {
935 if (EngineGetRPM() > EngineGetRPMMax())
936 AddHealth( "Engine", "Health", -GetMaxHealth("Engine", "") * 0.05 ); //CAR_RPM_DMG
937
938 dmg = EngineGetRPM() * 0.001 * Math.RandomFloat( 0.02, 1.0 ); //CARS_TICK_DMG_MIN; //CARS_TICK_DMG_MAX
939 ProcessDirectDamage(DamageType.CUSTOM, null, "Engine", "EnviroDmg", vector.Zero, dmg);
940 SetEngineZoneReceivedHit(true);
941 }
942 else
943 {
944 SetEngineZoneReceivedHit(false);
945 }
946
948 if ( IsVitalRadiator() )
949 {
950 if ( GetFluidFraction(CarFluid.COOLANT) > 0 && m_RadiatorHealth < 0.5 ) //CARS_LEAK_THRESHOLD
951 LeakFluid( CarFluid.COOLANT );
952 }
953
954 if ( GetFluidFraction(CarFluid.FUEL) > 0 && m_FuelTankHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
955 LeakFluid( CarFluid.FUEL );
956
957 if ( GetFluidFraction(CarFluid.BRAKE) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
958 LeakFluid( CarFluid.BRAKE );
959
960 if ( GetFluidFraction(CarFluid.OIL) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
961 LeakFluid( CarFluid.OIL );
962
963 if ( m_EngineHealth < 0.25 )
964 LeakFluid( CarFluid.OIL );
965
966 if ( IsVitalRadiator() )
967 {
968 if ( GetFluidFraction( CarFluid.COOLANT ) < 0.5 && GetFluidFraction( CarFluid.COOLANT ) >= 0 )
969 {
970 dmg = ( 1 - GetFluidFraction(CarFluid.COOLANT) ) * Math.RandomFloat( 0.02, 10.00 ); //CARS_DMG_TICK_MIN_COOLANT; //CARS_DMG_TICK_MAX_COOLANT
971 AddHealth( "Engine", "Health", -dmg );
972 SetEngineZoneReceivedHit(true);
973 }
974 }
975 }
976
977 //FX only on Client and in Single
978 if (!GetGame().IsDedicatedServer())
979 {
981 {
984 m_exhaustFx.SetParticleStateLight();
985 }
986
987 if (IsVitalRadiator() && GetFluidFraction(CarFluid.COOLANT) < 0.5)
988 {
990 {
993 }
994
995 if (m_coolantFx)
996 {
997 if (GetFluidFraction(CarFluid.COOLANT) > 0)
998 m_coolantFx.SetParticleStateLight();
999 else
1000 m_coolantFx.SetParticleStateHeavy();
1001 }
1002 }
1003 else
1004 {
1007 }
1008 }
1009 }
1010 else
1011 {
1012 //FX only on Client and in Single
1013 if ( !GetGame().IsDedicatedServer() )
1014 {
1016 {
1018 m_exhaustPtcFx = -1;
1019 }
1020
1022 {
1024 m_coolantPtcFx = -1;
1025 }
1026 }
1027 }
1028
1029 }
1030
1031 //FX only on Client and in Single
1032 if ( !GetGame().IsDedicatedServer() )
1033 {
1034 float carSpeed = GetVelocity(this).Length();
1035 for (int i = 0; i < WheelCount(); i++)
1036 {
1037 EffWheelSmoke eff = m_WheelSmokeFx.Get(i);
1038 int ptrEff = m_WheelSmokePtcFx.Get(i);
1039 bool haveParticle = false;
1040
1041 if (WheelHasContact(i))
1042 {
1043 CarWheel wheel = CarWheel.Cast(WheelGetEntity(i));
1044 float wheelSpeed = WheelGetAngularVelocity(i) * wheel.GetRadius();
1045
1046 vector wheelPos = WheelGetContactPosition(i);
1047 vector wheelVel = dBodyGetVelocityAt(this, wheelPos);
1048
1049 vector transform[3];
1050 transform[2] = WheelGetDirection(i);
1051 transform[1] = vector.Up;
1052 transform[0] = transform[2] * transform[1];
1053
1054 wheelVel = wheelVel.InvMultiply3(transform);
1055
1056 float bodySpeed = wheelVel[2];
1057
1058 bool applyEffect = false;
1059 if ((wheelSpeed > 0 && bodySpeed > 0) || (wheelSpeed < 0 && bodySpeed < 0))
1060 {
1061 applyEffect = Math.AbsFloat(wheelSpeed) > Math.AbsFloat(bodySpeed) + EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1062 }
1063 else
1064 {
1065 applyEffect = Math.AbsFloat(wheelSpeed) > EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1066 }
1067
1068 if (applyEffect)
1069 {
1070 haveParticle = true;
1071
1072 string surface;
1073 GetGame().SurfaceGetType(wheelPos[0], wheelPos[2], surface);
1074 wheelPos = WorldToModel(wheelPos);
1075
1076 if (!SEffectManager.IsEffectExist(ptrEff))
1077 {
1078 eff = new EffWheelSmoke();
1079 eff.SetSurface(surface);
1080 ptrEff = SEffectManager.PlayOnObject(eff, this, wheelPos, "0 1 -1");
1081 eff.SetCurrentLocalPosition(wheelPos);
1082 m_WheelSmokeFx.Set(i, eff);
1083 m_WheelSmokePtcFx.Set(i, ptrEff);
1084 }
1085 else
1086 {
1087 if (!eff.IsPlaying() && Surface.GetWheelParticleID(surface) != 0)
1088 eff.Start();
1089 eff.SetSurface(surface);
1090 eff.SetCurrentLocalPosition(wheelPos);
1091 }
1092 }
1093 }
1094
1095 if (!haveParticle)
1096 {
1097 if (eff && eff.IsPlaying())
1098 eff.Stop();
1099 }
1100 }
1101 }
1102 //}
1103 }
1104
1106 {
1107 UpdateLights();
1108 }
1109
1111 {
1112 UpdateLights();
1113 }
1114
1115 // Server side event for jump out processing
1117 {
1118 PlayerBase player = gotActionData.m_Player;
1119
1120 array<ClothingBase> equippedClothes = new array<ClothingBase>;
1121 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("LEGS")));
1122 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("BACK")));
1123 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("VEST")));
1124 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("HeadGear")));
1125 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("Mask")));
1126 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("BODY")));
1127 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("FEET")));
1128 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("GLOVES")));
1129
1130 // -----------------------------------------------
1131 float shockTaken = (gotActionData.m_Speed * gotActionData.m_Speed) / ActionGetOutTransport.DMG_FACTOR;
1132
1133 //Lower shock taken if player uses a helmet
1134 ItemBase headGear = ClothingBase.Cast(player.GetItemOnHead());
1135 HelmetBase helmet;
1136 if (Class.CastTo(helmet, headGear))
1137 shockTaken *= 0.5;
1138
1139 // -----------------------------------------------
1140
1141 int randNum; //value used for probability evaluation
1142 randNum = Math.RandomInt(0, 100);
1143 if (gotActionData.m_Speed < ActionGetOutTransport.LOW_SPEED_VALUE)
1144 {
1145 if (randNum < 20)
1146 player.GiveShock(-shockTaken); //To inflict shock, a negative value must be passed
1147
1148 randNum = Math.RandomIntInclusive(0, PlayerBase.m_BleedingSourcesLow.Count() - 1);
1149
1150 player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection(PlayerBase.m_BleedingSourcesLow[randNum]);
1151 }
1153 {
1154 if (randNum < 50)
1155 player.GiveShock(-shockTaken);
1156
1157 randNum = Math.RandomInt(0, PlayerBase.m_BleedingSourcesUp.Count() - 1);
1158
1159 player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection(PlayerBase.m_BleedingSourcesUp[randNum]);
1160 }
1161 else if (gotActionData.m_Speed >= ActionGetOutTransport.HIGH_SPEED_VALUE)
1162 {
1163 if (!headGear)
1164 player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection("Head");
1165
1166 if (randNum < 75)
1167 player.GiveShock(-shockTaken);
1168 }
1169
1170 float dmgTaken = (gotActionData.m_Speed * gotActionData.m_Speed) / ActionGetOutTransport.SHOCK_FACTOR;
1171
1172 //Damage all currently equipped clothes
1173 foreach (ClothingBase cloth : equippedClothes)
1174 {
1175 //If no item is equipped on slot, slot is ignored
1176 if (cloth == null)
1177 continue;
1178
1179 cloth.DecreaseHealth(dmgTaken, false);
1180 }
1181
1182 vector posMS = gotActionData.m_Player.WorldToModel(gotActionData.m_Player.GetPosition());
1183 gotActionData.m_Player.DamageAllLegs(dmgTaken); //Additionnal leg specific damage dealing
1184
1186 healthCoef = Math.Clamp(healthCoef, 0.0, 1.0);
1187 gotActionData.m_Player.ProcessDirectDamage(DamageType.CUSTOM, gotActionData.m_Player, "", "FallDamageHealth", posMS, healthCoef);
1188 }
1189
1190 protected override bool DetectFlipped(VehicleFlippedContext ctx)
1191 {
1192 if (!DetectFlippedUsingWheels(ctx, GameConstants.VEHICLE_FLIP_WHEELS_LIMITED))
1193 return false;
1194 if (!DetectFlippedUsingSurface(ctx, GameConstants.VEHICLE_FLIP_ANGLE_TOLERANCE))
1195 return false;
1196 return true;
1197 }
1198
1199 override void OnUpdate( float dt )
1200 {
1201 if ( GetGame().IsServer() )
1202 {
1203 ItemBase battery = GetBattery();
1204 if ( battery )
1205 {
1206 if ( EngineIsOn() )
1207 {
1208 m_BatteryTimer += dt;
1210 {
1211 battery.GetCompEM().ConsumeEnergy(GetBatteryRechargeRate() * m_BatteryTimer);
1212 m_BatteryTimer = 0;
1213 }
1214 }
1215 else if ( !EngineIsOn() && IsScriptedLightsOn() )
1216 {
1217 m_BatteryTimer += dt;
1219 {
1220 battery.GetCompEM().ConsumeEnergy(GetBatteryRuntimeConsumption() * m_BatteryTimer);
1221 m_BatteryTimer = 0;
1222
1223 if ( battery.GetCompEM().GetEnergy() <= 0 )
1224 {
1226 }
1227 }
1228 }
1229 }
1230
1231 if ( GetGame().GetWaterDepth( GetEnginePosWS() ) > 0 )
1232 {
1233 m_DrownTime += dt;
1235 {
1236 // *dt to get damage per second
1237 AddHealth( "Engine", "Health", -DROWN_ENGINE_DAMAGE * dt);
1238 SetEngineZoneReceivedHit(true);
1239 }
1240 }
1241 else
1242 {
1243 m_DrownTime = 0;
1244 }
1245 }
1246
1247 // For visualisation of brake lights for all players
1248 float brake_coef = GetBrake();
1249 if ( brake_coef > 0 )
1250 {
1251 if ( !m_BrakesArePressed )
1252 {
1253 m_BrakesArePressed = true;
1254 SetSynchDirty();
1256 }
1257 }
1258 else
1259 {
1260 if ( m_BrakesArePressed )
1261 {
1262 m_BrakesArePressed = false;
1263 SetSynchDirty();
1265 }
1266 }
1267
1268 if ( (!GetGame().IsDedicatedServer()) && m_ForceUpdateLights )
1269 {
1270 UpdateLights();
1271 m_ForceUpdateLights = false;
1272 }
1273 }
1274
1275 override void EEKilled(Object killer)
1276 {
1277 super.EEKilled(killer);
1278 m_EngineDestroyed = true;
1279 }
1280
1282 override void OnContact( string zoneName, vector localPos, IEntity other, Contact data )
1283 {
1284 if (GetGame().IsServer())
1285 {
1286 #ifdef DIAG_DEVELOPER
1287 m_ContactCalled = true;
1288 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
1289 {
1290 string output = "Zone: " + zoneName + " | Impulse:" + data.Impulse;
1291 Debug.Log(output);
1292 }
1293 #endif
1294 if (m_ContactCache.Count() == 0)
1295 {
1297 m_ContactCache.Insert(zoneName, ccd);
1298 float momentumDelta = GetMomentum() - m_MomentumPrevTick;
1299 float dot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1300 if (dot < 0)
1301 {
1302 momentumDelta = m_MomentumPrevTick;
1303 }
1304
1305 ccd.Insert(new CarContactData(localPos, other, momentumDelta));
1306 }
1307 }
1308 }
1309
1312 {
1313
1314 int contactZonesCount = m_ContactCache.Count();
1315
1316 if (contactZonesCount == 0)
1317 return;
1318
1319
1320 for (int i = 0; i < contactZonesCount; ++i)
1321 {
1322 string zoneName = m_ContactCache.GetKey(i);
1324
1325 float dmg = Math.AbsInt(data[0].impulse * m_dmgContactCoef);
1326 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
1327
1328 #ifdef DIAG_DEVELOPER
1329 CrashDebugData.m_CrashDataPoint = new CrashDebugData();
1330 CrashDebugData.m_CrashDataPoint.m_VehicleType = GetDisplayName();
1331 CrashDebugData.m_CrashDataPoint.m_Damage = dmg;
1332 CrashDebugData.m_CrashDataPoint.m_Zone = zoneName;
1333 CrashDebugData.m_CrashDataPoint.m_MomentumCurr = GetMomentum();
1334 CrashDebugData.m_CrashDataPoint.m_MomentumPrev = m_MomentumPrevTick;
1335 CrashDebugData.m_CrashDataPoint.m_MomentumDelta = data[0].impulse;
1336 CrashDebugData.m_CrashDataPoint.m_SpeedWorld = GetVelocity(this).Length() * 3.6;
1337 CrashDebugData.m_CrashDataPoint.m_SpeedWorldPrev = m_VelocityPrevTick.Length() * 3.6;
1338 CrashDebugData.m_CrashDataPoint.m_SpeedWorldDelta = (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6;
1339 CrashDebugData.m_CrashDataPoint.m_VelocityCur = GetVelocity(this);
1340 CrashDebugData.m_CrashDataPoint.m_VelocityPrev = m_VelocityPrevTick;
1341 CrashDebugData.m_CrashDataPoint.m_VelocityDot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1342 CrashDebugData.m_CrashDataPoint.m_Time = GetGame().GetTime();
1343
1344
1345
1346 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1347 {
1348 Debug.Log("--------------------------------------------------");
1349 Debug.Log("Vehicle:" + GetDisplayName());
1350 Debug.Log("DMG: " + dmg);
1351 Debug.Log("zoneName : "+ zoneName);
1352 Debug.Log("momentumCurr : "+ GetMomentum());
1353 Debug.Log("momentumPrev : "+ m_MomentumPrevTick);
1354 Debug.Log("momentumDelta : "+ data[0].impulse);
1355 Debug.Log("speed(km/h): "+ GetVelocity(this).Length() * 3.6);
1356 Debug.Log("speedPrev(km/h): "+ m_VelocityPrevTick.Length() * 3.6);
1357 Debug.Log("speedDelta(km/h) : "+ (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6);
1358 Debug.Log("velocityCur.): "+ GetVelocity(this));
1359 Debug.Log("velocityPrev.): "+ m_VelocityPrevTick);
1360 Debug.Log("velocityDot): "+ vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized()));
1361 Debug.Log("GetGame().GetTime(): "+ GetGame().GetTime());
1362 Debug.Log("--------------------------------------------------");
1363 }
1364 #endif
1366 continue;
1367
1368 int pddfFlags;
1369 #ifdef DIAG_DEVELOPER
1370 CrashDebugData.m_CrashData.Insert(CrashDebugData.m_CrashDataPoint);
1371 CrashDebugData.m_CrashDataPoint.m_Speedometer = GetSpeedometer();
1372 //Print("Crash data recorded");
1373 #endif
1375 {
1376 #ifdef DIAG_DEVELOPER
1377 CrashDebugData.m_CrashDataPoint.m_DamageType = "Small";
1378 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1379 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() ));
1380 #endif
1382 pddfFlags = ProcessDirectDamageFlags.NO_TRANSFER;
1383 }
1384 else
1385 {
1386 #ifdef DIAG_DEVELOPER
1387 CrashDebugData.m_CrashDataPoint.m_DamageType = "Big";
1388 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1389 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() ));
1390 #endif
1391 DamageCrew(crewDmgBase);
1393 pddfFlags = 0;
1394 }
1395
1396 #ifdef DEVELOPER
1397 m_DebugContactDamageMessage += string.Format("%1: %2\n", zoneName, dmg);
1398 #endif
1399
1400 ProcessDirectDamage(DamageType.CUSTOM, null, zoneName, "EnviroDmg", "0 0 0", dmg, pddfFlags);
1401
1402 //if (data[0].impulse > TRESHOLD)
1403 //{
1404 Object targetEntity = Object.Cast(data[0].other);
1405 if (targetEntity && targetEntity.IsTree())
1406 {
1407 SEffectManager.CreateParticleServer(targetEntity.GetPosition(), new TreeEffecterParameters("TreeEffecter", 1.0, 0.1));
1408 }
1409 //}
1410 }
1411
1413 UpdateLights();
1414
1415 m_ContactCache.Clear();
1416
1417 }
1418
1420 void DamageCrew(float dmg)
1421 {
1422 for ( int c = 0; c < CrewSize(); ++c )
1423 {
1424 Human crew = CrewMember( c );
1425 if ( !crew )
1426 continue;
1427
1428 PlayerBase player;
1429 if ( Class.CastTo(player, crew ) )
1430 {
1432 {
1433 #ifdef DIAG_DEVELOPER
1434 CrashDebugData.m_CrashDataPoint.m_CrewDamageBase = dmg;
1435 CrashDebugData.m_CrashDataPoint.m_DMGHealth = -100;
1436 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1437 {
1438 Debug.Log("--------------------------------------------------");
1439 Debug.Log("Killing the player");
1440 Debug.Log("Crew DMG Base: " + dmg);
1441 Debug.Log("--------------------------------------------------");
1442
1443 }
1444 #endif
1445 player.SetHealth(0.0);
1446 }
1447 else
1448 {
1450 shockTemp = Math.Clamp(shockTemp,0,1);
1451 float shock = Math.Lerp( 50, 150, shockTemp );
1452 float hp = Math.Lerp( 2, 100, shockTemp );
1453
1454 #ifdef DIAG_DEVELOPER
1455 CrashDebugData.m_CrashDataPoint.m_CrewDamageBase = dmg;
1456 CrashDebugData.m_CrashDataPoint.m_ShockTemp = shockTemp;
1457 CrashDebugData.m_CrashDataPoint.m_DMGHealth = hp;
1458 CrashDebugData.m_CrashDataPoint.m_DMGShock = shock;
1459 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1460 {
1461 Debug.Log("--------------------------------------------------");
1462 Debug.Log("Crew DMG Base: " + dmg);
1463 Debug.Log("Crew shockTemp: " + shockTemp);
1464 Debug.Log("Crew DMG Health: " + hp);
1465 Debug.Log("Crew DMG Shock: " + shock);
1466 Debug.Log("--------------------------------------------------");
1467 }
1468 #endif
1469
1470 player.AddHealth("", "Shock", -shock );
1471 player.AddHealth("", "Health", -hp );
1472 }
1473 }
1474 }
1475 }
1476
1482 override float OnSound( CarSoundCtrl ctrl, float oldValue )
1483 {
1484 switch (ctrl)
1485 {
1486 case CarSoundCtrl.ENGINE:
1487 if (!m_EngineStarted)
1488 {
1489 return 0.0;
1490 }
1491 break;
1492 }
1493
1494 return oldValue;
1495 }
1496
1497 override void OnAnimationPhaseStarted(string animSource, float phase)
1498 {
1499 #ifndef SERVER
1500 HandleDoorsSound(animSource, phase);
1501 HandleSeatAdjustmentSound(animSource, phase);
1502 #endif
1503 }
1504
1505 protected void HandleDoorsSound(string animSource, float phase)
1506 {
1507 switch (animSource)
1508 {
1509 case "doorsdriver":
1510 case "doorscodriver":
1511 case "doorscargo1":
1512 case "doorscargo2":
1513 case "doorshood":
1514 case "doorstrunk":
1515 EffectSound sound;
1516 if (phase == 0)
1518 else
1520
1521 if (sound)
1522 sound.SetAutodestroy(true);
1523
1524 break;
1525 }
1526 }
1527
1528 protected void HandleSeatAdjustmentSound(string animSource, float phase)
1529 {
1530 switch (animSource)
1531 {
1532 case "seatdriver":
1533 case "seatcodriver":
1534 EffectSound sound;
1535 if (phase == 0)
1537 else
1539
1540 if (sound)
1541 sound.SetAutodestroy(true);
1542
1543 break;
1544 }
1545 }
1546
1547
1548 protected void HandleCarHornSound(ECarHornState pState)
1549 {
1550 switch (pState)
1551 {
1552 case ECarHornState.SHORT:
1553 PlaySoundSet(m_CarHornSoundEffect, m_CarHornShortSoundName, 0, 0, false);
1554 break;
1555 case ECarHornState.LONG:
1556 PlaySoundSet(m_CarHornSoundEffect, m_CarHornLongSoundName, 0, 0, true);
1557 break;
1558 default:
1560 break;
1561 }
1562 }
1563
1564 void HandleEngineSound(CarEngineSoundState state)
1565 {
1566 #ifndef SERVER
1567 PlayerBase player = null;
1568 EffectSound sound = null;
1569 WaveKind waveKind = WaveKind.WAVEEFFECT;
1570
1572
1573 switch (state)
1574 {
1575 case CarEngineSoundState.STARTING:
1576 m_PreStartSound = SEffectManager.PlaySound("Offroad_02_Starting_SoundSet", ModelToWorld(GetEnginePos()));
1577 m_PreStartSound.SetSoundFadeOut(0.15);
1578 break;
1579 case CarEngineSoundState.START_OK:
1580 // play different sound based on selected camera
1581 if (Class.CastTo(player, CrewMember(0)))
1582 {
1583 if (!player.IsCameraInsideVehicle())
1584 {
1585 waveKind = WaveKind.WAVEEFFECTEX;
1586 }
1587
1588 sound = SEffectManager.CreateSound(m_EngineStartOK, ModelToWorld(GetEnginePos()));
1589 if (sound)
1590 {
1591 sound.SetSoundWaveKind(waveKind);
1592 sound.SoundPlay();
1593 sound.SetAutodestroy(true);
1594 }
1595 }
1596
1599 break;
1600
1601 case CarEngineSoundState.START_NO_FUEL:
1602 sound = SEffectManager.PlaySound("offroad_engine_failed_start_fuel_SoundSet", ModelToWorld(GetEnginePos()));
1603 sound.SetAutodestroy(true);
1604 break;
1605
1606 case CarEngineSoundState.START_NO_BATTERY:
1607 sound = SEffectManager.PlaySound("offroad_engine_failed_start_battery_SoundSet", ModelToWorld(GetEnginePos()));
1608 sound.SetAutodestroy(true);
1609 break;
1610
1611 case CarEngineSoundState.START_NO_SPARKPLUG:
1612 sound = SEffectManager.PlaySound("offroad_engine_failed_start_sparkplugs_SoundSet", ModelToWorld(GetEnginePos()));
1613 sound.SetAutodestroy(true);
1614 break;
1615
1616 case CarEngineSoundState.STOP_OK:
1617 case CarEngineSoundState.STOP_NO_FUEL:
1618 // play different sound based on selected camera
1619 if (Class.CastTo(player, CrewMember(0)))
1620 {
1621 if (!player.IsCameraInsideVehicle())
1622 {
1623 waveKind = WaveKind.WAVEEFFECTEX;
1624 }
1625
1626 sound = SEffectManager.CreateSound(m_EngineStopFuel, ModelToWorld(GetEnginePos()));
1627 if (sound)
1628 {
1629 sound.SetSoundWaveKind(waveKind);
1630 sound.SoundPlay();
1631 sound.SetAutodestroy(true);
1632 }
1633 }
1634
1635 SetEngineStarted(false);
1636 break;
1637
1638 default:
1639 break;
1640 }
1641 #endif
1642 }
1643
1645 {
1646 switch (state)
1647 {
1648 case ECrewMemberState.UNCONSCIOUS:
1649 foreach (int unconsciousCrewMemberIndex : m_UnconsciousCrewMemberIndices)
1650 {
1651 if (unconsciousCrewMemberIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
1652 {
1653 EngineStop();
1654 SetBrake(0.5);
1655 }
1656
1657 m_UnconsciousCrewMemberIndices.RemoveItem(unconsciousCrewMemberIndex);
1658 }
1659
1660 break
1661
1662 case ECrewMemberState.DEAD:
1663 foreach (int deadCrewMemberIndex : m_DeadCrewMemberIndices)
1664 {
1665 if (deadCrewMemberIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
1666 {
1667 EngineStop();
1668 SetBrake(0.5);
1669 }
1670
1671 m_DeadCrewMemberIndices.RemoveItem(deadCrewMemberIndex);
1672 }
1673
1674 break
1675 }
1676 }
1677
1680
1687 override void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
1688 {
1689 switch ( fluid )
1690 {
1691 case CarFluid.FUEL:
1692 m_FuelAmmount = newValue;
1693 break;
1694
1695 case CarFluid.OIL:
1696 m_OilAmmount = newValue;
1697 break;
1698
1699 case CarFluid.BRAKE:
1700 m_BrakeAmmount = newValue;
1701 break;
1702
1703 case CarFluid.COOLANT:
1704 m_CoolantAmmount = newValue;
1705 break;
1706 }
1707 }
1708
1715 override bool OnBeforeEngineStart()
1716 {
1717 EntityAI item = null;
1718
1720 {
1721 item = GetBattery();
1722 if (!item || (item && (item.IsRuined() || item.GetCompEM().GetEnergy() < m_BatteryEnergyStartMin)))
1723 {
1724 SetCarEngineSoundState(CarEngineSoundState.START_NO_BATTERY);
1725 return false;
1726 }
1727 }
1728
1729 if (IsVitalSparkPlug())
1730 {
1731 item = FindAttachmentBySlotName("SparkPlug");
1732 if (!item || (item && item.IsRuined()))
1733 {
1734 SetCarEngineSoundState(CarEngineSoundState.START_NO_SPARKPLUG);
1735 return false;
1736 }
1737 }
1738
1739 if (IsVitalGlowPlug())
1740 {
1741 item = FindAttachmentBySlotName("GlowPlug");
1742 if (!item || (item && item.IsRuined()))
1743 {
1744 SetCarEngineSoundState(CarEngineSoundState.START_NO_SPARKPLUG);
1745 return false;
1746 }
1747 }
1748
1749 if (GetFluidFraction(CarFluid.FUEL) <= 0)
1750 {
1751 SetCarEngineSoundState(CarEngineSoundState.START_NO_FUEL);
1752 return false;
1753 }
1754
1755 return true;
1756 }
1757
1758 // Whether the car engine can be started
1760 {
1761 EntityAI item = null;
1762
1763 if (GetFluidFraction(CarFluid.FUEL) <= 0)
1764 return false;
1765
1767 {
1768 item = GetBattery();
1769 if (!item || (item && (item.IsRuined() || item.GetCompEM().GetEnergy() < m_BatteryEnergyStartMin)))
1770 return false;
1771 }
1772
1773 if (IsVitalSparkPlug())
1774 {
1775 item = FindAttachmentBySlotName("SparkPlug");
1776 if (!item || (item && item.IsRuined()))
1777 return false;
1778 }
1779
1780 if (IsVitalGlowPlug())
1781 {
1782 item = FindAttachmentBySlotName("GlowPlug");
1783 if (!item || (item && item.IsRuined()))
1784 return false;
1785 }
1786
1787 return true;
1788 }
1789
1790 override void OnGearChanged(int newGear, int oldGear)
1791 {
1792 //Debug.Log(string.Format("OnGearChanged newGear=%1,oldGear=%2", newGear, oldGear));
1793 UpdateLights(newGear);
1794 }
1795
1797 override void OnEngineStart()
1798 {
1799 ItemBase battery = GetBattery();
1800 if (GetGame().IsServer() && battery)
1801 {
1802 battery.GetCompEM().ConsumeEnergy(GetBatteryConsumption());
1803 }
1804
1805 UpdateLights();
1806
1807 HandleEngineSound(CarEngineSoundState.START_OK);
1808 }
1809
1811 override void OnEngineStop()
1812 {
1813 UpdateLights();
1814
1815 HandleEngineSound(CarEngineSoundState.STOP_OK);
1816
1817 SetEngineZoneReceivedHit(false);
1818 }
1819
1824 bool OnBeforeSwitchLights( bool toOn )
1825 {
1826 return true;
1827 }
1828
1831 {
1832 return m_HeadlightsOn;
1833 }
1834
1837 {
1839 SetSynchDirty();
1840 }
1841
1842 void UpdateLights(int new_gear = -1)
1843 {
1844 #ifndef SERVER
1845 UpdateLightsClient(new_gear);
1846 #endif
1847 UpdateLightsServer(new_gear);
1848 }
1849
1850 void UpdateLightsClient(int newGear = -1)
1851 {
1852 int gear;
1853
1854 if (newGear == -1)
1855 {
1856 gear = GetGear();
1857 }
1858 else
1859 {
1860 gear = newGear;
1861 }
1862
1863 if (m_HeadlightsOn)
1864 {
1865 if (!m_Headlight && m_HeadlightsState != CarHeadlightBulbsState.NONE)
1866 {
1868 }
1869
1870 if (m_Headlight)
1871 {
1872 switch (m_HeadlightsState)
1873 {
1874 case CarHeadlightBulbsState.LEFT:
1876 m_Headlight.SegregateLight();
1877 break;
1878 case CarHeadlightBulbsState.RIGHT:
1880 m_Headlight.SegregateLight();
1881 break;
1882 case CarHeadlightBulbsState.BOTH:
1883 vector local_pos_left = GetMemoryPointPos(m_LeftHeadlightPoint);
1884 vector local_pos_right = GetMemoryPointPos(m_RightHeadlightPoint);
1885
1886 vector local_pos_middle = (local_pos_left + local_pos_right) * 0.5;
1887 m_Headlight.AttachOnObject(this, local_pos_middle);
1888 m_Headlight.AggregateLight();
1889 break;
1890 default:
1891 m_Headlight.FadeOut();
1892 m_Headlight = null;
1893 }
1894 }
1895 }
1896 else
1897 {
1898 if (m_Headlight)
1899 {
1900 m_Headlight.FadeOut();
1901 m_Headlight = null;
1902 }
1903 }
1904
1905 // brakes & reverse
1906 switch (gear)
1907 {
1908 case CarGear.REVERSE:
1911 m_RearLightType = CarRearLightType.BRAKES_AND_REVERSE;
1912 else
1913 m_RearLightType = CarRearLightType.REVERSE_ONLY;
1914 break;
1915 default:
1917 m_RearLightType = CarRearLightType.BRAKES_ONLY;
1918 else
1919 m_RearLightType = CarRearLightType.NONE;
1920 }
1921
1922 //Debug.Log(string.Format("m_BrakesArePressed=%1, m_RearLightType=%2", m_BrakesArePressed.ToString(), EnumTools.EnumToString(CarRearLightType, m_RearLightType)));
1923
1924 if (!m_RearLight && m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
1925 {
1926 if (EngineIsOn() || m_RearLightType == CarRearLightType.BRAKES_ONLY || m_RearLightType == CarRearLightType.BRAKES_AND_REVERSE)
1927 {
1929 vector localPos = GetMemoryPointPos(m_ReverseLightPoint);
1930 m_RearLight.AttachOnObject(this, localPos, "180 0 0");
1931 }
1932 }
1933
1934 // rear lights
1935 if (m_RearLight && m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
1936 {
1937 switch (m_RearLightType)
1938 {
1939 case CarRearLightType.BRAKES_ONLY:
1941 break;
1942 case CarRearLightType.REVERSE_ONLY:
1943 if (EngineIsOn())
1945 else
1946 NoRearLight();
1947
1948 break;
1949 case CarRearLightType.BRAKES_AND_REVERSE:
1950 if (EngineIsOn())
1952 else
1954
1955 break;
1956 default:
1957 NoRearLight();
1958 }
1959 }
1960 else
1961 {
1962 if (m_RearLight)
1963 {
1964 NoRearLight();
1965 }
1966 }
1967 }
1968
1969 void UpdateLightsServer(int newGear = -1)
1970 {
1971 int gear;
1972
1973 if (newGear == -1)
1974 {
1975 gear = GetGear();
1976 if (GearboxGetType() == CarGearboxType.AUTOMATIC)
1977 {
1978 gear = GearboxGetMode();
1979 }
1980 }
1981 else
1982 {
1983 gear = newGear;
1984 }
1985
1986 if (m_HeadlightsOn)
1987 {
1990
1991 switch (m_HeadlightsState)
1992 {
1993 case CarHeadlightBulbsState.LEFT:
1996 break;
1997 case CarHeadlightBulbsState.RIGHT:
2000 break;
2001 case CarHeadlightBulbsState.BOTH:
2004 break;
2005 default:
2008 }
2009
2010 //Debug.Log(string.Format("m_HeadlightsOn=%1, m_HeadlightsState=%2", m_HeadlightsOn.ToString(), EnumTools.EnumToString(CarHeadlightBulbsState, m_HeadlightsState)));
2011 }
2012 else
2013 {
2018 }
2019
2020
2021 // brakes & reverse
2022 switch (gear)
2023 {
2024 case CarGear.REVERSE:
2027 m_RearLightType = CarRearLightType.BRAKES_AND_REVERSE;
2028 else
2029 m_RearLightType = CarRearLightType.REVERSE_ONLY;
2030 break;
2031 default:
2033 m_RearLightType = CarRearLightType.BRAKES_ONLY;
2034 else
2035 m_RearLightType = CarRearLightType.NONE;
2036 }
2037
2038 //Debug.Log(string.Format("m_BrakesArePressed=%1, m_RearLightType=%2", m_BrakesArePressed.ToString(), EnumTools.EnumToString(CarRearLightType, m_RearLightType)));
2039
2040
2041 // rear lights
2042 if (m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
2043 {
2044 switch (m_RearLightType)
2045 {
2046 case CarRearLightType.BRAKES_ONLY:
2049 break;
2050 case CarRearLightType.REVERSE_ONLY:
2051 if (EngineIsOn())
2052 {
2055 }
2056 else
2057 {
2060 }
2061 break;
2062 case CarRearLightType.BRAKES_AND_REVERSE:
2063 if (EngineIsOn())
2064 {
2067 }
2068 else
2069 {
2072 }
2073 break;
2074 default:
2077 }
2078 }
2079 else
2080 {
2083 }
2084 }
2085
2086 protected void BrakesRearLight()
2087 {
2088 m_RearLight.SetAsSegregatedBrakeLight();
2089 }
2090
2091 protected void ReverseRearLight()
2092 {
2093 m_RearLight.SetAsSegregatedReverseLight();
2094 }
2095
2097 {
2098 m_RearLight.AggregateLight();
2099 m_RearLight.SetFadeOutTime(1);
2100 }
2101
2102 protected void NoRearLight()
2103 {
2104 m_RearLight.FadeOut();
2105 m_RearLight = null;
2106 }
2107
2108 protected void LeftFrontLightShineOn()
2109 {
2110 string material = ConfigGetString("frontReflectorMatOn");
2111
2112 if (material)
2113 {
2114 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_L, material);
2115 }
2116 }
2117
2118 protected void RightFrontLightShineOn()
2119 {
2120 string material = ConfigGetString("frontReflectorMatOn");
2121
2122 if (material)
2123 {
2124 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_R, material);
2125 }
2126 }
2127
2128 protected void LeftFrontLightShineOff()
2129 {
2130 string material = ConfigGetString("frontReflectorMatOff");
2131
2132 if (material)
2133 {
2134 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_L, material);
2135 }
2136 }
2137
2139 {
2140 string material = ConfigGetString("frontReflectorMatOff");
2141
2142 if (material)
2143 {
2144 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_R, material);
2145 }
2146 }
2147
2148 protected void ReverseLightsShineOn()
2149 {
2150 string material = ConfigGetString("ReverseReflectorMatOn");
2151
2152 if (material)
2153 {
2154 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_L, material);
2155 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_R, material);
2156 }
2157 }
2158
2159 protected void ReverseLightsShineOff()
2160 {
2161 string material = ConfigGetString("ReverseReflectorMatOff");
2162
2163 if (material)
2164 {
2165 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_L, material);
2166 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_R, material);
2167 }
2168 }
2169
2170 protected void BrakeLightsShineOn()
2171 {
2172 string material = ConfigGetString("brakeReflectorMatOn");
2173
2174 if (material)
2175 {
2176 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_L, material);
2177 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_R, material);
2178 }
2179 }
2180
2181 protected void BrakeLightsShineOff()
2182 {
2183 string material = ConfigGetString("brakeReflectorMatOff");
2184
2185 if (material)
2186 {
2187 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_L, material);
2188 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_R, material);
2189 }
2190 }
2191
2192 protected void TailLightsShineOn()
2193 {
2194 string material = ConfigGetString("TailReflectorMatOn");
2195 string materialOff = ConfigGetString("TailReflectorMatOff");
2196
2197 if (material && materialOff)
2198 {
2199 if (m_HeadlightsState == CarHeadlightBulbsState.LEFT)
2200 {
2201 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2202 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, materialOff);
2203 }
2204 else if (m_HeadlightsState == CarHeadlightBulbsState.RIGHT)
2205 {
2206 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, materialOff);
2207 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2208 }
2209 else if (m_HeadlightsState == CarHeadlightBulbsState.BOTH)
2210 {
2211 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2212 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2213 }
2214 }
2215 }
2216
2217 protected void TailLightsShineOff()
2218 {
2219 string material = ConfigGetString("TailReflectorMatOff");
2220
2221 if (material)
2222 {
2223 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2224 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2225 }
2226 }
2227
2228 protected void DashboardShineOn()
2229 {
2230 string material = ConfigGetString("dashboardMatOn");
2231
2232 if (material)
2233 {
2234 SetObjectMaterial(SELECTION_ID_DASHBOARD_LIGHT, material);
2235 }
2236 }
2237
2238 protected void DashboardShineOff()
2239 {
2240 string material = ConfigGetString("dashboardMatOff");
2241
2242 if (material)
2243 {
2244 SetObjectMaterial(SELECTION_ID_DASHBOARD_LIGHT, material);
2245 }
2246 }
2247
2248 // Override this for a car-specific light type
2250 {
2251 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
2252 }
2253
2254 // Override this for a car-specific light type
2256 {
2257 return CarLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
2258 }
2259
2260 protected void CheckVitalItem( bool isVital, string itemName )
2261 {
2262 if ( !isVital )
2263 return;
2264
2265 EntityAI item = FindAttachmentBySlotName(itemName);
2266
2267 if ( !item )
2268 EngineStop();
2269 else if ( item.IsRuined() )
2270 EngineStop();
2271 }
2272
2273 protected void LeakFluid(CarFluid fluid)
2274 {
2275 float ammount = 0;
2276
2277 switch (fluid)
2278 {
2279 case CarFluid.COOLANT:
2280 ammount = (1- m_RadiatorHealth) * Math.RandomFloat(0.02, 0.05);//CARS_LEAK_TICK_MIN; CARS_LEAK_TICK_MAX
2281 Leak(fluid, ammount);
2282 break;
2283
2284 case CarFluid.OIL:
2285 ammount = ( 1 - m_EngineHealth ) * Math.RandomFloat(0.02, 1.0);//CARS_LEAK_OIL_MIN; CARS_LEAK_OIL_MAX
2286 Leak(fluid, ammount);
2287 break;
2288
2289 case CarFluid.FUEL:
2290 ammount = ( 1 - m_FuelTankHealth ) * Math.RandomFloat(0.02, 0.05);//CARS_LEAK_TICK_MIN; CARS_LEAK_TICK_MAX
2291 Leak(fluid, ammount);
2292 break;
2293 }
2294 }
2295
2296 protected void CarPartsHealthCheck()
2297 {
2298 if (GetGame().IsServer())
2299 {
2300 if (HasRadiator())
2301 {
2302 m_RadiatorHealth = GetRadiator().GetHealth01("", "");
2303 }
2304 else
2305 {
2306 m_RadiatorHealth = 0;
2307 }
2308
2309 m_EngineHealth = GetHealth01("Engine", "");
2310 m_FuelTankHealth = GetHealth01("FuelTank", "");
2311 }
2312 }
2313
2315 {
2316 return m_PlayCrashSoundLight;
2317 }
2318
2319 void SynchCrashLightSound(bool play)
2320 {
2321 if (m_PlayCrashSoundLight != play)
2322 {
2323 m_PlayCrashSoundLight = play;
2324 SetSynchDirty();
2325 }
2326 }
2327
2329 {
2330 PlaySoundEx("offroad_hit_light_SoundSet", m_CrashSoundLight, m_PlayCrashSoundLight);
2331 }
2332
2334 {
2335 return m_PlayCrashSoundHeavy;
2336 }
2337
2338 void SynchCrashHeavySound(bool play)
2339 {
2340 if (m_PlayCrashSoundHeavy != play)
2341 {
2342 m_PlayCrashSoundHeavy = play;
2343 SetSynchDirty();
2344 }
2345 }
2346
2348 {
2349 PlaySoundEx("offroad_hit_heavy_SoundSet", m_CrashSoundHeavy, m_PlayCrashSoundHeavy);
2350 }
2351
2352 void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
2353 {
2354 #ifndef SERVER
2355 if (!sound)
2356 {
2358 if( sound )
2359 {
2360 sound.SetAutodestroy(true);
2361 }
2362 }
2363 else
2364 {
2365 if (!sound.IsSoundPlaying())
2366 {
2367 sound.SetPosition(GetPosition());
2368 sound.SoundPlay();
2369 }
2370 }
2371
2372 soundbool = false;
2373 #endif
2374 }
2375
2376 void PlaySound(string soundset, EffectSound sound, out bool soundbool)
2377 {
2378 PlaySoundEx(soundset, sound, soundbool);
2379 }
2380
2381 string GetAnimSourceFromSelection( string selection )
2382 {
2383 return "";
2384 }
2385
2386 string GetDoorConditionPointFromSelection( string selection )
2387 {
2388 switch( selection )
2389 {
2390 case "seat_driver":
2391 return "seat_con_1_1";
2392 break;
2393 case "seat_codriver":
2394 return "seat_con_2_1";
2395 break;
2396 case "seat_cargo1":
2397 return "seat_con_1_2";
2398 break;
2399 case "seat_cargo2":
2400 return "seat_con_2_2";
2401 break;
2402 }
2403
2404 return "";
2405 }
2406
2408 {
2409 return "";
2410 }
2411
2413 {
2414 return "";
2415 }
2416
2417 int GetCrewIndex( string selection )
2418 {
2419 return -1;
2420 }
2421
2422 override bool CanReachSeatFromDoors( string pSeatSelection, vector pFromPos, float pDistance = 1.0 )
2423 {
2424 string conPointName = GetDoorConditionPointFromSelection(pSeatSelection);
2425 if (conPointName.Length() > 0)
2426 {
2427 if ( MemoryPointExists(conPointName) )
2428 {
2429 vector conPointMS = GetMemoryPointPos(conPointName);
2430 vector conPointWS = ModelToWorld(conPointMS);
2431
2433 conPointWS[1] = 0;
2434 pFromPos[1] = 0;
2435
2436 if (vector.Distance(pFromPos, conPointWS) <= pDistance)
2437 {
2438 return true;
2439 }
2440 }
2441 }
2442
2443 return false;
2444 }
2445
2447 {
2448 return true;
2449 }
2450
2452 {
2453 return true;
2454 }
2455
2457 {
2458 return true;
2459 }
2460
2462 {
2463 return true;
2464 }
2465
2467 {
2468 return true;
2469 }
2470
2472 {
2473 return true;
2474 }
2475
2477 {
2478 return m_Radiator != null;
2479 }
2480
2482 {
2483 return m_Radiator;
2484 }
2485
2487 {
2488 return GetSpeedometerAbsolute() > 3.5;
2489 }
2490
2492 {
2493 return GetHandbrake() > 0.0;
2494 }
2495
2498 {
2500
2501 }
2502
2503 void SetEngineStarted(bool started)
2504 {
2505 m_EngineStarted = started;
2506 }
2507
2508 int GetCarDoorsState(string slotType)
2509 {
2510 return CarDoorState.DOORS_MISSING;
2511 }
2512
2514 {
2515 if (GetAnimationPhase(animation) > 0.5)
2516 {
2517 return CarDoorState.DOORS_OPEN;
2518 }
2519 else
2520 {
2521 return CarDoorState.DOORS_CLOSED;
2522 }
2523 }
2524
2526 {
2527 return "radiator";
2528 }
2529
2531 {
2532 return 2.0;
2533 }
2534
2536 {
2537 return "carradiator";
2538 }
2539
2541 {
2542 return 2.0;
2543 }
2544
2546 {
2547 return "carradiator";
2548 }
2549
2551 {
2552 return 2.0;
2553 }
2554
2555 override bool CanPutIntoHands(EntityAI parent)
2556 {
2557 return false;
2558 }
2559
2561 {
2563 if (!m_InputActionMap)
2564 {
2566 m_InputActionMap = iam;
2567 SetActions();
2568 m_CarTypeActionsMap.Insert(this.Type(), m_InputActionMap);
2569 }
2570 }
2571
2572 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
2573 {
2575 {
2576 m_ActionsInitialize = true;
2578 }
2579
2580 actions = m_InputActionMap.Get(action_input_type);
2581 }
2582
2593
2594 void AddAction(typename actionName)
2595 {
2596 ActionBase action = ActionManagerBase.GetAction(actionName);
2597
2598 if (!action)
2599 {
2600 Debug.LogError("Action " + actionName + " dosn't exist!");
2601 return;
2602 }
2603
2604 typename ai = action.GetInputType();
2605 if (!ai)
2606 {
2607 m_ActionsInitialize = false;
2608 return;
2609 }
2610 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
2611
2612 if (!action_array)
2613 {
2614 action_array = new array<ActionBase_Basic>;
2615 m_InputActionMap.Insert(ai, action_array);
2616 }
2617
2619 {
2620 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action" );
2621 }
2622 action_array.Insert(action);
2623 }
2624
2625 void RemoveAction(typename actionName)
2626 {
2627 PlayerBase player = PlayerBase.Cast(GetGame().GetPlayer());
2628 ActionBase action = player.GetActionManager().GetAction(actionName);
2629 typename ai = action.GetInputType();
2630 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
2631
2632 if (action_array)
2633 {
2634 action_array.RemoveItem(action);
2635 }
2636 }
2637
2638 override bool IsInventoryVisible()
2639 {
2640 return ( GetGame().GetPlayer() && ( !GetGame().GetPlayer().GetCommand_Vehicle() || GetGame().GetPlayer().GetCommand_Vehicle().GetTransport() == this ) );
2641 }
2642
2643 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
2644 {
2645 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
2646
2647 if (newLevel == GameConstants.STATE_RUINED && oldLevel != newLevel)
2648 {
2649 bool dummy;
2650 switch ( zone )
2651 {
2652 case "WindowLR":
2653 case "WindowRR":
2654 if (m_Initialized)
2655 {
2656 PlaySoundEx("offroad_hit_window_small_SoundSet", m_WindowSmall, dummy);
2657 }
2658 break;
2659
2660 case "WindowFront":
2661 case "WindowBack":
2662 case "WindowFrontLeft":
2663 case "WindowFrontRight":
2664 if (m_Initialized)
2665 {
2666 PlaySoundEx("offroad_hit_window_large_SoundSet", m_WindowLarge, dummy);
2667 }
2668 break;
2669
2670 case "Engine":
2671 #ifndef SERVER
2673 #endif
2674 break;
2675 }
2676 }
2677 }
2678
2679 override void EEOnCECreate()
2680 {
2681
2682 float maxVolume = GetFluidCapacity( CarFluid.FUEL );
2683 float amount = Math.RandomFloat(0.0, maxVolume * 0.35 );
2684
2685 Fill( CarFluid.FUEL, amount );
2686 }
2687
2688 /*override void EOnPostFrame(IEntity other, int extra)
2689 {
2690 //Prepared for fix particle simulation when player is not in vehicle
2691 }*/
2692
2694 {
2696 {
2697 m_ForceUpdateLights = true;
2698 SetSynchDirty();
2699 }
2700 }
2701
2703 {
2705 {
2706 m_ForceUpdateLights = false;
2707 SetSynchDirty();
2708 }
2709 }
2710
2711 //Get the engine start battery consumption
2713 {
2714 return m_BatteryConsume;
2715 }
2716
2721
2723 {
2724 return -m_BatteryRecharge;
2725 }
2726
2728 {
2729 if (IsVitalCarBattery())
2730 {
2731 return ItemBase.Cast(FindAttachmentBySlotName("CarBattery"));
2732 }
2733 else if (IsVitalTruckBattery())
2734 {
2735 return ItemBase.Cast(FindAttachmentBySlotName("TruckBattery"));
2736 }
2737
2738 return null;
2739 }
2740
2741 void SetCarHornState(int pState)
2742 {
2743 m_CarHornState = pState;
2744 SetSynchDirty();
2745
2746 if (GetGame().IsServer())
2747 {
2748 GenerateCarHornAINoise(pState);
2749 }
2750 }
2751
2752 // Only used for sound states which happen before engine start
2753 void SetCarEngineSoundState(CarEngineSoundState pState)
2754 {
2755 m_CarEngineSoundState = pState;
2756 SetSynchDirty();
2757 }
2758
2759 protected void GenerateCarHornAINoise(int pState)
2760 {
2761 if (pState != ECarHornState.OFF)
2762 {
2764 {
2765 float noiseMultiplier = 1.0;
2766 if (pState == ECarHornState.LONG)
2767 noiseMultiplier = 2.0;
2768
2769 noiseMultiplier *= NoiseAIEvaluate.GetNoiseReduction(GetGame().GetWeather());
2770
2771 m_NoiseSystem.AddNoiseTarget(GetPosition(), 5, m_NoisePar, noiseMultiplier);
2772 }
2773 }
2774 }
2775
2777 {
2778 return vector.Zero;
2779 }
2780
2782 {
2783 return 1.0;
2784 }
2785
2786#ifdef DEVELOPER
2787 override protected string GetDebugText()
2788 {
2789 string debug_output = super.GetDebugText();
2790 if (GetGame().IsServer())
2791 {
2792 debug_output += m_DebugContactDamageMessage + "\n";
2793 }
2794 debug_output += "Entity momentum: " + GetMomentum();
2795 debug_output += "\nIsEngineON: " + EngineIsOn();
2796
2797 return debug_output;
2798 }
2799#endif
2800
2801 protected void SpawnUniversalParts()
2802 {
2803 GetInventory().CreateInInventory("HeadlightH7");
2804 GetInventory().CreateInInventory("HeadlightH7");
2805 GetInventory().CreateInInventory("HeadlightH7");
2806 GetInventory().CreateInInventory("HeadlightH7");
2807
2808 if (IsVitalCarBattery())
2809 {
2810 GetInventory().CreateInInventory("CarBattery");
2811 GetInventory().CreateInInventory("CarBattery");
2812 }
2813
2814 if (IsVitalTruckBattery())
2815 {
2816 GetInventory().CreateInInventory("TruckBattery");
2817 GetInventory().CreateInInventory("TruckBattery");
2818 }
2819
2820 if (IsVitalRadiator())
2821 {
2822 GetInventory().CreateInInventory("CarRadiator");
2823 GetInventory().CreateInInventory("CarRadiator");
2824 }
2825
2826 if (IsVitalSparkPlug())
2827 {
2828 GetInventory().CreateInInventory("SparkPlug");
2829 GetInventory().CreateInInventory("SparkPlug");
2830 }
2831
2832 if (IsVitalGlowPlug())
2833 {
2834 GetInventory().CreateInInventory("GlowPlug");
2835 GetInventory().CreateInInventory("GlowPlug");
2836 }
2837 }
2838
2839 protected void SpawnAdditionalItems()
2840 {
2841 GetInventory().CreateInInventory("Wrench");
2842 GetInventory().CreateInInventory("LugWrench");
2843 GetInventory().CreateInInventory("Screwdriver");
2844 GetInventory().CreateInInventory("EpoxyPutty");
2845
2846 GetInventory().CreateInInventory("CanisterGasoline");
2847
2848 EntityAI ent;
2849 ItemBase container;
2850 ent = GetInventory().CreateInInventory("CanisterGasoline");
2851 if (Class.CastTo(container, ent))
2852 {
2853 container.SetLiquidType(LIQUID_WATER, true);
2854 }
2855
2856 ent = GetInventory().CreateInInventory("Blowtorch");
2857 if (ent)
2858 {
2859 ent.GetInventory().CreateInInventory("LargeGasCanister");
2860 }
2861
2862 ent = GetInventory().CreateInInventory("Blowtorch");
2863 if (ent)
2864 {
2865 ent.GetInventory().CreateInInventory("LargeGasCanister");
2866 }
2867 }
2868
2869 protected void FillUpCarFluids()
2870 {
2871 Fill(CarFluid.FUEL, 200.0);
2872 Fill(CarFluid.COOLANT, 200.0);
2873 Fill(CarFluid.OIL, 200.0);
2874 }
2875}
Param4< int, int, string, int > TSelectableActionInfoWithColor
Определения EntityAI.c:97
eBleedingSourceType GetType()
Определения BleedingSource.c:63
CarHornActionData ActionData ActionCarHornShort()
Определения ActionCarHorn.c:67
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
ref NoiseParams m_NoisePar
Определения ActionOpenDoors.c:94
ActionPushCarCB ActionPushObjectCB ActionPushCar()
Определения ActionPushCar.c:58
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void RemoveAction(typename actionName)
Определения AdvancedCommunication.c:252
TInputActionMap m_InputActionMap
Определения AdvancedCommunication.c:137
bool m_ActionsInitialize
Определения AdvancedCommunication.c:138
class PASBroadcaster extends AdvancedCommunication IsInventoryVisible
Определения AdvancedCommunication.c:135
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения AdvancedCommunication.c:202
void InitializeActions()
Определения AdvancedCommunication.c:190
override void OnVariablesSynchronized()
Определения AnniversaryMusicSource.c:42
int m_DamageType
Определения AreaDamageComponent.c:11
override void EEItemDetached(EntityAI item, string slot_name)
Определения BaseBuildingBase.c:1827
override void EEItemAttached(EntityAI item, string slot_name)
Определения BaseBuildingBase.c:1818
enum EBoatEffects STOP_OK
enum EBoatEffects START_NO_FUEL
enum EBoatEffects START_OK
CarAutomaticGearboxMode
Enumerated automatic gearbox modes. (native, do not change or extend)
Определения Car.c:69
CarSoundCtrl
Car's sound controller list. (native, do not change or extend)
Определения Car.c:4
CarFluid
Type of vehicle's fluid. (native, do not change or extend)
Определения Car.c:19
CarGearboxType
Enumerated gearbox types. (native, do not change or extend)
Определения Car.c:35
bool m_HeadlightsOn
Определения CarScript.c:234
void CreateCarDestroyedEffect()
Определения CarScript.c:652
void SetEngineStarted(bool started)
Определения CarScript.c:2503
void OnBrakesPressed()
Определения CarScript.c:1105
static const int SELECTION_ID_TAIL_LIGHT_R
Определения CarScript.c:267
void SpawnUniversalParts()
Определения CarScript.c:2801
string m_CarSeatShiftInSound
Определения CarScript.c:215
void ReverseLightsShineOn()
Определения CarScript.c:2148
enum CarDoorState START_NO_BATTERY
void OnVehicleJumpOutServer(GetOutTransportActionData gotActionData)
Определения CarScript.c:1116
void TailLightsShineOn()
Определения CarScript.c:2192
void SetCarEngineSoundState(CarEngineSoundState pState)
Определения CarScript.c:2753
vector m_VelocityPrevTick
Определения CarScript.c:143
CarDoorState TranslateAnimationPhaseToCarDoorState(string animation)
Определения CarScript.c:2513
float GetEnviroHeatComfortOverride()
DEPRECATED.
ItemBase GetBattery()
Определения CarScript.c:2727
CarDoorState
Определения CarScript.c:2
@ DOORS_CLOSED
Определения CarScript.c:5
@ DOORS_MISSING
Определения CarScript.c:3
@ DOORS_OPEN
Определения CarScript.c:4
void SpawnAdditionalItems()
Определения CarScript.c:2839
void BrakeLightsShineOff()
Определения CarScript.c:2181
float GetActionDistanceBrakes()
Определения CarScript.c:2550
ref EffVehicleSmoke m_coolantFx
Particles.
Определения CarScript.c:185
string m_EngineStartOK
Sounds.
Определения CarScript.c:207
void PlayCrashHeavySound()
Определения CarScript.c:2347
float m_FuelTankHealth
Определения CarScript.c:171
vector GetEnginePosWS()
Определения CarScript.c:448
static string m_RightHeadlightPoint
Определения CarScript.c:253
void DashboardShineOff()
Определения CarScript.c:2238
enum CarDoorState m_CarTypeActionsMap
ref array< ref EffWheelSmoke > m_WheelSmokeFx
Определения CarScript.c:270
override int Get3rdPersonCameraType()
camera type
Определения CarScript.c:2497
float GetBatteryRuntimeConsumption()
Определения CarScript.c:2717
float GetBatteryConsumption()
Определения CarScript.c:2712
void UpdateLightsServer(int newGear=-1)
Определения CarScript.c:1969
float m_BatteryHealth
Определения CarScript.c:172
void BrakeLightsShineOn()
Определения CarScript.c:2170
void CheckVitalItem(bool isVital, string itemName)
Определения CarScript.c:2260
static string m_DrownEnginePoint
Определения CarScript.c:256
void ReverseLightsShineOff()
Определения CarScript.c:2159
override bool OnBeforeEngineStart()
Определения CarScript.c:1715
vector m_exhaustPtcPos
Определения CarScript.c:193
int m_CarHornState
Определения CarScript.c:243
void GenerateCarHornAINoise(int pState)
Определения CarScript.c:2759
string m_CarDoorCloseSound
Определения CarScript.c:214
void ~CarScript()
Определения CarScript.c:508
int m_coolantPtcFx
Определения CarScript.c:190
vector m_enginePos
Определения CarScript.c:198
ref EffectSound m_WindowLarge
Определения CarScript.c:224
enum CarDoorState LONG
static string m_LeftHeadlightPoint
Определения CarScript.c:252
void RightFrontLightShineOn()
Определения CarScript.c:2118
vector m_backPos
Определения CarScript.c:200
void ForceUpdateLightsStart()
Определения CarScript.c:2693
void PlayCrashLightSound()
Определения CarScript.c:2328
static string m_ReverseLightPoint
Определения CarScript.c:251
int m_enginePtcFx
Определения CarScript.c:189
void DamageCrew(float dmg)
Responsible for damaging crew in a car crash.
Определения CarScript.c:1420
static const int SELECTION_ID_BRAKE_LIGHT_R
Определения CarScript.c:263
void ForceUpdateLightsEnd()
Определения CarScript.c:2702
void CleanupSound(EffectSound sound)
Определения CarScript.c:546
ref EffectSound m_WindowSmall
Определения CarScript.c:223
static const int SELECTION_ID_REVERSE_LIGHT_L
Определения CarScript.c:264
string m_EngineStartBattery
Определения CarScript.c:208
ref EffVehicleSmoke m_engineFx
Определения CarScript.c:186
float m_EngineHealth
Определения CarScript.c:169
void BrakesRearLight()
Определения CarScript.c:2086
float m_BatteryEnergyStartMin
Определения CarScript.c:182
static string m_LeftHeadlightTargetPoint
Определения CarScript.c:254
float m_DrownTime
Определения CarScript.c:165
int m_CarEngineSoundState
Определения CarScript.c:244
enum CarDoorState SHORT
float m_EnviroHeatComfortOverride
Определения CarScript.c:162
float m_BrakeAmmount
Определения CarScript.c:157
bool GetCrashHeavySound()
Определения CarScript.c:2333
string GetActionCompNameCoolant()
Определения CarScript.c:2525
float m_CoolantAmmount
Определения CarScript.c:155
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
Определения CarScript.c:1311
static float DROWN_ENGINE_DAMAGE
Определения CarScript.c:149
float m_BatteryContinuousConsume
Определения CarScript.c:178
string GetActionCompNameBrakes()
Определения CarScript.c:2545
string m_EngineStartPlug
Определения CarScript.c:209
bool m_ForceUpdateLights
Определения CarScript.c:239
int m_CarEngineLastSoundState
Определения CarScript.c:245
bool m_EngineStarted
Определения CarScript.c:240
EntityAI m_Radiator
Определения CarScript.c:175
ref EffectSound m_PreStartSound
Определения CarScript.c:225
bool m_PlayCrashSoundLight
Определения CarScript.c:231
bool m_BrakesArePressed
Определения CarScript.c:236
ref EffectSound m_CrashSoundHeavy
Определения CarScript.c:222
float m_OilAmmount
Определения CarScript.c:156
void SetCarHornState(int pState)
Определения CarScript.c:2741
static const int SELECTION_ID_BRAKE_LIGHT_L
Определения CarScript.c:262
override void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
Определения CarScript.c:1687
override vector GetDefaultHitPosition()
Определения CarScript.c:2776
bool IsHandbrakeActive()
Определения CarScript.c:2491
int m_exhaustPtcFx
Определения CarScript.c:191
void HandleCarHornSound(ECarHornState pState)
Определения CarScript.c:1548
void UpdateLightsClient(int newGear=-1)
Определения CarScript.c:1850
float m_BatteryTimer
Определения CarScript.c:180
bool IsMoving()
Определения CarScript.c:2486
override void HandleByCrewMemberState(ECrewMemberState state)
Определения CarScript.c:1644
vector Get_1_2PointPosWS()
Определения CarScript.c:474
void NoRearLight()
Определения CarScript.c:2102
string m_EngineStartFuel
Определения CarScript.c:210
void CleanupEffects()
Определения CarScript.c:515
override bool DetectFlipped(VehicleFlippedContext ctx)
Определения CarScript.c:1190
void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
Определения CarScript.c:2352
void LeakFluid(CarFluid fluid)
Определения CarScript.c:2273
string m_CarHornShortSoundName
Определения CarScript.c:218
NoiseSystem m_NoiseSystem
Определения CarScript.c:229
float m_MomentumPrevTick
Определения CarScript.c:142
static const int SELECTION_ID_FRONT_LIGHT_R
Определения CarScript.c:261
vector Get_2_2PointPosWS()
Определения CarScript.c:482
void BrakeAndReverseRearLight()
Определения CarScript.c:2096
void UpdateLights(int new_gear=-1)
Определения CarScript.c:1842
bool HasRadiator()
Определения CarScript.c:2476
static float DROWN_ENGINE_THRESHOLD
Определения CarScript.c:148
static const int SELECTION_ID_FRONT_LIGHT_L
Определения CarScript.c:260
void DashboardShineOn()
Определения CarScript.c:2228
static string m_RightHeadlightTargetPoint
Определения CarScript.c:255
vector Get_1_1PointPosWS()
Определения CarScript.c:470
const float BATTERY_UPDATE_DELAY
Определения CarScript.c:181
enum CarDoorState STARTING
void FillUpCarFluids()
Определения CarScript.c:2869
ref array< int > m_WheelSmokePtcFx
Определения CarScript.c:271
vector m_coolantPtcPos
Определения CarScript.c:196
vector m_frontPos
Определения CarScript.c:199
override void OnGearChanged(int newGear, int oldGear)
Определения CarScript.c:1790
override string GetVehicleType()
Определения CarScript.c:443
float GetActionDistanceOil()
Определения CarScript.c:2540
vector m_side_1_2Pos
Определения CarScript.c:202
string GetActionCompNameOil()
Определения CarScript.c:2535
void ReverseRearLight()
Определения CarScript.c:2091
float GetActionDistanceCoolant()
Определения CarScript.c:2530
static const string MEMORY_POINT_NAME_CAR_HORN
Определения CarScript.c:151
vector GetEnginePointPosWS()
Определения CarScript.c:458
vector GetCoolantPtcPosWS()
Определения CarScript.c:453
float m_BatteryRecharge
Определения CarScript.c:179
static const int SELECTION_ID_TAIL_LIGHT_L
Определения CarScript.c:266
vector GetFrontPointPosWS()
Определения CarScript.c:462
void ToggleHeadlights()
Switches headlights on/off, including the illumination of the control panel and synchronizes this cha...
Определения CarScript.c:1836
enum CarDoorState REVERSE_ONLY
float m_BatteryConsume
Определения CarScript.c:177
float GetBatteryRechargeRate()
Определения CarScript.c:2722
float m_FuelAmmount
keeps ammount of each fluid
Определения CarScript.c:154
void LeftFrontLightShineOn()
Определения CarScript.c:2108
vector m_enginePtcPos
Определения CarScript.c:195
void HandleDoorsSound(string animSource, float phase)
Определения CarScript.c:1505
vector m_exhaustPtcDir
Определения CarScript.c:194
bool m_EngineDestroyed
Определения CarScript.c:241
override bool CanReachSeatFromDoors(string pSeatSelection, vector pFromPos, float pDistance=1.0)
Определения CarScript.c:2422
void LeftFrontLightShineOff()
Определения CarScript.c:2128
string m_CarHornLongSoundName
Определения 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.
Определения CarScript.c:1282
ref EffVehicleSmoke m_exhaustFx
Определения CarScript.c:187
vector GetBackPointPosWS()
Определения CarScript.c:466
vector m_side_1_1Pos
Определения CarScript.c:201
CarRearLightBase m_RearLight
Определения CarScript.c:248
enum CarDoorState BRAKES_ONLY
ref EffectSound m_CrashSoundLight
Определения CarScript.c:221
bool CheckOperationalState()
Определения CarScript.c:1759
string m_EngineStopFuel
Определения CarScript.c:211
bool OnBeforeSwitchLights(bool toOn)
Определения CarScript.c:1824
void SynchCrashHeavySound(bool play)
Определения CarScript.c:2338
vector m_side_2_2Pos
Определения CarScript.c:204
void RightFrontLightShineOff()
Определения CarScript.c:2138
void OnBrakesReleased()
Определения CarScript.c:1110
ref EffectSound m_CarHornSoundEffect
Определения CarScript.c:227
void TailLightsShineOff()
Определения CarScript.c:2217
float m_PlugHealth
Определения CarScript.c:173
EntityAI GetRadiator()
Определения CarScript.c:2481
void UpdateHeadlightState()
Определения CarScript.c:714
float m_dmgContactCoef
Определения CarScript.c:161
void CarScript()
Определения CarScript.c:280
vector m_side_2_1Pos
Определения CarScript.c:203
bool m_RearLightType
Определения CarScript.c:237
void SynchCrashLightSound(bool play)
Определения CarScript.c:2319
bool GetCrashLightSound()
Определения CarScript.c:2314
vector Get_2_1PointPosWS()
Определения CarScript.c:478
override float GetLiquidThroughputCoef()
Определения CarScript.c:487
string m_CarSeatShiftOutSound
Определения CarScript.c:216
static const int SELECTION_ID_DASHBOARD_LIGHT
Определения CarScript.c:268
void HandleSeatAdjustmentSound(string animSource, float phase)
Определения CarScript.c:1528
void HandleEngineSound(CarEngineSoundState state)
Определения CarScript.c:1564
void CarPartsHealthCheck()
Определения CarScript.c:2296
enum CarDoorState START_NO_SPARKPLUG
static const int SELECTION_ID_REVERSE_LIGHT_R
Определения CarScript.c:265
bool m_PlayCrashSoundHeavy
Определения CarScript.c:232
bool IsScriptedLightsOn()
Propper way to get if light is swiched on. Use instead of IsLightsOn().
Определения CarScript.c:1830
float m_RadiatorHealth
Определения CarScript.c:170
string m_CarDoorOpenSound
Определения CarScript.c:213
bool IsVitalFuelTank()
Определения CarScript.c:2471
static vector m_DrownEnginePos
Определения CarScript.c:166
bool m_HeadlightsState
Определения CarScript.c:235
ref CarContactCache m_ContactCache
Определения CarScript.c:144
CarLightBase m_Headlight
Определения CarScript.c:247
class EconomyOutputStrings OFF
void Synchronize()
Определения CombinationLock.c:151
override void EEDelete(EntityAI parent)
Определения ContaminatedArea.c:57
map
Определения ControlsXboxNew.c:4
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
EActions
Определения EActions.c:2
ECrewMemberState
Определения ECrewMemberState.c:2
ERPCs
Определения ERPCs.c:2
void Effect()
ctor
Определения Effect.c:70
override void EEKilled(Object killer)
Определения ExplosivesBase.c:100
override bool CanPutIntoHands(EntityAI parent)
Определения ExplosivesBase.c:287
override void OnAttachmentRuined(EntityAI attachment)
Определения FireplaceBase.c:371
void PlaySound()
Определения HungerSoundHandler.c:38
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения ItemBase.c:7114
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения ItemBase.c:8848
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения ItemBase.c:7071
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения ItemBase.c:6808
override void EEOnCECreate()
Called when entity is being created as new by CE/ Debug.
Определения ItemBase.c:8781
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения ItemBase.c:6267
string Type
Определения JsonDataContaminatedArea.c:11
static string GetDisplayName(int liquid_type)
Определения Liquid.c:382
string GetDebugText()
Определения ModifierBase.c:71
PlayerBase GetPlayer()
Определения ModifierBase.c:51
class NoiseSystem NoiseParams()
Определения Noise.c:15
float GetTime()
Определения NotificationSystem.c:35
ProcessDirectDamageFlags
Определения Object.c:2
BOTH
Определения PluginRecipesManagerBase.c:2
WaveKind
Определения Sound.c:2
bool m_Initialized
Определения UiHintPanel.c:317
float m_Time
Определения WoundInfection.c:22
GetInputType()
Определения ActionBase.c:215
Определения ActionBase.c:53
const int SHOCK_FACTOR
Определения ActionGetOutTransport.c:27
const int LOW_SPEED_VALUE
Определения ActionGetOutTransport.c:30
const int HEALTH_HIGH_SPEED_VALUE
Определения ActionGetOutTransport.c:37
const int HIGH_SPEED_VALUE
Определения ActionGetOutTransport.c:31
const int HEALTH_LOW_SPEED_VALUE
Определения ActionGetOutTransport.c:36
const int DMG_FACTOR
Определения ActionGetOutTransport.c:26
proto native NoiseSystem GetNoiseSystem()
proto native void RPCSingleParam(Object target, int rpc_type, Param param, bool guaranteed, PlayerIdentity recipient=null)
see CGame.RPC
override ScriptCallQueue GetCallQueue(int call_category)
Определения DayZGame.c:1187
proto float SurfaceGetType(float x, float z, out string type)
Returns: Y position the surface was found.
proto int GetTime()
returns mission time in milliseconds
Определения CarRearLightBase.c:2
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Определения CivilianSedan.c:284
override bool IsVitalEngineBelt()
Определения Truck_01_Base.c:350
override string GetDoorSelectionNameFromSeatPos(int posIdx)
Определения CivilianSedan.c:240
override int GetCrewIndex(string selection)
Определения OffroadHatchback.c:358
override CarRearLightBase CreateRearLight()
Определения CivilianSedan.c:109
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Определения CivilianSedan.c:261
override string GetDoorConditionPointFromSelection(string selection)
Определения OffroadHatchback.c:341
override CarLightBase CreateFrontLight()
Определения CivilianSedan.c:103
override bool IsVitalGlowPlug()
Определения CivilianSedan.c:353
override int GetCarDoorsState(string slotType)
Определения CivilianSedan.c:163
override bool IsVitalTruckBattery()
Определения CivilianSedan.c:348
override void OnAnimationPhaseStarted(string animSource, float phase)
Определения Truck_01_Base.c:222
override string GetAnimSourceFromSelection(string selection)
Определения CivilianSedan.c:327
override void EOnPostSimulate(IEntity other, float timeSlice)
Определения CivilianSedan.c:64
override void OnEngineStart()
Определения CivilianSedan.c:44
override bool CanReleaseAttachment(EntityAI attachment)
Определения CivilianSedan.c:114
override void SetActions()
Определения OffroadHatchback.c:440
override void EEInit()
Определения CivilianSedan.c:26
override bool IsVitalRadiator()
Определения Offroad_02.c:384
override bool IsVitalCarBattery()
Определения Truck_01_Base.c:335
override bool IsVitalSparkPlug()
Определения Offroad_02.c:379
bool CanManipulateSpareWheel(string slotSelectionName)
Определения CivilianSedan.c:130
override float GetPushForceCoefficientMultiplier()
Определения CivilianSedan.c:421
override void OnEngineStop()
Определения CivilianSedan.c:54
Определения CivilianSedan.c:2
Определения InventoryItem.c:413
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения DallasMask.c:2
Определения EnPhysics.c:305
static const int DAYZCAMERA_3RD_VEHICLE
generic vehicle 3rd person
Определения DayZPlayerCameras.c:19
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.
Определения Debug.c:245
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.
Определения Debug.c:122
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения Debug.c:127
Определения Debug.c:2
Определения CoolantSteam.c:2
Определения EngineSmoke.c:2
Определения ExhaustSmoke.c:2
Определения VehicleSmoke.c:2
const float WHEEL_SMOKE_THRESHOLD
Определения WheelSmoke.c:3
void SetSurface(string surface)
Определения WheelSmoke.c:9
Определения WheelSmoke.c:2
override void Stop()
Stops all elements this effect consists of.
Определения EffectParticle.c:204
override void Start()
Plays all elements this effect consists of.
Определения EffectParticle.c:181
override void SetCurrentLocalPosition(vector pos, bool updateCached=true)
Set the current local position of the managed Particle.
Определения EffectParticle.c:411
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:603
void SetSoundWaveKind(WaveKind wave_kind)
Set WaveKind for the sound.
Определения EffectSound.c:771
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
bool SoundPlay()
Plays sound.
Определения EffectSound.c:199
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
Определения Building.c:6
Определения constants.c:659
Определения GreatHelm.c:2
Определения EnEntity.c:165
proto native EntityAI GetParent()
returns parent of current inventory location
proto native int GetSlot()
returns slot id if current type is Attachment
InventoryLocation.
Определения InventoryLocation.c:29
static proto bool GetSelectionForSlotId(int slot_Id, out string selection)
provides access to slot configuration
Определения InventorySlots.c:6
Определения InventoryItem.c:731
static bool IsActionLogEnable()
Определения Debug.c:638
Определения Debug.c:594
Определения EnMath.c:7
static float GetNoiseReduction(Weather weather)
Определения SensesAIEvaluate.c:18
Определения Noise.c:2
Определения ObjectTyped.c:2
Определения PlayerBaseClient.c:2
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.
Определения EffectManager.c:207
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.
Определения EffectManager.c:70
static int CreateParticleServer(vector pos, EffecterParameters parameters)
returns unique effecter ID
Определения EffectManager.c:577
static void Stop(int effect_id)
Stops the Effect.
Определения EffectManager.c:110
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.
Определения EffectManager.c:169
static bool IsEffectExist(int effect_id)
Checks whether an Effect ID is registered in SEffectManager.
Определения EffectManager.c:294
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.
Определения EffectManager.c:144
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Определения EffectManager.c:271
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
proto void CallLater(func fn, int delay=0, bool repeat=false, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
adds call into the queue with given parameters and arguments (arguments are held in memory until the ...
static int GetWheelParticleID(string surface_name)
Определения Surface.c:8
Определения Surface.c:2
Определения DamageSystem.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
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.
Определения EnConvert.c:271
static const vector Zero
Определения EnConvert.c:110
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Определения EnConvert.c:220
proto vector InvMultiply3(vector mat[3])
Invert-transforms vector.
static proto native float Distance(vector v1, vector v2)
Returns the distance between tips of two 3D vectors.
static const vector Up
Определения EnConvert.c:107
Определения EnConvert.c:106
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
Serializer ParamsReadContext
Определения gameplay.c:15
proto native CGame GetGame()
const float CARS_CONTACT_DMG_THRESHOLD
Определения constants.c:836
const float CARS_CONTACT_DMG_MIN
Определения constants.c:837
const float CARS_CONTACT_DMG_KILLCREW
Определения constants.c:838
const int CARS_FLUIDS_TICK
Определения constants.c:825
float Impulse
Определения EnPhysics.c:318
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.
Определения EnEntity.c:45
@ CONTACT
Определения EnEntity.c:97
const float DAMAGE_RUINED_VALUE
Определения constants.c:862
const float DAMAGE_DAMAGED_VALUE
Определения constants.c:860
const int STATE_RUINED
Определения constants.c:846
const float LIQUID_THROUGHPUT_CAR_DEFAULT
Определения constants.c:570
const int LIQUID_WATER
Определения constants.c:539
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,...
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
static proto float AbsFloat(float f)
Returns absolute value.
static int RandomIntInclusive(int min, int max)
Returns a random int number between and min [inclusive] and max [inclusive].
Определения EnMath.c:54
@ LEFT
Определения EnSystem.c:312
@ RIGHT
Определения EnSystem.c:313
@ NONE
No flags.
Определения EnProfiler.c:11
proto native vector dBodyGetVelocityAt(notnull IEntity body, vector globalpos)
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native float dBodyGetMass(notnull IEntity ent)
const int SAT_DEBUG_ACTION
Определения constants.c:452
class JsonUndergroundAreaTriggerData GetPosition
Определения UndergroundAreaLoader.c:9
proto native int Length()
Returns length of string.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
const int CALL_CATEGORY_GAMEPLAY
Определения tools.c:10
proto native void OnUpdate()
Определения tools.c:349
const float VEHICLE_FLIP_ANGLE_TOLERANCE
Определения constants.c:816
const bool VEHICLE_FLIP_WHEELS_LIMITED
Angle of the vehicle from the normal of the surface under the vehicle.
Определения constants.c:817