Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
hand_actions.c
Go to the documentation of this file.
1 
7 {
11  void Action (HandEventBase e) { }
12 };
13 
14 
15 class HandActionCreated extends HandActionBase
16 {
17  override void Action (HandEventBase e)
18  {
19  #ifdef DEVELOPER
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 
30 class HandActionTake extends HandActionBase
31 {
32  override void Action (HandEventBase e)
33  {
34  #ifdef DEVELOPER
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 
46 class HandActionDrop extends HandActionBase
47 {
48  override void Action (HandEventBase e)
49  {
50  #ifdef DEVELOPER
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 
62 class HandActionThrow extends HandActionBase
63 {
64  override void Action (HandEventBase e)
65  {
66  #ifdef DEVELOPER
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 
90 class HandActionMoveTo extends HandActionBase
91 {
92  override void Action (HandEventBase e)
93  {
94  #ifdef DEVELOPER
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 
112 class HandActionDestroy extends HandActionBase
113 {
114  override void Action (HandEventBase e)
115  {
116  #ifdef DEVELOPER
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 
128 class HandActionDestroyed extends HandActionBase
129 {
130  override void Action (HandEventBase e)
131  {
132  #ifdef DEVELOPER
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 DEVELOPER
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 
172 class HandActionDestroyAndReplaceWithNewElsewhere extends HandActionDestroyAndReplaceWithNew
173 {
174  override void Action (HandEventBase e)
175  {
176  super.Action(e);
177  }
178 };
179 
180 class HandActionReplaced extends HandActionBase
181 {
182  override void Action (HandEventBase e)
183  {
184  #ifdef DEVELOPER
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 
196 class HandActionSwap extends HandActionBase
197 {
198  override void Action (HandEventBase e)
199  {
200  #ifdef DEVELOPER
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 
217 class HandActionForceSwap extends HandActionBase
218 {
219  override void Action (HandEventBase e)
220  {
221  #ifdef DEVELOPER
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 
GetGame
proto native CGame GetGame()
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
LogManager
Definition: debug.c:734
HandEventSwap
Definition: hand_events.c:659
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
InventoryItem
Definition: itembase.c:13
HandEventBase
Abstracted event, not to be used, only inherited.
Definition: hand_events.c:194
DayZPlayer
Definition: dayzplayerimplement.c:72
HandEventDestroyAndReplaceWithNew
Definition: hand_events.c:753
Debug
Definition: debug.c:13
HandActionDestroyAndReplaceWithNew
Definition: hand_actions.c:172
HandActionBase
actions
Definition: hand_actions.c:6
EntityAI
Definition: building.c:5
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
DayZPlayerInstanceType
DayZPlayerInstanceType
defined in C++
Definition: dayzplayer.c:1058