DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
ActionSwitchSeats.c
Go to the documentation of this file.
1
3{
5 {
6 //m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_STARTENGINE;
7 m_StanceMask = DayZPlayerConstants.STANCEMASK_ALL;
9 m_LockTargetOnUse = false;
10 m_Text = "#change_seat";
11 }
12
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};
protected float m_SpecialtyWeight
Definition ActionBase.c:68
protected bool m_LockTargetOnUse
Definition ActionBase.c:51
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
void ActionBase()
Definition ActionBase.c:73
protected string m_Text
Definition ActionBase.c:49
protected int m_StanceMask
Definition ActionBase.c:53
class ActionTargets ActionTarget
void End()
called on surrender end request end
PlayerBase m_Player
Definition ActionBase.c:33
ref ActionTarget m_Target
Definition ActionBase.c:32
override void OnUpdate(ActionData action_data)
override void Start(ActionData action_data)
override void CreateConditionComponents()
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override bool CanBeUsedInVehicle()
Super root of all classes in Enforce script.
Definition EnScript.c:11
proto native void SwitchSeat(int pTransportPositionIndex, int pVehicleSeat)
Base native class for all motorized wheeled vehicles.
Definition Car.c:80
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
proto native CGame GetGame()
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
const int UA_START
Definition constants.c:423