DayZ 1.29
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 ECarOperationalState
25{
26 OK = 0,
27 RUINED = 1,
31}
32
33enum CarEngineSoundState
34{
35 NONE,
42 STOP_NO_FUEL
43}
44
45enum ECarHornState
46{
47 OFF = 0,
48 SHORT = 1,
49 LONG = 2
50}
51
52#ifdef DIAG_DEVELOPER
53enum EVehicleDebugOutputType
54{
55 NONE,
56 DAMAGE_APPLIED = 1,
57 DAMAGE_CONSIDERED = 2,
58 CONTACT = 4
59 //OTHER = 8
60 //OTHER = 16
61}
62
63class CrashDebugData
64{
65 static ref array<ref CrashDebugData> m_CrashData = new array<ref CrashDebugData>;
66 static ref CrashDebugData m_CrashDataPoint;
67 //data is recorded on server, upon request, sent to the client
68 static void SendData(PlayerBase player)
69 {
70 /*
71 m_CrashData.Clear();
72 CrashDebugData fakeData = new CrashDebugData();
73 fakeData.m_VehicleType = "FakeVehicle";
74 m_CrashData.Insert(fakeData);
75 */
76 g_Game.RPCSingleParam(player, ERPCs.DIAG_VEHICLES_DUMP_CRASH_DATA_CONTENTS, new Param1<array<ref CrashDebugData>>(m_CrashData), true, player.GetIdentity());
77 }
78
79 //this is client requesting to dump the data it previously received from the server
80 static void DumpDataArray(array<ref CrashDebugData> dataArray)
81 {
82 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");
83 foreach (CrashDebugData data:dataArray)
84 {
85 DumpData(data);
86 }
87 }
88
89 static void DumpData(CrashDebugData data)
90 {
91 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;
92 output += ";"+data.m_SpeedWorld+";"+data.m_SpeedWorldPrev+";"+data.m_SpeedWorldDelta+";"+data.m_VelocityCur;
93 output += ";"+data.m_VelocityPrev+";"+data.m_VelocityDot+";"+data.m_Time+";"+data.m_CrewDamageBase+";"+data.m_ShockTemp+";"+data.m_DMGHealth+";"+data.m_DMGShock;
94 Print(output);
95 }
96
97 string m_VehicleType;
98 string m_DamageType;
99 float m_Damage;
100 string m_Zone;
101 float m_MomentumCurr;
102 float m_MomentumPrev;
103 float m_MomentumDelta;
104 float m_Speedometer;
105 float m_SpeedWorld;
106 float m_SpeedWorldPrev;
107 float m_SpeedWorldDelta;
108 vector m_VelocityCur;
109 vector m_VelocityPrev;
110 float m_VelocityDot;
111 float m_Time;
112 float m_CrewDamageBase;
113 float m_ShockTemp;
114 float m_DMGHealth;
115 float m_DMGShock;
116}
117
118#endif
119class CarContactData
120{
121 vector localPos;
122 IEntity other;
123 float impulse;
124
125 void CarContactData(vector _localPos, IEntity _other, float _impulse)
126 {
127 localPos = _localPos;
128 other = _other;
129 impulse = _impulse;
130 }
131}
132
134
135class CarScriptOwnerState : CarOwnerState
136{
137 float m_fTime;
138
139 protected override event void Write(PawnStateWriter ctx)
140 {
141 ctx.Write(m_fTime);
142 }
143
144 protected override event void Read(PawnStateReader ctx)
145 {
146 ctx.Read(m_fTime);
147 }
148};
149
151{
152};
153
154#ifdef DIAG_DEVELOPER
155enum ECarDebugMode
156{
157 NONE,
158 FORWARD_10,
159 FORWARD_50,
160};
161#endif
162
163#ifdef DIAG_DEVELOPER
164CarScript _car;
165#endif
166
170class CarScript extends Car
171{
172 #ifdef DIAG_DEVELOPER
173 static EVehicleDebugOutputType DEBUG_OUTPUT_TYPE;
174 bool m_ContactCalled;
175 #endif
179 protected float m_MomentumPrevTick;
181 ref CarContactCache m_ContactCache;
182
183 protected float m_Time;
184
185 static float DROWN_ENGINE_THRESHOLD = 0.5;
186 static float DROWN_ENGINE_DAMAGE = 350.0;
187
188 static const string MEMORY_POINT_NAME_CAR_HORN = "pos_carHorn";
189
191 protected float m_FuelAmmount;
192 protected float m_CoolantAmmount;
193 protected float m_OilAmmount;
194 protected float m_BrakeAmmount;
195
197 //protected float m_dmgContactCoef = 0.023;
198 protected float m_dmgContactCoef = 0.058;
200
202 protected float m_DrownTime;
204
206 protected float m_EngineHealth;
207 protected float m_RadiatorHealth;
208 protected float m_FuelTankHealth;
209 protected float m_BatteryHealth;
210 protected float m_PlugHealth;
211
213
214 protected float m_BatteryConsume = 15; //Battery energy consumption upon engine start
215 protected float m_BatteryContinuousConsume = 0.25; //Battery consumption with lights on and engine is off
216 protected float m_BatteryRecharge = 0.15; //Battery recharge rate when engine is on
217 private float m_BatteryTimer = 0; //Used to factor energy consumption / recharging
218 private const float BATTERY_UPDATE_DELAY = 100;
219
224
225 protected int m_enginePtcFx;
226 protected int m_coolantPtcFx;
227 protected int m_exhaustPtcFx;
228
233
236 protected vector m_backPos;
241
243 string m_EngineStartOK = "";
245 string m_EngineStartPlug = "";
246 string m_EngineStartFuel = "";
247 string m_EngineStop = "";
248 string m_EngineStopFuel = "";
249
254
257
263
265 protected ref NoiseParams m_NoisePar;
267
268 protected bool m_PlayCrashSoundLight;
269 protected bool m_PlayCrashSoundHeavy;
270
271 protected int m_HeadlightsState;
272 protected int m_RearLightType;
273
274 protected bool m_ForceUpdateLights;
275 protected bool m_EngineStarted;
276 protected bool m_EngineDestroyed;
277
278 protected int m_CarHornState;
279
282
283 // Memory points
284 static string m_ReverseLightPoint = "light_reverse";
285 static string m_LeftHeadlightPoint = "light_left";
286 static string m_RightHeadlightPoint = "light_right";
287 static string m_LeftHeadlightTargetPoint = "light_left_dir";
288 static string m_RightHeadlightTargetPoint = "light_right_dir";
289 static string m_DrownEnginePoint = "drown_engine";
290
291 // Model selection IDs for texture/material changes
292 // If each car needs different IDs, then feel free to remove the 'static' flag and overwrite these numbers down the hierarchy
293 static const int SELECTION_ID_FRONT_LIGHT_L = 0;
294 static const int SELECTION_ID_FRONT_LIGHT_R = 1;
295 static const int SELECTION_ID_BRAKE_LIGHT_L = 2;
296 static const int SELECTION_ID_BRAKE_LIGHT_R = 3;
297 static const int SELECTION_ID_REVERSE_LIGHT_L = 4;
298 static const int SELECTION_ID_REVERSE_LIGHT_R = 5;
299 static const int SELECTION_ID_TAIL_LIGHT_L = 6;
300 static const int SELECTION_ID_TAIL_LIGHT_R = 7;
301 static const int SELECTION_ID_DASHBOARD_LIGHT = 8;
302
305
308
309 #ifdef DEVELOPER
310 private const int DEBUG_MESSAGE_CLEAN_TIME_SECONDS = 10;
311 private float m_DebugMessageCleanTime;
312 private string m_DebugContactDamageMessage;
313 #endif
314
315#ifdef DIAG_DEVELOPER
316 ECarDebugMode m_eDebugMode;
317#endif
318
320 {
321#ifdef DIAG_DEVELOPER
322 _car = this;
323#endif
324
325 SetEventMask(EntityEvent.POSTSIMULATE);
326 SetEventMask(EntityEvent.POSTFRAME);
327
328 m_ContactCache = new CarContactCache;
329
330 m_Time = 0;
331 // sets max health for all components at init
332 m_EngineHealth = 1;
334 m_RadiatorHealth = -1;
335 m_BatteryHealth = -1;
336 m_PlugHealth = -1;
337
338 m_enginePtcFx = -1;
339 m_coolantPtcFx = -1;
340 m_exhaustPtcFx = -1;
341
343
344 m_PlayCrashSoundLight = false;
345 m_PlayCrashSoundHeavy = false;
346
347 m_CarHornState = ECarHornState.OFF;
348 m_CarEngineSoundState = CarEngineSoundState.NONE;
349
350 RegisterNetSyncVariableBool("m_BrakesArePressed");
351 RegisterNetSyncVariableBool("m_ForceUpdateLights");
352 RegisterNetSyncVariableBoolSignal("m_PlayCrashSoundLight");
353 RegisterNetSyncVariableBoolSignal("m_PlayCrashSoundHeavy");
354 RegisterNetSyncVariableInt("m_CarHornState", ECarHornState.OFF, ECarHornState.LONG);
355 RegisterNetSyncVariableInt("m_CarEngineSoundState", CarEngineSoundState.NONE, CarEngineSoundState.STOP_NO_FUEL);
356
357 if ( MemoryPointExists("ptcExhaust_end") )
358 {
359 m_exhaustPtcPos = GetMemoryPointPos("ptcExhaust_end");
360 if ( MemoryPointExists("ptcExhaust_start") )
361 {
362 vector exhaustStart = GetMemoryPointPos("ptcExhaust_start");
363 vector tempOri = vector.Direction( exhaustStart, m_exhaustPtcPos);
364
365 m_exhaustPtcDir[0] = -tempOri[2];
366 m_exhaustPtcDir[1] = tempOri[1];
367 m_exhaustPtcDir[2] = tempOri[0];
368
369 m_exhaustPtcDir = m_exhaustPtcDir.Normalized().VectorToAngles();
370 }
371 }
372 else
373 {
374 m_exhaustPtcPos = "0 0 0";
375 m_exhaustPtcDir = "1 1 1";
376 }
377
378 if ( MemoryPointExists("ptcEnginePos") )
379 m_enginePtcPos = GetMemoryPointPos("ptcEnginePos");
380 else
381 m_enginePtcPos = "0 0 0";
382
383 if ( MemoryPointExists("ptcCoolantPos") )
384 m_coolantPtcPos = GetMemoryPointPos("ptcCoolantPos");
385 else
386 m_coolantPtcPos = "0 0 0";
387
388 if ( MemoryPointExists("drown_engine") )
389 m_DrownEnginePos = GetMemoryPointPos("drown_engine");
390 else
391 m_DrownEnginePos = "0 0 0";
392
393 if ( MemoryPointExists("dmgZone_engine") )
394 m_enginePos = GetMemoryPointPos("dmgZone_engine");
395 else
396 m_enginePos = "0 0 0";
397
398 if ( MemoryPointExists("dmgZone_front") )
399 m_frontPos = GetMemoryPointPos("dmgZone_front");
400 else
401 m_frontPos = "0 0 0";
402
403 if ( MemoryPointExists("dmgZone_back") )
404 m_backPos = GetMemoryPointPos("dmgZone_back");
405 else
406 m_backPos = "0 0 0";
407
408 if ( MemoryPointExists("dmgZone_fender_1_1") )
409 m_side_1_1Pos = GetMemoryPointPos("dmgZone_fender_1_1");
410 else
411 m_side_1_1Pos = "0 0 0";
412
413 if ( MemoryPointExists("dmgZone_fender_1_2") )
414 m_side_1_2Pos = GetMemoryPointPos("dmgZone_fender_1_2");
415 else
416 m_side_1_2Pos = "0 0 0";
417
418 if ( MemoryPointExists("dmgZone_fender_2_1") )
419 m_side_2_1Pos = GetMemoryPointPos("dmgZone_fender_2_1");
420 else
421 m_side_2_1Pos = "0 0 0";
422
423 if ( MemoryPointExists("dmgZone_fender_2_2") )
424 m_side_2_2Pos = GetMemoryPointPos("dmgZone_fender_2_2");
425 else
426 m_side_2_2Pos = "0 0 0";
427
428 if (!g_Game.IsDedicatedServer())
429 {
431 m_WheelSmokeFx.Resize(WheelCount());
433 m_WheelSmokePtcFx.Resize(WheelCount());
434 for (int i = 0; i < m_WheelSmokePtcFx.Count(); i++)
435 {
436 m_WheelSmokePtcFx.Set(i, -1);
437 }
438 }
439 }
440
441 override void EEInit()
442 {
443 super.EEInit();
444
445 if (g_Game.IsServer())
446 {
447 m_NoiseSystem = g_Game.GetNoiseSystem();
449 {
450 m_NoisePar = new NoiseParams();
451 m_NoisePar.LoadFromPath("cfgVehicles " + GetType() + " NoiseCarHorn");
452 }
453 }
454 }
455
456 #ifdef DIAG_DEVELOPER
457
458 override void FixEntity()
459 {
460 if (g_Game.IsServer())
461 {
462 FillUpCarFluids();
463 //server and single
464
465 for (int i = 5; i > 0; i--)//there is a problem with wheels when performed only once, this solves it
466 super.FixEntity();
467 if (!g_Game.IsMultiplayer())
468 {
469 //single
470 SEffectManager.DestroyEffect(m_engineFx);
471 }
472 }
473 else
474 {
475 //MP client
476 SEffectManager.DestroyEffect(m_engineFx);
477 }
478 }
479 #endif
480
481 override string GetVehicleType()
482 {
483 return "VehicleTypeCar";
484 }
485
487 {
488 return ModelToWorld( m_DrownEnginePos );
489 }
490
492 {
493 return ModelToWorld( m_coolantPtcPos );
494 }
495
497 {
498 return ModelToWorld( m_enginePos );
499 }
501 {
502 return ModelToWorld( m_frontPos );
503 }
505 {
506 return ModelToWorld( m_backPos );
507 }
509 {
510 return ModelToWorld( m_side_1_1Pos );
511 }
513 {
514 return ModelToWorld( m_side_1_2Pos );
515 }
517 {
518 return ModelToWorld( m_side_2_1Pos );
519 }
521 {
522 return ModelToWorld( m_side_2_2Pos );
523 }
524
525 override float GetLiquidThroughputCoef()
526 {
528 }
529
530 //here we should handle the damage dealt in OnContact event, but maybe we will react even in that event
531 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
532 {
533 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
534
536 g_Game.GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(ForceUpdateLightsEnd, 100, false);
537 }
538
539 override void EEDelete(EntityAI parent)
540 {
541 #ifndef SERVER
543 #endif
544 }
545
547 {
548 #ifndef SERVER
550 #endif
551 }
552
583
585 {
587 }
588
589 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
590 {
591 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_START_SHORT, "Car Horn Start Short", FadeColors.LIGHT_GREY));
592 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_START_LONG, "Car Horn Start Long", FadeColors.LIGHT_GREY));
593 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_HORN_STOP, "Car Horn Stop", FadeColors.LIGHT_GREY));
594 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
595
596 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "Car Fuel", FadeColors.RED));
597 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_FULL, "Full", FadeColors.LIGHT_GREY));
598 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_EMPTY, "Empty", FadeColors.LIGHT_GREY));
599 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_INCREASE, "10% increase", FadeColors.LIGHT_GREY));
600 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_FUEL_DECREASE, "10% decrease", FadeColors.LIGHT_GREY));
601 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
602
603 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "Car Cooler", FadeColors.RED));
604 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_FULL, "Full", FadeColors.LIGHT_GREY));
605 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_EMPTY, "Empty", FadeColors.LIGHT_GREY));
606 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_INCREASE, "10% increase", FadeColors.LIGHT_GREY));
607 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.CAR_COOLANT_DECREASE, "10% decrease", FadeColors.LIGHT_GREY));
608 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
609
610#ifdef DIAG_DEVELOPER
611 typename e = ECarDebugMode;
612
613 int i;
614
615 int cnt = e.GetVariableCount();
616 int val;
617
618 for (i = 0; i < cnt; i++)
619 {
620 if (!e.GetVariableValue(null, i, val))
621 continue;
622
623 val = val + EActions.PLAYER_BOT_INTERNAL_START;
624
625 string name = e.GetVariableName(i);
626
627 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, val, name, FadeColors.LIGHT_GREY));
628 }
629
630 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
631#endif
632
633 super.GetDebugActions(outputList);
634 }
635
636 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
637 {
638 if (super.OnAction(action_id, player, ctx))
639 return true;
640
641 if (!g_Game.IsServer())
642 {
643 return false;
644 }
645
646 switch (action_id)
647 {
648 case EActions.CAR_HORN_START_SHORT:
649 SetCarHornState(ECarHornState.SHORT);
650 return true;
651 case EActions.CAR_HORN_START_LONG:
652 SetCarHornState(ECarHornState.LONG);
653 return true;
654 case EActions.CAR_HORN_STOP:
655 SetCarHornState(ECarHornState.OFF);
656 return true;
657
658 case EActions.CAR_FUEL_FULL:
659 Fill(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL));
660 return true;
661 case EActions.CAR_FUEL_EMPTY:
662 LeakAll(CarFluid.FUEL);
663 return true;
664 case EActions.CAR_FUEL_INCREASE:
665 Fill(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL) * 0.1);
666 return true;
667 case EActions.CAR_FUEL_DECREASE:
668 Leak(CarFluid.FUEL, GetFluidCapacity(CarFluid.FUEL) * 0.1);
669 return true;
670
671 case EActions.CAR_COOLANT_FULL:
672 Fill(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT));
673 return true;
674 case EActions.CAR_COOLANT_EMPTY:
675 LeakAll(CarFluid.COOLANT);
676 return true;
677 case EActions.CAR_COOLANT_INCREASE:
678 Fill(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT) * 0.1);
679 return true;
680 case EActions.CAR_COOLANT_DECREASE:
681 Leak(CarFluid.COOLANT, GetFluidCapacity(CarFluid.COOLANT) * 0.1);
682 return true;
683 }
684
685#ifdef DIAG_DEVELOPER
686 typename e = ECarDebugMode;
687
688 int i;
689
690 int cnt = e.GetVariableCount();
691 int val;
692
693 for (i = 0; i < cnt; i++)
694 {
695 if (!e.GetVariableValue(null, i, val))
696 continue;
697
698 if ((val + EActions.PLAYER_BOT_INTERNAL_START) == action_id)
699 {
700 m_eDebugMode = val;
701 dBodyActive(this, ActiveState.ACTIVE);
702 }
703 }
704#endif
705
706 return false;
707 }
708
710 {
711 super.OnVariablesSynchronized();
712
713 if (GetCrashHeavySound())
714 {
716 }
717 else if (GetCrashLightSound())
718 {
720 }
721
723
726
727 UpdateLights();
728 }
729
731 {
732 if ( !SEffectManager.IsEffectExist( m_enginePtcFx ) && g_Game.GetWaterDepth( GetEnginePosWS() ) <= 0 )
733 {
735 m_engineFx.SetParticleStateHeavy();
737 }
738 }
739
740 override void EEItemAttached(EntityAI item, string slot_name)
741 {
742 super.EEItemAttached(item, slot_name);
743
744 switch (slot_name)
745 {
746 case "Reflector_1_1":
747 if (g_Game.IsServer())
748 {
749 SetHealth("Reflector_1_1", "Health", item.GetHealth());
750 }
751 break;
752 case "Reflector_2_1":
753 if (g_Game.IsServer())
754 {
755 SetHealth("Reflector_2_1", "Health", item.GetHealth());
756 }
757 break;
758 case "CarBattery":
759 case "TruckBattery":
760 if (g_Game.IsServer())
761 {
762 m_BatteryHealth = item.GetHealth01();
763 }
764 break;
765 case "SparkPlug":
766 case "GlowPlug":
767 if (g_Game.IsServer())
768 {
769 m_PlugHealth = item.GetHealth01();
770 }
771 break;
772 case "CarRadiator":
773 if (g_Game.IsServer())
774 {
775 m_RadiatorHealth = item.GetHealth01();
776 }
777
778 m_Radiator = item;
779 break;
780 }
781
782 if (g_Game.IsServer())
783 {
784 Synchronize();
785 }
786
788 UpdateLights();
789 }
790
791 // Updates state of attached headlight bulbs for faster access
793 {
794 EntityAI bulb_L = FindAttachmentBySlotName("Reflector_1_1");
795 EntityAI bulb_R = FindAttachmentBySlotName("Reflector_2_1");
796
797 if (bulb_L && !bulb_L.IsRuined() && bulb_R && !bulb_R.IsRuined())
798 {
799 m_HeadlightsState = CarHeadlightBulbsState.BOTH;
800 }
801 else if (bulb_L && !bulb_L.IsRuined())
802 {
803 m_HeadlightsState = CarHeadlightBulbsState.LEFT;
804 }
805 else if (bulb_R && !bulb_R.IsRuined())
806 {
807 m_HeadlightsState = CarHeadlightBulbsState.RIGHT;
808 }
809 else if ((!bulb_L || bulb_L.IsRuined()) && (!bulb_R || bulb_R.IsRuined()))
810 {
811 m_HeadlightsState = CarHeadlightBulbsState.NONE;
812 }
813 }
814
815 override void EEItemDetached(EntityAI item, string slot_name)
816 {
817 switch (slot_name)
818 {
819 case "CarBattery":
820 case "TruckBattery":
821 m_BatteryHealth = -1;
822 if (IsServerOrOwner())
823 {
824 if (EngineIsOn())
825 {
826 EngineStop();
827 }
828 }
829
830 if (g_Game.IsServer())
831 {
832 if (IsScriptedLightsOn())
833 {
835 }
836
837 UpdateBattery(ItemBase.Cast(item));
838 }
839 break;
840 case "SparkPlug":
841 case "GlowPlug":
842 m_PlugHealth = -1;
843 if (g_Game.IsServer() && EngineIsOn())
844 {
845 EngineStop();
846 }
847 break;
848 case "CarRadiator":
849 m_Radiator = null;
850 if (IsServerOrOwner())
851 {
852 LeakAll(CarFluid.COOLANT);
853 }
854
855 if (g_Game.IsServer())
856 {
857 if (m_DamageZoneMap.Contains("Radiator"))
858 {
859 SetHealth("Radiator", "Health", 0);
860 }
861 }
862 break;
863 }
864
865 if (g_Game.IsServer())
866 {
867 Synchronize();
868 }
869
871 UpdateLights();
872 }
873
874 override void OnAttachmentRuined(EntityAI attachment)
875 {
876 super.OnAttachmentRuined(attachment);
877
879 UpdateLights();
880 }
881
882 override bool CanReceiveAttachment(EntityAI attachment, int slotId)
883 {
884 if (!super.CanReceiveAttachment(attachment, slotId))
885 return false;
886
887 InventoryLocation attachmentInventoryLocation = new InventoryLocation();
888 attachment.GetInventory().GetCurrentInventoryLocation(attachmentInventoryLocation);
889 if (attachmentInventoryLocation.GetParent() == null)
890 {
891 return true;
892 }
893
894 if (attachment && attachment.Type().IsInherited(CarWheel))
895 {
896 string slotSelectionName;
897 InventorySlots.GetSelectionForSlotId(slotId, slotSelectionName);
898
899 switch (slotSelectionName)
900 {
901 case "wheel_spare_1":
902 case "wheel_spare_2":
903 return CanManipulateSpareWheel(slotSelectionName);
904 break;
905 }
906 }
907
908 return true;
909 }
910
911 override bool CanReleaseAttachment(EntityAI attachment)
912 {
913 if (!super.CanReleaseAttachment(attachment))
914 {
915 return false;
916 }
917
918 if (EngineIsOn() && IsMoving())
919 {
920 return false;
921 }
922
923 if (attachment && attachment.Type().IsInherited(CarWheel))
924 {
925 InventoryLocation attachmentInventoryLocation = new InventoryLocation();
926 attachment.GetInventory().GetCurrentInventoryLocation(attachmentInventoryLocation);
927
928 string slotSelectionName;
929 InventorySlots.GetSelectionForSlotId(attachmentInventoryLocation.GetSlot(), slotSelectionName);
930
931 switch (slotSelectionName)
932 {
933 case "wheel_spare_1":
934 case "wheel_spare_2":
935 return CanManipulateSpareWheel(slotSelectionName);
936 break;
937 }
938 }
939
940 return true;
941 }
942
943 protected bool CanManipulateSpareWheel(string slotSelectionName)
944 {
945 return false;
946 }
947
948 override void EOnPostSimulate(IEntity other, float timeSlice)
949 {
950 m_Time += timeSlice;
951
952 if (g_Game.IsServer())
953 {
954 #ifdef DIAG_DEVELOPER
955 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
956 {
957 if (m_ContactCalled)
958 {
959 Debug.Log("Momentum delta: " + (GetMomentum() - m_MomentumPrevTick));
960 Debug.Log("--------------------------------------------------------------------");
961 m_ContactCalled = false;
962 }
963 }
964 #endif
965
966
969 m_MomentumPrevTick = GetMomentum();
970 #ifdef DEVELOPER
971 m_DebugMessageCleanTime += timeSlice;
972 if (m_DebugMessageCleanTime >= DEBUG_MESSAGE_CLEAN_TIME_SECONDS)
973 {
974 m_DebugMessageCleanTime = 0;
975 m_DebugContactDamageMessage = "";
976 }
977 #endif
978 }
979
981 {
982 m_Time = 0;
983
985
986 bool isServerOrOwner = IsServerOrOwner();
987
988 //First of all check if the car should stop the engine
989 if (isServerOrOwner && EngineIsOn())
990 {
991 if (IsDamageDestroyed() || GetFluidFraction(CarFluid.FUEL) <= 0 || m_EngineHealth <= 0)
992 EngineStop();
993
994 //CheckVitalItem(IsVitalCarBattery(), CarBattery.SLOT_ID);
995 //CheckVitalItem(IsVitalTruckBattery(), TruckBattery.SLOT_ID);
996 CheckVitalItem(IsVitalSparkPlug(), "SparkPlug");
997 CheckVitalItem(IsVitalGlowPlug(), "GlowPlug");
998 }
999
1000 if (g_Game.IsServer())
1001 {
1002 if (IsVitalFuelTank())
1003 {
1005 {
1006 SetHealth("Engine", "Health", GameConstants.DAMAGE_RUINED_VALUE);
1007 }
1008 }
1009 }
1010
1012 if ( EngineIsOn() )
1013 {
1014 if ( g_Game.IsServer() )
1015 {
1016 float dmg;
1017
1018 if ( EngineGetRPM() >= EngineGetRPMRedline() )
1019 {
1020 if (EngineGetRPM() > EngineGetRPMMax())
1021 AddHealth( "Engine", "Health", -GetMaxHealth("Engine", "") * 0.05 ); //CAR_RPM_DMG
1022
1023 // only called on server, don't use deterministic RandomFloat
1024 dmg = EngineGetRPM() * 0.001 * Math.RandomFloat( 0.02, 1.0 ); //CARS_TICK_DMG_MIN; //CARS_TICK_DMG_MAX
1025 ProcessDirectDamage(DamageType.CUSTOM, null, "Engine", "EnviroDmg", vector.Zero, dmg);
1026 SetEngineZoneReceivedHit(true);
1027 }
1028 else
1029 {
1030 SetEngineZoneReceivedHit(false);
1031 }
1032 }
1033
1034 if (isServerOrOwner)
1035 {
1037 if ( IsVitalRadiator() )
1038 {
1039 if ( GetFluidFraction(CarFluid.COOLANT) > 0 && m_RadiatorHealth < 0.5 ) //CARS_LEAK_THRESHOLD
1040 LeakFluid( CarFluid.COOLANT );
1041 }
1042
1043 if ( GetFluidFraction(CarFluid.FUEL) > 0 && m_FuelTankHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
1044 LeakFluid( CarFluid.FUEL );
1045
1046 if ( GetFluidFraction(CarFluid.BRAKE) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
1047 LeakFluid( CarFluid.BRAKE );
1048
1049 if ( GetFluidFraction(CarFluid.OIL) > 0 && m_EngineHealth < GameConstants.DAMAGE_DAMAGED_VALUE )
1050 LeakFluid( CarFluid.OIL );
1051
1052 if ( m_EngineHealth < 0.25 )
1053 LeakFluid( CarFluid.OIL );
1054 }
1055
1056 if ( g_Game.IsServer() )
1057 {
1058 if ( IsVitalRadiator() )
1059 {
1060 if ( GetFluidFraction( CarFluid.COOLANT ) < 0.5 && GetFluidFraction( CarFluid.COOLANT ) >= 0 )
1061 {
1062 // only called on server, don't use deterministic RandomFloat
1063 dmg = ( 1 - GetFluidFraction(CarFluid.COOLANT) ) * Math.RandomFloat( 0.02, 10.00 ); //CARS_DMG_TICK_MIN_COOLANT; //CARS_DMG_TICK_MAX_COOLANT
1064 AddHealth( "Engine", "Health", -dmg );
1065 SetEngineZoneReceivedHit(true);
1066 }
1067 }
1068 }
1069
1070 //FX only on Client and in Single
1071 if (!g_Game.IsDedicatedServer())
1072 {
1074 {
1077 m_exhaustFx.SetParticleStateLight();
1078 }
1079
1080 if (IsVitalRadiator() && GetFluidFraction(CarFluid.COOLANT) < 0.5)
1081 {
1083 {
1086 }
1087
1088 if (m_coolantFx)
1089 {
1090 if (GetFluidFraction(CarFluid.COOLANT) > 0)
1091 m_coolantFx.SetParticleStateLight();
1092 else
1093 m_coolantFx.SetParticleStateHeavy();
1094 }
1095 }
1096 else
1097 {
1100 }
1101 }
1102 }
1103 else
1104 {
1105 //FX only on Client and in Single
1106 if ( !g_Game.IsDedicatedServer() )
1107 {
1109 {
1111 m_exhaustPtcFx = -1;
1112 }
1113
1115 {
1117 m_coolantPtcFx = -1;
1118 }
1119 }
1120 }
1121
1122 }
1123
1124 //FX only on Client and in Single
1125 if ( !g_Game.IsDedicatedServer() )
1126 {
1127 float carSpeed = GetVelocity(this).Length();
1128 for (int i = 0; i < WheelCount(); i++)
1129 {
1130 EffWheelSmoke eff = m_WheelSmokeFx.Get(i);
1131 int ptrEff = m_WheelSmokePtcFx.Get(i);
1132 bool haveParticle = false;
1133
1134 CarWheel wheel = CarWheel.Cast(WheelGetEntity(i));
1135 if (wheel && WheelHasContact(i))
1136 {
1137 float wheelSpeed = WheelGetAngularVelocity(i) * wheel.GetRadius();
1138
1139 vector wheelPos = WheelGetContactPosition(i);
1140 vector wheelVel = dBodyGetVelocityAt(this, wheelPos);
1141
1142 vector transform[3];
1143 transform[2] = WheelGetDirection(i);
1144 transform[1] = vector.Up;
1145 transform[0] = transform[2] * transform[1];
1146
1147 wheelVel = wheelVel.InvMultiply3(transform);
1148
1149 float bodySpeed = wheelVel[2];
1150
1151 bool applyEffect = false;
1152 if ((wheelSpeed > 0 && bodySpeed > 0) || (wheelSpeed < 0 && bodySpeed < 0))
1153 {
1154 applyEffect = Math.AbsFloat(wheelSpeed) > Math.AbsFloat(bodySpeed) + EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1155 }
1156 else
1157 {
1158 applyEffect = Math.AbsFloat(wheelSpeed) > EffWheelSmoke.WHEEL_SMOKE_THRESHOLD;
1159 }
1160
1161 if (applyEffect)
1162 {
1163 haveParticle = true;
1164
1165 string surface;
1166 g_Game.SurfaceGetType(wheelPos[0], wheelPos[2], surface);
1167 wheelPos = WorldToModel(wheelPos);
1168
1169 if (!SEffectManager.IsEffectExist(ptrEff))
1170 {
1171 eff = new EffWheelSmoke();
1172 eff.SetSurface(surface);
1173 ptrEff = SEffectManager.PlayOnObject(eff, this, wheelPos, "0 1 -1");
1174 eff.SetCurrentLocalPosition(wheelPos);
1175 m_WheelSmokeFx.Set(i, eff);
1176 m_WheelSmokePtcFx.Set(i, ptrEff);
1177 }
1178 else
1179 {
1180 if (!eff.IsPlaying() && Surface.GetWheelParticleID(surface) != 0)
1181 eff.Start();
1182 eff.SetSurface(surface);
1183 eff.SetCurrentLocalPosition(wheelPos);
1184 }
1185 }
1186 }
1187
1188 if (!haveParticle)
1189 {
1190 if (eff && eff.IsPlaying())
1191 eff.Stop();
1192 }
1193 }
1194 }
1195 }
1196
1198 {
1199 UpdateLights();
1200 }
1201
1203 {
1204 UpdateLights();
1205 }
1206
1207 override void OnDriverExit(Human player)
1208 {
1209 super.OnDriverExit(player);
1210
1211 if (GetGear() != GetNeutralGear())
1212 {
1213 EngineStop();
1214 }
1215 }
1216
1217 // Server side event for jump out processing
1219 {
1220 PlayerBase player = gotActionData.m_Player;
1221
1222 array<ClothingBase> equippedClothes = new array<ClothingBase>;
1223 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("LEGS")));
1224 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("BACK")));
1225 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("VEST")));
1226 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("HeadGear")));
1227 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("Mask")));
1228 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("BODY")));
1229 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("FEET")));
1230 equippedClothes.Insert(ClothingBase.Cast(player.GetItemOnSlot("GLOVES")));
1231
1232 // -----------------------------------------------
1233 float shockTaken = (gotActionData.m_Speed * gotActionData.m_Speed) / ActionGetOutTransport.DMG_FACTOR;
1234
1235 //Lower shock taken if player uses a helmet
1236 ItemBase headGear = ClothingBase.Cast(player.GetItemOnHead());
1237 HelmetBase helmet;
1238 if (Class.CastTo(helmet, headGear))
1239 shockTaken *= 0.5;
1240
1241 // -----------------------------------------------
1242
1243 int randNum; //value used for probability evaluation
1244 randNum = Math.RandomInt(0, 100);
1245 if (gotActionData.m_Speed < ActionGetOutTransport.LOW_SPEED_VALUE)
1246 {
1247 if (randNum < 20)
1248 player.GiveShock(-shockTaken); //To inflict shock, a negative value must be passed
1249
1250 randNum = Math.RandomIntInclusive(0, PlayerBase.m_BleedingSourcesLow.Count() - 1);
1251
1252 if (player.m_BleedingManagerServer)
1253 player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection(PlayerBase.m_BleedingSourcesLow[randNum]);
1254 }
1256 {
1257 if (randNum < 50)
1258 player.GiveShock(-shockTaken);
1259
1260 randNum = Math.RandomInt(0, PlayerBase.m_BleedingSourcesUp.Count() - 1);
1261
1262 if (player.m_BleedingManagerServer)
1263 player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection(PlayerBase.m_BleedingSourcesUp[randNum]);
1264 }
1265 else if (gotActionData.m_Speed >= ActionGetOutTransport.HIGH_SPEED_VALUE)
1266 {
1267 if (!headGear && player.m_BleedingManagerServer)
1268 player.m_BleedingManagerServer.AttemptAddBleedingSourceBySelection("Head");
1269
1270 if (randNum < 75)
1271 player.GiveShock(-shockTaken);
1272 }
1273
1274 float dmgTaken = (gotActionData.m_Speed * gotActionData.m_Speed) / ActionGetOutTransport.SHOCK_FACTOR;
1275
1276 //Damage all currently equipped clothes
1277 foreach (ClothingBase cloth : equippedClothes)
1278 {
1279 //If no item is equipped on slot, slot is ignored
1280 if (cloth == null)
1281 continue;
1282
1283 cloth.DecreaseHealth(dmgTaken, false);
1284 }
1285
1286 vector posMS = gotActionData.m_Player.WorldToModel(gotActionData.m_Player.GetPosition());
1287 gotActionData.m_Player.DamageAllLegs(dmgTaken); //Additionnal leg specific damage dealing
1288
1290 healthCoef = Math.Clamp(healthCoef, 0.0, 1.0);
1291 gotActionData.m_Player.ProcessDirectDamage(DamageType.CUSTOM, gotActionData.m_Player, "", "FallDamageHealth", posMS, healthCoef);
1292 }
1293
1294 protected override bool DetectFlipped(VehicleFlippedContext ctx)
1295 {
1296 if (!DetectFlippedUsingWheels(ctx, GameConstants.VEHICLE_FLIP_WHEELS_LIMITED))
1297 return false;
1298 if (!DetectFlippedUsingSurface(ctx, GameConstants.VEHICLE_FLIP_ANGLE_TOLERANCE))
1299 return false;
1300 return true;
1301 }
1302
1303 override void OnInput(float dt)
1304 {
1305 super.OnInput(dt);
1306
1307#ifdef DIAG_DEVELOPER
1308 if (m_eDebugMode == ECarDebugMode.NONE)
1309 return;
1310
1311 float currentRPM = EngineGetRPM();
1312 if (currentRPM < EngineGetRPMIdle())
1313 {
1314 if (currentRPM < 1.0 && EngineIsOn())
1315 {
1317 EngineStop();
1318 }
1319 else if (!EngineIsOn())
1320 {
1321 EngineStart();
1322 }
1323
1324 return;
1325 }
1326
1327 float speed = GetSpeedometerAbsolute();
1328
1329 float thrustWanted = 0.0;
1330 float steeringWanted = 0.0;
1331
1332 bool attemptSpeed = false;
1333 float speedWanted = 0;
1334
1335 switch (m_eDebugMode)
1336 {
1337 case ECarDebugMode.FORWARD_10:
1338 attemptSpeed = true;
1339 speedWanted = 10;
1340 break;
1341 case ECarDebugMode.FORWARD_50:
1342 attemptSpeed = true;
1343 speedWanted = 50;
1344 break;
1345 }
1346
1347 if (attemptSpeed)
1348 {
1349 // very basic and doesn't actually work
1350 thrustWanted = Math.Clamp(1.0 - Math.InverseLerp(0, speedWanted, speed), 0, 1);
1351 }
1352
1353 bool isManual = GearboxGetType() == CarGearboxType.MANUAL;
1354 bool isReverse = GetGear() == CarGear.REVERSE;
1355
1356 if (isManual)
1357 {
1358 float thrustWantedAbs = Math.AbsFloat(thrustWanted);
1359
1360 if (currentRPM > EngineGetRPMRedline() * 0.8)
1361 {
1362 if (thrustWantedAbs > 0.1)
1363 {
1364 ShiftUp();
1365 }
1366 }
1367 else if (GetGear() > CarGear.FIRST && thrustWantedAbs < 0.1)
1368 {
1369 ShiftDown();
1370 }
1371 else if (GetGear() < CarGear.FIRST || (thrustWanted > 0.0 && speed < 5.0))
1372 {
1373 ShiftTo(CarGear.FIRST);
1374 }
1375 }
1376
1377 SetThrottle(thrustWanted);
1378 SetSteering(steeringWanted);
1379 SetBrake(0.0);
1380 SetHandbrake(0.0);
1381 SetBrakesActivateWithoutDriver(false);
1382#endif
1383 }
1384
1385 override void OnUpdate(float dt)
1386 {
1387 Human driver = CrewDriver();
1388 if (driver && !driver.IsControllingVehicle())
1389 {
1390 // likely unconscious
1391 if (driver.IsAlive())
1392 {
1393 SetBrake(0.5);
1394 }
1395 }
1396
1397 if (g_Game.IsServer())
1398 {
1399 ItemBase battery = GetBattery();
1400 if (battery)
1401 {
1402 m_BatteryTimer += dt;
1404 {
1405 UpdateBattery(battery);
1406 }
1407 }
1408
1409 if ( g_Game.GetWaterDepth( GetEnginePosWS() ) > 0 )
1410 {
1411 m_DrownTime += dt;
1413 {
1414 // *dt to get damage per second
1415 AddHealth( "Engine", "Health", -DROWN_ENGINE_DAMAGE * dt);
1416 SetEngineZoneReceivedHit(true);
1417 }
1418 }
1419 else
1420 {
1421 m_DrownTime = 0;
1422 }
1423 }
1424
1425 // For visualisation of brake lights for all players
1426 float brake_coef = GetBrake();
1427 if ( brake_coef > 0 )
1428 {
1429 if ( !m_BrakesArePressed )
1430 {
1431 m_BrakesArePressed = true;
1432 SetSynchDirty();
1434 }
1435 }
1436 else
1437 {
1438 if ( m_BrakesArePressed )
1439 {
1440 m_BrakesArePressed = false;
1441 SetSynchDirty();
1443 }
1444 }
1445 }
1446
1447 override void EEKilled(Object killer)
1448 {
1449 super.EEKilled(killer);
1450 m_EngineDestroyed = true;
1451 }
1452
1454 override void OnContact( string zoneName, vector localPos, IEntity other, Contact data )
1455 {
1456 if (g_Game.IsServer())
1457 {
1458 #ifdef DIAG_DEVELOPER
1459 m_ContactCalled = true;
1460 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
1461 {
1462 string output = "Zone: " + zoneName + " | Impulse:" + data.Impulse;
1463 Debug.Log(output);
1464 }
1465 #endif
1466 if (m_ContactCache.Count() == 0)
1467 {
1469 m_ContactCache.Insert(zoneName, ccd);
1470 float momentumDelta = GetMomentum() - m_MomentumPrevTick;
1471 float dot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1472 if (dot < 0)
1473 {
1474 momentumDelta = m_MomentumPrevTick;
1475 }
1476
1477 ccd.Insert(new CarContactData(localPos, other, momentumDelta));
1478 }
1479 }
1480 }
1481
1484 {
1485
1486 int contactZonesCount = m_ContactCache.Count();
1487
1488 if (contactZonesCount == 0)
1489 return;
1490
1491
1492 for (int i = 0; i < contactZonesCount; ++i)
1493 {
1494 string zoneName = m_ContactCache.GetKey(i);
1496
1497 float dmg = Math.AbsInt(data[0].impulse * m_dmgContactCoef);
1498 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
1499
1500 #ifdef DIAG_DEVELOPER
1501 CrashDebugData.m_CrashDataPoint = new CrashDebugData();
1502 CrashDebugData.m_CrashDataPoint.m_VehicleType = GetDisplayName();
1503 CrashDebugData.m_CrashDataPoint.m_Damage = dmg;
1504 CrashDebugData.m_CrashDataPoint.m_Zone = zoneName;
1505 CrashDebugData.m_CrashDataPoint.m_MomentumCurr = GetMomentum();
1506 CrashDebugData.m_CrashDataPoint.m_MomentumPrev = m_MomentumPrevTick;
1507 CrashDebugData.m_CrashDataPoint.m_MomentumDelta = data[0].impulse;
1508 CrashDebugData.m_CrashDataPoint.m_SpeedWorld = GetVelocity(this).Length() * 3.6;
1509 CrashDebugData.m_CrashDataPoint.m_SpeedWorldPrev = m_VelocityPrevTick.Length() * 3.6;
1510 CrashDebugData.m_CrashDataPoint.m_SpeedWorldDelta = (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6;
1511 CrashDebugData.m_CrashDataPoint.m_VelocityCur = GetVelocity(this);
1512 CrashDebugData.m_CrashDataPoint.m_VelocityPrev = m_VelocityPrevTick;
1513 CrashDebugData.m_CrashDataPoint.m_VelocityDot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
1514 CrashDebugData.m_CrashDataPoint.m_Time = g_Game.GetTime();
1515
1516
1517
1518 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_CONSIDERED)
1519 {
1520 Debug.Log("--------------------------------------------------");
1521 Debug.Log("Vehicle:" + GetDisplayName());
1522 Debug.Log("DMG: " + dmg);
1523 Debug.Log("zoneName : "+ zoneName);
1524 Debug.Log("momentumCurr : "+ GetMomentum());
1525 Debug.Log("momentumPrev : "+ m_MomentumPrevTick);
1526 Debug.Log("momentumDelta : "+ data[0].impulse);
1527 Debug.Log("speed(km/h): "+ GetVelocity(this).Length() * 3.6);
1528 Debug.Log("speedPrev(km/h): "+ m_VelocityPrevTick.Length() * 3.6);
1529 Debug.Log("speedDelta(km/h) : "+ (m_VelocityPrevTick.Length() - GetVelocity(this).Length()) * 3.6);
1530 Debug.Log("velocityCur.): "+ GetVelocity(this));
1531 Debug.Log("velocityPrev.): "+ m_VelocityPrevTick);
1532 Debug.Log("velocityDot): "+ vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized()));
1533 Debug.Log("g_Game.GetTime(): "+ g_Game.GetTime());
1534 Debug.Log("--------------------------------------------------");
1535 }
1536 #endif
1538 continue;
1539
1540 int pddfFlags;
1541 #ifdef DIAG_DEVELOPER
1542 CrashDebugData.m_CrashData.Insert(CrashDebugData.m_CrashDataPoint);
1543 CrashDebugData.m_CrashDataPoint.m_Speedometer = GetSpeedometer();
1544 //Print("Crash data recorded");
1545 #endif
1547 {
1548 #ifdef DIAG_DEVELOPER
1549 CrashDebugData.m_CrashDataPoint.m_DamageType = "Small";
1550 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1551 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(), g_Game.GetTime() ));
1552 #endif
1554 pddfFlags = ProcessDirectDamageFlags.NO_TRANSFER;
1555 }
1556 else
1557 {
1558 #ifdef DIAG_DEVELOPER
1559 CrashDebugData.m_CrashDataPoint.m_DamageType = "Big";
1560 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1561 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(), g_Game.GetTime() ));
1562 #endif
1563 DamageCrew(crewDmgBase);
1565 pddfFlags = 0;
1566 }
1567
1568 #ifdef DEVELOPER
1569 m_DebugContactDamageMessage += string.Format("%1: %2\n", zoneName, dmg);
1570 #endif
1571
1572 ProcessDirectDamage(DamageType.CUSTOM, null, zoneName, "EnviroDmg", "0 0 0", dmg, pddfFlags);
1573
1574 //if (data[0].impulse > TRESHOLD)
1575 //{
1576 Object targetEntity = Object.Cast(data[0].other);
1577 if (targetEntity && targetEntity.IsTree())
1578 {
1579 SEffectManager.CreateParticleServer(targetEntity.GetPosition(), new TreeEffecterParameters("TreeEffecter", 1.0, 0.1));
1580 }
1581 //}
1582 }
1583
1585 UpdateLights();
1586
1587 m_ContactCache.Clear();
1588
1589 }
1590
1592 void DamageCrew(float dmg)
1593 {
1594 for ( int c = 0; c < CrewSize(); ++c )
1595 {
1596 Human crew = CrewMember( c );
1597 if ( !crew )
1598 continue;
1599
1600 PlayerBase player;
1601 if ( Class.CastTo(player, crew ) )
1602 {
1604 {
1605 #ifdef DIAG_DEVELOPER
1606 CrashDebugData.m_CrashDataPoint.m_CrewDamageBase = dmg;
1607 CrashDebugData.m_CrashDataPoint.m_DMGHealth = -100;
1608 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1609 {
1610 Debug.Log("--------------------------------------------------");
1611 Debug.Log("Killing the player");
1612 Debug.Log("Crew DMG Base: " + dmg);
1613 Debug.Log("--------------------------------------------------");
1614
1615 }
1616 #endif
1617 player.SetHealth(0.0);
1618 }
1619 else
1620 {
1622 shockTemp = Math.Clamp(shockTemp,0,1);
1623 float shock = Math.Lerp( 50, 150, shockTemp );
1624 float hp = Math.Lerp( 2, 100, shockTemp );
1625
1626 #ifdef DIAG_DEVELOPER
1627 CrashDebugData.m_CrashDataPoint.m_CrewDamageBase = dmg;
1628 CrashDebugData.m_CrashDataPoint.m_ShockTemp = shockTemp;
1629 CrashDebugData.m_CrashDataPoint.m_DMGHealth = hp;
1630 CrashDebugData.m_CrashDataPoint.m_DMGShock = shock;
1631 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.DAMAGE_APPLIED)
1632 {
1633 Debug.Log("--------------------------------------------------");
1634 Debug.Log("Crew DMG Base: " + dmg);
1635 Debug.Log("Crew shockTemp: " + shockTemp);
1636 Debug.Log("Crew DMG Health: " + hp);
1637 Debug.Log("Crew DMG Shock: " + shock);
1638 Debug.Log("--------------------------------------------------");
1639 }
1640 #endif
1641
1642 player.AddHealth("", "Shock", -shock );
1643 player.AddHealth("", "Health", -hp );
1644 }
1645 }
1646 }
1647 }
1648
1654 override float OnSound( CarSoundCtrl ctrl, float oldValue )
1655 {
1656 switch (ctrl)
1657 {
1658 case CarSoundCtrl.ENGINE:
1659 if (!m_EngineStarted)
1660 {
1661 return 0.0;
1662 }
1663 break;
1664 }
1665
1666 return oldValue;
1667 }
1668
1669 override void OnAnimationPhaseStarted(string animSource, float phase)
1670 {
1671 #ifndef SERVER
1672 HandleDoorsSound(animSource, phase);
1673 HandleSeatAdjustmentSound(animSource, phase);
1674 #endif
1675 }
1676
1677 protected EffectSound CreateSoundForAnimationSource(string animSource)
1678 {
1679 vector position = vector.Zero;
1680 int pivotIndex = -1;
1681
1682 string selectionName = GetSelectionFromAnimSource(animSource);
1683 if (selectionName != "")
1684 {
1685 position = GetSelectionBasePositionLS(selectionName);
1686
1687 int level = GetViewGeometryLevel();
1688
1689 array<int> pivots = new array<int>();
1690
1691 pivots.Clear();
1692 GetBonePivotsForAnimationSource(level, animSource, pivots);
1693
1694 if (pivots.Count())
1695 {
1696 pivotIndex = pivots[0];
1697 }
1698 }
1699
1700 WaveKind waveKind = WaveKind.WAVEEFFECTEX;
1701
1702 EffectSound sound = new EffectSound();
1703
1704 PlayerBase player;
1705 if (Class.CastTo(player, g_Game.GetPlayer()))
1706 {
1707 if (player.IsCameraInsideVehicle())
1708 {
1709 waveKind = WaveKind.WAVEEFFECT;
1710 }
1711 }
1712
1713 sound.SetAutodestroy(true);
1714 sound.SetParent(this, pivotIndex);
1715 sound.SetPosition(ModelToWorld(position));
1716 sound.SetLocalPosition(position);
1717 sound.SetSoundWaveKind(waveKind);
1718
1719 return sound;
1720 }
1721
1722 protected void HandleDoorsSound(string animSource, float phase)
1723 {
1724 switch (animSource)
1725 {
1726 case "doorsdriver":
1727 case "doorscodriver":
1728 case "doorscargo1":
1729 case "doorscargo2":
1730 case "doorshood":
1731 case "doorstrunk":
1732 EffectSound sound = CreateSoundForAnimationSource(animSource);
1733
1734 if (phase == 0)
1736 else
1738
1740 sound.SoundPlay();
1741
1742 break;
1743 }
1744 }
1745
1746 protected void HandleSeatAdjustmentSound(string animSource, float phase)
1747 {
1748 switch (animSource)
1749 {
1750 case "seatdriver":
1751 case "seatcodriver":
1752 EffectSound sound = CreateSoundForAnimationSource(animSource);
1753
1754 if (phase == 0)
1756 else
1758
1760 sound.SoundPlay();
1761
1762 break;
1763 }
1764 }
1765
1766
1767 protected void HandleCarHornSound(ECarHornState pState)
1768 {
1769 switch (pState)
1770 {
1771 case ECarHornState.SHORT:
1772 PlaySoundSet(m_CarHornSoundEffect, m_CarHornShortSoundName, 0, 0, false);
1773 break;
1774 case ECarHornState.LONG:
1775 PlaySoundSet(m_CarHornSoundEffect, m_CarHornLongSoundName, 0, 0, true);
1776 break;
1777 default:
1779 break;
1780 }
1781 }
1782
1783 // Only used for sound states which happen before engine start
1784 void SetCarEngineSoundState(CarEngineSoundState pState)
1785 {
1786 m_CarEngineSoundState = pState;
1787 SetSynchDirty();
1788 }
1789
1790 void HandleEngineSound(CarEngineSoundState state)
1791 {
1794
1795 #ifndef SERVER
1796 PlayerBase player = null;
1797 EffectSound sound = null;
1798 WaveKind waveKind = WaveKind.WAVEEFFECTEX;
1799
1800 bool doInside = false;
1801
1803
1804 switch (state)
1805 {
1806 case CarEngineSoundState.STARTING:
1807 sound = new EffectSound();
1808 sound.SetSoundSet("Offroad_02_Starting_SoundSet");
1809 sound.SetSoundFadeOut(0.15);
1810
1811 m_PreStartSound = sound;
1812 break;
1813 case CarEngineSoundState.START_OK:
1814 doInside = true;
1815
1816 sound = new EffectSound();
1818 sound.SetAutodestroy(true);
1819
1821 g_Game.GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(SetEngineStarted, 1000, false, true);
1822 break;
1823
1824 case CarEngineSoundState.START_NO_FUEL:
1825 sound = new EffectSound();
1826 sound.SetSoundSet("offroad_engine_failed_start_fuel_SoundSet");
1827 sound.SetAutodestroy(true);
1828 break;
1829
1830 case CarEngineSoundState.START_NO_BATTERY:
1831 sound = new EffectSound();
1832 sound.SetSoundSet("offroad_engine_failed_start_battery_SoundSet");
1833 sound.SetAutodestroy(true);
1834 break;
1835
1836 case CarEngineSoundState.START_NO_SPARKPLUG:
1837 sound = new EffectSound();
1838 sound.SetSoundSet("offroad_engine_failed_start_sparkplugs_SoundSet");
1839 sound.SetAutodestroy(true);
1840 break;
1841
1842 case CarEngineSoundState.STOP_OK:
1843 doInside = true;
1844
1845 sound = new EffectSound();
1847 sound.SetAutodestroy(true);
1848 break;
1849 case CarEngineSoundState.STOP_NO_FUEL:
1850 doInside = true;
1851
1852 sound = new EffectSound();
1854 sound.SetAutodestroy(true);
1855 break;
1856
1857 default:
1858 break;
1859 }
1860
1861 // play different sound based on selected camera
1862 if (doInside && Class.CastTo(player, g_Game.GetPlayer()))
1863 {
1864 if (player.IsCameraInsideVehicle())
1865 {
1866 waveKind = WaveKind.WAVEEFFECT;
1867 }
1868 }
1869
1870 if (sound)
1871 {
1872 vector enginePos = GetEnginePos();
1873
1874 sound.SetParent(this);
1875 sound.SetPosition(ModelToWorld(enginePos));
1876 sound.SetLocalPosition(enginePos);
1877 sound.SetSoundWaveKind(waveKind);
1879
1880 sound.SoundPlay();
1881 }
1882
1883 #endif
1884 }
1885
1886 override void MarkCrewMemberUnconscious(int crewMemberIndex)
1887 {
1888 if (!IsAuthority())
1889 return;
1890
1891 if (crewMemberIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
1892 {
1893 EngineStop();
1894 }
1895 }
1896
1897 override void MarkCrewMemberDead(int crewMemberIndex)
1898 {
1899 if (!IsAuthority())
1900 return;
1901
1902 if (crewMemberIndex == DayZPlayerConstants.VEHICLESEAT_DRIVER)
1903 {
1904 EngineStop();
1905 }
1906 }
1907
1914 override void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
1915 {
1916 switch ( fluid )
1917 {
1918 case CarFluid.FUEL:
1919 m_FuelAmmount = newValue;
1920 break;
1921
1922 case CarFluid.OIL:
1923 m_OilAmmount = newValue;
1924 break;
1925
1926 case CarFluid.BRAKE:
1927 m_BrakeAmmount = newValue;
1928 break;
1929
1930 case CarFluid.COOLANT:
1931 m_CoolantAmmount = newValue;
1932 break;
1933 }
1934 }
1935
1941 override bool OnBeforeEngineStart()
1942 {
1943 SetCarEngineSoundState(CarEngineSoundState.NONE);
1944
1945 ECarOperationalState state = CheckOperationalRequirements();
1946 return state == ECarOperationalState.OK;
1947 }
1948
1950 {
1951 ECarOperationalState state = CheckOperationalRequirements();
1952
1953 if (state == ECarOperationalState.RUINED)
1954 {
1955 return;
1956 }
1957
1958 if (state & ECarOperationalState.NO_BATTERY)
1959 {
1960 HandleEngineSound(CarEngineSoundState.START_NO_BATTERY);
1961 return;
1962 }
1963
1964 if (state & ECarOperationalState.NO_IGNITER)
1965 {
1966 HandleEngineSound(CarEngineSoundState.START_NO_SPARKPLUG);
1967 return;
1968 }
1969
1970 if (state & ECarOperationalState.NO_FUEL)
1971 {
1972 HandleEngineSound(CarEngineSoundState.START_NO_FUEL);
1973 return;
1974 }
1975
1976 HandleEngineSound(CarEngineSoundState.STARTING);
1977 }
1978
1979 // Whether the car engine can be started
1981 {
1982 int state = ECarOperationalState.OK;
1983
1984 EntityAI item = null;
1985
1986 if (IsDamageDestroyed() || GetHealthLevel("Engine") >= GameConstants.STATE_RUINED)
1987 {
1988 state |= ECarOperationalState.RUINED;
1989 }
1990
1991 if (GetFluidFraction(CarFluid.FUEL) <= 0)
1992 {
1993 state |= ECarOperationalState.NO_FUEL;
1994 }
1995
1997 {
1998 item = GetBattery();
1999 float batteryConsume = GetBatteryConsumption();
2000 if (!item || (item && (item.IsRuined() || item.GetCompEM().GetEnergy() < batteryConsume)))
2001 state |= ECarOperationalState.NO_BATTERY;
2002 }
2003
2004 if (IsVitalSparkPlug())
2005 {
2006 item = FindAttachmentBySlotName("SparkPlug");
2007 if (!item || (item && item.IsRuined()))
2008 state |= ECarOperationalState.NO_IGNITER;
2009 }
2010
2011 if (IsVitalGlowPlug())
2012 {
2013 item = FindAttachmentBySlotName("GlowPlug");
2014 if (!item || (item && item.IsRuined()))
2015 state |= ECarOperationalState.NO_IGNITER;
2016 }
2017
2018 return state;
2019 }
2020
2022 {
2023 return CheckOperationalRequirements() == ECarOperationalState.OK;
2024 }
2025
2026 override void OnGearChanged(int newGear, int oldGear)
2027 {
2028 //Debug.Log(string.Format("OnGearChanged newGear=%1,oldGear=%2", newGear, oldGear));
2029 UpdateLights(newGear);
2030 }
2031
2033 override void OnEngineStart()
2034 {
2035 ItemBase battery = GetBattery();
2036 if (g_Game.IsServer() && battery)
2037 {
2038 float batteryConsume = GetBatteryConsumption();
2039 battery.GetCompEM().ConsumeEnergy(batteryConsume);
2040
2041 UpdateBattery(battery);
2042 }
2043
2044 UpdateLights();
2045
2046 HandleEngineSound(CarEngineSoundState.START_OK);
2047 }
2048
2050 override void OnEngineStop()
2051 {
2052 ItemBase battery = GetBattery();
2053 if (g_Game.IsServer() && battery)
2054 {
2055 UpdateBattery(battery);
2056 }
2057
2058 UpdateLights();
2059
2060 CarEngineSoundState stopSoundState = CarEngineSoundState.STOP_OK;
2061 if (GetFluidFraction(CarFluid.FUEL) <= 0)
2062 stopSoundState = CarEngineSoundState.STOP_NO_FUEL;
2063
2064 HandleEngineSound(stopSoundState);
2065
2066 SetEngineZoneReceivedHit(false);
2067 }
2068
2071 {
2072 return LightIsOn();
2073 }
2074
2075 override bool OnBeforeLightOn()
2076 {
2077 ItemBase neededItem = GetBattery();
2078
2079 if (neededItem && !neededItem.IsRuined())
2080 {
2081 return neededItem.GetCompEM() && neededItem.GetCompEM().GetEnergy() > 0.0;
2082 }
2083
2084 return false;
2085 }
2086
2089 {
2090 // TODO(kumarjac): Call 'UpdateBattery' here. Probably can't right now
2091
2092 LightToggle();
2093 }
2094
2095 override void UpdateLights(int new_gear = -1)
2096 {
2097 #ifndef SERVER
2098 UpdateLightsClient(new_gear);
2099 #endif
2100 UpdateLightsServer(new_gear);
2101 }
2102
2103 void UpdateLightsClient(int newGear = -1)
2104 {
2105 int gear;
2106
2107 if (newGear == -1)
2108 {
2109 gear = GetGear();
2110 }
2111 else
2112 {
2113 gear = newGear;
2114 }
2115
2116 if (LightIsOn())
2117 {
2118 if (!m_Headlight && m_HeadlightsState != CarHeadlightBulbsState.NONE)
2119 {
2121 }
2122
2123 if (m_Headlight)
2124 {
2125 switch (m_HeadlightsState)
2126 {
2127 case CarHeadlightBulbsState.LEFT:
2129 m_Headlight.SegregateLight();
2130 break;
2131 case CarHeadlightBulbsState.RIGHT:
2133 m_Headlight.SegregateLight();
2134 break;
2135 case CarHeadlightBulbsState.BOTH:
2136 vector local_pos_left = GetMemoryPointPos(m_LeftHeadlightPoint);
2137 vector local_pos_right = GetMemoryPointPos(m_RightHeadlightPoint);
2138
2139 vector local_pos_middle = (local_pos_left + local_pos_right) * 0.5;
2140 m_Headlight.AttachOnObject(this, local_pos_middle);
2141 m_Headlight.AggregateLight();
2142 break;
2143 default:
2144 m_Headlight.FadeOut();
2145 m_Headlight = null;
2146 }
2147 }
2148 }
2149 else
2150 {
2151 if (m_Headlight)
2152 {
2153 m_Headlight.FadeOut();
2154 m_Headlight = null;
2155 }
2156 }
2157
2158 // brakes & reverse
2159 switch (gear)
2160 {
2161 case CarGear.REVERSE:
2164 m_RearLightType = CarRearLightType.BRAKES_AND_REVERSE;
2165 else
2166 m_RearLightType = CarRearLightType.REVERSE_ONLY;
2167 break;
2168 default:
2170 m_RearLightType = CarRearLightType.BRAKES_ONLY;
2171 else
2172 m_RearLightType = CarRearLightType.NONE;
2173 }
2174
2175 //Debug.Log(string.Format("m_BrakesArePressed=%1, m_RearLightType=%2", m_BrakesArePressed.ToString(), EnumTools.EnumToString(CarRearLightType, m_RearLightType)));
2176
2177 if (!m_RearLight && m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
2178 {
2179 if (EngineIsOn() || m_RearLightType == CarRearLightType.BRAKES_ONLY || m_RearLightType == CarRearLightType.BRAKES_AND_REVERSE)
2180 {
2182 vector localPos = GetMemoryPointPos(m_ReverseLightPoint);
2183 m_RearLight.AttachOnObject(this, localPos, "180 0 0");
2184 }
2185 }
2186
2187 // rear lights
2188 if (m_RearLight && m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
2189 {
2190 switch (m_RearLightType)
2191 {
2192 case CarRearLightType.BRAKES_ONLY:
2194 break;
2195 case CarRearLightType.REVERSE_ONLY:
2196 if (EngineIsOn())
2198 else
2199 NoRearLight();
2200
2201 break;
2202 case CarRearLightType.BRAKES_AND_REVERSE:
2203 if (EngineIsOn())
2205 else
2207
2208 break;
2209 default:
2210 NoRearLight();
2211 }
2212 }
2213 else
2214 {
2215 if (m_RearLight)
2216 {
2217 NoRearLight();
2218 }
2219 }
2220 }
2221
2222 void UpdateLightsServer(int newGear = -1)
2223 {
2224 int gear;
2225
2226 if (newGear == -1)
2227 {
2228 gear = GetGear();
2229 if (GearboxGetType() == CarGearboxType.AUTOMATIC)
2230 {
2231 gear = GearboxGetMode();
2232 }
2233 }
2234 else
2235 {
2236 gear = newGear;
2237 }
2238
2239 if (LightIsOn())
2240 {
2243
2244 switch (m_HeadlightsState)
2245 {
2246 case CarHeadlightBulbsState.LEFT:
2249 break;
2250 case CarHeadlightBulbsState.RIGHT:
2253 break;
2254 case CarHeadlightBulbsState.BOTH:
2257 break;
2258 default:
2261 }
2262
2263 //Debug.Log(string.Format("LightIsOn=%1, m_HeadlightsState=%2", LightIsOn().ToString(), EnumTools.EnumToString(CarHeadlightBulbsState, m_HeadlightsState)));
2264 }
2265 else
2266 {
2271 }
2272
2273
2274 // brakes & reverse
2275 switch (gear)
2276 {
2277 case CarGear.REVERSE:
2280 m_RearLightType = CarRearLightType.BRAKES_AND_REVERSE;
2281 else
2282 m_RearLightType = CarRearLightType.REVERSE_ONLY;
2283 break;
2284 default:
2286 m_RearLightType = CarRearLightType.BRAKES_ONLY;
2287 else
2288 m_RearLightType = CarRearLightType.NONE;
2289 }
2290
2291 //Debug.Log(string.Format("m_BrakesArePressed=%1, m_RearLightType=%2", m_BrakesArePressed.ToString(), EnumTools.EnumToString(CarRearLightType, m_RearLightType)));
2292
2293
2294 // rear lights
2295 if (m_RearLightType != CarRearLightType.NONE && m_HeadlightsState != CarHeadlightBulbsState.NONE)
2296 {
2297 switch (m_RearLightType)
2298 {
2299 case CarRearLightType.BRAKES_ONLY:
2302 break;
2303 case CarRearLightType.REVERSE_ONLY:
2304 if (EngineIsOn())
2305 {
2308 }
2309 else
2310 {
2313 }
2314 break;
2315 case CarRearLightType.BRAKES_AND_REVERSE:
2316 if (EngineIsOn())
2317 {
2320 }
2321 else
2322 {
2325 }
2326 break;
2327 default:
2330 }
2331 }
2332 else
2333 {
2336 }
2337 }
2338
2339 protected void BrakesRearLight()
2340 {
2341 m_RearLight.SetAsSegregatedBrakeLight();
2342 }
2343
2344 protected void ReverseRearLight()
2345 {
2346 m_RearLight.SetAsSegregatedReverseLight();
2347 }
2348
2350 {
2351 m_RearLight.AggregateLight();
2352 m_RearLight.SetFadeOutTime(1);
2353 }
2354
2355 protected void NoRearLight()
2356 {
2357 m_RearLight.FadeOut();
2358 m_RearLight = null;
2359 }
2360
2361 protected void LeftFrontLightShineOn()
2362 {
2363 string material = ConfigGetString("frontReflectorMatOn");
2364
2365 if (material)
2366 {
2367 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_L, material);
2368 }
2369 }
2370
2371 protected void RightFrontLightShineOn()
2372 {
2373 string material = ConfigGetString("frontReflectorMatOn");
2374
2375 if (material)
2376 {
2377 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_R, material);
2378 }
2379 }
2380
2381 protected void LeftFrontLightShineOff()
2382 {
2383 string material = ConfigGetString("frontReflectorMatOff");
2384
2385 if (material)
2386 {
2387 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_L, material);
2388 }
2389 }
2390
2392 {
2393 string material = ConfigGetString("frontReflectorMatOff");
2394
2395 if (material)
2396 {
2397 SetObjectMaterial(SELECTION_ID_FRONT_LIGHT_R, material);
2398 }
2399 }
2400
2401 protected void ReverseLightsShineOn()
2402 {
2403 string material = ConfigGetString("ReverseReflectorMatOn");
2404
2405 if (material)
2406 {
2407 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_L, material);
2408 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_R, material);
2409 }
2410 }
2411
2412 protected void ReverseLightsShineOff()
2413 {
2414 string material = ConfigGetString("ReverseReflectorMatOff");
2415
2416 if (material)
2417 {
2418 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_L, material);
2419 SetObjectMaterial(SELECTION_ID_REVERSE_LIGHT_R, material);
2420 }
2421 }
2422
2423 protected void BrakeLightsShineOn()
2424 {
2425 string material = ConfigGetString("brakeReflectorMatOn");
2426
2427 if (material)
2428 {
2429 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_L, material);
2430 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_R, material);
2431 }
2432 }
2433
2434 protected void BrakeLightsShineOff()
2435 {
2436 string material = ConfigGetString("brakeReflectorMatOff");
2437
2438 if (material)
2439 {
2440 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_L, material);
2441 SetObjectMaterial(SELECTION_ID_BRAKE_LIGHT_R, material);
2442 }
2443 }
2444
2445 protected void TailLightsShineOn()
2446 {
2447 string material = ConfigGetString("TailReflectorMatOn");
2448 string materialOff = ConfigGetString("TailReflectorMatOff");
2449
2450 if (material && materialOff)
2451 {
2452 if (m_HeadlightsState == CarHeadlightBulbsState.LEFT)
2453 {
2454 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2455 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, materialOff);
2456 }
2457 else if (m_HeadlightsState == CarHeadlightBulbsState.RIGHT)
2458 {
2459 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, materialOff);
2460 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2461 }
2462 else if (m_HeadlightsState == CarHeadlightBulbsState.BOTH)
2463 {
2464 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2465 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2466 }
2467 }
2468 }
2469
2470 protected void TailLightsShineOff()
2471 {
2472 string material = ConfigGetString("TailReflectorMatOff");
2473
2474 if (material)
2475 {
2476 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_L, material);
2477 SetObjectMaterial(SELECTION_ID_TAIL_LIGHT_R, material);
2478 }
2479 }
2480
2481 protected void DashboardShineOn()
2482 {
2483 string material = ConfigGetString("dashboardMatOn");
2484
2485 if (material)
2486 {
2487 SetObjectMaterial(SELECTION_ID_DASHBOARD_LIGHT, material);
2488 }
2489 }
2490
2491 protected void DashboardShineOff()
2492 {
2493 string material = ConfigGetString("dashboardMatOff");
2494
2495 if (material)
2496 {
2497 SetObjectMaterial(SELECTION_ID_DASHBOARD_LIGHT, material);
2498 }
2499 }
2500
2501 // Override this for a car-specific light type
2503 {
2504 return CarRearLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
2505 }
2506
2507 // Override this for a car-specific light type
2509 {
2510 return CarLightBase.Cast(ScriptedLightBase.CreateLight(OffroadHatchbackFrontLight));
2511 }
2512
2513 protected void CheckVitalItem(bool isVital, int slotId)
2514 {
2515 GameInventory inventory = GetInventory();
2516 if ( !isVital || !inventory )
2517 return;
2518
2519 EntityAI item = inventory.FindAttachment(slotId);
2520
2521 if (!item || item.IsRuined())
2522 {
2523 EngineStop();
2524 }
2525 }
2526
2527 protected void CheckVitalItem(bool isVital, string slot_name)
2528 {
2529 if ( !isVital )
2530 return;
2531
2532 int slotId = InventorySlots.GetSlotIdFromString(slot_name);
2533 CheckVitalItem(isVital, slotId);
2534 }
2535
2536 protected void LeakFluid(CarFluid fluid)
2537 {
2538 float ammount = 0;
2539
2540 switch (fluid)
2541 {
2542 case CarFluid.COOLANT:
2543 ammount = (1 - m_RadiatorHealth) * RandomFloat(0.02, 0.05);//CARS_LEAK_TICK_MIN; CARS_LEAK_TICK_MAX
2544 Leak(fluid, ammount);
2545 break;
2546
2547 case CarFluid.OIL:
2548 ammount = (1 - m_EngineHealth) * RandomFloat(0.02, 1.0);//CARS_LEAK_OIL_MIN; CARS_LEAK_OIL_MAX
2549 Leak(fluid, ammount);
2550 break;
2551
2552 case CarFluid.FUEL:
2553 ammount = (1 - m_FuelTankHealth) * RandomFloat(0.02, 0.05);//CARS_LEAK_TICK_MIN; CARS_LEAK_TICK_MAX
2554 Leak(fluid, ammount);
2555 break;
2556 }
2557 }
2558
2559 protected void CarPartsHealthCheck()
2560 {
2561 if (HasRadiator())
2562 {
2563 EntityAI radiator = GetRadiator();
2564 int radiatorHealthLevel = radiator.GetHealthLevel("");
2565 m_RadiatorHealth = GetHealthLevelValue(radiatorHealthLevel, "");
2566 }
2567 else
2568 {
2569 m_RadiatorHealth = 0;
2570 }
2571
2572 int engineHealthLevel = GetHealthLevel("Engine");
2573 m_EngineHealth = GetHealthLevelValue(engineHealthLevel, "Engine");
2574
2575 int fuelTankHealthLevel = GetHealthLevel("FuelTank");
2576 m_FuelTankHealth = GetHealthLevelValue(fuelTankHealthLevel, "FuelTank");
2577 }
2578
2580 {
2581 return m_PlayCrashSoundLight;
2582 }
2583
2584 void SynchCrashLightSound(bool play)
2585 {
2586 if (m_PlayCrashSoundLight != play)
2587 {
2588 m_PlayCrashSoundLight = play;
2589 SetSynchDirty();
2590 }
2591 }
2592
2594 {
2595 PlaySoundEx("offroad_hit_light_SoundSet", m_CrashSoundLight, m_PlayCrashSoundLight);
2596 }
2597
2599 {
2600 return m_PlayCrashSoundHeavy;
2601 }
2602
2603 void SynchCrashHeavySound(bool play)
2604 {
2605 if (m_PlayCrashSoundHeavy != play)
2606 {
2607 m_PlayCrashSoundHeavy = play;
2608 SetSynchDirty();
2609 }
2610 }
2611
2613 {
2614 PlaySoundEx("offroad_hit_heavy_SoundSet", m_CrashSoundHeavy, m_PlayCrashSoundHeavy);
2615 }
2616
2617 void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
2618 {
2619 #ifndef SERVER
2620 if (!sound)
2621 {
2623 if( sound )
2624 {
2625 sound.SetAutodestroy(true);
2626 }
2627 }
2628 else
2629 {
2630 if (!sound.IsSoundPlaying())
2631 {
2632 sound.SetPosition(GetPosition());
2633 sound.SoundPlay();
2634 }
2635 }
2636
2637 soundbool = false;
2638 #endif
2639 }
2640
2641 void PlaySound(string soundset, EffectSound sound, out bool soundbool)
2642 {
2643 PlaySoundEx(soundset, sound, soundbool);
2644 }
2645
2646 string GetAnimSourceFromSelection( string selection )
2647 {
2648 return "";
2649 }
2650
2651 string GetSelectionFromAnimSource( string animSource )
2652 {
2653 // Brute force for vehicles that aren't set up
2654
2655 TStringArray allSelections = new TStringArray();
2656 GetSelectionList(allSelections);
2657
2658 foreach (string selectionAll : allSelections)
2659 {
2660 string animSrc = GetAnimSourceFromSelection(selectionAll);
2661 animSrc.ToLower();
2662 if (animSrc != animSource)
2663 continue;
2664
2665 if (animSrc)
2666 {
2667 return selectionAll;
2668 }
2669 }
2670
2671 return "";
2672 }
2673
2674 string GetDoorConditionPointFromSelection( string selection )
2675 {
2676 switch( selection )
2677 {
2678 case "seat_driver":
2679 return "seat_con_1_1";
2680 break;
2681 case "seat_codriver":
2682 return "seat_con_2_1";
2683 break;
2684 case "seat_cargo1":
2685 return "seat_con_1_2";
2686 break;
2687 case "seat_cargo2":
2688 return "seat_con_2_2";
2689 break;
2690 }
2691
2692 return "";
2693 }
2694
2696 {
2697 return "";
2698 }
2699
2701 {
2702 return "";
2703 }
2704
2705 int GetCrewIndex( string selection )
2706 {
2707 return -1;
2708 }
2709
2710 override bool CanReachSeatFromDoors( string pSeatSelection, vector pFromPos, float pDistance = 1.0 )
2711 {
2712 string conPointName = GetDoorConditionPointFromSelection(pSeatSelection);
2713 if (conPointName.Length() > 0)
2714 {
2715 if ( MemoryPointExists(conPointName) )
2716 {
2717 vector conPointMS = GetMemoryPointPos(conPointName);
2718 vector conPointWS = ModelToWorld(conPointMS);
2719
2721 conPointWS[1] = 0;
2722 pFromPos[1] = 0;
2723
2724 if (vector.Distance(pFromPos, conPointWS) <= pDistance)
2725 {
2726 return true;
2727 }
2728 }
2729 }
2730
2731 return false;
2732 }
2733
2735 {
2736 return true;
2737 }
2738
2740 {
2741 return true;
2742 }
2743
2745 {
2746 return true;
2747 }
2748
2750 {
2751 return true;
2752 }
2753
2755 {
2756 return true;
2757 }
2758
2760 {
2761 return true;
2762 }
2763
2765 {
2766 return m_Radiator != null;
2767 }
2768
2770 {
2771 return m_Radiator;
2772 }
2773
2775 {
2776 return GetSpeedometerAbsolute() > 3.5;
2777 }
2778
2780 {
2781 return GetHandbrake() > 0.0;
2782 }
2783
2786 {
2788
2789 }
2790
2791 void SetEngineStarted(bool started)
2792 {
2793 m_EngineStarted = started;
2794 }
2795
2796 int GetCarDoorsState(string slotType)
2797 {
2798 return CarDoorState.DOORS_MISSING;
2799 }
2800
2802 {
2803 if (GetAnimationPhase(animation) > 0.5)
2804 {
2805 return CarDoorState.DOORS_OPEN;
2806 }
2807 else
2808 {
2809 return CarDoorState.DOORS_CLOSED;
2810 }
2811 }
2812
2814 {
2815 return "radiator";
2816 }
2817
2819 {
2820 return 2.0;
2821 }
2822
2824 {
2825 return "carradiator";
2826 }
2827
2829 {
2830 return 2.0;
2831 }
2832
2834 {
2835 return "carradiator";
2836 }
2837
2839 {
2840 return 2.0;
2841 }
2842
2843 override bool CanPutIntoHands(EntityAI parent)
2844 {
2845 return false;
2846 }
2847
2849 {
2851 if (!m_InputActionMap)
2852 {
2854 m_InputActionMap = iam;
2855 SetActions();
2856 m_CarTypeActionsMap.Insert(this.Type(), m_InputActionMap);
2857 }
2858 }
2859
2860 override void GetActions(typename action_input_type, out array<ActionBase_Basic> actions)
2861 {
2863 {
2864 m_ActionsInitialize = true;
2866 }
2867
2868 actions = m_InputActionMap.Get(action_input_type);
2869 }
2870
2881
2882 void AddAction(typename actionName)
2883 {
2884 ActionBase action = ActionManagerBase.GetAction(actionName);
2885
2886 if (!action)
2887 {
2888 Debug.LogError("Action " + actionName + " dosn't exist!");
2889 return;
2890 }
2891
2892 typename ai = action.GetInputType();
2893 if (!ai)
2894 {
2895 m_ActionsInitialize = false;
2896 return;
2897 }
2898 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
2899
2900 if (!action_array)
2901 {
2902 action_array = new array<ActionBase_Basic>;
2903 m_InputActionMap.Insert(ai, action_array);
2904 }
2905
2907 {
2908 Debug.ActionLog(action.ToString() + " -> " + ai, this.ToString() , "n/a", "Add action" );
2909 }
2910 action_array.Insert(action);
2911 }
2912
2913 void RemoveAction(typename actionName)
2914 {
2915 PlayerBase player = PlayerBase.Cast(g_Game.GetPlayer());
2916 ActionBase action = player.GetActionManager().GetAction(actionName);
2917 typename ai = action.GetInputType();
2918 array<ActionBase_Basic> action_array = m_InputActionMap.Get(ai);
2919
2920 if (action_array)
2921 {
2922 action_array.RemoveItem(action);
2923 }
2924 }
2925
2926 override bool IsInventoryVisible()
2927 {
2928 return ( g_Game.GetPlayer() && ( !g_Game.GetPlayer().GetCommand_Vehicle() || g_Game.GetPlayer().GetCommand_Vehicle().GetTransport() == this ) );
2929 }
2930
2931 override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
2932 {
2933 super.EEHealthLevelChanged(oldLevel,newLevel,zone);
2934
2935 if (newLevel == GameConstants.STATE_RUINED && oldLevel != newLevel)
2936 {
2937 bool dummy;
2938 switch ( zone )
2939 {
2940 case "WindowLR":
2941 case "WindowRR":
2942 if (m_Initialized)
2943 {
2944 PlaySoundEx("offroad_hit_window_small_SoundSet", m_WindowSmall, dummy);
2945 }
2946 break;
2947
2948 case "WindowFront":
2949 case "WindowBack":
2950 case "WindowFrontLeft":
2951 case "WindowFrontRight":
2952 if (m_Initialized)
2953 {
2954 PlaySoundEx("offroad_hit_window_large_SoundSet", m_WindowLarge, dummy);
2955 }
2956 break;
2957
2958 case "Engine":
2959 #ifndef SERVER
2961 #endif
2962 break;
2963 }
2964 }
2965 }
2966
2967 override void EEOnCECreate()
2968 {
2969
2970 float maxVolume = GetFluidCapacity( CarFluid.FUEL );
2971 float amount = Math.RandomFloat(0.0, maxVolume * 0.35 );
2972
2973 Fill( CarFluid.FUEL, amount );
2974 }
2975
2976 /*override void EOnPostFrame(IEntity other, int extra)
2977 {
2978 //Prepared for fix particle simulation when player is not in vehicle
2979 }*/
2980
2982 {
2984 {
2985 m_ForceUpdateLights = true;
2986 SetSynchDirty();
2987 }
2988 }
2989
2991 {
2993 {
2994 m_ForceUpdateLights = false;
2995 SetSynchDirty();
2996 }
2997 }
2998
2999 //Get the engine start battery consumption
3001 {
3002 return m_BatteryConsume;
3003 }
3004
3009
3011 {
3012 return -m_BatteryRecharge;
3013 }
3014
3016 {
3017 if (IsVitalCarBattery())
3018 {
3019 return ItemBase.Cast(GetInventory().FindAttachment(CarBattery.SLOT_ID));
3020 }
3021 else if (IsVitalTruckBattery())
3022 {
3023 return ItemBase.Cast(GetInventory().FindAttachment(TruckBattery.SLOT_ID));
3024 }
3025
3026 return null;
3027 }
3028
3029 protected void UpdateBattery(ItemBase battery)
3030 {
3031 if (!battery)
3032 {
3033 m_BatteryTimer = 0;
3034 return;
3035 }
3036
3037 // unlikely
3038 if (m_BatteryTimer < 0)
3039 {
3040 m_BatteryTimer = 0;
3041 }
3042
3043 bool engineOn = EngineIsOn();
3044 bool lightsOn = IsScriptedLightsOn();
3045
3046 if (engineOn)
3047 {
3048 // alternator
3049 battery.GetCompEM().ConsumeEnergy(GetBatteryRechargeRate() * m_BatteryTimer);
3050 }
3051 else if (!engineOn && lightsOn)
3052 {
3053 battery.GetCompEM().ConsumeEnergy(GetBatteryRuntimeConsumption() * m_BatteryTimer);
3054 }
3055
3056 if (lightsOn && battery.GetCompEM().GetEnergy() <= 0)
3057 {
3058 // lights currently don't automatically turn back on if the headlight was last turned on, so we just keep them on if the engine is on
3059 if (!engineOn)
3060 {
3062 }
3063 }
3064
3065 m_BatteryTimer = 0;
3066 }
3067
3068 void SetCarHornState(int pState)
3069 {
3070 m_CarHornState = pState;
3071 SetSynchDirty();
3072
3073 if (g_Game.IsServer())
3074 {
3075 GenerateCarHornAINoise(pState);
3076 }
3077 }
3078
3079 protected void GenerateCarHornAINoise(int pState)
3080 {
3081 if (pState != ECarHornState.OFF)
3082 {
3084 {
3085 float noiseMultiplier = 1.0;
3086 if (pState == ECarHornState.LONG)
3087 noiseMultiplier = 2.0;
3088
3089 noiseMultiplier *= NoiseAIEvaluate.GetNoiseReduction(g_Game.GetWeather());
3090
3091 m_NoiseSystem.AddNoiseTarget(GetPosition(), 5, m_NoisePar, noiseMultiplier);
3092 }
3093 }
3094 }
3095
3097 {
3098 return vector.Zero;
3099 }
3100
3102 {
3103 return 1.0;
3104 }
3105
3106#ifdef DEVELOPER
3107 override protected string GetDebugText()
3108 {
3109 string debug_output = super.GetDebugText();
3110 if (g_Game.IsServer())
3111 {
3112 debug_output += m_DebugContactDamageMessage + "\n";
3113 }
3114 debug_output += "Entity momentum: " + GetMomentum();
3115 debug_output += "\nIsEngineON: " + EngineIsOn();
3116
3117 return debug_output;
3118 }
3119#endif
3120
3121 protected void SpawnUniversalParts()
3122 {
3123 GameInventory inventory = GetInventory();
3124 inventory.CreateInInventory("HeadlightH7");
3125 inventory.CreateInInventory("HeadlightH7");
3126 inventory.CreateInInventory("HeadlightH7");
3127 inventory.CreateInInventory("HeadlightH7");
3128
3129 if (IsVitalCarBattery())
3130 {
3131 inventory.CreateInInventory("CarBattery");
3132 inventory.CreateInInventory("CarBattery");
3133 }
3134
3135 if (IsVitalTruckBattery())
3136 {
3137 inventory.CreateInInventory("TruckBattery");
3138 inventory.CreateInInventory("TruckBattery");
3139 }
3140
3141 if (IsVitalRadiator())
3142 {
3143 inventory.CreateInInventory("CarRadiator");
3144 inventory.CreateInInventory("CarRadiator");
3145 }
3146
3147 if (IsVitalSparkPlug())
3148 {
3149 inventory.CreateInInventory("SparkPlug");
3150 inventory.CreateInInventory("SparkPlug");
3151 }
3152
3153 if (IsVitalGlowPlug())
3154 {
3155 inventory.CreateInInventory("GlowPlug");
3156 inventory.CreateInInventory("GlowPlug");
3157 }
3158 }
3159
3160 protected void SpawnAdditionalItems()
3161 {
3162 GameInventory inventory = GetInventory();
3163 inventory.CreateInInventory("Wrench");
3164 inventory.CreateInInventory("LugWrench");
3165 inventory.CreateInInventory("Screwdriver");
3166 inventory.CreateInInventory("EpoxyPutty");
3167
3168 inventory.CreateInInventory("CanisterGasoline");
3169
3170 EntityAI ent;
3171 ItemBase container;
3172 ent = inventory.CreateInInventory("CanisterGasoline");
3173 if (Class.CastTo(container, ent))
3174 {
3175 container.SetLiquidType(LIQUID_WATER, true);
3176 }
3177
3178 ent = inventory.CreateInInventory("Blowtorch");
3179 if (ent)
3180 {
3181 ent.GetInventory().CreateInInventory("LargeGasCanister");
3182 }
3183
3184 ent = inventory.CreateInInventory("Blowtorch");
3185 if (ent)
3186 {
3187 ent.GetInventory().CreateInInventory("LargeGasCanister");
3188 }
3189 }
3190
3191 protected void FillUpCarFluids()
3192 {
3193 Fill(CarFluid.FUEL, 200.0);
3194 Fill(CarFluid.COOLANT, 200.0);
3195 Fill(CarFluid.OIL, 200.0);
3196 }
3197
3198 protected override event typename GetOwnerStateType()
3199 {
3200 return CarScriptOwnerState;
3201 }
3202
3203 protected override event typename GetMoveType()
3204 {
3205 return CarScriptMove;
3206 }
3207
3208 protected override event void ObtainState(/*inout*/ PawnOwnerState pState)
3209 {
3210 auto state = CarScriptOwnerState.Cast(pState);
3211 state.m_fTime = m_Time;
3212 }
3213
3214 protected override event void RewindState(PawnOwnerState pState, /*inout*/ PawnMove pMove, inout NetworkRewindType pRewindType)
3215 {
3216 auto state = CarScriptOwnerState.Cast(pState);
3217 m_Time = state.m_fTime;
3218 }
3219
3220 // Cars that use the old networking only perform this part of the simulation on the server and not the clients
3221 // TODO(kumarjac): Obsolete this function once new networking is permanently enabled
3223 {
3224 bool isServer = g_Game.IsServer();
3225 if (isServer || GetNetworkMoveStrategy() != NetworkMoveStrategy.PHYSICS)
3226 {
3227 return isServer;
3228 }
3229
3230 return IsOwner();
3231 }
3232
3234 protected float m_BatteryEnergyStartMin = 5.0;
3235 protected bool m_HeadlightsOn;
3236 protected bool m_BrakesArePressed; // not yet actually removed, but functionality will be moved to native to prevent requiring updating of lights every game tick
3237
3242 [Obsolete("no replacement")]
3243 bool OnBeforeSwitchLights(bool toOn)
3244 {
3245 return true;
3246 }
3247
3248 [Obsolete("no replacement")]
3250}
Param4< int, int, string, int > TSelectableActionInfoWithColor
eBleedingSourceType GetType()
CarHornActionData ActionData ActionCarHornShort()
Определения ActionCarHorn.c:67
void ActionManagerBase(PlayerBase player)
Определения ActionManagerBase.c:63
map< typename, ref array< ActionBase_Basic > > TInputActionMap
Определения ActionManagerClient.c:1
ActionPushCarCB ActionPushObjectCB ActionPushCar()
Определения ActionPushCar.c:58
void AddAction(typename actionName)
Определения AdvancedCommunication.c:220
void InitializeActions()
Определения AdvancedCommunication.c:190
int m_DamageType
Определения AreaDamageComponent.c:11
@ OK
0 - No error. Can be returned from any call.
Определения BIOSErrorModule.c:9
enum EBoatEffects STOP_OK
enum EBoatEffects NO_FUEL
enum EBoatEffects NO_IGNITER
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
enum CarDoorState START_NO_BATTERY
CarDoorState
Определения CarScript.c:2
@ DOORS_CLOSED
Определения CarScript.c:5
@ DOORS_MISSING
Определения CarScript.c:3
@ DOORS_OPEN
Определения CarScript.c:4
enum CarDoorState LONG
override event void Read(PawnStateReader ctx)
Определения CarScript.c:144
enum CarDoorState NO_BATTERY
enum CarDoorState SHORT
enum CarDoorState STARTING
enum CarDoorState REVERSE_ONLY
enum CarDoorState BRAKES_ONLY
override event void Write(PawnStateWriter ctx)
Определения CarScript.c:139
enum CarDoorState START_NO_SPARKPLUG
class EconomyOutputStrings OFF
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
void Synchronize()
Определения CombinationLock.c:151
DamageType
exposed from C++ (do not change)
Определения DamageSystem.c:11
DayZGame g_Game
Определения DayZGame.c:3942
float m_fTime
Определения DayZPlayerCamera3rdPerson.c:351
EActions
Определения EActions.c:2
ERPCs
Определения ERPCs.c:2
void Effect()
ctor
Определения Effect.c:72
float m_Time
Определения Environment.c:59
bool IsOwner()
Определения Hand_Events.c:60
@ RUINED
Определения InjuryHandler.c:24
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
string Type
Определения JsonDataContaminatedArea.c:11
static string GetDisplayName(int liquid_type)
Определения Liquid.c:382
string GetDebugText()
Определения ModifierBase.c:71
class NoiseSystem NoiseParams()
Определения Noise.c:15
ProcessDirectDamageFlags
Определения Object.c:2
BOTH
Определения PluginRecipesManagerBase.c:2
WaveKind
Определения Sound.c:2
bool m_Initialized
Определения UiHintPanel.c:317
GetInputType()
Определения ActionBase.c:221
Определения ActionBase.c:59
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
int m_CarHornState
Определения CarScript.c:278
float m_DrownTime
Определения CarScript.c:202
float GetEnviroHeatComfortOverride()
string m_EngineStartOK
Sounds.
Определения CarScript.c:243
override void OnGearChanged(int newGear, int oldGear)
Определения CarScript.c:2026
vector m_side_2_2Pos
Определения CarScript.c:240
override event void ObtainState(PawnOwnerState pState)
Определения CarScript.c:3208
vector GetEnginePosWS()
Определения CarScript.c:486
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:1454
ref EffVehicleSmoke m_engineFx
Определения CarScript.c:222
bool IsVitalGlowPlug()
Определения CarScript.c:2744
float m_FuelAmmount
keeps ammount of each fluid
Определения CarScript.c:191
EffectSound CreateSoundForAnimationSource(string animSource)
Определения CarScript.c:1677
void RemoveAction(typename actionName)
Определения CarScript.c:2913
int m_CarEngineLastSoundState
Определения CarScript.c:307
override vector GetDefaultHitPosition()
Определения CarScript.c:3096
void CarScript()
Определения CarScript.c:319
float m_dmgContactCoef
Определения CarScript.c:198
string GetActionCompNameOil()
Определения CarScript.c:2823
void BrakeAndReverseRearLight()
Определения CarScript.c:2349
override void MarkCrewMemberUnconscious(int crewMemberIndex)
Определения CarScript.c:1886
int m_CarEngineSoundState
Определения CarScript.c:306
static string m_LeftHeadlightPoint
Определения CarScript.c:285
bool IsVitalRadiator()
Определения CarScript.c:2754
void OnIgnition()
Определения CarScript.c:1949
float GetBatteryRechargeRate()
Определения CarScript.c:3010
void BrakeLightsShineOn()
Определения CarScript.c:2423
void CleanupSound(EffectSound sound)
Определения CarScript.c:584
ItemBase GetBattery()
Определения CarScript.c:3015
vector m_exhaustPtcDir
Определения CarScript.c:230
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения CarScript.c:531
float GetActionDistanceOil()
Определения CarScript.c:2828
void LeftFrontLightShineOn()
Определения CarScript.c:2361
float m_BatteryRecharge
Определения CarScript.c:216
vector m_coolantPtcPos
Определения CarScript.c:232
override void MarkCrewMemberDead(int crewMemberIndex)
Определения CarScript.c:1897
static string m_ReverseLightPoint
Определения CarScript.c:284
void UpdateLightsServer(int newGear=-1)
Определения CarScript.c:2222
void TailLightsShineOn()
Определения CarScript.c:2445
vector GetEnginePointPosWS()
Определения CarScript.c:496
void LeftFrontLightShineOff()
Определения CarScript.c:2381
static const int SELECTION_ID_TAIL_LIGHT_L
Определения CarScript.c:299
bool IsVitalTruckBattery()
Определения CarScript.c:2739
static float DROWN_ENGINE_THRESHOLD
Определения CarScript.c:185
EntityAI GetRadiator()
Определения CarScript.c:2769
void SetEngineStarted(bool started)
Определения CarScript.c:2791
void RightFrontLightShineOff()
Определения CarScript.c:2391
static const int SELECTION_ID_BRAKE_LIGHT_R
Определения CarScript.c:296
override event GetMoveType()
Определения CarScript.c:3203
void CheckVitalItem(bool isVital, string slot_name)
Определения CarScript.c:2527
override void EEItemAttached(EntityAI item, string slot_name)
Определения CarScript.c:740
void HandleCarHornSound(ECarHornState pState)
Определения CarScript.c:1767
bool m_ActionsInitialize
Определения CarScript.c:178
float m_BrakeAmmount
Определения CarScript.c:194
static ref map< typename, ref TInputActionMap > m_CarTypeActionsMap
Определения CarScript.c:176
override void OnFluidChanged(CarFluid fluid, float newValue, float oldValue)
Определения CarScript.c:1914
float m_BatteryConsume
Определения CarScript.c:214
bool GetCrashHeavySound()
Определения CarScript.c:2598
ref EffectSound m_CrashSoundHeavy
Определения CarScript.c:259
void ReverseLightsShineOn()
Определения CarScript.c:2401
float m_EnviroHeatComfortOverride
Определения CarScript.c:199
bool CheckOperationalState()
Определения CarScript.c:2021
vector m_side_1_1Pos
Определения CarScript.c:237
void UpdateHeadlightState()
Определения CarScript.c:792
float m_BatteryEnergyStartMin
DEPRECATED.
Определения CarScript.c:3234
void UpdateBattery(ItemBase battery)
Определения CarScript.c:3029
static const int SELECTION_ID_BRAKE_LIGHT_L
Определения CarScript.c:295
override float GetLiquidThroughputCoef()
Определения CarScript.c:525
void ForceUpdateLightsEnd()
Определения CarScript.c:2990
void HandleEngineSound(CarEngineSoundState state)
Определения CarScript.c:1790
static string m_LeftHeadlightTargetPoint
Определения CarScript.c:287
vector m_side_1_2Pos
Определения CarScript.c:238
void LeakFluid(CarFluid fluid)
Определения CarScript.c:2536
override bool CanPutIntoHands(EntityAI parent)
Определения CarScript.c:2843
ref EffectSound m_CarHornSoundEffect
Определения CarScript.c:264
void OnBrakesPressed()
Определения CarScript.c:1197
bool m_HeadlightsOn
Определения CarScript.c:3235
vector m_enginePos
Определения CarScript.c:234
void OnBrakesReleased()
Определения CarScript.c:1202
float m_PlugHealth
Определения CarScript.c:210
bool IsScriptedLightsOn()
Proper way to get if light is swiched on.
Определения CarScript.c:2070
override int Get3rdPersonCameraType()
camera type
Определения CarScript.c:2785
static const string MEMORY_POINT_NAME_CAR_HORN
Определения CarScript.c:188
static const int SELECTION_ID_REVERSE_LIGHT_R
Определения CarScript.c:298
static string m_DrownEnginePoint
Определения CarScript.c:289
vector m_VelocityPrevTick
Определения CarScript.c:180
override event void RewindState(PawnOwnerState pState, PawnMove pMove, inout NetworkRewindType pRewindType)
Определения CarScript.c:3214
vector Get_1_1PointPosWS()
Определения CarScript.c:508
override void OnEngineStop()
Gets called everytime the engine stops.
Определения CarScript.c:2050
static string m_RightHeadlightTargetPoint
Определения CarScript.c:288
override void OnEngineStart()
Gets called everytime the engine starts.
Определения CarScript.c:2033
void TailLightsShineOff()
Определения CarScript.c:2470
float m_MomentumPrevTick
Определения CarScript.c:179
override float OnSound(CarSoundCtrl ctrl, float oldValue)
Определения CarScript.c:1654
override bool OnBeforeLightOn()
Определения CarScript.c:2075
override void OnUpdate(float dt)
Определения CarScript.c:1385
ref EffVehicleSmoke m_coolantFx
Particles.
Определения CarScript.c:221
void NoRearLight()
Определения CarScript.c:2355
int CheckOperationalRequirements()
Определения CarScript.c:1980
override string GetVehicleType()
Определения CarScript.c:481
string m_EngineStartFuel
Определения CarScript.c:246
ref EffectSound m_WindowSmall
Определения CarScript.c:260
void PlayCrashHeavySound()
Определения CarScript.c:2612
float m_OilAmmount
Определения CarScript.c:193
float GetBatteryConsumption()
Определения CarScript.c:3000
vector m_enginePtcPos
Определения CarScript.c:231
string GetDoorSelectionNameFromSeatPos(int posIdx)
Определения CarScript.c:2695
void CleanupEffects()
Определения CarScript.c:553
vector m_side_2_1Pos
Определения CarScript.c:239
void SetActions()
Определения CarScript.c:2871
NoiseSystem m_NoiseSystem
Определения CarScript.c:266
ref NoiseParams m_NoisePar
Определения CarScript.c:265
void CreateCarDestroyedEffect()
Определения CarScript.c:730
float m_BatteryContinuousConsume
Определения CarScript.c:215
void BrakesRearLight()
Определения CarScript.c:2339
string m_CarHornShortSoundName
Определения CarScript.c:255
void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
Определения CarScript.c:2617
CarLightBase m_Headlight
Определения CarScript.c:280
int GetCrewIndex(string selection)
Определения CarScript.c:2705
bool GetCrashLightSound()
Определения CarScript.c:2579
string m_CarDoorCloseSound
Определения CarScript.c:251
override bool CanReleaseAttachment(EntityAI attachment)
Определения CarScript.c:911
override bool OnBeforeEngineStart()
Определения CarScript.c:1941
vector m_frontPos
Определения CarScript.c:235
string m_CarHornLongSoundName
Определения CarScript.c:256
override void OnAttachmentRuined(EntityAI attachment)
Определения CarScript.c:874
string m_CarSeatShiftInSound
Определения CarScript.c:252
static const int SELECTION_ID_REVERSE_LIGHT_L
Определения CarScript.c:297
vector GetCoolantPtcPosWS()
Определения CarScript.c:491
float m_Time
Определения CarScript.c:183
vector Get_2_1PointPosWS()
Определения CarScript.c:516
float m_EngineHealth
Определения CarScript.c:206
void ReverseRearLight()
Определения CarScript.c:2344
void HandleSeatAdjustmentSound(string animSource, float phase)
Определения CarScript.c:1746
override void OnVariablesSynchronized()
Определения CarScript.c:709
CarRearLightBase m_RearLight
Определения CarScript.c:281
string GetAnimSourceFromSelection(string selection)
Определения CarScript.c:2646
int m_RearLightType
Определения CarScript.c:272
string m_EngineStartBattery
Определения CarScript.c:244
override void OnInput(float dt)
Определения CarScript.c:1303
string m_EngineStopFuel
Определения CarScript.c:248
bool IsMoving()
Определения CarScript.c:2774
override bool DetectFlipped(VehicleFlippedContext ctx)
Определения CarScript.c:1294
override void EEInit()
Определения CarScript.c:441
void CarPartsHealthCheck()
Определения CarScript.c:2559
vector m_exhaustPtcPos
Определения CarScript.c:229
void SetCarHornState(int pState)
Определения CarScript.c:3068
void FillUpCarFluids()
Определения CarScript.c:3191
void SynchCrashHeavySound(bool play)
Определения CarScript.c:2603
override void EEHealthLevelChanged(int oldLevel, int newLevel, string zone)
Определения CarScript.c:2931
string GetSelectionFromAnimSource(string animSource)
Определения CarScript.c:2651
bool m_EngineStarted
Определения CarScript.c:275
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения CarScript.c:636
void DashboardShineOff()
Определения CarScript.c:2491
string GetActionCompNameCoolant()
Определения CarScript.c:2813
bool IsVitalCarBattery()
Определения CarScript.c:2734
override void EEItemDetached(EntityAI item, string slot_name)
Определения CarScript.c:815
CarLightBase CreateFrontLight()
Определения CarScript.c:2508
void CheckContactCache()
Responsible for damaging the car according to contact events from OnContact.
Определения CarScript.c:1483
float m_RadiatorHealth
Определения CarScript.c:207
void OnVehicleJumpOutServer(GetOutTransportActionData gotActionData)
Определения CarScript.c:1218
void SynchCrashLightSound(bool play)
Определения CarScript.c:2584
override void OnAnimationPhaseStarted(string animSource, float phase)
Определения CarScript.c:1669
static float DROWN_ENGINE_DAMAGE
Определения CarScript.c:186
void GenerateCarHornAINoise(int pState)
Определения CarScript.c:3079
override void EEDelete(EntityAI parent)
Определения CarScript.c:539
void PlayCrashLightSound()
Определения CarScript.c:2593
float m_FuelTankHealth
Определения CarScript.c:208
static const int SELECTION_ID_FRONT_LIGHT_R
Определения CarScript.c:294
string m_CarDoorOpenSound
Определения CarScript.c:250
CarDoorState TranslateAnimationPhaseToCarDoorState(string animation)
Определения CarScript.c:2801
void HandleDoorsSound(string animSource, float phase)
Определения CarScript.c:1722
void ReverseLightsShineOff()
Определения CarScript.c:2412
ref EffectSound m_CrashSoundLight
Определения CarScript.c:258
const float BATTERY_UPDATE_DELAY
Определения CarScript.c:218
float m_CoolantAmmount
Определения CarScript.c:192
override event GetOwnerStateType()
Определения CarScript.c:3198
int m_exhaustPtcFx
Определения CarScript.c:227
vector Get_1_2PointPosWS()
Определения CarScript.c:512
override void EEKilled(Object killer)
Определения CarScript.c:1447
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения CarScript.c:589
static const int SELECTION_ID_TAIL_LIGHT_R
Определения CarScript.c:300
float GetBatteryRuntimeConsumption()
Определения CarScript.c:3005
ref EffectSound m_WindowLarge
Определения CarScript.c:261
ref EffVehicleSmoke m_exhaustFx
Определения CarScript.c:223
bool m_EngineDestroyed
Определения CarScript.c:276
override void OnDriverExit(Human player)
Определения CarScript.c:1207
static string m_RightHeadlightPoint
Определения CarScript.c:286
bool OnBeforeSwitchLights(bool toOn)
Определения CarScript.c:3243
static vector m_DrownEnginePos
Определения CarScript.c:203
override bool CanReceiveAttachment(EntityAI attachment, int slotId)
Определения CarScript.c:882
vector GetBackPointPosWS()
Определения CarScript.c:504
void SpawnUniversalParts()
Определения CarScript.c:3121
string m_CarSeatShiftOutSound
Определения CarScript.c:253
float GetActionDistanceBrakes()
Определения CarScript.c:2838
void AddAction(typename actionName)
Определения CarScript.c:2882
vector m_backPos
Определения CarScript.c:236
bool IsVitalEngineBelt()
Определения CarScript.c:2749
string GetDoorConditionPointFromSelection(string selection)
Определения CarScript.c:2674
string GetActionCompNameBrakes()
Определения CarScript.c:2833
bool m_PlayCrashSoundLight
Определения CarScript.c:268
ref array< int > m_WheelSmokePtcFx
Определения CarScript.c:304
vector Get_2_2PointPosWS()
Определения CarScript.c:520
int m_HeadlightsState
Определения CarScript.c:271
float GetPushForceCoefficientMultiplier()
Определения CarScript.c:3101
void CheckVitalItem(bool isVital, int slotId)
Определения CarScript.c:2513
void DashboardShineOn()
Определения CarScript.c:2481
bool m_ForceUpdateLights
Определения CarScript.c:274
override bool CanReachSeatFromDoors(string pSeatSelection, vector pFromPos, float pDistance=1.0)
Определения CarScript.c:2710
CarRearLightBase CreateRearLight()
Определения CarScript.c:2502
string GetDoorInvSlotNameFromSeatPos(int posIdx)
Определения CarScript.c:2700
void SpawnAdditionalItems()
Определения CarScript.c:3160
ref EffectSound m_PreStartSound
Определения CarScript.c:262
void RightFrontLightShineOn()
Определения CarScript.c:2371
ref CarContactCache m_ContactCache
Определения CarScript.c:181
float m_BatteryHealth
Определения CarScript.c:209
override void GetActions(typename action_input_type, out array< ActionBase_Basic > actions)
Определения CarScript.c:2860
bool CanManipulateSpareWheel(string slotSelectionName)
Определения CarScript.c:943
void SetCarEngineSoundState(CarEngineSoundState pState)
Определения CarScript.c:1784
vector GetFrontPointPosWS()
Определения CarScript.c:500
static const int SELECTION_ID_DASHBOARD_LIGHT
Определения CarScript.c:301
bool HasRadiator()
Определения CarScript.c:2764
void DamageCrew(float dmg)
Responsible for damaging crew in a car crash.
Определения CarScript.c:1592
void ForceUpdateLightsStart()
Определения CarScript.c:2981
override void EEOnCECreate()
Определения CarScript.c:2967
override void UpdateLights(int new_gear=-1)
Определения CarScript.c:2095
string m_EngineStartPlug
Определения CarScript.c:245
int m_coolantPtcFx
Определения CarScript.c:226
override bool IsInventoryVisible()
Определения CarScript.c:2926
void PlaySound(string soundset, EffectSound sound, out bool soundbool)
Определения CarScript.c:2641
void BrakeLightsShineOff()
Определения CarScript.c:2434
override void EOnPostSimulate(IEntity other, float timeSlice)
Определения CarScript.c:948
void ~CarScript()
Определения CarScript.c:546
string m_EngineStop
Определения CarScript.c:247
ref array< ref EffWheelSmoke > m_WheelSmokeFx
Определения CarScript.c:303
bool IsHandbrakeActive()
Определения CarScript.c:2779
TInputActionMap m_InputActionMap
Определения CarScript.c:177
bool m_BrakesArePressed
Определения CarScript.c:3236
bool IsVitalFuelTank()
Определения CarScript.c:2759
bool IsServerOrOwner()
Определения CarScript.c:3222
void InitializeActions()
Определения CarScript.c:2848
void UpdateLightsClient(int newGear=-1)
Определения CarScript.c:2103
int m_enginePtcFx
Определения CarScript.c:225
bool m_PlayCrashSoundHeavy
Определения CarScript.c:269
EntityAI m_Radiator
Определения CarScript.c:212
void ToggleHeadlights()
Switches headlights on/off, including the illumination of the control panel and synchronizes this cha...
Определения CarScript.c:2088
int GetCarDoorsState(string slotType)
Определения CarScript.c:2796
float m_BatteryTimer
Определения CarScript.c:217
static const int SELECTION_ID_FRONT_LIGHT_L
Определения CarScript.c:293
float GetActionDistanceCoolant()
Определения CarScript.c:2818
static int SLOT_ID
Определения CarBattery.c:3
Определения CarBattery.c:2
Определения CarScript.c:171
Определения CarRearLightBase.c:2
Определения Car.c:94
Определения Car.c:90
override CarRearLightBase CreateRearLight()
Определения CivilianSedan.c:119
override string GetDoorConditionPointFromSelection(string selection)
Определения OffroadHatchback.c:351
override CarLightBase CreateFrontLight()
Определения CivilianSedan.c:113
override bool IsVitalGlowPlug()
Определения CivilianSedan.c:363
override bool IsVitalTruckBattery()
Определения CivilianSedan.c:358
override string GetAnimSourceFromSelection(string selection)
Определения CivilianSedan.c:337
override void SetActions()
Определения OffroadHatchback.c:450
override bool IsVitalRadiator()
Определения Offroad_02.c:394
override bool IsVitalCarBattery()
Определения Truck_01_Base.c:346
override bool IsVitalSparkPlug()
Определения Offroad_02.c:389
bool CanManipulateSpareWheel(string slotSelectionName)
Определения CivilianSedan.c:140
Определения CivilianSedan.c:2
Определения CarScript.c:151
Super root of all classes in Enforce script.
Определения EnScript.c:11
Определения DallasMask.c:2
float Impulse
Impulse applied to resolve the collision.
Определения Contact.c:21
Определения Contact.c:10
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.
Определения 3_Game/DayZ/tools/Debug.c:305
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.
Определения 3_Game/DayZ/tools/Debug.c:182
static void ActionLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Определения 3_Game/DayZ/tools/Debug.c:187
Определения 3_Game/DayZ/tools/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
void SetSoundSet(string snd)
Set soundset for the sound.
Определения EffectSound.c:794
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:784
void SetSoundFadeOut(float fade_out)
Set the sound fade out duration.
Определения EffectSound.c:904
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
override void SetParent(Object parent_obj, int pivot)
Set parent for the sound to follow.
Определения EffectSound.c:654
bool SoundPlay()
Plays sound.
Определения EffectSound.c:199
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)
script counterpart to engine's class Inventory
Определения GreatHelm.c:2
proto native bool IsControllingVehicle()
Определения human.c:1333
Определения 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:30
static proto native int GetSlotIdFromString(string slot_name)
converts string to slot_id
static proto bool GetSelectionForSlotId(int slot_Id, out string selection)
provides access to slot configuration
Определения InventorySlots.c:6
static bool IsActionLogEnable()
Определения 3_Game/DayZ/tools/Debug.c:736
Определения 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 bool IsEffectExist(int effect_id)
Checks whether an Effect ID is registered in SEffectManager.
Определения EffectManager.c:294
static int EffectRegister(Effect effect)
Registers Effect in SEffectManager.
Определения EffectManager.c:322
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Определения EffectManager.c:271
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
static int GetWheelParticleID(string surface_name)
Определения Surface.c:8
Определения Surface.c:2
Определения DamageSystem.c:2
static int SLOT_ID
Определения TruckBattery.c:3
Определения TruckBattery.c:2
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Определения CachedEquipmentStorage.c:4
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:284
static const vector Zero
Определения EnConvert.c:123
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Определения EnConvert.c:233
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:120
Определения EnConvert.c:119
DayZPlayerConstants
defined in C++
Определения dayzplayer.c:602
Serializer ParamsReadContext
Определения gameplay.c:15
const float CARS_CONTACT_DMG_THRESHOLD
Определения 3_Game/DayZ/constants.c:841
const float CARS_CONTACT_DMG_MIN
Определения 3_Game/DayZ/constants.c:842
const float CARS_CONTACT_DMG_KILLCREW
Определения 3_Game/DayZ/constants.c:843
const int CARS_FLUIDS_TICK
Определения 3_Game/DayZ/constants.c:830
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.
array< string > TStringArray
Определения EnScript.c:712
void Obsolete(string msg="")
Определения EnScript.c:371
EntityEvent
Entity events for event-mask, or throwing event from code.
Определения EnEntity.c:45
@ CONTACT
Определения EnEntity.c:97
const float DAMAGE_RUINED_VALUE
Определения 3_Game/DayZ/constants.c:867
const float DAMAGE_DAMAGED_VALUE
Определения 3_Game/DayZ/constants.c:865
const int STATE_RUINED
Определения 3_Game/DayZ/constants.c:851
const float LIQUID_THROUGHPUT_CAR_DEFAULT
Определения 3_Game/DayZ/constants.c:575
const int LIQUID_WATER
Определения 3_Game/DayZ/constants.c:544
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
body is not in simulation, nor in collision world
Определения SimulationState.c:15
ActiveState
Определения ActiveState.c:10
proto native vector dBodyGetVelocityAt(notnull IEntity body, vector globalpos)
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native void dBodyActive(notnull IEntity ent, ActiveState activeState)
proto native float dBodyGetMass(notnull IEntity ent)
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:457
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
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.
proto int ToLower()
Changes string to lowercase. Returns length.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
const float VEHICLE_FLIP_ANGLE_TOLERANCE
Определения 3_Game/DayZ/constants.c:821
const bool VEHICLE_FLIP_WHEELS_LIMITED
Angle of the vehicle from the normal of the surface under the vehicle.
Определения 3_Game/DayZ/constants.c:822