Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
hand_actions.c
Go to the documentation of this file.
1
2
7{
11 void Action (HandEventBase e) { }
12};
13
14
15class HandActionCreated extends HandActionBase
16{
17 override void Action (HandEventBase e)
18 {
19 #ifdef ENABLE_LOGGING
20 if ( LogManager.IsInventoryHFSMLogEnable() )
21 {
22 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionCreated", e.m_Player.ToString() );
23 }
24 #endif
25
26 e.m_Player.OnItemInHandsChanged();
27 }
28};
29
30class HandActionTake extends HandActionBase
31{
32 override void Action (HandEventBase e)
33 {
34 #ifdef ENABLE_LOGGING
35 if ( LogManager.IsInventoryHFSMLogEnable() )
36 {
37 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionTake", e.m_Player.ToString() );
38 }
39 #endif
40
41 GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
42 e.m_Player.OnItemInHandsChanged();
43 }
44};
45
46class HandActionDrop extends HandActionBase
47{
48 override void Action (HandEventBase e)
49 {
50 #ifdef ENABLE_LOGGING
51 if ( LogManager.IsInventoryHFSMLogEnable() )
52 {
53 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDrop", e.m_Player.ToString() );
54 }
55 #endif
56
57 GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
58 e.m_Player.OnItemInHandsChanged();
59 }
60};
61
62class HandActionThrow extends HandActionBase
63{
64 override void Action (HandEventBase e)
65 {
66 #ifdef ENABLE_LOGGING
67 if ( LogManager.IsInventoryHFSMLogEnable() )
68 {
69 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionThrow", e.m_Player.ToString() );
70 }
71 #endif
72 HandEventThrow throwEvent = HandEventThrow.Cast(e);
73
74 GameInventory.LocationSyncMoveEntity(e.GetSrc(), e.GetDst());
75
76 DayZPlayer player = DayZPlayer.Cast(e.m_Player);
77 if ( player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE )
78 {
79 InventoryItem item = InventoryItem.Cast(e.GetSrcEntity());
80 if( item )
81 item.ThrowPhysically(player, throwEvent.GetForce());
82 else
83 Error("[hndfsm] HandActionThrow - src entity null!");
84 }
85
86 player.OnItemInHandsChanged();
87 }
88};
89
90class HandActionMoveTo extends HandActionBase
91{
92 override void Action (HandEventBase e)
93 {
94 #ifdef ENABLE_LOGGING
95 if ( LogManager.IsInventoryHFSMLogEnable() )
96 {
97 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionMoveTo", e.m_Player.ToString() );
98 }
99 #endif
100
101 HandEventMoveTo es = HandEventMoveTo.Cast(e);
102 if (es)
103 {
104 GameInventory.LocationSyncMoveEntity(e.GetSrc(), es.m_Dst);
105 e.m_Player.OnItemInHandsChanged();
106 }
107 else
108 Error("[hndfsm] HandActionMoveTo - this is no HandEventMoveTo");
109 }
110};
111
112class HandActionDestroy extends HandActionBase
113{
114 override void Action (HandEventBase e)
115 {
116 #ifdef ENABLE_LOGGING
117 if ( LogManager.IsInventoryHFSMLogEnable() )
118 {
119 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroy", e.m_Player.ToString() );
120 }
121 #endif
122
123 GetGame().ObjectDelete(e.GetSrcEntity());
124 e.m_Player.OnItemInHandsChanged();
125 }
126};
127
128class HandActionDestroyed extends HandActionBase
129{
130 override void Action (HandEventBase e)
131 {
132 #ifdef ENABLE_LOGGING
133 if ( LogManager.IsInventoryHFSMLogEnable() )
134 {
135 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroyed", e.m_Player.ToString() );
136 }
137 #endif
138 e.m_Player.OnItemInHandsChanged();
139 }
140};
141
143{
144 override void Action (HandEventBase e)
145 {
146 #ifdef ENABLE_LOGGING
147 if ( LogManager.IsInventoryHFSMLogEnable() )
148 {
149 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionDestroyAndReplaceWithNew", e.m_Player.ToString() );
150 }
151 #endif
152 Man player = e.m_Player;
153 EntityAI itemInHands = player.GetHumanInventory().GetEntityInHands();
154
156 if (itemInHands.GetInventory().GetCurrentInventoryLocation(src))
157 {
159 if (edr)
160 {
161 edr.m_Lambda.Execute();
162 return;
163 }
164 else
165 Error("[hndfsm] HandActionDestroyAndReplaceWithNew - not a HandEventDestroyAndReplaceWithNew event");
166 }
167 else
168 Error("[hndfsm] HandActionDestroyAndReplaceWithNew - itemInHands has no InventoryLocation");
169 }
170};
171
172class HandActionDestroyAndReplaceWithNewElsewhere extends HandActionDestroyAndReplaceWithNew
173{
174 override void Action (HandEventBase e)
175 {
176 super.Action(e);
177 }
178};
179
180class HandActionReplaced extends HandActionBase
181{
182 override void Action (HandEventBase e)
183 {
184 #ifdef ENABLE_LOGGING
185 if ( LogManager.IsInventoryHFSMLogEnable() )
186 {
187 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionReplaced", e.m_Player.ToString() );
188 }
189 #endif
190 Man player = e.m_Player;
191
192 player.OnItemInHandsChanged();
193 }
194};
195
196class HandActionSwap extends HandActionBase
197{
198 override void Action (HandEventBase e)
199 {
200 #ifdef ENABLE_LOGGING
201 if ( LogManager.IsInventoryHFSMLogEnable() )
202 {
203 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionSwap", e.m_Player.ToString() );
204 }
205 #endif
206 HandEventSwap es = HandEventSwap.Cast(e);
207 if (es)
208 {
209 GameInventory.LocationSwap(es.GetSrc(), es.m_Src2, es.GetDst(), es.m_Dst2);
210 e.m_Player.OnItemInHandsChanged();
211 }
212 else
213 Error("[hndfsm] HandActionSwap - this is no HandEventSwap");
214 }
215};
216
217class HandActionForceSwap extends HandActionBase
218{
219 override void Action (HandEventBase e)
220 {
221 #ifdef ENABLE_LOGGING
222 if ( LogManager.IsInventoryHFSMLogEnable() )
223 {
224 Debug.InventoryHFSMLog("Action - STS = " + e.m_Player.GetSimulationTimeStamp(), e.ToString() , "n/a", "HandActionForceSwap", e.m_Player.ToString() );
225 }
226 #endif
227 HandEventForceSwap es = HandEventForceSwap.Cast(e);
228 if (es)
229 {
230 GameInventory.LocationSwap(es.GetSrc(), es.m_Src2, es.GetDst(), es.m_Dst2);
231 e.m_Player.OnItemInHandsChanged();
232 }
233 else
234 Error("[hndfsm] HandActionForceSwap - this is no HandEventForceSwap");
235 }
236};
237
239
override void OnItemInHandsChanged()
Definition debug.c:2
script counterpart to engine's class Inventory
Definition inventory.c:79
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 LocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
swaps two entities
Abstracted event, not to be used, only inherited.
InventoryLocation.
DayZPlayerInstanceType
defined in C++
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition endebug.c:90