Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
actioncardoors.c
Go to the documentation of this file.
2{
3 protected int m_CommandUIDPerCrewIdx[4];
4 protected bool m_IsOpening = true;
5 // --- Backwards compatibility 1.09 -> 1.10 (But please do not use these)
7 string m_AnimSource = "";
8 // ---
9
11 {
12 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_OPENDOORFW;
13 m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
14 m_LockTargetOnUse = false;
15 }
16
18 {
21 }
22
23 override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
24 {
25 CarScript car = null;
26 string animSource = "";
27
29 if (player && player.GetCommand_Vehicle())
30 {
31 if (Class.CastTo(car, player.GetCommand_Vehicle().GetTransport()))
32 {
33 int crewIdx = car.CrewMemberIndex(player);
34
36 if (crewIdx < 0 || crewIdx > car.CrewSize() || car.GetCarDoorsState(car.GetDoorInvSlotNameFromSeatPos(crewIdx)) == CarDoorState.DOORS_MISSING)
37 {
38 return false;
39 }
40
42
44 if (!car.CanReachDoorsFromSeat(animSource, crewIdx) || !car.IsAreaAtDoorFree(crewIdx))
45 {
46 return false;
47 }
48
49 int safeCrewIdx = crewIdx % 4;
51
52 float animationPhaseInside = car.GetAnimationPhase(animSource);
53 return (m_IsOpening && animationPhaseInside <= 0.5) || (!m_IsOpening && animationPhaseInside > 0.5);
54 }
55 }
56
57 return false;
58 }
59
60 override void OnStartServer(ActionData action_data)
61 {
62 super.OnStartServer(action_data);
63
64 PlayerBase player = action_data.m_Player;
65
66 float phase;
67 if (m_IsOpening)
68 {
69 phase = 1.0;
70 }
71 else
72 {
73 phase = 0.0;
74 }
75
76 string animSource = "";
77
78 CarScript car;
79 if (player && player.GetCommand_Vehicle())
80 {
81 car = CarScript.Cast(player.GetCommand_Vehicle().GetTransport());
82 if (car)
83 {
84 int crewIdx = car.CrewMemberIndex(player);
86 }
87 }
88
89 if (car)
90 {
91 car.ForceUpdateLightsStart();
92 car.SetAnimationPhase(animSource, phase);
93 }
94 }
95
96 override void OnEndServer(ActionData action_data)
97 {
98 super.OnEndServer(action_data);
99
100 CarScript car;
101 PlayerBase player = action_data.m_Player;
102 if (player && player.GetCommand_Vehicle())
103 {
104 car = CarScript.Cast(player.GetCommand_Vehicle().GetTransport());
105 }
106
107 if (car)
108 {
109 car.ForceUpdateLightsEnd();
110 }
111 }
112
113 override void OnEnd(ActionData action_data)
114 {
115 if (m_Car || m_AnimSource.Length() > 0)
116 {
117 Error("[WARNING] m_Car and m_AnimSource are left for backwards compatibility to not crash mods that are using it, but should no longer be used.");
118 }
119 }
120
121 override bool CanBeUsedInVehicle()
122 {
123 return true;
124 }
125
126 override bool HasTarget()
127 {
128 return false;
129 }
130
131 protected void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
132 {
133 m_CommandUIDPerCrewIdx[0] = crewIdx0;
134 m_CommandUIDPerCrewIdx[1] = crewIdx1;
135 m_CommandUIDPerCrewIdx[2] = crewIdx2;
136 m_CommandUIDPerCrewIdx[3] = crewIdx3;
137 }
138
139 protected void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
140 {
141 FillCommandUIDPerCrewIdx(evenCrewIdx0, unevenCrewIdx1, evenCrewIdx0, unevenCrewIdx1);
142 }
143};
ActionBase ActionData
Definition actionbase.c:30
class ActionTargets ActionTarget
CarDoorState
Definition carscript.c:2
bool m_LockTargetOnUse
Definition actionbase.c:66
ref CCIBase m_ConditionItem
Definition actionbase.c:70
ref CCTBase m_ConditionTarget
Definition actionbase.c:71
int m_StanceMask
Definition actionbase.c:68
override void OnEndServer(ActionData action_data)
void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
override void CreateConditionComponents()
int m_CommandUIDPerCrewIdx[4]
override void OnEnd(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override bool HasTarget()
override bool CanBeUsedInVehicle()
void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
override void OnStartServer(ActionData action_data)
CarScript m_Car
override int GetCarDoorsState(string slotType)
override bool CanReachDoorsFromSeat(string pDoorsSelection, int pCurrentSeat)
override string GetAnimSourceFromSelection(string selection)
override string GetDoorSelectionNameFromSeatPos(int posIdx)
override string GetDoorInvSlotNameFromSeatPos(int posIdx)
Super root of all classes in Enforce script.
Definition enscript.c:11
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.