Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actiongetintransport.c
Go to the documentation of this file.
2 {
4  {
5  m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
6  m_Text = "#get_in_vehicle";
7  }
8 
9 
10  override void CreateConditionComponents()
11  {
14  }
15 
16  override typename GetInputType()
17  {
19  }
20 
21  override bool HasProgress()
22  {
23  return false;
24  }
25 
26  override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
27  {
28  Transport trans = null;
29 
30  if (!target)
31  {
32  return false;
33  }
34 
35  if (!Class.CastTo(trans, target.GetObject()))
36  {
37  return false;
38  }
39 
40  if (player.GetItemInHands() && player.GetItemInHands().IsHeavyBehaviour())
41  {
42  return false;
43  }
44 
45  if (player.GetCommand_Vehicle())
46  {
47  return false;
48  }
49 
50  int componentIndex = target.GetComponentIndex();
51  int crew_index = trans.CrewPositionIndex(componentIndex);
52  if (crew_index < 0)
53  {
54  return false;
55  }
56 
57  Human crew = trans.CrewMember(crew_index);
58  if (crew)
59  {
60  return false;
61  }
62 
63  if (!trans.CrewCanGetThrough(crew_index) || !trans.IsAreaAtDoorFree(crew_index))
64  {
65  return false;
66  }
67 
68  array<string> selections = new array<string>();
69  trans.GetActionComponentNameList(componentIndex, selections);
70 
71  for (int i = 0; i < selections.Count(); i++)
72  {
73  if (trans.CanReachSeatFromDoors(selections[i], player.GetPosition(), 1.0))
74  {
75  return true;
76  }
77  }
78 
79  return false;
80  }
81 
82  override void Start(ActionData action_data)
83  {
84  super.Start( action_data );
85 
86  Transport trans = Transport.Cast(action_data.m_Target.GetObject());
87  int componentIndex = action_data.m_Target.GetComponentIndex();
88  int crew_index = trans.CrewPositionIndex(componentIndex);
89 
90 
91  int seat = trans.GetSeatAnimationType(crew_index);
92  HumanCommandVehicle vehCommand = action_data.m_Player.StartCommand_Vehicle(trans, crew_index, seat);
93  if (vehCommand)
94  {
95  vehCommand.SetVehicleType(trans.GetAnimInstance());
96 
97  GetDayZGame().GetBacklit().OnEnterCar();
98  if (action_data.m_Player.GetInventory())
99  {
100  action_data.m_Player.GetInventory().LockInventory(LOCK_FROM_SCRIPT);
101  }
102  }
103  }
104 
105  override void OnStartServer(ActionData action_data)
106  {
107  CarScript car = CarScript.Cast(action_data.m_Target.GetObject());
108  if (car)
109  {
110  car.ForceUpdateLightsStart();
111  }
112  }
113 
114  override bool CanBeUsedInRestrain()
115  {
116  return true;
117  }
118 
119  override void OnUpdate(ActionData action_data)
120  {
121 
122  if (action_data.m_State == UA_START)
123  {
124  if (!action_data.m_Player.GetCommand_Vehicle() || !action_data.m_Player.GetCommand_Vehicle().IsGettingIn())
125  {
126  End(action_data);
127  }
128  }
129  }
130 
131  override int GetActionCategory()
132  {
133  return AC_INTERACT;
134  }
135 
136  override void OnEndClient(ActionData action_data)
137  {
138  if (action_data.m_Player.GetInventory())
139  {
140  action_data.m_Player.GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
141  }
142  }
143 
144  override void OnEndServer(ActionData action_data)
145  {
146  if (action_data.m_Player.GetInventory())
147  {
148  action_data.m_Player.GetInventory().UnlockInventory(LOCK_FROM_SCRIPT);
149  }
150 
151  CarScript car = CarScript.Cast(action_data.m_Target.GetObject());
152  if (car)
153  {
154  car.ForceUpdateLightsEnd();
155  }
156  }
157 };
ItemBase
Definition: inventoryitem.c:730
End
void End()
called on surrender end request end
GetDayZGame
DayZGame GetDayZGame()
Definition: dayzgame.c:3729
ContinuousInteractActionInput
Definition: actioninput.c:521
CCINone
Definition: ccinone.c:1
AC_INTERACT
const int AC_INTERACT
Definition: _constants.c:4
CarScript
Definition: civiliansedan.c:1
ActionGetInTransport
Definition: actiongetintransport.c:1
CCTCursorNoRuinCheck
Definition: cctcursornoruincheck.c:1
PlayerBase
Definition: playerbaseclient.c:1
UA_START
const int UA_START
Definition: constants.c:439
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
HumanCommandVehicle
Definition: human.c:689
array< string >
ActionBase
void ActionBase()
Definition: actionbase.c:73
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