DayZ 1.24
Loading...
Searching...
No Matches
ActionSwitchLights.c
Go to the documentation of this file.
2{
4 {
5 m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_HEADLIGHT;
6 m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
7 m_Text = "#switch_lights";
8 }
9
11 {
14 }
15
16 override typename GetInputType()
17 {
19 }
20
21 override bool HasTarget()
22 {
23 return false;
24 }
25
26 override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
27 {
28 HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
29
30 if (vehCommand)
31 {
32 Transport trans = vehCommand.GetTransport();
33 if (trans)
34 {
36 if (Class.CastTo(car, trans))
37 {
38 if (car.CrewMemberIndex(player) == DayZPlayerConstants.VEHICLESEAT_DRIVER)
39 {
40 if (!car.IsScriptedLightsOn())
41 {
43
44 if (car.IsVitalCarBattery()) neededItem = car.FindAttachmentBySlotName("CarBattery");
45 if (car.IsVitalTruckBattery()) neededItem = car.FindAttachmentBySlotName("TruckBattery");
46
47 if (neededItem && !neededItem.IsRuined())
48 return neededItem.GetCompEM() && neededItem.GetCompEM().GetEnergy() > 0;
49 }
50 else
51 return true;
52 }
53 }
54 }
55 }
56
57 return false;
58 }
59
61 {
62 HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
63 if (vehCommand)
64 {
65 Transport trans = vehCommand.GetTransport();
66 if (trans)
67 {
69 if (Class.CastTo(car, trans))
70 car.ToggleHeadlights();
71 }
72 }
73 }
74
75 override bool CanBeUsedInVehicle()
76 {
77 return true;
78 }
79};
string m_Text
Definition ActionBase.c:49
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
override bool CanBeUsedInVehicle()
override bool HasTarget()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override void CreateConditionComponents()
override void OnExecuteServer(ActionData action_data)
Super root of all classes in Enforce script.
Definition EnScript.c:11
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.