DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionCarDoorsOutside.c
Go to the documentation of this file.
2{
3 protected int m_CommandUIDPerCrewIdx[4];
4 protected bool m_IsOpening = true;
5
7 {
8 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
9 m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
10 m_LockTargetOnUse = false;
11 }
12
14 {
17 }
18
19 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
20 {
21 CarScript car = null;
22
24 if (!IsInReach(player, target, UAMaxDistances.DEFAULT))
25 {
26 return false;
27 }
28
30 if (Class.CastTo(car, target.GetParent()))
31 {
32 array<string> selections = new array<string>();
33
34 CarDoor carDoor = CarDoor.Cast(target.GetObject());
35 if (carDoor)
36 {
37 carDoor.GetActionComponentNameList(target.GetComponentIndex(), selections);
38
39 string animSource = "";
40
41 for (int i = 0; i < selections.Count(); i++)
42 {
43 animSource = car.GetAnimSourceFromSelection(selections[i]);
44 if (animSource != "")
45 {
46 int idx = car.GetSeatIndexFromDoor(animSource);
47 if (idx != -1 && !car.IsAreaAtDoorFree(idx))
48 {
49 return false;
50 }
51
53 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
54
55 float animationPhase = car.GetAnimationPhase(animSource);
57 return (m_IsOpening && animationPhase <= 0.5 ) || ( !m_IsOpening && animationPhase > 0.5);
58 }
59 }
60 }
61 }
62
63 return false;
64 }
65
66 override void OnStartServer( ActionData action_data )
67 {
68 float phase;
69
70 if (m_IsOpening)
71 {
72 phase = 1.0;
73 }
74 else
75 {
76 phase = 0.0;
77 }
78
79 string animSource = "";
80
81 CarScript car = CarScript.Cast(action_data.m_Target.GetParent());
82 if (car)
83 {
84 array<string> selections = new array<string>();
85 CarDoor carDoor = CarDoor.Cast(action_data.m_Target.GetObject());
86 if (carDoor)
87 {
88 carDoor.GetActionComponentNameList(action_data.m_Target.GetComponentIndex(), selections);
89 for (int i = 0; i < selections.Count(); i++)
90 {
91 animSource = car.GetAnimSourceFromSelection(selections[i]);
92 if (animSource != "")
93 {
94 break;
95 }
96 }
97 }
98 }
99
100 if (car)
101 {
102 car.ForceUpdateLightsStart();
103 car.SetAnimationPhase(animSource, phase);
104 }
105 }
106
107 override void OnEndServer(ActionData action_data)
108 {
109 CarScript car = CarScript.Cast(action_data.m_Target.GetParent());
110 if (car)
111 {
112 car.ForceUpdateLightsEnd();
113 }
114 }
115
116 //--------- Not used for this class
117 protected void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
118 {
119 m_CommandUIDPerCrewIdx[0] = crewIdx0;
120 m_CommandUIDPerCrewIdx[1] = crewIdx1;
121 m_CommandUIDPerCrewIdx[2] = crewIdx2;
122 m_CommandUIDPerCrewIdx[3] = crewIdx3;
123 }
124
125 protected void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
126 {
127 FillCommandUIDPerCrewIdx(evenCrewIdx0, unevenCrewIdx1, evenCrewIdx0, unevenCrewIdx1);
128 }
129 //-----------------------------------
130};
protected bool m_LockTargetOnUse
Definition ActionBase.c:51
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
protected bool IsInReach(PlayerBase player, ActionTarget target, float maxDistance=1.0)
Definition ActionBase.c:927
protected int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
protected int m_CommandUIDPerCrewIdx[4]
override void OnEndServer(ActionData action_data)
override void CreateConditionComponents()
protected void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
protected void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
override void OnStartServer(ActionData action_data)
ref ActionTarget m_Target
Definition ActionBase.c:32
override int GetSeatIndexFromDoor(string pDoorSelection)
override string GetAnimSourceFromSelection(string selection)
Super root of all classes in Enforce script.
Definition EnScript.c:11
const float DEFAULT
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.