DayZ 1.24
Loading...
Searching...
No Matches
DayZPlayerInventory.c
Go to the documentation of this file.
1//Post event containers
8
9
11{
14
21
23 {
24 if (!inventory.AddInventoryReservationEx(m_dst.GetItem(), m_dst, GameInventory.c_InventoryReservationTimeoutShortMS))
25 return false;
26 return true;
27 }
28
30 {
31 inventory.ClearInventoryReservationEx(m_dst.GetItem(), m_dst);
32 }
33}
34
36{
41
50
52 {
54 return false;
56 {
57 inventory.ClearInventoryReservationEx(m_item1, m_dst1);
58 return false;
59 }
60 return true;
61 }
62
64 {
65 inventory.ClearInventoryReservationEx(m_item1, m_dst1);
66 inventory.ClearInventoryReservationEx(m_item2, m_dst2);
67 }
68}
69
71{
76
85
87 {
89 return false;
91 {
92 inventory.ClearInventoryReservationEx(m_item1, m_dst1);
93 return false;
94 }
95 return true;
96 }
97
99 {
100 inventory.ClearInventoryReservationEx(m_item1, m_dst1);
101 inventory.ClearInventoryReservationEx(m_item2, m_dst2);
102 }
103}
104
106{
113
115 {
116 return m_event.ReserveInventory();
117 }
118
120 {
121 m_event.ClearInventoryReservation();
122 }
123}
124
125
130{
133 //protected ref HandEventBase m_PostedHandEvent = NULL; /// deferred hand event
134
135
138 // states with animations
139 protected ref HandAnimatedTakingFromAtt m_Taking;
140 protected ref HandAnimatedMovingToAtt m_MovingTo;
141 protected ref HandAnimatedSwapping m_Swapping;
142 protected ref HandAnimatedForceSwapping m_FSwapping;
143 protected ref HandAnimatedForceSwapping_Inst m_FSwappingInst;
144
146 {
147 }
148
149 DayZPlayer GetDayZPlayerOwner() { return DayZPlayer.Cast(GetInventoryOwner()); }
150
152 {
154 if (!Class.CastTo(player, GetInventoryOwner()))
155 return false;
156
157 return (player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_CLIENT && player.GetInstanceType() != DayZPlayerInstanceType.INSTANCETYPE_REMOTE);
158 }
159
160 bool IsOwner()
161 {
163 if (!Class.CastTo(player, GetInventoryOwner()))
164 return false;
165
166 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SERVER || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_SINGLEPLAYER);
167 }
168
169 bool IsProxy()
170 {
172 if (!Class.CastTo(player, GetInventoryOwner()))
173 return false;
174
175 return (player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_REMOTE || player.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_AI_REMOTE);
176 }
177
178 override void Init()
179 {
181 hndDebugPrint("[hndfsm] Creating DayZPlayer Inventory FSM");
182
183 CreateStableStates(); // stable states needs to be created first
184
185 m_Taking = new HandAnimatedTakingFromAtt(GetManOwner(), null);
186 m_MovingTo = new HandAnimatedMovingToAtt(GetManOwner(), null);
187 m_Swapping = new HandAnimatedSwapping(GetManOwner(), null);
188 m_FSwapping = new HandAnimatedForceSwapping(GetManOwner(), null);
189 m_FSwappingInst = new HandAnimatedForceSwapping_Inst(GetManOwner(), null);
190
191 // events
192 HandEventBase _fin_ = new HandEventHumanCommandActionFinished;
193 HandEventBase _abt_ = new HandEventHumanCommandActionAborted;
194 HandEventBase __T__ = new HandEventTake;
195 HandEventBase __M__ = new HandEventMoveTo;
197 //HandEventBase __D__ = new HandEventDropping;
198 HandEventBase __Xd_ = new HandEventDestroyed;
199 HandEventBase __F__ = new HandEventForceSwap;
200
201 // setup transitions
202 m_FSM.AddTransition(new HandTransition(m_Empty, __T__, m_Taking, NULL, new HandSelectAnimationOfTakeToHandsEvent(GetManOwner())));
203 m_FSM.AddTransition(new HandTransition(m_Taking, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
204 m_FSM.AddTransition(new HandTransition(m_Taking, _fin_, m_Equipped, null, null));
205 m_FSM.AddTransition(new HandTransition(m_Taking, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
206 m_Taking.AddTransition(new HandTransition(m_Taking.m_Hide, _abt_, m_Empty));
207 m_Taking.AddTransition(new HandTransition(m_Taking.m_Show, _abt_, m_Equipped));
208
209 m_FSM.AddTransition(new HandTransition(m_Equipped, __M__, m_MovingTo, NULL, new HandSelectAnimationOfMoveFromHandsEvent(GetManOwner())));
210 m_FSM.AddTransition(new HandTransition(m_MovingTo, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
211 m_FSM.AddTransition(new HandTransition(m_MovingTo, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
212 m_FSM.AddTransition(new HandTransition(m_MovingTo, _fin_, m_Empty, null, null));
213 m_MovingTo.AddTransition(new HandTransition(m_MovingTo.m_Hide, _abt_, m_Equipped));
214 m_MovingTo.AddTransition(new HandTransition(m_MovingTo.m_Show, _abt_, m_Empty));
215
216 m_FSM.AddTransition(new HandTransition(m_Equipped, __W__, m_Swapping, NULL, new HandSelectAnimationOfSwapInHandsEvent(GetManOwner())));
217 m_FSM.AddTransition(new HandTransition(m_Swapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
218 m_FSM.AddTransition(new HandTransition(m_Swapping, _fin_, m_Empty, null, new HandGuardNot(new HandGuardHasItemInHands(GetManOwner()))));
219 m_FSM.AddTransition(new HandTransition(m_Swapping, _fin_, m_Equipped, null, null));
220 m_FSM.AddTransition(new HandTransition(m_Swapping, _abt_, m_Equipped, null, null));
221
222 m_FSM.AddTransition(new HandTransition(m_Equipped, __F__, m_FSwappingInst, NULL, new HandGuardAnd(new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner()), new HandGuardInstantForceSwap(GetManOwner()))));
223 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
224 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _fin_, m_Empty, null, null));
225 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
226 m_FSM.AddTransition(new HandTransition(m_FSwappingInst, _abt_, m_Equipped, null, null));
227
228 m_FSM.AddTransition(new HandTransition(m_Equipped, __F__, m_FSwapping, NULL, new HandSelectAnimationOfForceSwapInHandsEvent(GetManOwner())));
229 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Equipped, null, new HandGuardHasItemInHands(GetManOwner())));
230 m_FSM.AddTransition(new HandTransition(m_FSwapping, _fin_, m_Empty, null, null));
231 m_FSM.AddTransition(new HandTransition(m_FSwapping, __Xd_, m_Empty, new HandActionDestroyed, new HandGuardHasDestroyedItemInHands(GetManOwner())));
232 m_FSwapping.AddTransition(new HandTransition(m_FSwapping.m_Start, _abt_, m_Equipped));
233 m_FSwapping.AddTransition(new HandTransition(m_FSwapping.m_Hide, _abt_, m_Empty));
234 m_FSwapping.AddTransition(new HandTransition(m_FSwapping.m_Show, _abt_, m_Equipped));
235
236 super.Init(); // initialize ordinary human fsm (no anims)
237 }
238
244 {
246 //m_postedHandEvent = null;
247 }
248
254
256 {
257 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
258
260 Class.CastTo(weapon, GetEntityInHands());
261
262 if (hcw && weapon && weapon.CanProcessWeaponEvents() && !weapon.IsIdle())
263 {
265 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
266
267 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
268 }
269 }
270
276 {
278 {
280
282 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " Posted event m_DeferredWeaponEvent=" + m_DeferredWeaponEvent.DumpToString());
283 }
284 else
285 Error("[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " warning - pending event already posted, curr_event=" + m_DeferredWeaponEvent.DumpToString() + " new_event=" + e.DumpToString());
286 }
287
289 {
291 Class.CastTo(weapon, GetEntityInHands());
292
293 string secondPart = " - ENTITY IN HANDS IS NOT A WEAPON: " + Object.GetDebugName(GetEntityInHands());
294
295 string firstPart = "[wpnfsm] " + Object.GetDebugName(GetInventoryOwner()) + " failed to perform weaponevent " + m_DeferredWeaponEvent.DumpToString();
296 if (weapon)
297 {
298 secondPart = " on " + Object.GetDebugName(GetEntityInHands()) + " which is in state " + weapon.GetCurrentState();
299 secondPart += " with physical state: J: " + weapon.IsJammed() + " | ";
300 for (int i = 0; i < weapon.GetMuzzleCount(); ++i)
301 {
302 secondPart += "Chamber_" + i + ": B(" + weapon.IsChamberFull(i) + ") F(" + weapon.IsChamberFiredOut(i) + ") E(" + weapon.IsChamberEmpty(i) + ") | ";
303 secondPart += "Magazine_" + i + ": " + weapon.GetMagazine(i);
304 if (i < weapon.GetMuzzleCount() - 1)
305 secondPart += " | ";
306 }
307 }
308
311 }
312
314 {
315 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
316
318 Class.CastTo(weapon, GetEntityInHands());
319
320 if (hcw && weapon && weapon.CanProcessWeaponEvents())
321 {
322 weapon.GetCurrentState().OnUpdate(dt);
323
325 wpnDebugSpamALot("[wpnfsm] " + Object.GetDebugName(weapon) + " HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
326
327 if (!weapon.IsIdle())
328 {
329 while (true)
330 {
331 int weaponEventId = hcw.IsEvent();
332 if (weaponEventId == -1)
333 break;
334
335 if (weaponEventId == WeaponEvents.CHANGE_HIDE)
336 break;
337
339
341 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " HandleWeapons: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
342
343 if (anim_event != NULL)
344 weapon.ProcessWeaponEvent(anim_event);
345 }
346
347 if (hcw.IsActionFinished())
348 {
349 if (weapon.IsWaitingForActionFinish())
350 {
352 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: finished! notifying waiting state=" + weapon.GetCurrentState());
353
354 weapon.ProcessWeaponEvent(new WeaponEventHumanCommandActionFinished(GetDayZPlayerOwner()));
355 }
356 else
357 {
359 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: ABORT! notifying running state=" + weapon.GetCurrentState());
360
361 weapon.ProcessWeaponAbortEvent(new WeaponEventHumanCommandActionAborted(GetDayZPlayerOwner()));
362 }
363 }
364 }
365
367 {
369 wpnDebugPrint("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: deferred " + m_DeferredWeaponEvent.DumpToString());
370
371 if (weapon.ProcessWeaponEvent(m_DeferredWeaponEvent))
372 {
373 exitIronSights = true;
374
376 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(weapon) + " Weapon event: resetting deferred event" + m_DeferredWeaponEvent.DumpToString());
377
380 }
381 else if (!m_DeferredWeaponTimer.IsRunning())
382 m_DeferredWeaponTimer.Run(3, this, "DeferredWeaponFailed");
383 }
384 }
385 }
386
387 void HandleInventory(float dt)
388 {
389 HumanCommandWeapons hcw = GetDayZPlayerOwner().GetCommandModifier_Weapons();
390
391 EntityAI ih = GetEntityInHands();
394
395 if (hcw)
396 {
397 m_FSM.GetCurrentState().OnUpdate(dt);
398
399#ifdef DEVELOPER
401 hndDebugSpamALot("[hndfsm] HCW: playing A=" + typename.EnumToString(WeaponActions, hcw.GetRunningAction()) + " AT=" + WeaponActionTypeToString(hcw.GetRunningAction(), hcw.GetRunningActionType()) + " fini=" + hcw.IsActionFinished());
402#endif
403
404 if (!m_FSM.GetCurrentState().IsIdle() || !m_FSM.IsRunning())
405 {
406 while (true)
407 {
408 int weaponEventId = hcw.IsEvent();
409 if (weaponEventId == -1)
410 break;
411
413
414#ifdef DEVELOPER
416 hndDebugPrint("[hndfsm] HandleInventory: event arrived " + typename.EnumToString(WeaponEvents, weaponEventId) + "(" + weaponEventId + ") fsm_ev=" + anim_event.ToString());
417#endif
418
419 if (anim_event != NULL)
420 {
422 ProcessHandEvent(anim_event);
423 }
424 }
425
426 if (hcw.IsActionFinished())
427 {
428 if (m_FSM.GetCurrentState().IsWaitingForActionFinish())
429 {
430#ifdef DEVELOPER
432 hndDebugPrint("[hndfsm] Hand-Weapon event: finished! notifying waiting state=" + m_FSM.GetCurrentState());
433#endif
434
435 HandEventBase fin_event = new HandEventHumanCommandActionFinished(GetManOwner());
437 ProcessHandEvent(fin_event);
438 }
439 else
440 {
441#ifdef DEVELOPER
443 hndDebugPrint("[hndfsm] Hand-Weapon event: ABORT! notifying running state=" + m_FSM.GetCurrentState());
444#endif
445
446 HandEventBase abt_event = new HandEventHumanCommandActionAborted(GetManOwner());
448 ProcessHandAbortEvent(abt_event);
449 //m_FSM.ProcessHandAbortEvent(new WeaponEventHumanCommandActionAborted(GetManOwner()));
450 }
451 }
452 }
453 }
454 }
455
456
458
465 {
466 int tmp = -1;
467 ctx.Read(tmp);
468
470 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store Juncture packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
471
473
474 return true;
475 }
476
478
485 {
486 /* InventoryLocation il = new InventoryLocation;
487 if (!il.ReadFromContext(ctx) )
488 return false;
489
490 InventoryLocation il_current = new InventoryLocation;
491
492 EntityAI item = il.GetItem();
493 item.GetInventory().GetCurrentInventoryLocation(il_current);
494
495 if( !il_current.CompareLocationOnly(il))
496 {
497 LocationMoveEntity(il_current,il);
498 }*/
499 return true;
500 }
501
503
510 {
524 if (GetGame().IsDedicatedServer())
525 return;
526
527 int udtIdentifier = -1;
529 return;
530
534
535 InventoryCommandType type = -1;
536 if (!ctx.Read(type))
537 return;
538
539 switch (type)
540 {
541 case InventoryCommandType.SYNC_MOVE:
542 {
543 src.ReadFromContext(ctx);
544 dst.ReadFromContext(ctx);
545 break;
546 }
547 case InventoryCommandType.HAND_EVENT:
548 {
549 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
550 src = e.GetSrc();
551 dst = e.GetDst();
552 break;
553 }
554 case InventoryCommandType.SWAP:
555 {
556 src.ReadFromContext(ctx);
557 temp.ReadFromContext(ctx);
558 dst.ReadFromContext(ctx);
559 temp.ReadFromContext(ctx);
560 break;
561 }
562 case InventoryCommandType.FORCESWAP:
563 {
564 break;
565 }
566 case InventoryCommandType.DESTROY:
567 {
568 src.ReadFromContext(ctx);
569 break;
570 }
571 }
572
574 if (!ctx.Read(reason))
576
578 }
579
581 {
582 if (reason == InventoryValidationReason.DROP_PREVENTED)
583 {
585 return;
586 }
587
588 }
589
595 {
596 int tmp = -1;
597 ctx.Read(tmp);
598
600 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle JunctureData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
601
603 ProcessInputData(ctx, true, false);
604 }
605
612
613
615
622 {
624 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " store InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
625
627 return true;
628 }
629
635 {
636 int tmp = -1;
637 ctx.Read(tmp);
638
640 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " handle InputUserData packet STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp());
641
642 ProcessInputData(ctx, false, false);
643 }
644
650
652 {
654 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " remote handling InputUserData packet from server");
655
656 ProcessInputData(ctx, false, true);
657 }
658
660 {
662 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " DZPInventory command from server");
663
664 ProcessInputData(ctx, true, true);
665 }
666
668 {
670
673
674 src.ReadFromContext(ctx);
675 dst.ReadFromContext(ctx);
676
677#ifdef DEVELOPER
679 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + "src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
680#endif
681
682 if (validation.m_IsRemote && (!src.GetItem() || !dst.GetItem()))
683 {
685
686#ifdef DEVELOPER
688 Debug.InventoryMoveLog("Failed - item not in bubble", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
689#endif
690
692 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SYNC_MOVE) dropped, item not in bubble! src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
693
694 return true;
695 }
696
697 EnableMovableOverride(src.GetItem());
698
703 {
705
706#ifdef DEVELOPER
708 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
709#endif
710
712 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src));
713
714 RemoveMovableOverride(src.GetItem());
715 return true;
716 }
717
722 {
723#ifdef DEVELOPER
725 Debug.InventoryMoveLog("Failed - CheckMoveToDstRequest", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
726#endif
727
729 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
730
731 RemoveMovableOverride(src.GetItem());
732 return true;
733 }
734
735 RemoveMovableOverride(src.GetItem());
736
738 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " HandleInputData t=" + GetGame().GetTime() + "ms received cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
739
741 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
742 {
744 if (result_mv == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
745 {
746#ifdef DEVELOPER
748 Debug.InventoryMoveLog("Juncture not required", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
749#endif
750
752
753 LocationSyncMoveEntity(src, dst);
754
755 validation.m_Result = InventoryValidationResult.SUCCESS;
756 return true;
757 }
758 else if (result_mv == JunctureRequestResult.JUNCTURE_ACQUIRED)
759 {
760#ifdef DEVELOPER
762 Debug.InventoryMoveLog("Juncture sended", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
763#endif
764
766 {
767#ifdef DEVELOPER
769
771 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity - Juncture denied", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
772#endif
773
774 return true;
775 }
776
777 validation.m_Result = InventoryValidationResult.JUNCTURE;
778 EnableMovableOverride(src.GetItem());
779 return true;
780 }
781 else if (result_mv == JunctureRequestResult.JUNCTURE_DENIED)
782 {
783#ifdef DEVELOPER
785 Debug.InventoryMoveLog("Juncture denied", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
786#endif
787
788 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
789 return true;
790 }
791 else
792 {
793 Error("[syncinv] HandleInputData: unexpected return code from AcquireInventoryJunctureFromServer");
794
795 return true;
796 }
797 }
798
799 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
801
803 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
805
809 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.LocationCanMoveEntitySyncCheck(src, dst))
810 {
811#ifdef DEVELOPER
813
815 Debug.InventoryMoveLog("Failed - LocationCanMoveEntity", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
816#endif
817
818 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT move cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
819 return true;
820 }
821
822#ifdef DEVELOPER
824 Debug.InventoryMoveLog("Success - LocationSyncMoveEntity", "SYNC_MOVE", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
825#endif
826
827 LocationSyncMoveEntity(src, dst);
828
829 validation.m_Result = InventoryValidationResult.SUCCESS;
830 return true;
831 }
832
834 {
836
837 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
838 e.ClearInventoryReservation();
839
843 e.m_IsRemote = validation.m_IsRemote;
844 e.m_IsJuncture = validation.m_IsJuncture;
845
846 EntityAI itemSrc = e.GetSrcEntity();
847 EntityAI itemDst = e.GetSecondSrcEntity();
848
849#ifdef DEVELOPER
851 Debug.InventoryMoveLog("STS = " + e.m_Player.GetSimulationTimeStamp() + " event= " + e.DumpToString(), "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
852#endif
853
854 if (validation.m_IsRemote && !e.GetSrcEntity())
855 {
857
858#ifdef DEVELOPER
860 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
861#endif
862
863 Error("[syncinv] HandleInputData remote input (cmd=HAND_EVENT, event=" + e.DumpToString() + ") dropped, item not in bubble");
864
865 return true;
866 }
867
869 if (itemSrc)
871 if (itemDst)
873
877 if (!validation.m_IsRemote && !validation.m_IsJuncture && !e.CheckRequestSrc())
878 {
879#ifdef DEVELOPER
881 Debug.InventoryMoveLog("Failed - CheckRequestSrc", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
882#endif
883
884 if (!validation.m_IsRemote)
885 {
888 }
889
892
893 return true;
894 }
895
896 if (!e.CheckRequestEx(validation))
897 {
898#ifdef DEVELOPER
900 Debug.InventoryMoveLog("Failed - CheckRequest", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
901#endif
902
904
907
909 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
910
913 return true;
914 }
915
918 if (!validation.m_IsRemote && !e.CanPerformEventEx(validation))
919 {
920#ifdef DEVELOPER
922 Debug.InventoryMoveLog("Failed - CanPerformEvent", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
923#endif
924
926
929
931 syncDebugPrint("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT do cmd=HAND_EVENT e=" + e.DumpToString());
932
935 return true;
936 }
937
940
942 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
943 {
944 JunctureRequestResult result_ev = e.AcquireInventoryJunctureFromServer(GetDayZPlayerOwner());
945 if (result_ev == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
946 {
947#ifdef DEVELOPER
949 Debug.InventoryMoveLog("Juncture not required", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
950#endif
951
953 }
954 else if (result_ev == JunctureRequestResult.JUNCTURE_ACQUIRED)
955 {
956#ifdef DEVELOPER
958 Debug.InventoryMoveLog("Juncture sended", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
959#endif
960
963
964 validation.m_Result = InventoryValidationResult.JUNCTURE;
965
966 if (itemSrc)
968 if (itemDst)
970 return true;
971 }
972 else if (result_ev == JunctureRequestResult.JUNCTURE_DENIED)
973 {
974#ifdef DEVELOPER
976 Debug.InventoryMoveLog("Juncture denied", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
977#endif
978
979 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
980 return true;
981 }
982 else
983 {
984 Error("[syncinv] HandleInputData: unexpected return code from AcquireInventoryJunctureFromServer");
985
986 return true;
987 }
988 }
989
991 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
992 CheckForRope(e.GetSrc(), e.GetDst());
993
994#ifdef DEVELOPER
996 Debug.InventoryMoveLog("Success - ProcessHandEvent", "HAND_EVENT", "n/a", "ProcessInputData", e.m_Player.ToString());
997#endif
998
999 validation.m_Result = InventoryValidationResult.SUCCESS;
1000 if (!e.m_Player.GetHumanInventory().ProcessHandEvent(e))
1001 {
1003 //result = InventoryValidationResult.FAILURE;
1004 }
1005
1006 return true;
1007 }
1008
1010 {
1012
1015
1018
1019 bool skippedSwap = false;
1020
1021 src1.ReadFromContext(ctx);
1022 src2.ReadFromContext(ctx);
1023 dst1.ReadFromContext(ctx);
1024 dst2.ReadFromContext(ctx);
1025 ctx.Read(skippedSwap);
1026
1027#ifdef DEVELOPER
1029 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2), "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1030#endif
1031
1032 if (validation.m_IsRemote && (!src1.GetItem() || !src2.GetItem()))
1033 {
1034 if (skippedSwap)
1035 {
1036#ifdef DEVELOPER
1038 Debug.InventoryMoveLog("Remote - skipped", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1039#endif
1040 /*
1041 if (LogManager.IsSyncLogEnable())
1042 {
1043 syncDebugPrint("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, swap is skipped");
1044 }
1045 */
1046 }
1047 else
1048 {
1050
1051#ifdef DEVELOPER
1053 Debug.InventoryMoveLog("Failed - item1 or item2 not exist", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1054#endif
1055
1056 Error("[syncinv] HandleInputData remote input (cmd=SWAP) dropped, item not in bubble");
1057 }
1058
1059 return true;
1060 }
1061
1062 EnableMovableOverride(src1.GetItem());
1063 EnableMovableOverride(src2.GetItem());
1064
1069 {
1070#ifdef DEVELOPER
1072 Debug.InventoryMoveLog("Failed - CheckRequestSrc1", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1073#endif
1074
1076 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src1 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1));
1077
1078 RemoveMovableOverride(src1.GetItem());
1079 RemoveMovableOverride(src2.GetItem());
1080 return true;
1081 }
1082
1087 {
1088#ifdef DEVELOPER
1090 Debug.InventoryMoveLog("Failed - CheckRequestSrc2", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1091#endif
1092
1094 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " failed src2 check with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2));
1095
1096 RemoveMovableOverride(src1.GetItem());
1097 RemoveMovableOverride(src2.GetItem());
1098 return true;
1099 }
1100
1105 {
1106#ifdef DEVELOPER
1108 Debug.InventoryMoveLog("Failed - CheckSwapItemsRequest", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1109#endif
1110
1112 syncDebugPrint("[cheat] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " is cheating with cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1113
1114 RemoveMovableOverride(src1.GetItem());
1115 RemoveMovableOverride(src2.GetItem());
1116 return true;
1117 }
1118
1119 RemoveMovableOverride(src1.GetItem());
1120 RemoveMovableOverride(src2.GetItem());
1121
1122 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1123 {
1126 }
1127
1131 if (!validation.m_IsRemote && !validation.m_IsJuncture && !GameInventory.CanForceSwapEntitiesEx(src1.GetItem(), dst1, src2.GetItem(), dst2))
1132 {
1133#ifdef DEVELOPER
1135
1137 Debug.InventoryMoveLog("Failed - CanForceSwapEntitiesEx", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1138#endif
1139
1140 Error("[desync] HandleInputData man=" + Object.GetDebugName(GetManOwner()) + " CANNOT swap cmd=" + typename.EnumToString(InventoryCommandType, type) + " src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " | src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1141 return true;
1142 }
1143
1144 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1145 {
1146 AddInventoryReservationEx(dst1.GetItem(), dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1147 AddInventoryReservationEx(dst2.GetItem(), dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1148 }
1149
1150 if (!(src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid()))
1151 {
1152 Error("HandleInputData: cmd=" + typename.EnumToString(InventoryCommandType, type) + " invalid input(s): src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
1153 return true;
1154 }
1155
1157 if (!validation.m_IsJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1158 {
1160 if (result_sw == JunctureRequestResult.JUNCTURE_NOT_REQUIRED)
1161 {
1162#ifdef DEVELOPER
1164 Debug.InventoryMoveLog("Juncture not required", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1165#endif
1166
1168 }
1169 else if (result_sw == JunctureRequestResult.JUNCTURE_ACQUIRED)
1170 {
1171#ifdef DEVELOPER
1173 Debug.InventoryMoveLog("Juncture sended", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1174#endif
1175
1176 validation.m_Result = InventoryValidationResult.JUNCTURE;
1177 EnableMovableOverride(src1.GetItem());
1178 EnableMovableOverride(src2.GetItem());
1179 return true;
1180 }
1181 else if (result_sw == JunctureRequestResult.JUNCTURE_DENIED)
1182 {
1183#ifdef DEVELOPER
1185 Debug.InventoryMoveLog("Juncture denied", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1186#endif
1187
1188 validation.m_Reason = InventoryValidationReason.JUNCTURE_DENIED;
1189 return true;
1190 }
1191 else
1192 {
1193 Error("[syncinv] HandleInputData: unexpected return code from TryAcquireTwoInventoryJuncturesFromServer"); return true;
1194
1195 return true;
1196 }
1197 }
1198
1199 if (GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_CLIENT)
1200 {
1203 }
1204
1205#ifdef DEVELOPER
1207 Debug.InventoryMoveLog("Success - item swap", "SWAP", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1208#endif
1209
1210 bool isNotSkipped = LocationSwap(src1, src2, dst1, dst2);
1211
1212 ctx = new ScriptInputUserData();
1214
1215 validation.m_Result = InventoryValidationResult.SUCCESS;
1216 return true;
1217 }
1218
1220 {
1222
1223 if (validation.m_IsJuncture)
1224 {
1232 return true;
1233 }
1234
1236 src.ReadFromContext(ctx);
1237
1238#ifdef DEVELOPER
1240 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src), "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1241#endif
1242
1243 if (validation.m_IsRemote && !src.GetItem())
1244 {
1245#ifdef DEVELOPER
1247 Debug.InventoryMoveLog("Failed item not exist", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1248#endif
1249
1250 Error("[syncinv] HandleInputData remote input (cmd=DESTROY) dropped, item not in bubble");
1251 return true;
1252 }
1253
1258 {
1259#ifdef DEVELOPER
1261 Debug.InventoryMoveLog("Failed CheckRequestSrc", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1262#endif
1263
1264 return true;
1265 }
1266
1271 {
1272#ifdef DEVELOPER
1274 Debug.InventoryMoveLog("Failed CheckDropRequest", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1275#endif
1276
1277 return true;
1278 }
1279
1280#ifdef DEVELOPER
1282 Debug.InventoryMoveLog("Success ObjectDelete", "DESTROY", "n/a", "ProcessInputData", GetDayZPlayerOwner().ToString());
1283#endif
1284
1285 GetGame().ObjectDelete(src.GetItem());
1286
1287 validation.m_Result = InventoryValidationResult.SUCCESS;
1288 return true;
1289 }
1290
1296 {
1297 if (isJuncture && isRemote)
1298 {
1300 return false;
1301 }
1302
1303 int type = -1;
1304 if (!ctx.Read(type))
1305 return false;
1306
1308 validation.m_IsJuncture = isJuncture;
1309 validation.m_IsRemote = isRemote;
1310
1313
1314 switch (type)
1315 {
1316 case InventoryCommandType.USER_RESERVATION_CANCEL:
1317 if (!ValidateUserReservationCancel(serializer, validation))
1318 return false;
1319 break;
1320 case InventoryCommandType.SYNC_MOVE:
1322 return false;
1323 break;
1324 case InventoryCommandType.HAND_EVENT:
1326 return false;
1327 break;
1328 case InventoryCommandType.SWAP:
1330 return false;
1331 break;
1332 case InventoryCommandType.DESTROY:
1334 return false;
1335 break;
1336 default:
1337 break;
1338 }
1339
1340 bool canSendJuncture = !isJuncture && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER;
1341
1342 switch (validation.m_Result)
1343 {
1344 case InventoryValidationResult.FAILED:
1345 if (canSendJuncture)
1346 {
1348 if (!serializer.CanWrite())
1349 {
1353 }
1354
1355 serializer.Write(validation.m_Reason);
1356
1358 }
1359 break;
1360 case InventoryValidationResult.JUNCTURE:
1361 if (canSendJuncture)
1362 {
1364 //StoreInputForRemotes(isJuncture, isRemote, serializer);
1365 }
1366 else
1367 Error("InventoryValidationResult.JUNCTURE returned when not possible to send!");
1368 break;
1369 case InventoryValidationResult.SUCCESS:
1371 break;
1372 }
1373
1374 return true;
1375 }
1376
1378 {
1379 ItemBase itemIB = ItemBase.Cast(item);
1380 if (itemIB)
1381 itemIB.SetCanBeMovedOverride(false);
1382 }
1383
1385 {
1386 ItemBase itemIB = ItemBase.Cast(item);
1387 if (itemIB)
1388 itemIB.SetCanBeMovedOverride(true);
1389 }
1390
1391 // Hacky solution for dealing with fencekit rope related issues, could be fixed by introducing some indicator that this item behaves differently or sth..
1393 {
1394 Rope rope = Rope.Cast(src.GetItem());
1395 if (rope)
1396 rope.SetTargetLocation(dst);
1397 }
1398
1400 {
1401 return GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER || GetDayZPlayerOwner() == GetGame().GetPlayer());
1402 }
1403
1405 {
1406 if (!remote && GetDayZPlayerOwner().GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1407 {
1408#ifdef DEVELOPER
1410 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a", "n/a", "StoreInputForRemotes", GetDayZPlayerOwner().ToString());
1411#endif
1412
1413 GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @NOTE: needs to be called _after_ the operation
1414 return true;
1415 }
1416
1417 return false;
1418 }
1419
1421 {
1422 if (GetManOwner().IsAlive() == false)
1423 return super.TakeToDst(mode, src, dst);
1424
1425#ifdef DEVELOPER
1427 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "TakeToDst", GetDayZPlayerOwner().ToString());
1428#endif
1429
1430 switch (mode)
1431 {
1432 case InventoryMode.SERVER:
1433 if (RedirectToHandEvent(mode, src, dst))
1434 {
1435#ifdef DEVELOPER
1437 Debug.InventoryMoveLog("RedirectToHandEvent", "n/a", "n/a", "TakeToDst", GetDayZPlayerOwner().ToString());
1438#endif
1439
1440 return true;
1441 }
1442
1443
1444 if (GetDayZPlayerOwner().NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1445 {
1446 if (GetGame().AddInventoryJunctureEx(GetDayZPlayerOwner(), src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1447 {
1449 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1450 }
1451 else
1452 {
1453#ifdef DEVELOPER
1455 Debug.InventoryMoveLog("Juncture failed", "n/a", "n/a", "TakeToDst", GetDayZPlayerOwner().ToString());
1456#endif
1457
1459 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + ") got juncture");
1460
1461 return false;
1462 }
1463
1464 }
1465
1468
1470
1472 syncDebugPrint("[syncinv] " + Object.GetDebugName(GetDayZPlayerOwner()) + " STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " store input for remote - DZPI::Take2Dst(" + typename.EnumToString(InventoryMode, mode) + " server sync move src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1473
1475 //GetDayZPlayerOwner().StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1476#ifdef DEVELOPER
1478 Debug.InventoryMoveLog("Success - store input for remote mode - " + typename.EnumToString(InventoryMode, mode) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst), "n/a", "n/a", "TakeToDst", GetDayZPlayerOwner().ToString());
1479#endif
1480 return true;
1481
1482 case InventoryMode.LOCAL:
1483 LocationSyncMoveEntity(src, dst);
1484 return true;
1485 }
1486 if (!super.TakeToDst(mode, src, dst))
1487 {
1488 if (!m_DeferredEvent)
1489 {
1491 if (m_DeferredEvent.ReserveInventory(this))
1492 return true;
1493 }
1494
1496 return false;
1497 }
1498 return true;
1499 }
1500
1502 {
1505 {
1506#ifdef DEVELOPER
1508 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1509#endif
1510
1511 deferred_take_to_dst.ClearInventoryReservation(this);
1512
1515
1516 switch (deferred_take_to_dst.m_mode)
1517 {
1518 case InventoryMode.PREDICTIVE:
1519#ifdef DEVELOPER
1521 Debug.InventoryHFSMLog("PREDICTIVE ", "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1522#endif
1523
1524 if (LocationCanMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst))
1525 {
1527 LocationSyncMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst);
1528 }
1529 else
1530 {
1531#ifdef DEVELOPER
1533 Debug.InventoryMoveLog("Can not move entity (PREDICTIVE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item = " + deferred_take_to_dst.m_dst.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_take_to_dst.m_dst), "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1534#endif
1535 }
1536 break;
1537 case InventoryMode.JUNCTURE:
1538#ifdef DEVELOPER
1540 Debug.InventoryHFSMLog("JUNCTURE ", "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1541#endif
1542
1543 if (LocationCanMoveEntity(deferred_take_to_dst.m_src, deferred_take_to_dst.m_dst))
1544 {
1545 DayZPlayer player = GetGame().GetPlayer();
1546 player.GetHumanInventory().AddInventoryReservationEx(deferred_take_to_dst.m_dst.GetItem(), deferred_take_to_dst.m_dst, GameInventory.c_InventoryReservationTimeoutShortMS);
1549 }
1550 else
1551 {
1552#ifdef DEVELOPER
1554 Debug.InventoryMoveLog("Can not move entity (JUNCTURE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item = " + deferred_take_to_dst.m_dst.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_take_to_dst.m_dst), "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1555#endif
1556 }
1557 break;
1558 case InventoryMode.LOCAL:
1559#ifdef DEVELOPER
1561 Debug.InventoryHFSMLog("LOCAL ", "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1562#endif
1563 break;
1564 case InventoryMode.SERVER:
1565#ifdef DEVELOPER
1567 Debug.InventoryHFSMLog("SERVER ", "n/a", "n/a", "HandleTakeToDst", GetDayZPlayerOwner().ToString());
1568#endif
1569 break;
1570 default:
1571 Error("HandEvent - Invalid mode");
1572 break;
1573 }
1574 }
1575 }
1576
1578 {
1579#ifdef DEVELOPER
1581 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2, "n/a", "n/a", "SwapEntities", GetDayZPlayerOwner().ToString());
1582#endif
1583
1585 if (mode == InventoryMode.LOCAL)
1586 {
1588 {
1589 LocationSwap(src1, src2, dst1, dst2);
1590 return true;
1591 }
1592 }
1593
1594 if (!super.SwapEntities(mode, item1, item2))
1595 {
1596 if (!m_DeferredEvent)
1597 {
1599 {
1601 if (m_DeferredEvent.ReserveInventory(this))
1602 return true;
1603 }
1604 }
1606 return false;
1607 }
1608 return true;
1609 }
1610
1612 {
1615 {
1616 deferred_swap_entities.ClearInventoryReservation(this);
1619 {
1622
1623 switch (deferred_swap_entities.m_mode)
1624 {
1625 case InventoryMode.PREDICTIVE:
1626 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst2.GetItem()))
1627 {
1629 LocationSwap(src1, src2, deferred_swap_entities.m_dst1, deferred_swap_entities.m_dst2);
1630 }
1631 else
1632 {
1633#ifdef DEVELOPER
1635 Debug.InventoryMoveLog("Can not swap (PREDICTIVE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst2), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1636#endif
1637 }
1638 break;
1639
1640 case InventoryMode.JUNCTURE:
1641 if (CanSwapEntitiesEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst2.GetItem()))
1642 {
1643 DayZPlayer player = GetGame().GetPlayer();
1644 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst1.GetItem(), deferred_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1645 player.GetHumanInventory().AddInventoryReservationEx(deferred_swap_entities.m_dst2.GetItem(), deferred_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1649 }
1650 else
1651 {
1652#ifdef DEVELOPER
1654 Debug.InventoryMoveLog("Can not swap (JUNCTURE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_swap_entities.m_dst2), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1655#endif
1656 }
1657 break;
1658
1659 case InventoryMode.LOCAL:
1660 break;
1661
1662 default:
1663 Error("SwapEntities - HandEvent - Invalid mode");
1664 }
1665 }
1666 else
1667 Error("SwapEntities - MakeSrcAndDstForSwap - no inv loc");
1668 }
1669 }
1670
1672 {
1673#ifdef DEVELOPER
1675 Debug.InventoryMoveLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + item1 + " item2 = " + item2 + " dst=" + InventoryLocation.DumpToStringNullSafe(item2_dst), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1676#endif
1677
1678 if (mode == InventoryMode.LOCAL)
1679 {
1682 {
1683 LocationSwap(src1, src2, dst1, item2_dst);
1684 return true;
1685 }
1686
1687 }
1688
1689 if (!super.ForceSwapEntities(mode, item1, item2, item2_dst))
1690 {
1691 if (!m_DeferredEvent)
1692 {
1694 {
1696 if (m_DeferredEvent.ReserveInventory(this))
1697 return true;
1698
1699 }
1700 }
1702 return false;
1703 }
1704
1705 return true;
1706 }
1707
1709 {
1712 {
1713 deferred_force_swap_entities.ClearInventoryReservation(this);
1716 deferred_force_swap_entities.m_item1.GetInventory().GetCurrentInventoryLocation(src1);
1717 deferred_force_swap_entities.m_item2.GetInventory().GetCurrentInventoryLocation(src2);
1718
1719 DayZPlayer player = GetGame().GetPlayer();
1720
1723
1724 switch (deferred_force_swap_entities.m_mode)
1725 {
1726 case InventoryMode.PREDICTIVE:
1727 if (CanForceSwapEntitiesEx(deferred_force_swap_entities.m_dst1.GetItem(), deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2.GetItem(), deferred_force_swap_entities.m_dst2))
1728 {
1731 }
1732 else
1733 {
1734#ifdef DEVELOPER
1736 Debug.InventoryMoveLog("Can not force swap (PREDICTIVE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_force_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_force_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_force_swap_entities.m_dst2), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1737#endif
1738 }
1739 break;
1740
1741 case InventoryMode.JUNCTURE:
1742 if (CanForceSwapEntitiesEx(deferred_force_swap_entities.m_dst1.GetItem(), deferred_force_swap_entities.m_dst1, deferred_force_swap_entities.m_dst2.GetItem(), deferred_force_swap_entities.m_dst2))
1743 {
1744 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item1, deferred_force_swap_entities.m_dst1, GameInventory.c_InventoryReservationTimeoutShortMS);
1745 player.GetHumanInventory().AddInventoryReservationEx(deferred_force_swap_entities.m_item2, deferred_force_swap_entities.m_dst2, GameInventory.c_InventoryReservationTimeoutShortMS);
1746
1748 }
1749 else
1750 {
1751#ifdef DEVELOPER
1753 Debug.InventoryMoveLog("Can not force swap (JUNCTURE) STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp() + " item1 = " + deferred_force_swap_entities.m_dst1.GetItem() + " item2 = " + deferred_force_swap_entities.m_dst2.GetItem() + " dst=" + InventoryLocation.DumpToStringNullSafe(deferred_force_swap_entities.m_dst2), "n/a", "n/a", "ForceSwapEntities", GetDayZPlayerOwner().ToString());
1754#endif
1755 }
1756 break;
1757
1758 case InventoryMode.LOCAL:
1759 break;
1760
1761 default:
1762 Error("ForceSwapEntities - HandEvent - Invalid mode");
1763 }
1764 }
1765 }
1766
1768 {
1769 if (GetGame().IsServer())
1770 {
1771 if (e.IsServerSideOnly())
1772 Error("[syncinv] " + Object.GetDebugName(player) + " SendServerHandEventViaJuncture - called on server side event only, e=" + e.DumpToString());
1773
1774 if (player.IsAlive())
1775 {
1776 InventoryLocation dst = e.GetDst();
1777 InventoryLocation src = e.GetSrc();
1778 if (src.IsValid() && dst.IsValid())
1779 {
1780 if (player.NeedInventoryJunctureFromServer(src.GetItem(), src.GetParent(), dst.GetParent()))
1781 {
1783 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") need juncture src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1784
1785 if (GetGame().AddInventoryJunctureEx(player, src.GetItem(), dst, true, GameInventory.c_InventoryReservationTimeoutMS))
1786 {
1788 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") got juncture");
1789 }
1790 else
1791 {
1793 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + ") !got juncture");
1794 }
1795 }
1796
1798 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + " server hand event src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1799
1803
1805 syncDebugPrint("[syncinv] " + Object.GetDebugName(player) + " STS = " + player.GetSimulationTimeStamp() + " store input for remote - SendServerHandEventViaJuncture(" + typename.EnumToString(InventoryMode, InventoryMode.SERVER) + " server hand event src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
1806
1808 //player.StoreInputForRemotes(ctx); // @TODO: is this right place? maybe in HandleInputData(server=true, ...)
1809 }
1810 }
1811 else
1812 Error("[syncinv] SendServerHandEventViaJuncture - called on dead player, juncture is for living only");
1813 }
1814 }
1815
1819 override void NetSyncCurrentStateID(int id)
1820 {
1821 super.NetSyncCurrentStateID(id);
1822
1823 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged();
1824 }
1825
1832 override void OnAfterStoreLoad()
1833 {
1834 GetDayZPlayerOwner().GetItemAccessor().OnItemInHandsChanged(true);
1835 }
1836
1841 {
1842 if (GetEntityInHands())
1843 {
1844 Weapon_Base wpn = Weapon_Base.Cast(GetEntityInHands());
1845 if (wpn)
1846 {
1848
1850 if (pb && e)
1851 {
1852 pb.GetWeaponManager().SetRunning(true);
1853
1855 fsmDebugSpam("[wpnfsm] " + Object.GetDebugName(wpn) + " recv event from remote: created event=" + e);
1856
1857 if (e.GetEventID() == WeaponEventID.HUMANCOMMAND_ACTION_ABORTED)
1858 wpn.ProcessWeaponAbortEvent(e);
1859 else
1860 wpn.ProcessWeaponEvent(e);
1861 pb.GetWeaponManager().SetRunning(false);
1862 }
1863 }
1864 else
1865 Error("OnEventForRemoteWeapon - entity in hands, but not weapon. item=" + GetEntityInHands());
1866 }
1867 else
1868 Error("OnEventForRemoteWeapon - no entity in hands");
1869 return true;
1870 }
1871
1872
1877 {
1878 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
1879 if (e)
1880 {
1882 hndDebugSpam("[hndfsm] recv event from remote: created event=" + e);
1883
1884 //m_FSM.ProcessEvent(e);
1885
1886 if (e.GetEventID() == HandEventID.HUMANCOMMAND_ACTION_ABORTED)
1887 {
1889 m_FSM.ProcessAbortEvent(e, aa);
1890 }
1891 else
1892 m_FSM.ProcessEvent(e);
1893
1894 return true;
1895 }
1896 return false;
1897 }
1898
1900 {
1902 if (p && p.GetInstanceType() == DayZPlayerInstanceType.INSTANCETYPE_SERVER)
1903 {
1905
1907 e.WriteToContext(ctx);
1908
1910 hndDebugPrint("[hndfsm] send 2 remote: sending e=" + e + " id=" + e.GetEventID() + " p=" + p + " e=" + e.DumpToString());
1911
1912 p.StoreInputForRemotes(ctx);
1913 }
1914 }
1915
1917 {
1918 super.OnHandsExitedStableState(src, dst);
1919
1921 hndDebugPrint("[hndfsm] hand fsm exit stable src=" + src.Type().ToString());
1922 }
1923
1925 {
1926 super.OnHandsEnteredStableState(src, dst);
1927
1929 hndDebugPrint("[hndfsm] hand fsm entered stable dst=" + dst.Type().ToString());
1930 }
1931
1933 {
1934 super.OnHandsStateChanged(src, dst);
1935
1937 hndDebugPrint("[hndfsm] hand fsm changed state src=" + src.Type().ToString() + " ---> dst=" + dst.Type().ToString());
1938
1939 if (src.IsIdle())
1941
1942 if (dst.IsIdle())
1944
1945#ifdef BOT
1947 if (p && p.m_Bot)
1948 p.m_Bot.ProcessEvent(new BotEventOnItemInHandsChanged(p));
1949#endif
1950 }
1951
1953 {
1954 if (!IsProcessing())
1955 {
1956 EntityAI itemInHands = GetEntityInHands();
1957
1959 handInventoryLocation.SetHands(GetInventoryOwner(), itemInHands);
1960
1962 if (e.CanPerformEventEx(validation))
1963 {
1965 if (m_DeferredEvent.ReserveInventory(this))
1966 return true;
1967 }
1968
1970
1972 if (!GetGame().IsMultiplayer() || GetGame().IsClient())
1973 {
1975 OnInventoryFailure(InventoryCommandType.HAND_EVENT, validation.m_Reason, e.GetSrc(), e.GetDst());
1976 }
1977 else
1978 {
1980
1982 serializer.Write(validation.m_Reason);
1983
1985 }
1986 }
1987
1988 return false;
1989 }
1990
1991
1993 {
1996
1999 {
2000#ifdef DEVELOPER
2002 Debug.InventoryHFSMLog("STS = " + GetDayZPlayerOwner().GetSimulationTimeStamp(), "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2003#endif
2004
2006 hndDebugPrint("[inv] HumanInventory::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ") ev=" + deferred_hand_event.m_event.DumpToString());
2007
2008 switch (deferred_hand_event.m_mode)
2009 {
2010 case InventoryMode.PREDICTIVE:
2011#ifdef DEVELOPER
2013 Debug.InventoryHFSMLog("PREDICTIVE", "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2014#endif
2015
2016 deferred_hand_event.ClearInventoryReservation(this);
2017 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2018 {
2020 ProcessHandEvent(deferred_hand_event.m_event);
2021 }
2022 break;
2023
2024 case InventoryMode.JUNCTURE:
2025#ifdef DEVELOPER
2027 Debug.InventoryHFSMLog("JUNCTURE", "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2028#endif
2029
2030 deferred_hand_event.ClearInventoryReservation(this);
2031 if (deferred_hand_event.m_event.CanPerformEventEx(validation))
2032 {
2033 deferred_hand_event.ReserveInventory(this);
2035
2036 //Functionality to prevent desync when two players perform interfering action at the same time
2037 EntityAI itemSrc = deferred_hand_event.m_event.GetSrcEntity();
2039 if (deferred_hand_event.m_event.GetDst())
2040 itemDst = deferred_hand_event.m_event.GetDst().GetItem();
2041 if (itemSrc)
2043 if (itemDst)
2045 }
2046 break;
2047
2048 case InventoryMode.LOCAL:
2049#ifdef DEVELOPER
2051 Debug.InventoryHFSMLog("LOCAL", "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2052#endif
2053
2054 deferred_hand_event.ClearInventoryReservation(this);
2055 ProcessHandEvent(deferred_hand_event.m_event);
2056 //PostHandEvent(deferred_hand_event.m_event);
2057 break;
2058
2059 case InventoryMode.SERVER:
2060#ifdef DEVELOPER
2062 Debug.InventoryHFSMLog("SERVER", "n/a", "n/a", "HandleHandEvent", GetDayZPlayerOwner().ToString());
2063#endif
2064
2066 hndDebugPrint("[inv] DZPI::HandEvent(" + typename.EnumToString(InventoryMode, deferred_hand_event.m_mode) + ")");
2067
2068 if (!deferred_hand_event.m_event.IsServerSideOnly())
2069 {
2070 if (GetDayZPlayerOwner().IsAlive())
2072 else
2074 }
2075 else
2076 ProcessHandEvent(deferred_hand_event.m_event);
2077 break;
2078
2079 default:
2080 Error("HumanInventory::HandEvent - Invalid mode");
2081 }
2082 }
2083 }
2084
2098
2099
2101 {
2102 return !m_FSM.GetCurrentState().IsIdle() || m_DeferredEvent || m_DeferredPostedHandEvent;
2103 }
2104
2106 {
2107 bool result = true;
2108
2109 EntityAI ent = src.GetParent();
2110 if (ent)
2111 {
2112 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2113 if (player)
2114 {
2115 if (GetDayZPlayerOwner() != player)
2116 {
2117 if (player.IsAlive())
2118 {
2119 if (!player.IsRestrained() && !player.IsUnconscious())
2120 return false;
2121 }
2122 }
2123 }
2124 }
2125
2126 if (result)
2127 result = CheckRequestSrc(GetManOwner(), src, radius);
2128
2129 return result;
2130 }
2131
2133 {
2134 bool result = true;
2135
2136 EntityAI ent = dst.GetParent();
2137 if (ent)
2138 {
2139 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2140 if (player)
2141 {
2142 if (GetDayZPlayerOwner() != player)
2143 {
2144 if (player.IsAlive())
2145 {
2146 if (!player.IsRestrained() && !player.IsUnconscious())
2147 return false;
2148 }
2149 }
2150 }
2151 }
2152
2153 if (result)
2154 result = CheckMoveToDstRequest(GetManOwner(), src, dst, radius);
2155
2156 return result;
2157 }
2158
2160 {
2161 bool result = true;
2162
2163 EntityAI ent = dst1.GetParent();
2165 if (ent)
2166 {
2167 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2168 if (player)
2169 {
2170 if (GetDayZPlayerOwner() != player)
2171 {
2172 if (player.IsAlive())
2173 {
2174 if (!player.IsRestrained() && !player.IsUnconscious())
2175 return false;
2176 }
2177 }
2178 }
2179 }
2180
2181 ent = dst2.GetParent();
2182 if (ent)
2183 {
2184 player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2185 if (player)
2186 {
2187 if (GetDayZPlayerOwner() != player)
2188 {
2189 if (player.IsAlive())
2190 {
2191 if (!player.IsRestrained() && !player.IsUnconscious())
2192 return false;
2193 }
2194 }
2195 }
2196 }
2197
2198
2199 if (result)
2200 result = CheckSwapItemsRequest(GetManOwner(), src1, src2, dst1, dst2, GameInventory.c_MaxItemDistanceRadius);
2201
2202 return result;
2203
2204 }
2205
2207 {
2208 bool result = true;
2209
2210 EntityAI ent = src.GetParent();
2211 if (ent)
2212 {
2213 PlayerBase player = PlayerBase.Cast(ent.GetHierarchyRootPlayer());
2214 if (player)
2215 {
2216 if (GetDayZPlayerOwner() != player)
2217 {
2218 if (player.IsAlive())
2219 {
2220 if (!player.IsRestrained() && !player.IsUnconscious())
2221 return false;
2222 }
2223 }
2224 }
2225 }
2226
2227 if (result)
2228 result = CheckDropRequest(GetManOwner(), src, radius);
2229
2230 return result;
2231 }
2232};
2233
void syncDebugPrint(string s)
Definition Debug.c:1
void inventoryDebugPrint(string s)
Definition Debug.c:19
InventoryCommandType
Definition Inventory.c:3
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition Inventory.c:22
InventoryValidationResult
Definition Inventory.c:30
InventoryValidationReason
Definition Inventory.c:37
const int INPUT_UDT_INVENTORY
Definition _constants.c:9
const int INPUT_UDT_HAND_REMOTE_EVENT
Definition _constants.c:14
void wpnDebugSpamALot(string s)
Definition Debug.c:25
void wpnDebugPrint(string s)
Definition Debug.c:9
void ClearInventoryReservationEx(ActionData action_data)
Definition ActionBase.c:790
override Widget Init()
Definition DayZGame.c:120
override void OnAfterStoreLoad()
engine reaction to load from database originates in: engine - Person::BinLoad script - PlayerBase....
bool PlayerCheckDropRequest(notnull InventoryLocation src, float radius)
bool ValidateSyncMove(inout Serializer ctx, InventoryValidation validation)
bool ValidateHandEvent(inout Serializer ctx, InventoryValidation validation)
void EnableMovableOverride(EntityAI item)
void OnHandleStoredInputUserData(ParamsReadContext ctx)
bool ProcessInputData(ParamsReadContext ctx, bool isJuncture, bool isRemote)
ref HandAnimatedForceSwapping m_FSwapping
m_DeferredEvent
void HandleHandEvent(DeferredEvent deferred_event)
bool IsProcessing()
void HandleWeaponEvents(float dt, out bool exitIronSights)
proto native void StoreInputUserData(ParamsReadContext ctx)
void OnHandleStoredJunctureData(ParamsReadContext ctx)
void SyncHandEventToRemote(HandEventBase e)
void HandleTakeToDst(DeferredEvent deferred_event)
void DeferredForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
ref HandAnimatedForceSwapping_Inst m_FSwappingInst
ref HandAnimatedSwapping m_Swapping
bool ValidateDestroy(inout Serializer ctx, InventoryValidation validation)
void CheckForRope(InventoryLocation src, InventoryLocation dst)
bool PlayerCheckRequestSrc(notnull InventoryLocation src, float radius)
void AbortWeaponEvent()
override void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
void PostWeaponEvent(WeaponEventBase e)
override void NetSyncCurrentStateID(int id)
override void OnHandsEnteredStableState(HandStateBase src, HandStateBase dst)
bool IsServerOrLocalPlayer()
override bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
override void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
void RemoveMovableOverride(EntityAI item)
ref HandEventBase m_DeferredPostedHandEvent
override void HandleInventoryManipulation()
override bool OnInventoryJunctureFromServer(ParamsReadContext ctx)
void DayZPlayerInventory()
ref HandAnimatedTakingFromAtt m_Taking
deferred weapon event
override bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
ref HandAnimatedMovingToAtt m_MovingTo
override bool OnInventoryJunctureRepairFromServer(ParamsReadContext ctx)
void DeferredTakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
override void OnHandsExitedStableState(HandStateBase src, HandStateBase dst)
void CancelHandEvent()
cancels any handevents that will be executed this frame @NOTE: this is used in situations where the p...
override void OnHandsStateChanged(HandStateBase src, HandStateBase dst)
bool OnHandEventForRemote(ParamsReadContext ctx)
ref InventoryLocation m_dst1
ref WeaponEventBase m_DeferredWeaponEvent
deferred hand event
void OnInputUserDataForRemote(ParamsReadContext ctx)
DayZPlayer GetDayZPlayerOwner()
void DeferredHandEvent(InventoryMode mode, HandEventBase e)
override bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
bool ValidateSwap(inout Serializer ctx, InventoryValidation validation)
void HandleSwapEntities(DeferredEvent deferred_event)
bool PlayerCheckSwapItemsRequest(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
void HandleInventory(float dt)
void DeferredWeaponFailed()
ref InventoryLocation m_dst
void HandleForceSwapEntities(DeferredEvent deferred_event)
ref Timer m_DeferredWeaponTimer
bool PlayerCheckRequestDst(notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
bool OnEventForRemoteWeapon(ParamsReadContext ctx)
override void OnServerInventoryCommand(ParamsReadContext ctx)
proto native void StoreJunctureData(ParamsReadContext ctx)
ref InventoryLocation m_dst2
DeferredSwapEntities m_item1
override bool HandEvent(InventoryMode mode, HandEventBase e)
void CancelWeaponEvent()
class DeferredEvent m_src
EntityAI m_item2
static void SendServerHandEventViaJuncture(notnull DayZPlayer player, HandEventBase e)
bool OnInputUserDataProcess(int userDataType, ParamsReadContext ctx)
proto string ToString()
WeaponEventBase WeaponAnimEventFactory(WeaponEvents type, DayZPlayer p=NULL, Magazine m=NULL)
creates animation system events
Definition Events.c:251
WeaponEventBase CreateWeaponEventFromContext(ParamsReadContext ctx)
Definition Events.c:281
WeaponEventID
identifier for events. mainly for rpc purposes
Definition Events.c:6
ProcessEventResult
Definition FSMBase.c:41
void fsmDebugSpam(string s)
Definition HFSMBase.c:9
bool CheckRequestSrc()
bool IsAuthoritative()
Definition Hand_Events.c:55
bool ReserveInventory()
HandEventBase HandAnimEventFactory(WeaponEvents type, Man p=null, InventoryLocation src=null)
JunctureRequestResult
Definition Hand_Events.c:28
HandEventID
events
Definition Hand_Events.c:7
bool IsOwner()
Definition Hand_Events.c:60
void ClearInventoryReservation()
bool IsProxy()
Definition Hand_Events.c:65
void hndDebugSpam(string s)
Definition HandFSM.c:9
void hndDebugSpamALot(string s)
Definition HandFSM.c:17
void hndDebugPrint(string s)
Definition HandFSM.c:1
FSMTransition< HandStateBase, HandEventBase, HandActionBase, HandGuardBase > HandTransition
Definition HandFSM.c:27
bool TryAcquireInventoryJunctureFromServer(notnull Man player, notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Junctures.c:2
bool TryAcquireTwoInventoryJuncturesFromServer(notnull Man player, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
Definition Junctures.c:27
float GetTime()
Super root of all classes in Enforce script.
Definition EnScript.c:11
override void OnItemInHandsChanged()
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
static void InventoryMoveLog(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Definition Debug.c:163
bool ReserveInventory(HumanInventory inventory)
void ClearInventoryReservation(HumanInventory inventory)
InventoryMode m_mode
override bool ReserveInventory(HumanInventory inventory)
ref HandEventBase m_event
void DeferredHandEvent(InventoryMode mode, HandEventBase e)
override void ClearInventoryReservation(HumanInventory inventory)
ref InventoryLocation m_dst1
void DeferredSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
override void ClearInventoryReservation(HumanInventory inventory)
override bool ReserveInventory(HumanInventory inventory)
ref InventoryLocation m_dst2
script counterpart to engine's class Inventory
Definition Inventory.c:79
const int c_InventoryReservationTimeoutShortMS
Definition Inventory.c:688
static bool MakeSrcAndDstForSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
helper function for swap
Definition Inventory.c:1166
static bool MakeSrcAndDstForForceSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, notnull InventoryLocation dst2)
helper function for ForceSwap
Definition Inventory.c:1178
const int c_InventoryReservationTimeoutMS
reservations
Definition Inventory.c:687
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition Inventory.c:378
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Definition Inventory.c:645
const float c_MaxItemDistanceRadius
anti-cheats
Definition Inventory.c:788
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.
represent hand state base
inventory for plain man/human
HumanInventory... with FSM (synchronous, no anims)
static void SerializeSwap(ParamsWriteContext ctx, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap)
swap
static void SendInputUserDataHandEvent(HandEventBase e)
static void SendInputUserDataMove(int type, notnull InventoryLocation src, notnull InventoryLocation dst)
static void SendInputUserDataSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, bool skippedSwap=false)
static void SerializeHandEvent(ParamsWriteContext ctx, HandEventBase e)
hand
static void SerializeMove(ParamsWriteContext ctx, int type, notnull InventoryLocation src, notnull InventoryLocation dst)
move
static void SendServerHandEventViaInventoryCommand(notnull Man player, HandEventBase e)
InventoryLocation.
static string DumpToStringNullSafe(InventoryLocation loc)
static bool IsWeaponLogEnable()
Definition Debug.c:799
static bool IsSyncLogEnable()
Definition Debug.c:759
static bool IsInventoryHFSMLogEnable()
Definition Debug.c:749
static bool IsInventoryMoveLogEnable()
Definition Debug.c:729
proto static native bool CanStoreInputUserData()
Serialization general interface. Serializer API works with:
Definition Serializer.c:56
signalize mechanism manipulation
Definition Events.c:35
proto native void StoreInputForRemotes(ParamsWriteContext ctx)
DayZPlayerInstanceType
defined in C++
proto native DayZPlayerInstanceType GetInstanceType()
proto native CGame GetGame()
void Error(string err)
Messagebox with error message.
Definition EnDebug.c:90
static proto bool CastTo(out Class to, Class from)
Try to safely down-cast base class to child class.
WeaponActions
actions
Definition human.c:796
WeaponEvents
events
Definition human.c:943
string WeaponActionTypeToString(int A, int AT)
Definition human.c:923