DayZ 1.24
Loading...
Searching...
No Matches
ActionSwitchSeats.c
Go to the documentation of this file.
1
2class ActionSwitchSeats: ActionBase
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
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
54 {
55 super.Start(action_data);
56 HumanCommandVehicle vehCommand = action_data.m_Player.GetCommand_Vehicle();
57 if (vehCommand)
58 {
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 action_data.m_Player.OnVehicleSwitchSeat(nextSeat);
71 }
72 }
73 }
74 }
75
77 {
78
79 if (action_data.m_State == UA_START)
80 {
81 HumanCommandVehicle hcv = action_data.m_Player.GetCommand_Vehicle();
82 if (!hcv || !action_data.m_Player.GetCommand_Vehicle().IsSwitchSeat())
84 }
85 }
86
87 override bool CanBeUsedInVehicle()
88 {
89 return true;
90 }
91};
string m_Text
Definition ActionBase.c:49
bool m_LockTargetOnUse
Definition ActionBase.c:51
ref CCIBase m_ConditionItem
Definition ActionBase.c:55
float m_SpecialtyWeight
Definition ActionBase.c:68
ref CCTBase m_ConditionTarget
Definition ActionBase.c:56
int m_StanceMask
Definition ActionBase.c:53
void End()
called on surrender end request end
override void Start(ActionData action_data)
override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
override bool CanBeUsedInVehicle()
override void CreateConditionComponents()
override void OnUpdate(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
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:439