DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
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 > 3 || 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
50
51 float animationPhaseInside = car.GetAnimationPhase(animSource);
52 return (m_IsOpening && animationPhaseInside <= 0.5) || (!m_IsOpening && animationPhaseInside > 0.5);
53 }
54 }
55
56 return false;
57 }
58
59 override void OnStartServer(ActionData action_data)
60 {
61 PlayerBase player = action_data.m_Player;
62
63 float phase;
64 if (m_IsOpening)
65 {
66 phase = 1.0;
67 }
68 else
69 {
70 phase = 0.0;
71 }
72
73 string animSource = "";
74
75 CarScript car;
76 if (player && player.GetCommand_Vehicle())
77 {
78 car = CarScript.Cast(player.GetCommand_Vehicle().GetTransport());
79 if (car)
80 {
81 int crewIdx = car.CrewMemberIndex(player);
83 }
84 }
85
86 if (car)
87 {
88 car.ForceUpdateLightsStart();
89 car.SetAnimationPhase(animSource, phase);
90 }
91 }
92
93 override void OnEndServer(ActionData action_data)
94 {
95 CarScript car;
96 PlayerBase player = action_data.m_Player;
97 if (player && player.GetCommand_Vehicle())
98 {
99 car = CarScript.Cast(player.GetCommand_Vehicle().GetTransport());
100 }
101
102 if (car)
103 {
104 car.ForceUpdateLightsEnd();
105 }
106 }
107
108 override void OnEnd(ActionData action_data)
109 {
110 if (m_Car || m_AnimSource.Length() > 0)
111 {
112 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.");
113 }
114 }
115
116 override bool CanBeUsedInVehicle()
117 {
118 return true;
119 }
120
121 protected void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
122 {
123 m_CommandUIDPerCrewIdx[0] = crewIdx0;
124 m_CommandUIDPerCrewIdx[1] = crewIdx1;
125 m_CommandUIDPerCrewIdx[2] = crewIdx2;
126 m_CommandUIDPerCrewIdx[3] = crewIdx3;
127 }
128
129 protected void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
130 {
131 FillCommandUIDPerCrewIdx(evenCrewIdx0, unevenCrewIdx1, evenCrewIdx0, unevenCrewIdx1);
132 }
133};
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 int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
CarDoorState
Definition CarScript.c:2
protected int m_CommandUIDPerCrewIdx[4]
override void OnEndServer(ActionData action_data)
protected bool m_IsOpening
override void CreateConditionComponents()
protected void FillCommandUIDPerCrewIdx(int evenCrewIdx0, int unevenCrewIdx1)
override void OnEnd(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
protected void FillCommandUIDPerCrewIdx(int crewIdx0, int crewIdx1, int crewIdx2, int crewIdx3)
override bool CanBeUsedInVehicle()
override void OnStartServer(ActionData action_data)
CarScript m_Car
PlayerBase m_Player
Definition ActionBase.c:33
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.
proto native int Length()
Returns length of string.