DayZ 1.30
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено
Transport.c
См. документацию.
1
5{
6
7};
8
9#ifdef FEATURE_NETWORK_RECONCILIATION
10
11class TransportOwnerState : PawnOwnerState
12{
13 proto native void SetWorldTransform(vector transform[4]);
14 proto native void GetWorldTransform(out vector transform[4]);
15
16 proto native void SetLinearVelocity(vector value);
17 proto native void GetLinearVelocity(out vector value);
18
19 proto native void SetAngularVelocity(vector value);
20 proto native void GetAngularVelocity(out vector value);
21
22 proto native void SetBuoyancySubmerged(float value);
23 proto native float GetBuoyancySubmerged();
24
25#ifdef DIAG_DEVELOPER
26 override event void GetTransform(inout vector transform[4])
27 {
28 GetWorldTransform(transform);
29 }
30#endif
31};
32
33class TransportMove : PawnMove
34{
35 proto native void SetWorldTransform(vector transform[4]);
36 proto native void GetWorldTransform(out vector transform[4]);
37
38 proto native void SetLinearVelocity(vector value);
39 proto native void GetLinearVelocity(out vector value);
40
41 proto native void SetAngularVelocity(vector value);
42 proto native void GetAngularVelocity(out vector value);
43
44#ifdef DIAG_DEVELOPER
45 override event void GetTransform(inout vector transform[4])
46 {
47 GetWorldTransform(transform);
48 }
49#endif
50};
51
52enum ETransportFluid
53{
54 FUEL,
55 OIL,
56 BRAKE,
57 COOLANT,
58
59 USER1,
60 USER2,
61 USER3,
62 USER4
63};
64
66class Transport extends Pawn
67#else
68class Transport extends EntityAI
69#endif
70{
73
77
78 protected bool m_EngineStarted;
79 protected bool m_EngineDestroyed;
80
81 protected int m_HeadlightsState;
82 protected int m_RearLightType;
83
85 protected vector m_fuelPos;
86
87 protected ref set<int> m_UnconsciousCrewMemberIndices;
88 protected ref set<int> m_DeadCrewMemberIndices;
89
91 protected float m_dmgContactCoef = 0.023;
92 protected float m_VehicleContactDamageCoef = 0.12;
93 protected float m_CrewContactDamageCoef = 0.023;
95 protected float m_MomentumPrevTick;
97
98 protected bool m_PlayCrashSoundLight;
99 protected bool m_PlayCrashSoundHeavy;
102
103 #ifdef DIAG_DEVELOPER
104 static EVehicleDebugOutputType DEBUG_OUTPUT_TYPE;
105 bool m_ContactCalled;
106 #endif
107
109 {
110 RegisterNetSyncVariableBool("m_EngineZoneReceivedHit");
111
112 if ( MemoryPointExists("refill") )
113 m_fuelPos = GetMemoryPointPos("refill");
114 else
115 m_fuelPos = "0 0 0";
116
117 m_UnconsciousCrewMemberIndices = new set<int>();
118 m_DeadCrewMemberIndices = new set<int>();
119
121
122 m_PlayCrashSoundLight = false;
123 m_PlayCrashSoundHeavy = false;
124 }
125
127 {
128 #ifndef SERVER
129 #ifndef NO_GUI
131 #endif
132 #endif
133 }
134
135 override void EEDelete(EntityAI parent)
136 {
137 #ifndef SERVER
138 #ifndef NO_GUI
140 #endif
141 #endif
142 }
143
144 override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
145 {
146 super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
147
148 SetEngineZoneReceivedHit(dmgZone == "Engine");
149
150 // TODO(kumarjac): Lets call this in native instead after script events have gone through? Cheaper, faster.
151 GetGame().GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallLater(OnUpdateLight, 100, false);
152 }
153
154 override int GetMeleeTargetType()
155 {
156 return EMeleeTargetType.NONALIGNABLE;
157 }
158
160 protected override event typename GetOwnerStateType()
161 {
162 return TransportOwnerState;
163 }
164
166 protected override event typename GetMoveType()
167 {
168 return TransportMove;
169 }
170
172 proto native void Synchronize();
173
175 proto native int CrewSize();
176
179 proto native int CrewPositionIndex( int componentIdx );
180
183 proto native int CrewMemberIndex( Human player );
184
187 proto native Human CrewMember( int posIdx );
188
191 proto native Human CrewDriver();
192
194 proto void CrewEntry( int posIdx, out vector pos, out vector dir );
195
197 proto void CrewEntryWS( int posIdx, out vector pos, out vector dir );
198
200 proto void CrewTransform( int posIdx, out vector mat[4] );
201
203 proto void CrewTransformWS( int posIdx, out vector mat[4] );
204
206 proto native void CrewGetIn( Human player, int posIdx );
207
209 proto native Human CrewGetOut( int posIdx );
210
212 proto native void CrewDeath( int posIdx );
213
218 void OnDriverEnter(Human player) {}
219
224 void OnDriverExit(Human player) {}
225
227 proto native bool LightIsOn();
228
230 proto native void LightOn();
231
233 proto native void LightOff();
234
236 proto native void LightToggle();
237
244 {
245 // light can turn on by default
246 return true;
247 }
248
253 {
254 UpdateLights();
255 }
256
258
260 proto void ApplyForce(vector force);
261
263 proto void ApplyTorque(vector force);
264
266 proto void ApplyForceAt(vector pos, vector force);
267
269 proto void ApplyCentralImpulse(vector centralImpulse);
270
272 proto void ApplyTorqueImpulse(vector torqueImpulse);
273
275 proto void ApplyImpulseAt(vector pos, vector force);
276
278
283 proto native int Random();
284
290 proto native float RandomRange(int pRange);
291
296 proto native float Random01();
297
302 float RandomFloat(float min, float max)
303 {
304 return Random01() * (max - min) + min;
305 }
306
315 void OnContact(string zoneName, vector localPos, IEntity other, Contact data)
316 {
317 if (GetGame().IsServer())
318 {
319 #ifdef DIAG_DEVELOPER
320 m_ContactCalled = true;
321 if (DEBUG_OUTPUT_TYPE & EVehicleDebugOutputType.CONTACT)
322 {
323 string output = "Zone: " + zoneName + " | Impulse:" + data.Impulse;
324 Debug.Log(output);
325 }
326 #endif
327 if (m_ContactCache.Count() == 0)
328 {
330 m_ContactCache.Insert(zoneName, ccd);
331 float momentumDelta = GetMomentum() - m_MomentumPrevTick;
332 float dot = vector.Dot(m_VelocityPrevTick.Normalized(), GetVelocity(this).Normalized());
333 if (dot < 0)
334 {
335 momentumDelta = m_MomentumPrevTick;
336 }
337
338 VehicleContactData contactData = new VehicleContactData();
339 contactData.SetData(localPos, other, momentumDelta);
340 ccd.Insert(contactData);
341 }
342 }
343 }
344
353 void OnInput(float dt) {}
354
359 void OnUpdate(float dt) {}
360
361 // Scripted function
362 void UpdateLights(int new_gear = -1) {}
363
364 override bool IsTransport()
365 {
366 return true;
367 }
368
370 {
371 return true;
372 }
373
375 {
376 return false;
377 }
378
379 override bool IsHealthVisible()
380 {
381 return true;
382 }
383
384 override bool ShowZonesHealth()
385 {
386 return true;
387 }
388
389 override int GetHideIconMask()
390 {
391 return EInventoryIconVisibility.HIDE_VICINITY;
392 }
393
394 override bool CanPutIntoHands(EntityAI parent)
395 {
396 return false;
397 }
398
400 {
401 return GetVelocity(this).Length() * dBodyGetMass(this);
402 }
403
405 {
406 return true;
407 }
408
410 {
411 return true;
412 }
413
415 {
416 return true;
417 }
418
419
420 protected void CheckVitalItemCallback(bool isVital, int slotId, Object caller = null, string callbackMethodName = "", Param params = null)
421 {
422 GameInventory inventory = GetInventory();
423 if ( !isVital || !inventory )
424 return;
425
426 EntityAI item = inventory.FindAttachment(slotId);
427
428 if (!item || item.IsRuined())
429 {
430 if (caller && callbackMethodName)
431 {
432 g_Game.GetCallQueue(CALL_CATEGORY_GAMEPLAY).CallByName(caller, callbackMethodName, params);
433 }
434 }
435 }
436
437 protected void PartsHealthCheck();
438
440 int GetFluidCapacityScript(ETransportFluid fluidType)
441 {
442 return 0;
443 }
444
445 float GetFluidFractionScript(ETransportFluid fluidType)
446 {
447 return 0.0;
448 }
449
450 void FillScript(ETransportFluid fluidType, float amount);
451
452 void UpdateBattery(IEntity battery);
453
455 {
456 return "VehicleTypeUndefined";
457 }
458
460 {
461 return "refill";
462 }
463
465 {
466 return 1.5;
467 }
468
470 {
471 return ModelToWorld( m_fuelPos );
472 }
473
476 {
477 return 1.0;
478 }
479
480
481 protected string GetSelectionFromAnimSource( string animSource )
482 {
483 // Brute force for vehicles that aren't set up
484
485 TStringArray allSelections = new TStringArray();
486 GetSelectionList(allSelections);
487
488 int allSelectionCount = allSelections.Count();
489 for (int s = 0; s < allSelectionCount; ++s)
490 {
491 string selectionAll = allSelections[s];
492 string animSrc = GetAnimSourceFromSelection(selectionAll);
493 animSrc.ToLower();
494 if (animSrc != animSource)
495 continue;
496
497 if (animSrc)
498 {
499 return selectionAll;
500 }
501 }
502
503 return "";
504 }
505
506 protected EffectSound CreateSoundForAnimationSource(string animSource);
507
509 {
510 if (!m_FlippedContext)
511 {
513 }
514
515#ifdef DIAG_DEVELOPER
516 m_FlippedContext.Reset(DiagMenu.GetBool(DiagMenuIDs.VEHICLE_DRAW_FLIP_CONTEXT));
517#endif
518
519 return m_FlippedContext;
520 }
521
522 protected bool DetectFlippedUsingSurface(VehicleFlippedContext ctx, float angleTolerance)
523 {
524 vector corners[4];
525 GetTightlyPackedCorners(ETransformationAxis.BOTTOM, corners);
526
527 // compute the average position to find the lowest "center-most" position
528 vector avgPosition = vector.Zero;
529 for (int i = 0; i < 4; i++)
530 {
531 avgPosition = avgPosition + corners[i];
532 }
533
534 avgPosition = avgPosition * 0.25;
535
536 // get depth of the water to determine if we should use the roadway surface normal or just up vector
537 float depth = g_Game.GetWaterDepth(avgPosition);
538
539 vector normal = vector.Up;
540 vector dirUp = GetDirectionUp();
541
542 bool testLand = depth < -1.0;
543
544 // iterate over the corners to find the average normal
545 if (testLand)
546 {
547 // trace roadway, incase the vehicle is on a rock, or bridge
549
550 // ignore expensive water computation, we already know we are above land
551 ctx.m_SurfaceParams.includeWater = false;
552
553 // ignore this vehicle, it may have a roadway LOD
554 ctx.m_SurfaceParams.ignore = this;
555
556 // detect closest to the given point
557 ctx.m_SurfaceParams.rsd = RoadSurfaceDetection.CLOSEST;
558
559 for (i = 0; i < 4; i++)
560 {
561 ctx.m_SurfaceParams.position = corners[i];
562
563 g_Game.GetSurface(ctx.m_SurfaceParams, ctx.m_SurfaceResult);
564
565 corners[i][1] = ctx.m_SurfaceResult.height;
566 }
567
568 vector d0 = vector.Direction(corners[0], corners[1]);
569 vector d1 = vector.Direction(corners[0], corners[2]);
570
571 d0.Normalize();
572 d1.Normalize();
573
574 // cross product the two directions to get the normal vector of the land
575 normal = d0 * d1;
576 }
577
578 bool isFlipped = vector.Dot(normal, dirUp) < Math.Cos(angleTolerance * Math.DEG2RAD);
579
580#ifdef DIAG_DEVELOPER
581 if (ctx.IsDebug())
582 {
583 int color = 0xFF00FF00;
584 if (isFlipped)
585 color = 0xFFFF0000;
586
587 ctx.AddShape(Shape.Create(ShapeType.LINE, color, ShapeFlags.NOZBUFFER, corners[0], corners[0] + normal));
588 ctx.AddShape(Shape.Create(ShapeType.LINE, color, ShapeFlags.NOZBUFFER, corners[1], corners[1] + normal));
589 ctx.AddShape(Shape.Create(ShapeType.LINE, color, ShapeFlags.NOZBUFFER, corners[2], corners[2] + normal));
590 ctx.AddShape(Shape.Create(ShapeType.LINE, color, ShapeFlags.NOZBUFFER, corners[3], corners[3] + normal));
591 }
592#endif
593
594 return isFlipped;
595 }
596
599 {
600 return false;
601 }
602
604 /*sealed*/ bool IsFlipped()
605 {
607 ctx.m_bIsAction = false;
608 ctx.m_ActionPlayer = null;
609 return DetectFlipped(ctx);
610 }
611
613 /*sealed*/ bool IsActionFlipped(Man player)
614 {
616 ctx.m_bIsAction = true;
617 ctx.m_ActionPlayer = player;
618 return DetectFlipped(ctx);
619 }
620
622 {
623 for (int index = 0; index < CrewSize(); ++index)
624 {
625 if (CrewMember(index) != null)
626 return true;
627 }
628
629 return false;
630 }
631
632 bool IsAnyCrewPresent(TIntArray positionIndices)
633 {
634 TIntArray indices = new TIntArray();
635 bool isPresent;
636 for (int index = 0; index < CrewSize(); ++index)
637 {
638 if (CrewMember(index) != null)
639 {
640 isPresent = true;
641 indices.Insert(index);
642 }
643 }
644
645 positionIndices.Copy(indices);
646 return isPresent;
647 }
648
650 {
651 return 4.0;
652 }
653
654 void MarkCrewMemberUnconscious(int crewMemberIndex);
655 void MarkCrewMemberDead(int crewMemberIndex);
656
658 {
659 return "0 1.3 0";
660 }
661
663 {
664#ifndef CFGMODS_DEFINE_TEST
665 Error("GetAnimInstance() not implemented");
666 return 0;
667#else
668 return 2;
669#endif
670 }
671
672 bool CanGetIn()
673 {
674 return true;
675 }
676
678 {
679 return false;
680 }
681
682 int GetSeatAnimationType(int posIdx)
683 {
684#ifndef CFGMODS_DEFINE_TEST
685 Error("GetSeatAnimationType() not implemented");
686#endif
687 return 0;
688 }
689
690 int GetSeatAnimationTypeDirectional(int posIdx, int directionIndex)
691 {
692#ifndef CFGMODS_DEFINE_TEST
693 Error("GetSeatAnimationTypeDirectional() not implemented");
694#endif
695 return 0;
696 }
697
699 {
700#ifndef CFGMODS_DEFINE_TEST
701 Error("Get3rdPersonCameraType() not implemented");
702 return 0;
703#else
704 return 31;
705#endif
706 }
707
711 bool CrewCanEject(int posIdx)
712 {
713 return false;
714 }
715
719 bool CrewShouldEject(int posIdx)
720 {
721 return false;
722 }
723
724 bool CrewCanGetThrough( int posIdx )
725 {
726#ifndef CFGMODS_DEFINE_TEST
727 return false;
728#else
729 return true;
730#endif
731 }
732
733 bool CanReachSeatFromSeat( int currentSeat, int nextSeat )
734 {
735#ifndef CFGMODS_DEFINE_TEST
736 return false;
737#else
738 return true;
739#endif
740 }
741
742 bool CanReachSeatFromDoors( string pSeatSelection, vector pFromPos, float pDistance = 1.0 )
743 {
744#ifndef CFGMODS_DEFINE_TEST
745 return false;
746#else
747 return true;
748#endif
749 }
750
751 bool CanReachDoorsFromSeat( string pDoorsSelection, int pCurrentSeat )
752 {
753#ifndef CFGMODS_DEFINE_TEST
754 return false;
755#else
756 return true;
757#endif
758 }
759
760 int GetSeatIndexFromDoor( string pDoorSelection )
761 {
762 //Potientially could be fixed some other way, currently follows the unfortunate pattern that CanReachDoorsFromSeat has created
763 switch (pDoorSelection)
764 {
765 case "DoorsDriver":
766 return 0;
767 break;
768 case "DoorsCoDriver":
769 return 1;
770 break;
771 case "DoorsCargo1":
772 return 2;
773 break;
774 case "DoorsCargo2":
775 return 3;
776 break;
777 }
778 return -1;
779 }
780
782 {
783 if (!o)
784 return false;
785
787 int layer = dBodyGetInteractionLayer(o);
788 bool interacts = dGetInteractionLayer(this, PhxInteractionLayers.CHARACTER, layer);
789 if (!interacts)
790 {
791 return true;
792 }
793
794 DayZPlayer player;
795 if (Class.CastTo(player, o))
796 {
798 HumanCommandVehicle hcv = player.GetCommand_Vehicle();
799 if (hcv && hcv.GetTransport() == this)
800 {
801 return true;
802 }
803 }
804
805 EntityAI e = EntityAI.Cast(o);
806 // CanBeSkinned means it is a dead entity which should not block the door
807 return ( ( e && (e.IsZombie() || e.IsHologram()) ) || o.CanBeSkinned() || o.IsBush() || o.IsTree() );
808 }
809
810 void SetEngineZoneReceivedHit(bool pState)
811 {
813 SetSynchDirty();
814 }
815
817 {
819 }
820
822 {
823 return true;
824 }
825
827 {
828 return null;
829 }
830
832 {
833 return "";
834 }
835
836 string GetAnimSourceFromSelection(string selection)
837 {
838 return "";
839 }
840
843
844 bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight, inout vector extents, out vector transform[4] )
845 {
846 GetTransform(transform);
847
848 vector crewPos;
849 vector crewDir;
850 CrewEntry( currentSeat, crewPos, crewDir );
851
852 vector entry[4];
853 entry[2] = crewDir;
854 entry[0] = vector.Up * crewDir;
855 entry[1] = entry[2] * entry[0];
856 entry[3] = crewPos;
857
858 Math3D.MatrixMultiply4( transform, entry, transform );
859
860 vector position = transform[3];
862
863 position[1] = position[1] + maxAllowedObjHeight + (extents[1] * 0.5);
864
865 array<Object> excluded = new array<Object>;
866 array<Object> collided = new array<Object>;
867
868 excluded.Insert(this);
869
870 g_Game.IsBoxColliding(position, orientation, extents, excluded, collided);
871
872 orientation.RotationMatrixFromAngles(transform);
873 transform[3] = position;
874
875 foreach (Object o : collided)
876 {
877 EntityAI e = EntityAI.Cast(o);
878 if (IsIgnoredObject(o))
879 continue;
880
881 vector minmax[2];
882 if (o.GetCollisionBox(minmax))
883 return false;
884 }
885
886 return true;
887 }
888
889 bool IsAreaAtDoorFree( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
890 {
891 vector transform[4];
892 vector extents;
893
894 extents[0] = horizontalExtents;
895 extents[1] = playerHeight;
896 extents[2] = horizontalExtents;
897
898 return IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform );
899 }
900
901 bool IsAreaAtDoorFreeDiag(int currentSeat, float maxAllowedObjHeight, inout vector extents, out vector transform[4])
902 {
903 if (DiagMenu.GetBool(DiagMenuIDs.TRANSPORT_FREESPACE_DISABLED))
904 return true;
905
906 return IsAreaAtDoorFree(currentSeat, maxAllowedObjHeight, extents, transform);
907 }
908
909 bool IsAreaAtDoorFreeDiag(int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7)
910 {
911 if (DiagMenu.GetBool(DiagMenuIDs.TRANSPORT_FREESPACE_DISABLED))
912 return true;
913
914 return IsAreaAtDoorFree(currentSeat, maxAllowedObjHeight, horizontalExtents, playerHeight);
915 }
916
917 // --------------------------------------------------------------------------------
918
919 protected bool GetCrashLightSound()
920 {
922 }
923
924 // --------------------------------------------------------------------------------
925
926 protected bool GetCrashHeavySound()
927 {
929 }
930
931 // --------------------------------------------------------------------------------
932
933 protected void SynchCrashLightSound(bool play)
934 {
935 if (m_PlayCrashSoundLight != play)
936 {
938 SetSynchDirty();
939 }
940 }
941
942 // --------------------------------------------------------------------------------
943
944 protected void SynchCrashHeavySound(bool play)
945 {
946 if (m_PlayCrashSoundHeavy != play)
947 {
949 SetSynchDirty();
950 }
951 }
952
953 // --------------------------------------------------------------------------------
954
955 protected void PlayCrashLightSound();
956
957 // --------------------------------------------------------------------------------
958
959 protected void PlayCrashHeavySound();
960
961 // --------------------------------------------------------------------------------
962
963 protected void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
964 {
965 #ifndef SERVER
966 #ifndef NO_GUI
967 if (!sound)
968 {
970 if( sound )
971 {
972 sound.SetAutodestroy(true);
973 }
974 }
975 else
976 {
977 if (!sound.IsSoundPlaying())
978 {
979 sound.SetPosition(GetPosition());
980 sound.SoundPlay();
981 }
982 }
983
984 soundbool = false;
985 #endif
986 #endif
987 }
988
989 // --------------------------------------------------------------------------------
990
991 void PlaySound(string soundset, EffectSound sound, out bool soundbool)
992 {
993 PlaySoundEx(soundset, sound, soundbool);
994 }
995
996 // --------------------------------------------------------------------------------
997
1003
1004 // --------------------------------------------------------------------------------
1005
1006 #ifdef DIAG_DEVELOPER
1007 override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
1008 {
1009 super.GetDebugActions(outputList);
1010
1011 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.DELETE, "Delete", FadeColors.RED));
1012 if (Gizmo_IsSupported())
1013 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_OBJECT, "Gizmo Object", FadeColors.LIGHT_GREY));
1014 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.GIZMO_PHYSICS, "Gizmo Physics (SP Only)", FadeColors.LIGHT_GREY)); // intentionally allowed for testing physics desync
1015 outputList.Insert(new TSelectableActionInfoWithColor(SAT_DEBUG_ACTION, EActions.SEPARATOR, "___________________________", FadeColors.RED));
1016 }
1017
1018 override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
1019 {
1020 if (super.OnAction(action_id, player, ctx))
1021 return true;
1022
1023 if (GetGame().IsClient() || !GetGame().IsMultiplayer())
1024 {
1025 switch (action_id)
1026 {
1027 case EActions.GIZMO_OBJECT:
1028 if (GetGizmoApi())
1029 GetGizmoApi().SelectObject(this);
1030 return true;
1031 case EActions.GIZMO_PHYSICS:
1032 if (GetGizmoApi())
1033 GetGizmoApi().SelectPhysics(GetPhysics());
1034 return true;
1035 }
1036 }
1037
1038 if (GetGame().IsServer())
1039 {
1040 switch (action_id)
1041 {
1042 case EActions.DELETE:
1043 Delete();
1044 return true;
1045 }
1046 }
1047
1048 return false;
1049 }
1050 #endif
1051
1052 Shape DebugFreeAreaAtDoor( int currentSeat, float maxAllowedObjHeight = 0.5, float horizontalExtents = 0.5, float playerHeight = 1.7 )
1053 {
1054 int color = ARGB(20, 0, 255, 0);
1055
1056 vector transform[4];
1057 vector extents;
1058
1059 extents[0] = horizontalExtents;
1060 extents[1] = playerHeight;
1061 extents[2] = horizontalExtents;
1062
1063 if (!IsAreaAtDoorFree( currentSeat, maxAllowedObjHeight, extents, transform ))
1064 {
1065 color = ARGB(20, 255, 0, 0);
1066 }
1067
1068 Shape shape = Debug.DrawBox(-extents * 0.5, extents * 0.5, color);
1069 shape.SetMatrix(transform);
1070 return shape;
1071 }
1072}
1073
1074#ifdef DIAG_DEVELOPER
1075enum EVehicleDebugOutputType
1076{
1077 NONE,
1078 DAMAGE_APPLIED = 1,
1079 DAMAGE_CONSIDERED = 2,
1080 CONTACT = 4
1081 //OTHER = 8
1082 //OTHER = 16
1083}
1084
1085class CrashDebugData
1086{
1087 static ref array<ref CrashDebugData> m_CrashData = new array<ref CrashDebugData>;
1088 static ref CrashDebugData m_CrashDataPoint;
1089 //data is recorded on server, upon request, sent to the client
1090 static void SendData(DayZPlayer player)
1091 {
1092 /*
1093 m_CrashData.Clear();
1094 CrashDebugData fakeData = new CrashDebugData();
1095 fakeData.m_VehicleType = "FakeVehicle";
1096 m_CrashData.Insert(fakeData);
1097 */
1098 GetGame().RPCSingleParam(player, ERPCs.DIAG_VEHICLES_DUMP_CRASH_DATA_CONTENTS, new Param1<array<ref CrashDebugData>>(m_CrashData), true, player.GetIdentity());
1099 }
1100
1101 //this is client requesting to dump the data it previously received from the server
1102 static void DumpDataArray(array<ref CrashDebugData> dataArray)
1103 {
1104 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");
1105 foreach (CrashDebugData data:dataArray)
1106 {
1107 DumpData(data);
1108 }
1109 }
1110
1111 static void DumpData(CrashDebugData data)
1112 {
1113 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;
1114 output += ";"+data.m_SpeedWorld+";"+data.m_SpeedWorldPrev+";"+data.m_SpeedWorldDelta+";"+data.m_VelocityCur;
1115 output += ";"+data.m_VelocityPrev+";"+data.m_VelocityDot+";"+data.m_Time+";"+data.m_CrewDamageBase+";"+data.m_ShockTemp+";"+data.m_DMGHealth+";"+data.m_DMGShock;
1116 Print(output);
1117 }
1118
1119 string m_VehicleType;
1120 string m_DamageType;
1121 float m_Damage;
1122 string m_Zone;
1123 float m_MomentumCurr;
1124 float m_MomentumPrev;
1125 float m_MomentumDelta;
1126 float m_Speedometer;
1127 float m_SpeedWorld;
1128 float m_SpeedWorldPrev;
1129 float m_SpeedWorldDelta;
1130 vector m_VelocityCur;
1131 vector m_VelocityPrev;
1132 float m_VelocityDot;
1133 float m_Time;
1134 float m_CrewDamageBase;
1135 float m_ShockTemp;
1136 float m_DMGHealth;
1137 float m_DMGShock;
1138}
1139
1140#endif
1141
1143
1145{
1149
1150 void SetData(vector localPos, IEntity other, float impulse)
1151 {
1152 m_LocalPos = localPos;
1153 m_Other = other;
1154 m_Impulse = impulse;
1155 }
1156};
1157
1159{
1160 bool m_bIsAction = false;
1162
1165
1166#ifdef DIAG_DEVELOPER
1167 private ref array<Shape> m_DebugShapes;
1168 private bool m_bIsDebug;
1169
1171 {
1172 m_DebugShapes = new array<Shape>();
1173 }
1174
1176 {
1177 Reset();
1178 }
1179
1180 void Reset(bool isDebug = false)
1181 {
1182 foreach (Shape shape : m_DebugShapes)
1183 {
1184 shape.Destroy();
1185 }
1186
1187 m_DebugShapes.Clear();
1188
1189 m_bIsDebug = isDebug;
1190 }
1191
1192 void AddShape(Shape shape)
1193 {
1194 m_DebugShapes.Insert(shape);
1195 }
1196
1197 bool IsDebug()
1198 {
1199 return m_bIsDebug;
1200 }
1201#endif
1202
1203 [Obsolete("no replacement")]
1205}
Param4< int, int, string, int > TSelectableActionInfoWithColor
int m_DamageType
Определения AreaDamageComponent.c:11
override bool OnAction(int action_id, Man player, ParamsReadContext ctx)
Определения DayZAnimal.c:136
override void GetDebugActions(out TSelectableActionInfoArrayEx outputList)
Определения DayZAnimal.c:125
DayZGame g_Game
Определения DayZGame.c:4074
PhxInteractionLayers
Определения DayZPhysics.c:2
vector position
Определения DustKickupEffects.c:20
vector orientation
Определения DustKickupEffects.c:21
EActions
Определения EActions.c:2
ECrewMemberState
Определения ECrewMemberState.c:3
DiagMenuIDs
Определения EDiagMenuIDs.c:2
EMeleeTargetType
Определения EMeleeTargetType.c:2
ERPCs
Определения ERPCs.c:2
ETransformationAxis
Определения ETransformationAxis.c:2
proto GizmoApi GetGizmoApi()
class BoxCollidingParams component
ComponentInfo for BoxCollidingResult.
override void UpdateLights(int new_gear=-1)
Определения MotorbikeScript.c:1080
override void CleanupEffects()
Определения MotorbikeScript.c:1414
SurfaceDetectionType
Определения SurfaceInfo.c:86
map VehicleContactCache
override string GetAnimSourceFromSelection(string selection)
float m_Time
Определения WoundInfection.c:22
Super root of all classes in Enforce script.
Определения EnScript.c:11
float Impulse
Impulse applied to resolve the collision.
Определения Contact.c:21
Определения Contact.c:10
Определения DayZPlayerImplement.c:87
static Shape DrawBox(vector pos1, vector pos2, int color=0x1fff7f7f)
Определения 3_Game/DayZ/tools/Debug.c:362
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:183
Определения 3_Game/DayZ/tools/Debug.c:2
Определения EnDebug.c:241
override void SetAutodestroy(bool auto_destroy)
Sets whether Effect automatically cleans up when it stops.
Определения EffectSound.c:607
bool IsSoundPlaying()
Get whether EffectSound is currently playing.
Определения EffectSound.c:274
bool SoundPlay()
Plays sound.
Определения EffectSound.c:199
Wrapper class for managing sound through SEffectManager.
Определения EffectSound.c:5
void EntityAIType()
Определения EntityAIType.c:21
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
proto void SelectObject(Object object)
proto void SelectPhysics(Physics physics)
proto native Transport GetTransport()
Определения human.c:712
Определения human.c:1360
Определения EnEntity.c:165
TODO doc.
Определения EnScript.c:118
Определения EnMath3D.c:28
Определения EnMath.c:7
Определения ObjectTyped.c:2
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Определения param.c:12
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:216
static void DestroyEffect(Effect effect)
Unregisters, stops and frees the Effect.
Определения EffectManager.c:280
Manager class for managing Effect (EffectParticle, EffectSound)
Определения EffectManager.c:6
bool includeWater
Include water in the surface detection, will return the water if it is higher than the surface.
Определения SurfaceInfo.c:103
SurfaceDetectionType type
Type of surface to detect.
Определения SurfaceInfo.c:97
RoadSurfaceDetection rsd
See RoadSurfaceDetection, SurfaceTraceType.Roadway only.
Определения SurfaceInfo.c:112
Object ignore
Object to ignore tracing against, SurfaceTraceType.Roadway only.
Определения SurfaceInfo.c:109
vector position
3D position to trace the surface from
Определения SurfaceInfo.c:100
float height
Height position.
Определения SurfaceInfo.c:122
Определения DamageSystem.c:2
override bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Определения Car.c:110
Native class for boats - handles physics simulation.
Определения Boat.c:29
Определения Transport.c:5
void SetData(vector localPos, IEntity other, float impulse)
Определения Transport.c:1150
IEntity m_Other
Определения Transport.c:1147
vector m_LocalPos
Определения Transport.c:1146
float m_Impulse
Определения Transport.c:1148
Определения Transport.c:1145
Man m_ActionPlayer
Определения Transport.c:1161
ref SurfaceDetectionParameters m_SurfaceParams
Определения Transport.c:1163
void HandleByCrewMemberState(ECrewMemberState state)
bool m_bIsAction
Определения Transport.c:1160
ref SurfaceDetectionResult m_SurfaceResult
Определения Transport.c:1164
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
string GetActionCompNameFuel()
Определения Transport.c:459
int m_RearLightType
Определения Transport.c:82
override bool CanPutIntoHands(EntityAI parent)
Определения Transport.c:394
void OnDriverExit(Human player)
Определения Transport.c:224
vector m_VelocityPrevTick
Определения Transport.c:96
void OnUpdateLight()
Определения Transport.c:252
void SetEngineZoneReceivedHit(bool pState)
Определения Transport.c:810
proto void CrewEntry(int posIdx, out vector pos, out vector dir)
Reads entry point and direction into vehicle on given position in model space.
override bool IsHealthVisible()
Определения Transport.c:379
void OnDriverEnter(Human player)
Определения Transport.c:218
Shape DebugFreeAreaAtDoor(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Определения Transport.c:1052
void CleanupEffects()
Определения Transport.c:998
proto void CrewEntryWS(int posIdx, out vector pos, out vector dir)
Reads entry point and direction into vehicle on given position in world space.
void SynchCrashHeavySound(bool play)
Определения Transport.c:944
vector GetTransportCameraOffset()
Определения Transport.c:657
float GetWeightCoef()
artificial value that helps to distinguish between different weight categories (mainly for particles)
Определения Transport.c:475
bool GetCrashHeavySound()
Определения Transport.c:926
void OnUpdate(float dt)
Определения Transport.c:359
ref VehicleContactData m_ContactData
Определения Transport.c:94
proto native int CrewMemberIndex(Human player)
bool DetectFlippedUsingSurface(VehicleFlippedContext ctx, float angleTolerance)
Определения Transport.c:522
ref TIntArray m_ContinuousActions
Определения Transport.c:75
bool IsAnyCrewPresent(TIntArray positionIndices)
Определения Transport.c:632
ref TIntArray m_InteractActions
Определения Transport.c:76
int m_HeadlightsState
Определения Transport.c:81
float GetFluidFractionScript(ETransportFluid fluidType)
Определения Transport.c:445
bool m_PlayCrashSoundLight
Определения Transport.c:98
float GetTransportCameraDistance()
Определения Transport.c:649
override int GetHideIconMask()
Определения Transport.c:389
ref EffectSound m_CrashSoundHeavy
Определения Transport.c:101
override event GetMoveType()
Определения Transport.c:166
float m_MomentumPrevTick
Определения Transport.c:95
bool m_EngineZoneReceivedHit
Определения Transport.c:84
bool m_EngineDestroyed
Определения Transport.c:79
bool NeedElectricitySourceDevice()
Определения Transport.c:821
EffectSound CreateSoundForAnimationSource(string animSource)
proto void CrewTransformWS(int posIdx, out vector mat[4])
Returns crew transformation indside vehicle in world space.
proto native void Synchronize()
Synchronizes car's state in case the simulation is not running.
bool IsIgnoredObject(Object o)
Определения Transport.c:781
float m_dmgContactCoef
Определения Transport.c:91
int Get3rdPersonCameraType()
Определения Transport.c:698
ref EffectSound m_CrashSoundLight
Определения Transport.c:100
vector m_fuelPos
Определения Transport.c:85
override event GetOwnerStateType()
Определения Transport.c:160
Managed GetVehicleHornComponent()
component helpers
bool IsFlipped()
Don't override, may change to native for caching 'DetectFlipped' in the future based on active-ness (...
Определения Transport.c:604
void PlayCrashHeavySound()
string GetElectricitySourceDeviceType()
Определения Transport.c:831
void Transport()
Определения Transport.c:108
bool CanReachSeatFromDoors(string pSeatSelection, vector pFromPos, float pDistance=1.0)
Определения Transport.c:742
void FillScript(ETransportFluid fluidType, float amount)
proto void ApplyTorque(vector force)
Applies constant torque on the physics body.
string GetVehicleType()
Определения Transport.c:454
void PlaySound(string soundset, EffectSound sound, out bool soundbool)
Определения Transport.c:991
override void EEDelete(EntityAI parent)
Определения Transport.c:135
bool IsVitalGlowPlug()
Определения Transport.c:409
bool OnBeforeLightOn()
Определения Transport.c:243
bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Определения Transport.c:889
proto native void CrewGetIn(Human player, int posIdx)
Performs transfer of player from world into vehicle on given position.
VehicleFlippedContext GetFlipContext()
Определения Transport.c:508
void MarkCrewMemberUnconscious(int crewMemberIndex)
EntityAI GetElectricitySourceDevice()
Определения Transport.c:826
void UpdateBattery(IEntity battery)
proto native void LightToggle()
Calls LightOn/LightOff depending on current light state.
static ref VehicleFlippedContext m_FlippedContext
Определения Transport.c:72
proto void ApplyCentralImpulse(vector centralImpulse)
Applies impulse on the physics body (at origin).
proto native void CrewDeath(int posIdx)
Handles death of player in vehicle and awakes its physics if needed.
bool m_PlayCrashSoundHeavy
Определения Transport.c:99
bool IsVitalSparkPlug()
Определения Transport.c:404
override bool IsDetectableByVicinityCone()
Определения Transport.c:369
bool CanGetIn()
Определения Transport.c:672
proto native int Random()
-------------— deterministic random numbers ---------------------—
bool IsAnyCrewPresent()
Определения Transport.c:621
proto void CrewTransform(int posIdx, out vector mat[4])
Returns crew transformation indside vehicle in model space.
float GetActionDistanceFuel()
Определения Transport.c:464
void MarkCrewMemberDead(int crewMemberIndex)
proto native Human CrewDriver()
void OnInput(float dt)
Определения Transport.c:353
override int GetMeleeTargetType()
Определения Transport.c:154
bool IsAreaAtDoorFreeDiag(int currentSeat, float maxAllowedObjHeight=0.5, float horizontalExtents=0.5, float playerHeight=1.7)
Определения Transport.c:909
bool m_EngineStarted
Определения Transport.c:78
proto native int CrewSize()
Returns crew capacity of this vehicle.
bool IsVitalFuelTank()
Определения Transport.c:414
string GetSelectionFromAnimSource(string animSource)
Определения Transport.c:481
vector GetRefillPointPosWS()
Определения Transport.c:469
bool IsAreaAtDoorFree(int currentSeat, float maxAllowedObjHeight, inout vector extents, out vector transform[4])
Определения Transport.c:844
ref set< int > m_UnconsciousCrewMemberIndices
Определения Transport.c:87
proto native bool LightIsOn()
Returns true when lights are on, false otherwise.
override bool ShowZonesHealth()
Определения Transport.c:384
proto native Human CrewGetOut(int posIdx)
Performs transfer of player from vehicle into world from given position.
override bool IsIgnoredByConstruction()
Определения Transport.c:374
int GetSeatAnimationTypeDirectional(int posIdx, int directionIndex)
Определения Transport.c:690
void SynchCrashLightSound(bool play)
Определения Transport.c:933
int GetAnimInstance()
Определения Transport.c:662
void PlayCrashLightSound()
void PlaySoundEx(string soundset, EffectSound sound, out bool soundbool)
Определения Transport.c:963
bool HasEngineZoneReceivedHit()
Определения Transport.c:816
proto void ApplyForce(vector force)
-------------— deterministic physics ---------------------—
void OnContact(string zoneName, vector localPos, IEntity other, Contact data)
Определения Transport.c:315
ref TIntArray m_SingleUseActions
Определения Transport.c:74
bool CrewCanEject(int posIdx)
Определения Transport.c:711
float GetMomentum()
Определения Transport.c:399
proto void ApplyTorqueImpulse(vector torqueImpulse)
Applies impulse torque on the physics body.
proto native Human CrewMember(int posIdx)
bool IsActionFlipped(Man player)
Don't override, may change to native for caching 'DetectFlipped' in the future based on active-ness (...
Определения Transport.c:613
void CheckVitalItemCallback(bool isVital, int slotId, Object caller=null, string callbackMethodName="", Param params=null)
Определения Transport.c:420
override bool IsTransport()
Определения Transport.c:364
float RandomFloat(float min, float max)
Random number in range of <min,max> - !!! use this only during deterministic simulation (EOnSimulate/...
Определения Transport.c:302
string GetAnimSourceFromSelection(string selection)
Определения Transport.c:836
bool CrewShouldEject(int posIdx)
Определения Transport.c:719
bool DetectFlipped(VehicleFlippedContext ctx)
Override based on vehicle implementation (Car, Boat, modded, etc.)
Определения Transport.c:598
int GetSeatIndexFromDoor(string pDoorSelection)
Определения Transport.c:760
proto native void LightOn()
Signals for LightIsOn to return true.
float m_CrewContactDamageCoef
Определения Transport.c:93
bool CrewCanGetThrough(int posIdx)
Определения Transport.c:724
int GetFluidCapacityScript(ETransportFluid fluidType)
fluids
Определения Transport.c:440
override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
Определения Transport.c:144
proto native int CrewPositionIndex(int componentIdx)
void UpdateLights(int new_gear=-1)
Определения Transport.c:362
bool IsAreaAtDoorFreeDiag(int currentSeat, float maxAllowedObjHeight, inout vector extents, out vector transform[4])
Определения Transport.c:901
proto void ApplyForceAt(vector pos, vector force)
Applies constant force on the physics body at a position (world space coordinates).
ref VehicleContactCache m_ContactCache
Определения Transport.c:90
proto void ApplyImpulseAt(vector pos, vector force)
Applies impulse on the physics body at a position (world space coordinates).
bool CanReachSeatFromSeat(int currentSeat, int nextSeat)
Определения Transport.c:733
void ~Transport()
Определения Transport.c:126
bool HasDirectionalInOutAction()
Определения Transport.c:677
int GetSeatAnimationType(int posIdx)
Определения Transport.c:682
proto native float RandomRange(int pRange)
Random number in range of <0,pRange-1> - !!! use this only during deterministic simulation (EOnSimula...
proto native void LightOff()
Signals for LightIsOn to return false.
proto native float Random01()
Random number in range of <0,1> - !!! use this only during deterministic simulation (EOnSimulate/EOnP...
bool GetCrashLightSound()
Определения Transport.c:919
ref set< int > m_DeadCrewMemberIndices
Определения Transport.c:88
bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
Определения Transport.c:751
void PartsHealthCheck()
float m_VehicleContactDamageCoef
Определения Transport.c:92
Определения Transport.c:70
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:305
static const vector Zero
Определения EnConvert.c:123
proto float Normalize()
Normalizes vector. Returns length.
static vector Direction(vector p1, vector p2)
Returns direction vector from point p1 to point p2.
Определения EnConvert.c:254
static const vector Up
Определения EnConvert.c:120
Определения EnConvert.c:119
proto native float Random01()
Random number in range of <0,1> - !!! use this only during deterministic simulation (CommandHandler)
Serializer ParamsReadContext
Определения gameplay.c:15
DayZGame GetGame()
Определения gameplay.c:636
void Error(string err)
Messagebox with error message.
Определения EnDebug.c:90
proto void Print(void var)
Prints content of variable to console/log.
ShapeType
Определения EnDebug.c:116
ShapeFlags
Определения EnDebug.c:126
static proto bool GetBool(int id, bool reverse=false)
Get value as bool from the given script id.
class DiagMenu Shape
don't call destructor directly. Use Destroy() instead
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
array< int > TIntArray
Определения EnScript.c:733
class array< Class T > TStringArray
void Obsolete(string msg="")
Определения EnScript.c:371
@ CONTACT
Определения EnEntity.c:97
@ USER4
Определения EnEntity.c:156
@ USER1
Flags for custom usage and filterings.
Определения EnEntity.c:153
@ USER2
Определения EnEntity.c:154
@ USER3
Определения EnEntity.c:155
static proto vector MatrixToAngles(vector mat[3])
Returns angles of rotation matrix.
static proto void MatrixMultiply4(vector mat0[4], vector mat1[4], out vector res[4])
Transforms matrix.
static proto float Cos(float angle)
Returns cosinus of angle in radians.
static const float DEG2RAD
Определения EnMath.c:17
@ NONE
body is not in simulation, nor in collision world
Определения SimulationState.c:15
proto native bool dGetInteractionLayer(notnull IEntity worldEntity, int mask1, int mask2)
proto native vector GetVelocity(notnull IEntity ent)
Returns linear velocity.
proto native float dBodyGetMass(notnull IEntity ent)
proto native int dBodyGetInteractionLayer(notnull IEntity ent)
const int SAT_DEBUG_ACTION
Определения 3_Game/DayZ/constants.c:486
vector GetPosition()
Get the world position of the Effect.
Определения Effect.c:473
proto int ToLower()
Changes string to lowercase. Returns length.
const int CALL_CATEGORY_GAMEPLAY
Определения 3_Game/DayZ/tools/tools.c:10
int ARGB(int a, int r, int g, int b)
Определения proto.c:322