DayZ 1.24
Loading...
Searching...
No Matches
ActionCarHorn.c
Go to the documentation of this file.
2{
4 {
5 HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
6
7 if (vehCommand)
8 {
9 Transport trans = vehCommand.GetTransport();
10 if (trans)
11 {
13 return false;
14
16 if (Class.CastTo(car, trans))
17 return BatteryIsVital(car.GetBattery());
18 }
19 }
20
21 return false;
22 }
23
25 {
26 if (!pActionData.m_Player)
27 return;
28
29 if (!pActionData.m_Car)
30 return;
31
32 pActionData.m_Car.SetCarHornState(pState);
33 }
34
36 {
37 return trans.GetSeatAnimationType(trans.CrewMemberIndex(player)) == DayZPlayerConstants.VEHICLESEAT_DRIVER;
38 }
39
40 protected static bool BatteryIsVital(ItemBase battery)
41 {
42 return battery && battery.GetHealthLevel("Health") <= GameConstants.STATE_DAMAGED;
43 }
44}
45
46class CarHornActionReceiveData : ActionReciveData
47{
48 bool m_ActionNeedEnd;
50
51}
52
58
60
62{
64 {
65 m_CallbackClass = ActionCarHornShortCB;
66 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_TOOTHORN;
67 m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
68 }
69
70 override bool HasTarget()
71 {
72 return false;
73 }
74
75 override bool HasProgress()
76 {
77 return false;
78 }
79
80 override bool CanBeUsedInVehicle()
81 {
82 return true;
83 }
84
85 override bool UseMainItem()
86 {
87 return false;
88 }
89
91 {
94 }
95
96 override typename GetInputType()
97 {
99 }
100
102 {
104 return action_data;
105 }
106
107 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
108 {
110 }
111
114 {
115 super.OnUpdate(action_data);
116
118 if (carHornData.m_WasExecuted && carHornData.m_ActionNeedEnd)
119 {
120 carHornData.m_Callback.SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
121 carHornData.m_ActionNeedEnd = false;
122 }
123 }
124
132
135 {
136 super.OnStart(action_data);
137
139 carHornData.m_ActionNeedEnd = true;
140 carHornData.m_Car = CarScript.Cast(action_data.m_Player.GetCommand_Vehicle().GetTransport());
141 }
142
150
158
160 {
161 super.WriteToContext(ctx, action_data);
162
164
165 ctx.Write(carHornData.m_ActionNeedEnd);
166 ctx.Write(carHornData.m_Car);
167 }
168
170 {
173
174 super.ReadFromContext(ctx, action_recive_data);
175
176 bool needUpdate;
177 if (!ctx.Read(needUpdate))
178 return false;
179
181 if (!ctx.Read(carScript))
182 return false;
183
185 carHornReceivedData.m_ActionNeedEnd = needUpdate;
187
188 return true;
189 }
190
200}
201
203{
205 {
206 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_TOOTHORN;
207 m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
208 }
209
210 override bool HasTarget()
211 {
212 return false;
213 }
214
215 override bool HasProgress()
216 {
217 return false;
218 }
219
220 override bool CanBeUsedInVehicle()
221 {
222 return true;
223 }
224
225 override typename GetInputType()
226 {
228 }
229
230 override bool UseMainItem()
231 {
232 return false;
233 }
234
236 {
237 m_ConditionItem = new CCINone();
239 }
240
242 {
244 return action_data;
245 }
246
247 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
248 {
250 }
251
254 {
255 super.OnUpdate(action_data);
256
258 if (carHornData.m_ReciveEndInput && carHornData.m_ActionNeedEnd)
259 {
260 carHornData.m_Callback.SetCommand(DayZPlayerConstants.CMD_ACTIONINT_END);
261 carHornData.m_ActionNeedEnd = false;
262 }
263 }
264
272
274 {
275 super.OnStart(action_data);
276
278 carHornData.m_ActionNeedEnd = true;
279 carHornData.m_Car = CarScript.Cast(action_data.m_Player.GetCommand_Vehicle().GetTransport());
280 }
281
283 {
284 super.OnStartServer(action_data);
285
287 carHornData.m_ActionNeedEnd = true;
289 }
290
298
300 {
301 super.WriteToContext(ctx, action_data);
302
304
305 ctx.Write(carHornData.m_ActionNeedEnd);
306 ctx.Write(carHornData.m_Car);
307 }
308
310 {
313
314 super.ReadFromContext(ctx, action_recive_data);
315
316 bool needUpdate;
317 if (!ctx.Read(needUpdate))
318 return false;
319
321 if (!ctx.Read(carScript))
322 return false;
323
325 carHornReceivedData.m_ActionNeedEnd = needUpdate;
327
328 return true;
329 }
330
340}
ActionData CreateActionData()
Definition ActionBase.c:191
void OnEndServer(ActionData action_data)
Definition ActionBase.c:962
void OnEndInput(ActionData action_data)
Definition ActionBase.c:577
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
void OnStartServer(ActionData action_data)
Definition ActionBase.c:949
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
bool UseMainItem()
Definition ActionBase.c:335
int m_StanceMask
Definition ActionBase.c:53
bool HasProgress()
For UI: hiding of progress bar.
Definition ActionBase.c:216
void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
Definition ActionBase.c:485
bool CanBeUsedInVehicle()
Definition ActionBase.c:289
class ActionCarHornBase m_ActionNeedEnd
CarHornActionData ActionData ActionCarHornShort()
void CarHornShortActionInput(PlayerBase player)
ToggleLightsActionInput CarHornLongActionInput
CarScript m_Car
void ReadFromContext(ParamsReadContext ctx)
Definition Hand_Events.c:70
void WriteToContext(ParamsWriteContext ctx)
Definition Hand_Events.c:72
void OnStart(Param par=null)
static void SetCarHornState(CarHornActionData pActionData, int pState)
static bool ActionCondition(PlayerBase player)
static bool PlayerIsDriver(Transport trans, PlayerBase player)
static bool BatteryIsVital(ItemBase battery)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void HandleReciveData(ActionReciveData action_recive_data, ActionData action_data)
override void OnEndInput(ActionData action_data)
override bool UseMainItem()
override void OnStart(ActionData action_data)
override ActionData CreateActionData()
override bool HasTarget()
override bool ReadFromContext(ParamsReadContext ctx, out ActionReciveData action_recive_data)
override void OnStartServer(ActionData action_data)
override bool HasProgress()
override void WriteToContext(ParamsWriteContext ctx, ActionData action_data)
override void OnUpdate(ActionData action_data)
special case - manually ends the action on exec event
override void CreateConditionComponents()
override GetInputType()
override void OnEndServer(ActionData action_data)
override bool CanBeUsedInVehicle()
override bool HasTarget()
Definition ActionPin.c:14
override void CreateConditionComponents()
Definition ActionPin.c:8
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
Definition ActionPin.c:19
Super root of all classes in Enforce script.
Definition EnScript.c:11
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
Base native class for all motorized wheeled vehicles.
Definition Car.c:75
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int STATE_DAMAGED
Definition constants.c:759
proto native void OnUpdate()
Definition tools.c:333