Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
actionswitchseats.c
Go to the documentation of this file.
1 
3 {
4  void ActionSwitchSeats()
5  {
6  //m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_STARTENGINE;
7  m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
8  m_SpecialtyWeight = 1.0;
9  m_LockTargetOnUse = false;
10  m_Text = "#change_seat";
11  }
12 
13  override void CreateConditionComponents()
14  {
17  }
18 
19  override bool ActionCondition( PlayerBase player, ActionTarget target, ItemBase item )
20  {
21 
22  Transport trans = null;
23  int nextSeatIdx = -1;
24 
25  HumanCommandVehicle vehCommand = player.GetCommand_Vehicle();
26 
27  if ( !vehCommand )
28  return false;
29 
30  int componentIndex = target.GetComponentIndex();
31 
32  if ( !target )
33  return false;
34 
35  if ( !Class.CastTo(trans, target.GetObject()) )
36  return false;
37 
38  nextSeatIdx = trans.CrewPositionIndex( componentIndex );
39 
40  if ( nextSeatIdx < 0 )
41  return false;
42 
43  Human crew = trans.CrewMember( nextSeatIdx );
44  if ( crew )
45  return false;
46 
47  if ( !trans.CanReachSeatFromSeat( trans.CrewMemberIndex( player ), nextSeatIdx ) )
48  return false;
49 
50  return true;
51  }
52 
53  override void Start( ActionData action_data )
54  {
55  super.Start( action_data );
56  HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
57  if ( vehCommand )
58  {
59  Transport trans;
60  if ( Class.CastTo(trans, action_data.m_Target.GetObject()) )
61  {
62  int nextSeat = trans.CrewPositionIndex( action_data.m_Target.GetComponentIndex() );
63  int seat = trans.GetSeatAnimationType( nextSeat );
64  if ( seat >= 0 )
65  {
66  //pTransportPositionIndex, int pVehicleSeat
67  vehCommand.SwitchSeat( nextSeat, seat );
68  if ( !GetGame().IsDedicatedServer() )
69  {
70 
71  action_data.m_Player.OnVehicleSwitchSeat( nextSeat );
72  }
73  }
74  }
75  }
76  }
77 
78  override void OnUpdate(ActionData action_data)
79  {
80 
81  if(action_data.m_State == UA_START)
82  {
83  HumanCommandVehicle hcv = action_data.m_Player.GetCommand_Vehicle();
84  if( !hcv || !action_data.m_Player.GetCommand_Vehicle().IsSwitchSeat() )
85  {
86  End(action_data);
87  }
88  }
89  }
90 
91  override bool CanBeUsedInVehicle()
92  {
93  return true;
94  }
95 };
ItemBase
Definition: inventoryitem.c:730
End
void End()
called on surrender end request end
GetGame
proto native CGame GetGame()
ActionSwitchSeats
Definition: actionswitchseats.c:2
CCINone
Definition: ccinone.c:1
CCTObject
Definition: cctobject.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
m_LockTargetOnUse
protected bool m_LockTargetOnUse
Definition: actionbase.c:51
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_SpecialtyWeight
protected float m_SpecialtyWeight
Definition: actionbase.c:68
m_StanceMask
protected int m_StanceMask
Definition: actionbase.c:53