Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
hand_events.c
Go to the documentation of this file.
1 
7 {
9  TAKE,
25 };
26 
28 {
32  ERROR,
33 }
34 
39 {
40  int m_EventID = 0;
41  int m_AnimationID = -1;
44 
50  bool m_IsRemote;
51 
52  void HandEventBase (Man p = null, InventoryLocation src = null) { Class.CastTo(m_Player, p); m_Src = src; }
54 
56  {
57  return m_Player && (m_Player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT && m_Player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE);
58  }
59 
60  bool IsOwner()
61  {
62  return m_Player && (m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER || m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER);
63  }
64 
65  bool IsProxy()
66  {
67  return m_Player && (m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE || m_Player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE);
68  }
69 
70  void ReadFromContext (ParamsReadContext ctx) { } // actual read is in CreateHandEventFromContext
71 
72  void WriteToContext (ParamsWriteContext ctx)
73  {
74  ctx.Write(m_EventID);
75  ctx.Write(m_Player);
77  ctx.Write(m_AnimationID);
78  }
79 
82  {
83  if (m_Src)
84  return m_Src.GetItem();
85  return null;
86  }
87  EntityAI GetSecondSrcEntity () { return null; }
88  InventoryLocation GetDst () { return null; }
89  int GetAnimationID () { return m_AnimationID; }
90  bool AcquireInventoryJunctureFromServer (notnull Man player) { return false; }
91  bool CheckRequest () { return true; }
93  {
97  if (validation.m_IsRemote || validation.m_IsJuncture)
98  return true;
99 
100  return CheckRequest();
101  }
102  bool CanPerformEvent () { return true; }
103  bool CanPerformEventEx (InventoryValidation validation) { return CanPerformEvent(); }
104  bool CheckRequestSrc () { return true; }
105  bool IsServerSideOnly () { return false; }
106 
107  static HandEventBase HandEventFactory (HandEventID id, Man p = null, InventoryLocation src = null)
108  {
109  switch (id)
110  {
111  case HandEventID.UNKNOWN: return null;
112  case HandEventID.TAKE: return new HandEventTake(p, src);
113  case HandEventID.MOVETO: return new HandEventMoveTo(p, src);
114  case HandEventID.DROP: return new HandEventDrop(p, src);
115  case HandEventID.THROW: return new HandEventThrow(p, src);
116  case HandEventID.SWAP: return new HandEventSwap(p, src);
117  case HandEventID.FORCESWAP: return new HandEventForceSwap(p, src);
118  case HandEventID.DESTROY: return new HandEventDestroy(p, src);
119  case HandEventID.CREATED: return new HandEventCreated(p, src);
120  case HandEventID.DESTROYED: return new HandEventDestroyed(p, src);
121  case HandEventID.REPLACE: return new HandEventDestroyAndReplaceWithNew(p, src);
122  case HandEventID.REPLACE2: return new HandEventDestroyAndReplaceWithNewElsewhere(p, src);
123  case HandEventID.REPLACE3: return new HandEventDestroyElsewhereAndReplaceWithNewInHands(p, src);
124  case HandEventID.REPLACED: return new HandEventReplaced(p, src);
125  case HandEventID.ANIMEVENT_CHANGE_HIDE: return HandAnimEventChanged(p, src);
126  case HandEventID.HUMANCOMMAND_ACTION_FINISHED : return HandEventHumanCommandActionFinished(p, src);
127  case HandEventID.HUMANCOMMAND_ACTION_ABORTED : return HandEventHumanCommandActionAborted(p, src);
128  }
129  Error("[hndfsm] HandEventFactory - unregistered hand event with id=" + id);
130  return null;
131  }
132 
133  static HandEventBase CreateHandEventFromContext (ParamsReadContext ctx)
134  {
135  int eventID = -1;
136  if (!ctx.Read(eventID))
137  {
138  Error("[hndfsm] CreateHandEventFromContext - cannot read eventID");
139  return null;
140  }
141  Man player;
142  if (!ctx.Read(player))
143  {
144  Error("[hndfsm] CreateHandEventFromContext - cannot read player");
145  return null;
146  }
147  InventoryLocation src;
149 
150  int animID = -1;
151  if (!ctx.Read(animID))
152  {
153  Error("[hndfsm] CreateHandEventFromContext - cannot read animID");
154  return null;
155  }
156  HandEventBase b = HandEventFactory(eventID, player, src);
157  if (b)
158  {
159  b.m_AnimationID = animID;
160  b.ReadFromContext(ctx);
161  }
162  return b;
163  }
164 
165  string DumpToString ()
166  {
167  string res = "{ HandEv id=" + typename.EnumToString(HandEventID, GetEventID());
168  res = res + " pl=" + Object.GetDebugName(m_Player);
169  res = res + " src=" + InventoryLocation.DumpToStringNullSafe(m_Src);
170  res = res + " }";
171  return res;
172  }
173 
174  bool ReserveInventory()
175  {
176  InventoryLocation dst = GetDst();
177  if( dst && !m_Player.GetHumanInventory().AddInventoryReservationEx(dst.GetItem(), dst, GameInventory.c_InventoryReservationTimeoutShortMS) )
178  {
179  return false;
180  }
181  return true;
182  }
183 
184  void ClearInventoryReservation()
185  {
186  InventoryLocation dst = GetDst();
187  if(dst)
188  {
189  m_Player.GetHumanInventory().ClearInventoryReservationEx(dst.GetItem(), dst);
190  }
191  }
192 };
193 
194 class HandEventTake extends HandEventBase
195 {
196  void HandEventTake (Man p = null, InventoryLocation src = null) { m_EventID = HandEventID.TAKE; }
197 
198  override InventoryLocation GetDst ()
199  {
201  dst.SetHands(m_Player, GetSrcEntity());
202  return dst;
203  }
204 
205  override bool CheckRequestSrc ()
206  {
207  if (false == GameInventory.CheckRequestSrc(m_Player, GetSrc(), GameInventory.c_MaxItemDistanceRadius))
208  {
209  Debug.InventoryHFSMLog("CANNOT perform", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CheckRequestSrc", m_Player.ToString() );
210  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(m_Player) + " failed src1 check with cmd=" + typename.EnumToString(HandEventID, GetEventID()) + " src1=" + InventoryLocation.DumpToStringNullSafe(GetSrc()));
211  return false; // stale packet
212  }
213  return true;
214  }
215 
216  override bool CheckRequest ()
217  {
218  return GameInventory.CheckMoveToDstRequest(m_Player, GetSrc(), GetDst(), GameInventory.c_MaxItemDistanceRadius);
219  }
220 
221  override bool CanPerformEventEx(InventoryValidation validation)
222  {
223  if (validation.m_IsJuncture)
224  {
225  return true;
226  }
227 
228  if (!GameInventory.LocationCanMoveEntity(GetSrc(), GetDst()))
229  {
230  #ifdef DEVELOPER
231  if ( LogManager.IsInventoryHFSMLogEnable() )
232  {
233  Debug.InventoryHFSMLog("CANNOT perform", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CanPerformEvent", m_Player.ToString() );
234  }
235  #endif
236  //if (LogManager.IsInventoryHFSMLogEnable()) hndDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(m_Player) + " CANNOT perform ev=" + DumpToString());
237  return false;
238  }
239 
240  return super.CanPerformEventEx(validation);
241  }
242 
243  override bool AcquireInventoryJunctureFromServer (notnull Man player)
244  {
245  InventoryLocation src = GetSrc();
246  InventoryLocation dst = GetDst();
247  if (src && dst)
248  {
249  return TryAcquireInventoryJunctureFromServer(player, src, dst);
250  }
251  Error("[hndfsm] HandEventTake. AcquireInventoryJunctureFromServer: no src or dst for ev=" + DumpToString());
252  return JunctureRequestResult.ERROR;
253  }
254 };
255 
256 class HandEventMoveTo extends HandEventBase
257 {
258  ref InventoryLocation m_Dst;
259 
260  void HandEventMoveTo (Man p = null, InventoryLocation src = null, InventoryLocation dst = null) { m_EventID = HandEventID.MOVETO; m_Dst = dst; }
261 
262  override void ReadFromContext (ParamsReadContext ctx)
263  {
264  m_Dst = new InventoryLocation;
265  super.ReadFromContext(ctx);
266  m_Dst.ReadFromContext(ctx);
267  }
268  override void WriteToContext (ParamsWriteContext ctx)
269  {
270  super.WriteToContext(ctx);
271  m_Dst.WriteToContext(ctx);
272  }
273 
274  override InventoryLocation GetDst () { return m_Dst; }
275 
276  override bool CheckRequestSrc ()
277  {
278  if (false == GameInventory.CheckRequestSrc(m_Player, GetSrc(), GameInventory.c_MaxItemDistanceRadius))
279  {
280  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(m_Player) + " failed src1 check with cmd=" + typename.EnumToString(HandEventID, GetEventID()) + " src1=" + InventoryLocation.DumpToStringNullSafe(GetSrc()));
281  return false; // stale packet
282  }
283  return true;
284  }
285 
286  override bool CheckRequest ()
287  {
288  return GameInventory.CheckMoveToDstRequest(m_Player, GetSrc(), GetDst(), GameInventory.c_MaxItemDistanceRadius);
289  }
290 
291  override bool CanPerformEvent ()
292  {
293  if (false == GameInventory.LocationCanMoveEntity(GetSrc(), GetDst()))
294  {
295  #ifdef DEVELOPER
296  if ( LogManager.IsInventoryHFSMLogEnable() )
297  {
298  Debug.InventoryHFSMLog("CANNOT perform", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CanPerformEvent", m_Player.ToString() );
299  }
300  #endif
301  return false;
302  }
303  return true;
304  }
305 
306  override bool AcquireInventoryJunctureFromServer (notnull Man player)
307  {
308  InventoryLocation src = GetSrc();
309  InventoryLocation dst = GetDst();
310  if (src && dst)
311  {
312  return TryAcquireInventoryJunctureFromServer(player, src, dst);
313  }
314  Error("[hndfsm] HandEventMoveTo. AcquireInventoryJunctureFromServer: no src or dst for ev=" + DumpToString());
315  return JunctureRequestResult.ERROR;
316  }
317 
318  override string DumpToString ()
319  {
320  string res = "{ HandEventMoveTo id=" + typename.EnumToString(HandEventID, GetEventID()) + " pl=" + Object.GetDebugName(m_Player) + " src=" + InventoryLocation.DumpToStringNullSafe(m_Src) + " dst=" + InventoryLocation.DumpToStringNullSafe(m_Dst) + " }";
321  return res;
322  }
323 };
324 
326 class HandEventRemove extends HandEventBase
327 {
328  override InventoryLocation GetDst ()
329  {
330  return m_Dst;
331  }
332 
333  override bool CheckRequestSrc ()
334  {
335  if (false == GameInventory.CheckRequestSrc(m_Player, GetSrc(), GameInventory.c_MaxItemDistanceRadius))
336  {
337  #ifdef DEVELOPER
338  if ( LogManager.IsInventoryHFSMLogEnable() )
339  {
340  Debug.InventoryHFSMLog("Check src - failed, src = " + InventoryLocation.DumpToStringNullSafe(GetSrc()), typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CheckRequestSrc", m_Player.ToString() );
341  }
342  #endif
343  return false; // stale packet
344  }
345  return true;
346  }
347 
348  override bool CheckRequest ()
349  {
350  return GameInventory.CheckMoveToDstRequest(m_Player, GetSrc(), GetDst(), GameInventory.c_MaxItemDistanceRadius);
351  }
352 
353  override bool CanPerformEvent ()
354  {
355  if (false == GameInventory.LocationCanMoveEntity(GetSrc(), GetDst()))
356  {
357  #ifdef DEVELOPER
358  if ( LogManager.IsInventoryHFSMLogEnable() )
359  {
360  Debug.InventoryHFSMLog("CANNOT perform", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CanPerformEvent", m_Player.ToString() );
361  }
362  #endif
363  return false;
364  }
365  return true;
366  }
367 
368  override bool AcquireInventoryJunctureFromServer (notnull Man player)
369  {
370  InventoryLocation src = GetSrc();
371  InventoryLocation dst = GetDst();
372  if (src && dst)
373  {
374  return TryAcquireInventoryJunctureFromServer(player, src, dst);
375  }
376  Error("[hndfsm] HandEventThrow. AcquireInventoryJunctureFromServer: no src or dst for ev=" + DumpToString());
377  return JunctureRequestResult.ERROR;
378  }
379 
380  ref InventoryLocation m_Dst;
381 };
382 
383 class HandEventDrop extends HandEventRemove
384 {
385  void HandEventDrop (Man p = null, InventoryLocation src = null)
386  {
387  m_EventID = HandEventID.DROP;
388  m_CanPerformDrop = true;
389  }
390 
391  override void ReadFromContext(ParamsReadContext ctx)
392  {
393  super.ReadFromContext(ctx);
394 
395  ctx.Read(m_CanPerformDrop);
397  if (!m_Dst)
398  {
399  m_Dst = new InventoryLocation();
400  }
401  }
402 
403  override void WriteToContext(ParamsWriteContext ctx)
404  {
405  super.WriteToContext(ctx);
406 
407  ctx.Write(m_CanPerformDrop);
408  OptionalLocationWriteToContext(m_Dst, ctx);
409  }
410 
411  override bool CheckRequestEx(InventoryValidation validation)
412  {
414  if (!validation.m_IsJuncture && IsAuthoritative())
415  {
416  m_CanPerformDrop = GameInventory.SetGroundPosByOwner(m_Player, GetSrcEntity(), m_Dst);
417  }
418 
419  if (!m_CanPerformDrop)
420  {
421  validation.m_Reason = InventoryValidationReason.DROP_PREVENTED;
422  return false;
423  }
424 
425  return super.CheckRequestEx(validation);
426  }
427 
428  override bool CanPerformEventEx(InventoryValidation validation)
429  {
430  if (!m_CanPerformDrop)
431  {
432  return false;
433  }
434 
436  if (!validation.m_IsJuncture && !validation.m_IsRemote && !GetDst() && (GetGame().IsMultiplayer() && GetGame().IsClient()))
437  {
438  return true;
439  }
440 
442  if (!validation.m_IsRemote && !GetDst())
443  {
444  m_Dst = new InventoryLocation();
445  m_CanPerformDrop = GameInventory.SetGroundPosByOwner(m_Player, GetSrcEntity(), m_Dst);
446 
447  if (!m_CanPerformDrop)
448  {
449  validation.m_Reason = InventoryValidationReason.DROP_PREVENTED;
450  return false;
451  }
452  }
453 
454  return super.CanPerformEventEx(validation);
455  }
456 
457  bool m_CanPerformDrop;
458 };
459 
460 class HandEventThrow extends HandEventRemove
461 {
462  void HandEventThrow (Man p = null, InventoryLocation src = null)
463  {
464  m_EventID = HandEventID.THROW;
465  if( src )
466  {
467  vector mat[4];
468  EntityAI entity = GetSrcEntity();
469  if (entity)
470  {
471  m_Dst = new InventoryLocation;
472  entity.GetTransform(mat);
473  m_Dst.SetGround(entity, mat);
474  }
475  else
476  {
477  Error("[hndfsm] HandEventThrow src entity null!");
478  }
479  }
480  }
481 
482  override void ReadFromContext (ParamsReadContext ctx)
483  {
484  super.ReadFromContext(ctx);
485 
486  m_Dst = new InventoryLocation;
487  m_Dst.ReadFromContext(ctx);
488 
489  float x, y, z;
490  ctx.Read(x);
491  ctx.Read(y);
492  ctx.Read(z);
493  m_Force[0] = x;
494  m_Force[1] = y;
495  m_Force[2] = z;
496  }
497 
498  override void WriteToContext (ParamsWriteContext ctx)
499  {
500  super.WriteToContext(ctx);
501 
502  m_Dst.WriteToContext(ctx);
503 
504  ctx.Write(m_Force[0]);
505  ctx.Write(m_Force[1]);
506  ctx.Write(m_Force[2]);
507  }
508 
509  void SetForce(vector force) { m_Force = force; }
510  vector GetForce() { return m_Force; }
511 
512  vector m_Force;
513 };
514 
515 class HandEventSwap extends HandEventBase
516 {
517  // super.m_Src == src location of new item (that will be taken)
518  ref InventoryLocation m_Dst;
519  ref InventoryLocation m_Src2;
520  ref InventoryLocation m_Dst2;
521  int m_Animation2ID = -1;
522 
523  void HandEventSwap (Man p = null, InventoryLocation src = null, InventoryLocation src2 = null, InventoryLocation dst = null, InventoryLocation dst2 = null)
524  {
525  m_EventID = HandEventID.SWAP;
526  m_Dst = dst;
527  m_Src2 = src2;
528  m_Dst2 = dst2;
529  }
530 
531  override void ReadFromContext (ParamsReadContext ctx)
532  {
533  super.ReadFromContext(ctx);
534 
535  m_Src2 = new InventoryLocation;
536  m_Dst = new InventoryLocation;
537  m_Dst2 = new InventoryLocation;
538 
539  m_Src2.ReadFromContext(ctx);
540  m_Dst.ReadFromContext(ctx);
541  m_Dst2.ReadFromContext(ctx);
542  ctx.Read(m_Animation2ID);
543  }
544 
545  override void WriteToContext (ParamsWriteContext ctx)
546  {
547  super.WriteToContext(ctx);
548 
549  m_Src2.WriteToContext(ctx);
550  m_Dst.WriteToContext(ctx);
551  m_Dst2.WriteToContext(ctx);
552  ctx.Write(m_Animation2ID);
553  }
554 
555  override InventoryLocation GetDst ()
556  {
557  return m_Dst;
558  }
559 
560  override EntityAI GetSecondSrcEntity()
561  {
562  return m_Src2.GetItem();
563  }
564 
565  override bool CheckRequestSrc ()
566  {
567  //return false;
568 
569  if (false == GameInventory.CheckRequestSrc(m_Player, GetSrc(), GameInventory.c_MaxItemDistanceRadius))
570  {
571  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(m_Player) + " failed src1 check with cmd=" + typename.EnumToString(HandEventID, GetEventID()) + " src1=" + InventoryLocation.DumpToStringNullSafe(GetSrc()));
572  return false; // stale packet
573  }
574  if (false == GameInventory.CheckRequestSrc(m_Player, m_Src2, GameInventory.c_MaxItemDistanceRadius))
575  {
576  if (LogManager.IsSyncLogEnable()) syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(m_Player) + " failed src2 check with cmd=" + typename.EnumToString(HandEventID, GetEventID()) + " src2=" + InventoryLocation.DumpToStringNullSafe(m_Src2));
577  return false; // stale packet
578  }
579  return true;
580  }
581 
582  override bool CheckRequest ()
583  {
584  if (!GameInventory.CheckSwapItemsRequest(m_Player, m_Src, m_Src2, m_Dst, m_Dst2, GameInventory.c_MaxItemDistanceRadius))
585  {
586  #ifdef DEVELOPER
587  if ( LogManager.IsInventoryHFSMLogEnable() )
588  {
589  Debug.InventoryHFSMLog("CheckSwapItemsRequest - failed", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CheckRequest", m_Player.ToString() );
590  }
591  #endif
592  }
593  else if (!m_Player.GetHumanInventory().CanAddSwappedEntity(m_Src, m_Src2, m_Dst, m_Dst2))
594  {
595  #ifdef DEVELOPER
596  if ( LogManager.IsInventoryHFSMLogEnable() )
597  {
598  Debug.InventoryHFSMLog("CanAddSwappedEntity - failed", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CheckRequest", m_Player.ToString() );
599  }
600  #endif
601  }
602  else
603  return true;
604 
605  return false;
606  }
607 
608  override bool CanPerformEvent ()
609  {
610  if (GameInventory.CanForceSwapEntitiesEx(GetSrc().GetItem(), m_Dst, m_Src2.GetItem(), m_Dst2))
611  return true;
612 
613  #ifdef DEVELOPER
614  if ( LogManager.IsInventoryHFSMLogEnable() )
615  {
616  Debug.InventoryHFSMLog("CANNOT perform", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CanPerformEvent", m_Player.ToString() );
617  }
618  #endif
619  return false;
620  }
621 
622  override bool AcquireInventoryJunctureFromServer (notnull Man player)
623  {
624  return TryAcquireTwoInventoryJuncturesFromServer(player, m_Src, m_Src2, m_Dst, m_Dst2);
625  }
626 
627  override string DumpToString ()
628  {
629  return "{ HandEventSwap id=" + typename.EnumToString(HandEventID, GetEventID()) + " pl=" + Object.GetDebugName(m_Player) + " src1=" + InventoryLocation.DumpToStringNullSafe(m_Src) + " src2=" + InventoryLocation.DumpToStringNullSafe(m_Src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(m_Dst) + " dst2=" + InventoryLocation.DumpToStringNullSafe(m_Dst2) + " }";
630  }
631 
632  void CheckAndExecuteForceStandUp()
633  {
634  DayZPlayer player = DayZPlayer.Cast(m_Player);
635  player.ForceStandUpForHeavyItemsSwap( m_Src.GetItem(), m_Src2.GetItem() );
636  }
637 
638  override bool ReserveInventory()
639  {
640  if( !m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst.GetItem(), m_Dst, GameInventory.c_InventoryReservationTimeoutShortMS) )
641  {
642  return false;
643  }
644  if( !m_Player.GetHumanInventory().AddInventoryReservationEx(m_Dst2.GetItem(), m_Dst2, GameInventory.c_InventoryReservationTimeoutShortMS) )
645  {
646  m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
647  return false;
648  }
649  return true;
650  }
651 
652  override void ClearInventoryReservation()
653  {
654  m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst.GetItem(), m_Dst);
655  m_Player.GetHumanInventory().ClearInventoryReservationEx(m_Dst2.GetItem(), m_Dst2);
656  }
657 };
658 
659 class HandEventForceSwap extends HandEventSwap
660 {
661  void HandEventForceSwap (Man p = null, InventoryLocation src = null, InventoryLocation src2 = null, InventoryLocation dst = null, InventoryLocation dst2 = null) { m_EventID = HandEventID.FORCESWAP; }
662 
663  override bool CheckRequest ()
664  {
665  bool test1 = false;
666  EntityAI inHands = m_Player.GetHumanInventory().GetEntityInHands();
667  if (GetSrcEntity() && inHands && m_Dst && m_Dst.IsValid())
668  {
669  test1 = GameInventory.CheckSwapItemsRequest(m_Player, m_Src, m_Src2, m_Dst, m_Dst2, GameInventory.c_MaxItemDistanceRadius);
670  #ifdef DEVELOPER
671  if ( LogManager.IsInventoryHFSMLogEnable() )
672  {
673  if (!test1)
674  Debug.InventoryHFSMLog("CheckSwapItemsRequest failed", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CheckRequest", m_Player.ToString() );
675  }
676  #endif
677  }
678  return test1;
679  }
680 
681  override bool CanPerformEvent ()
682  {
683  bool test2 = GameInventory.CanForceSwapEntitiesEx(m_Src.GetItem(), m_Dst, m_Src2.GetItem(), m_Dst2); // null here means 'do not search for dst2' (already have valid one from constructor)
684  #ifdef DEVELOPER
685  if ( LogManager.IsInventoryHFSMLogEnable() )
686  {
687  if (!test2)
688  Debug.InventoryHFSMLog("CanForceSwapEntitiesEx failed", typename.EnumToString(HandEventID, GetEventID()) , "n/a", "CanPerformEvent", m_Player.ToString() );
689  }
690  #endif
691  return test2;
692  }
693 };
694 
695 class HandEventDestroy extends HandEventBase
696 {
697  void HandEventDestroy (Man p = null, InventoryLocation src = null) { m_EventID = HandEventID.DESTROY; }
698 
699  override bool IsServerSideOnly () { return true; }
700 };
701 
702 class HandEventCreated extends HandEventBase
703 {
704  void HandEventCreated (Man p = null, InventoryLocation src = null) { m_EventID = HandEventID.CREATED; }
705 };
706 
707 class HandEventDestroyed extends HandEventBase
708 {
709  void HandEventDestroyed (Man p = null, InventoryLocation src = null) { m_EventID = HandEventID.DESTROYED; }
710 };
711 
713 {
714  string m_Type;
715  ref ReplaceItemWithNewLambdaBase m_Lambda;
716 
717  void HandEvengReplaceWithNewBase (Man p = null, InventoryLocation src = null, ReplaceItemWithNewLambdaBase lambda = NULL) { m_EventID = HandEventID.REPLACE; m_Lambda = lambda; }
718 
719  override void ReadFromContext (ParamsReadContext ctx)
720  {
721  super.ReadFromContext(ctx);
722  ctx.Read(m_Type);
723  Error("[hndfsm] HandEventDestroyAndReplaceWithNew - Cannot serialize lambda (read)");
724  }
725  override void WriteToContext (ParamsWriteContext ctx)
726  {
727  super.WriteToContext(ctx);
728  ctx.Write(m_Type);
729  Error("[hndfsm] HandEventDestroyAndReplaceWithNew - Cannot serialize lambda (write)");
730  }
731 
732  override bool IsServerSideOnly () { return true; }
733 
734  override InventoryLocation GetDst ()
735  {
737  dst.SetHands(m_Player, GetSrcEntity());
738  return dst;
739  }
740 
741  override string DumpToString ()
742  {
743  string res = "{ HandEvenReplaceWithNewBase id=" + typename.EnumToString(HandEventID, GetEventID()) + " pl=" + Object.GetDebugName(m_Player) + " src=" + InventoryLocation.DumpToStringNullSafe(GetSrc()) + " lambda=" + m_Lambda + " dst=" + InventoryLocation.DumpToStringNullSafe(GetDst()) + " }";
744  return res;
745  }
746 };
747 
749 {
750  void HandEventDestroyAndReplaceWithNew (Man p = null, InventoryLocation src = null, ReplaceItemWithNewLambdaBase lambda = NULL) { m_EventID = HandEventID.REPLACE; m_Lambda = lambda; }
751 };
752 
753 class HandEventDestroyAndReplaceWithNewElsewhere extends HandEventDestroyAndReplaceWithNew
754 {
755  void HandEventDestroyAndReplaceWithNewElsewhere (Man p = null, InventoryLocation src = null, ReplaceItemWithNewLambdaBase lambda = NULL) { m_EventID = HandEventID.REPLACE3; m_Lambda = lambda; }
756 };
757 
758 class HandEventDestroyElsewhereAndReplaceWithNewInHands extends HandEventReplaceWithNewBase
759 {
760  void HandEventDestroyElsewhereAndReplaceWithNewInHands (Man p = null, InventoryLocation src = null, ReplaceItemWithNewLambdaBase lambda = NULL) { m_EventID = HandEventID.REPLACE3; m_Lambda = lambda; }
761 };
762 
763 class HandEventReplaced extends HandEventBase
764 {
765  void HandEventReplaced (Man p = null, InventoryLocation src = null) { m_EventID = HandEventID.REPLACED; }
766 };
767 
768 // anim events
769 
770 class HandAnimEventChanged extends HandEventBase
771 {
772  void HandAnimEventChanged (Man p = null, InventoryLocation src = null) { m_EventID = HandEventID.ANIMEVENT_CHANGE_HIDE; }
773 };
774 
776 {
777  switch (type)
778  {
779  case WeaponEvents.CHANGE_HIDE: return new HandAnimEventChanged(p, src);
780  case WeaponEvents.CHANGE_SHOW: return new HandAnimEventChanged(p, src);
781  }
782  return null;
783 }
784 
787 class HandEventHumanCommandActionFinished extends HandEventBase
788 {
789  void HandEventHumanCommandActionFinished (Man p = null, InventoryLocation src = null) { m_EventID = HandEventID.HUMANCOMMAND_ACTION_FINISHED; }
790 };
793 class HandEventHumanCommandActionAborted extends HandEventBase
794 {
795  void HandEventHumanCommandActionAborted (Man p = null, InventoryLocation src = null) { m_EventID = HandEventID.HUMANCOMMAND_ACTION_ABORTED; }
796 };
797 
799 
GetGame
proto native CGame GetGame()
MOVETO
@ MOVETO
Definition: hand_events.c:10
m_EventID
m_EventID
InventoryValidationReason
InventoryValidationReason
Definition: inventory.c:36
IsOwner
bool IsOwner()
Definition: hand_events.c:60
REPLACE
@ REPLACE
Definition: hand_events.c:18
ReadFromContext
void ReadFromContext(ParamsReadContext ctx)
Definition: hand_events.c:70
Error
void Error(string err)
Messagebox with error message.
Definition: endebug.c:90
CheckRequest
bool CheckRequest()
Definition: hand_events.c:91
m_IsJuncture
bool m_IsJuncture
Definition: hand_events.c:49
LogManager
Definition: debug.c:734
m_Src
ref InventoryLocation m_Src
Definition: hand_events.c:43
DROP
@ DROP
Definition: hand_events.c:11
REPLACE3
@ REPLACE3
Definition: hand_events.c:20
WriteToContext
void WriteToContext(ParamsWriteContext ctx)
Definition: hand_events.c:72
HandEventSwap
Definition: hand_events.c:659
m_Type
eBleedingSourceType m_Type
Definition: bleedingsource.c:25
m_IsRemote
bool m_IsRemote
Definition: hand_events.c:50
HandEventID
HandEventID
events
Definition: hand_events.c:6
OptionalLocationReadFromContext
bool OptionalLocationReadFromContext(out InventoryLocation loc, notnull ParamsReadContext ctx)
Definition: inventorylocation.c:605
GetAnimationID
int GetAnimationID()
Definition: hand_events.c:89
CheckRequestEx
bool CheckRequestEx(InventoryValidation validation)
Definition: hand_events.c:92
y
Icon y
InventoryLocation
InventoryLocation.
Definition: inventorylocation.c:27
WeaponEvents
WeaponEvents
events
Definition: human.c:955
CanPerformEvent
bool CanPerformEvent()
Definition: hand_events.c:102
GetSrc
InventoryLocation GetSrc()
Definition: hand_events.c:80
GetEventID
HandEventID GetEventID()
Definition: hand_events.c:53
CanPerformEventEx
bool CanPerformEventEx(InventoryValidation validation)
Definition: hand_events.c:103
IsAuthoritative
bool IsAuthoritative()
Definition: hand_events.c:55
SWAP
@ SWAP
swapping from ground
Definition: hand_events.c:13
CheckRequestSrc
bool CheckRequestSrc()
Definition: hand_events.c:104
REPLACE2
@ REPLACE2
Definition: hand_events.c:19
TryAcquireTwoInventoryJuncturesFromServer
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Definition: junctures.c:29
DESTROYED
@ DESTROYED
Definition: hand_events.c:17
InventoryValidation
Definition: inventory.c:43
GetDst
InventoryLocation GetDst()
Definition: hand_events.c:88
HandEventBase
Abstracted event, not to be used, only inherited.
Definition: hand_events.c:194
JUNCTURE_ACQUIRED
JUNCTURE_ACQUIRED
Definition: hand_events.c:37
DayZPlayer
Definition: dayzplayerimplement.c:72
TAKE
@ TAKE
Definition: hand_events.c:9
GetSrcEntity
EntityAI GetSrcEntity()
Definition: hand_events.c:81
Serializer
Serialization general interface. Serializer API works with:
Definition: serializer.c:55
CREATED
@ CREATED
Definition: hand_events.c:16
OptionalLocationWriteToContext
bool OptionalLocationWriteToContext(InventoryLocation loc, notnull ParamsWriteContext ctx)
Definition: inventorylocation.c:583
ClearInventoryReservation
void ClearInventoryReservation()
Definition: hand_events.c:184
HandEventBase
void HandEventBase(Man p=null, InventoryLocation src=null)
Definition: hand_events.c:52
HUMANCOMMAND_ACTION_ABORTED
@ HUMANCOMMAND_ACTION_ABORTED
Definition: hand_events.c:23
FORCESWAP
@ FORCESWAP
Definition: hand_events.c:14
vector
Definition: enconvert.c:105
UNKNOWN
@ UNKNOWN
Definition: hand_events.c:8
JUNCTURE_DENIED
JUNCTURE_DENIED
Definition: hand_events.c:38
HandEventReplaceWithNewBase
Definition: hand_events.c:748
AcquireInventoryJunctureFromServer
bool AcquireInventoryJunctureFromServer(notnull Man player)
Definition: hand_events.c:90
DESTROY
@ DESTROY
Definition: hand_events.c:15
ANIMEVENT_CHANGE_HIDE
@ ANIMEVENT_CHANGE_HIDE
Definition: hand_events.c:24
JunctureRequestResult
JunctureRequestResult
Definition: hand_events.c:27
m_AnimationID
int m_AnimationID
Definition: hand_events.c:41
GetItem
EntityAI GetItem()
Definition: radialquickbarmenu.c:37
THROW
@ THROW
Definition: hand_events.c:12
Object
Definition: objecttyped.c:1
m_Player
DayZPlayer m_Player
Definition: hand_events.c:42
JUNCTURE_NOT_REQUIRED
JUNCTURE_NOT_REQUIRED
Definition: hand_events.c:36
IsServerSideOnly
bool IsServerSideOnly()
Definition: hand_events.c:105
HandEventDestroyAndReplaceWithNew
Definition: hand_events.c:753
DumpToString
string DumpToString()
Definition: hand_events.c:165
HUMANCOMMAND_ACTION_FINISHED
@ HUMANCOMMAND_ACTION_FINISHED
Definition: hand_events.c:22
x
Icon x
HandAnimEventFactory
HandEventBase HandAnimEventFactory(WeaponEvents type, Man p=null, InventoryLocation src=null)
Definition: hand_events.c:775
REPLACED
@ REPLACED
Definition: hand_events.c:21
Debug
Definition: debug.c:13
ERROR
ERROR
Definition: hand_events.c:39
GetSecondSrcEntity
EntityAI GetSecondSrcEntity()
Definition: hand_events.c:87
syncDebugPrint
void syncDebugPrint(string s)
Definition: debug.c:1
ReplaceItemWithNewLambdaBase
base class for transformation operations (creating one item from another)
Definition: replaceitemwithnewlambdabase.c:4
TryAcquireInventoryJunctureFromServer
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition: junctures.c:2
HandEventRemove
Definition: hand_events.c:383
Class
Super root of all classes in Enforce script.
Definition: enscript.c:10
EntityAI
Definition: building.c:5
IsProxy
bool IsProxy()
Definition: hand_events.c:65
GameInventory
script counterpart to engine's class Inventory
Definition: inventory.c:78
ReserveInventory
bool ReserveInventory()
Definition: hand_events.c:174
DayZPlayerInstanceType
DayZPlayerInstanceType
defined in C++
Definition: dayzplayer.c:1058