DayZ 1.24
Loading...
Searching...
No Matches
HandAnimatedMovingToAtt.c
Go to the documentation of this file.
1class HandStartHidingAnimated extends HandStartAction
2{
5
6 override void OnEntry(HandEventBase e)
7 {
8 super.OnEntry(e);
9 }
10
11 override void OnAbort(HandEventBase e)
12 {
13 super.OnAbort(e);
14 }
15
16 override void OnExit(HandEventBase e)
17 {
18 super.OnExit(e);
19 }
20
21 override bool IsWaitingForActionFinish() { return m_ActionType == -1; }
22};
23
24// When editing this, take a look at HandAnimatedMoveToDst_W4T_Basic as well
25// They can not be inherited from each other because of different inheritance
27{
29
30 override void OnEntry(HandEventBase e)
31 {
32 Man player = e.m_Player;
33 if (m_Dst && m_Dst.IsValid())
34 {
35 EntityAI item = m_Dst.GetItem();
37 if (item.GetInventory().GetCurrentInventoryLocation(src))
38 {
40 {
42 player.OnItemInHandsChanged();
43 }
44 else
45 {
46#ifdef DEVELOPER
48 Debug.InventoryHFSMLog("[hndfsm] HandAnimatedMoveToDst_W4T - not allowed");
49#endif
50 }
51 }
52 else
53 Error("[hndfsm] " + Object.GetDebugName(e.m_Player) + " STS = " + e.m_Player.GetSimulationTimeStamp() + " HandAnimatedMoveToDst_W4T - item " + item + " has no Inventory or Location, inv=" + item.GetInventory());
54 }
55 else
56 Error("[hndfsm] HandAnimatedMoveToDst_W4T - event has no valid m_Dst");
57
58 super.OnEntry(e);
59 }
60
61 override void OnAbort(HandEventBase e)
62 {
63 m_Dst = null;
64 super.OnAbort(e);
65 }
66
67 override void OnExit(HandEventBase e)
68 {
69 m_Dst = null;
70 super.OnExit(e);
71 }
72
73 override bool IsWaitingForActionFinish() { return true; }
74};
75
76class HandAnimatedMovingToAtt extends HandStateBase
77{
79
80 ref HandStartHidingAnimated m_Hide;
82
84
86 {
87 // setup nested state machine
88 m_Hide = new HandStartHidingAnimated(player, this, WeaponActions.HIDE, -1);
89 m_Show = new HandAnimatedMoveToDst_W4T(player, this, WeaponActions.SHOW, -1);
90
91 // events:
92 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
93 HandEventBase _AEh_ = new HandAnimEventChanged;
94
95 m_FSM = new HandFSM(this); // @NOTE: set owner of the submachine fsm
96
97 m_FSM.AddTransition(new HandTransition(m_Hide, _AEh_, m_Show));
98 m_FSM.AddTransition(new HandTransition(m_Show, _fin_, null));
99
100 m_FSM.SetInitialState(m_Hide);
101 }
102
103 override void OnEntry(HandEventBase e)
104 {
105 m_Entity = e.GetSrcEntity();
106 HandEventMoveTo ev_move = HandEventMoveTo.Cast(e);
107 if (ev_move)
108 {
109 m_Show.m_Dst = ev_move.GetDst();
110 m_Hide.m_ActionType = ev_move.GetAnimationID();
111 m_Show.m_ActionType = ev_move.GetAnimationID();
112
113 m_ilEntity = m_Show.m_Dst;
114
115 e.m_Player.GetHumanInventory().AddInventoryReservationEx(m_Entity, m_ilEntity, GameInventory.c_InventoryReservationTimeoutShortMS);
116 }
117
118 super.OnEntry(e); // @NOTE: super at the end (prevent override from submachine start)
119 }
120
121 override void OnAbort(HandEventBase e)
122 {
123 if (!GetGame().IsDedicatedServer())
124 e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Entity, m_ilEntity);
125 else
126 GetGame().ClearJunctureEx(e.m_Player, m_Entity);
127
128 m_Entity = null;
129 m_ilEntity = null;
130
131 super.OnAbort(e);
132 }
133
134 override void OnExit(HandEventBase e)
135 {
136 if (!GetGame().IsDedicatedServer())
137 e.m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Entity, m_ilEntity);
138
139 m_Entity = null;
140 m_ilEntity = null;
141
142 super.OnExit(e);
143 }
144};
145
EntityAI m_Entity
Definition ActionDebug.c:11
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition HandFSM.c:27
Definition Debug.c:14
static void InventoryHFSMLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:183
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutShortMS
Definition Inventory.c:688
static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
synchronously removes item from current inventory location and adds it to destination no anims involv...
static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst)
queries if the entity contained in inv_loc.m_item can be moved to another location This is a shorthan...
Abstracted event, not to be used, only inherited.
Hand finite state machine.
simple class starting animation action specified by m_action and m_actionType
override bool IsWaitingForActionFinish()
override void OnAbort(HandEventBase e)
void HandStartHidingAnimated(Man player=null, HandStateBase parent=null, WeaponActions action=WeaponActions.NONE, int actionType=-1)
ref InventoryLocation m_Dst
override void OnEntry(HandEventBase e)
override void OnExit(HandEventBase e)
represent hand state base
override void OnExit(HandEventBase e)
override void OnEntry(HandEventBase e)
ref HandStartHidingAnimated m_Hide
weapon to be taken
ref HandAnimatedMoveToDst_W4T m_Show
override void OnAbort(HandEventBase e)
ref InventoryLocation m_ilEntity
void HandAnimatedMovingToAtt(Man player=null, HandStateBase parent=null)
InventoryLocation.
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:749
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
WeaponActions
actions
Definition human.c:796