Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionswitchlights.c
Go to the documentation of this file.
2 {
3  void ActionSwitchLights()
4  {
5  m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_HEADLIGHT;
6  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
7  m_Text = "#switch_lights";
8  }
9 
10  override void CreateConditionComponents()
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  {
35  CarScript car;
36  if ( Class.CastTo(car, trans) )
37  {
38  if ( car.CrewMemberIndex( player ) == DayZPlayerConstants.VEHICLESEAT_DRIVER )
39  {
40  if ( !car.IsScriptedLightsOn() )
41  {
42  EntityAI neededItem = null;
43 
44  if ( car.IsVitalCarBattery() ) neededItem = car.FindAttachmentBySlotName("CarBattery");
45  if ( car.IsVitalTruckBattery() ) neededItem = car.FindAttachmentBySlotName("TruckBattery");
46 
47  if (neededItem && !neededItem.IsRuined())
48  {
49  return neededItem.GetCompEM() && neededItem.GetCompEM().GetEnergy() > 0;
50  }
51  }
52  else
53  {
54  return true;
55  }
56  }
57  }
58  }
59  }
60 
61  return false;
62  }
63 
64  override void OnExecuteServer( ActionData action_data )
65  {
66  HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
67  if ( vehCommand )
68  {
69  Transport trans = vehCommand.GetTransport();
70  if ( trans )
71  {
72  CarScript car;
73  if ( Class.CastTo(car, trans) )
74  {
75  car.ToggleHeadlights();
76  }
77  }
78  }
79  }
80 
81  override bool CanBeUsedInVehicle()
82  {
83  return true;
84  }
85 };
ItemBase
Definition: inventoryitem.c:730
ToggleLightsActionInput
Definition: actioninput.c:746
CCINone
Definition: ccinone.c:1
CarScript
Definition: civiliansedan.c:1
CCTNone
Definition: cctnone.c:1
ActionInteractBase
Definition: actioninteractbase.c:54
PlayerBase
Definition: playerbaseclient.c:1
ActionTarget
class ActionTargets ActionTarget
ActionData
Definition: actionbase.c:20
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
Transport
Base native class for all motorized wheeled vehicles.
Definition: car.c:79
ActionSwitchLights
Definition: actionswitchlights.c:1
HumanCommandVehicle
Definition: human.c:689
m_Text
protected string m_Text
Definition: actionbase.c:49
m_ConditionItem
ref CCIBase m_ConditionItem
Definition: actionbase.c:55
m_ConditionTarget
ref CCTBase m_ConditionTarget
Definition: actionbase.c:56
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53
EntityAI
Definition: building.c:5