Dayz Explorer 1.29.162510
Loading...
Searching...
No Matches
inventory.c
Go to the documentation of this file.
1//-------------------------------------------------------
14{
16 SWAP,
17 //LOAD, ///< load mag from ground
18};
19
28
35
42
44{
45 bool m_IsJuncture = false;
46 bool m_IsRemote = false;
47
50
51 InventoryMode m_Mode = InventoryMode.JUNCTURE;
52
53 bool IsAuthoritative()
54 {
55 return !m_IsJuncture && !m_IsRemote;
56 }
57};
58
64
65enum FindInventoryReservationMode
66{
75};
76
81{
82 protected static int m_inventory_check_context = InventoryCheckContext.DEFAULT;
83
84//-------------------------------------------------------
87
93
94#ifdef DEVELOPER
99 proto native void DumpInventoryDebug();
100
105 static proto native void DumpStaticInventoryDebug();
106#endif
107
118 proto native bool HasEntityInInventory(notnull EntityAI item);
119
128
134 proto native int CountInventory();
135
136
138 proto native CargoBase GetCargo();
139 proto native CargoBase GetCargoFromIndex(int index);
143 proto native EntityAI CreateEntityInCargo(string typeName);
150 proto native EntityAI CreateEntityInCargoEx(string typeName, int idx, int row, int col, bool flip);
151
152 proto native bool HasEntityInCargo(notnull EntityAI e);
153 proto native bool HasEntityInCargoEx(notnull EntityAI e, int idx, int row, int col);
154 proto native bool CanAddEntityInCargo(notnull EntityAI e, bool flip);
155 proto native bool CanAddEntityInCargoEx(notnull EntityAI e, int idx, int row, int col, bool flip);
157 proto native bool TestAddEntityInCargoEx(notnull EntityAI e, int idx, int row, int col, bool flip, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check);
158 proto native bool TestAddEntityInCargoExLoc(notnull InventoryLocation loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check);
159 //proto native bool AddEntityInCargo (notnull EntityAI owner, EntityAI cargo);
160 //proto native bool AddEntityInCargoEx (notnull EntityAI owner, notnull EntityAI e, int idx, int row, int col);
161 proto native bool CanRemoveEntityInCargo(notnull EntityAI e);
162 proto native bool CanRemoveEntityInCargoEx(notnull EntityAI e, int idx, int row, int col);
164
165
167
171 proto native int GetSlotId(int index);
175 proto native int GetSlotIdCount();
180 proto native int GetAttachmentSlotId(int index);
184 proto native int GetAttachmentSlotsCount();
188 /*proto native*/bool HasAttachmentSlot(int slotId) //TODO - flip to code
189 {
190 int count = GetAttachmentSlotsCount();
191 for (int i = 0; i < count; i++)
192 {
193 if (GetAttachmentSlotId(i) == slotId)
194 return true;
195 }
196 return false;
197 }
198
201 proto native bool HasInventorySlot(int slotId);
205 proto native int AttachmentCount();
209 proto native EntityAI CreateAttachment(string typeName);
215 proto native EntityAI CreateAttachmentEx(string typeName, int slotId);
220 proto native EntityAI GetAttachmentFromIndex(int index);
224 proto native EntityAI FindAttachment(int slot);
232 proto native bool HasAttachment(notnull EntityAI e);
236 proto native bool HasAttachmentEx(notnull EntityAI e, int slot);
241 proto native bool CanAddAttachment(notnull EntityAI e);
246 proto native bool CanAddAttachmentEx(notnull EntityAI e, int slot);
247
248 proto native bool CanRemoveAttachment(EntityAI attachment);
249 proto native bool CanRemoveAttachmentEx(EntityAI attachment, int slot);
250
251 //proto native bool RemoveAttachment(EntityAI attachment);
252 //proto native bool RemoveAttachmentEx(EntityAI attachment, int slot);
253
257 proto native EntityAI FindPlaceholderForSlot(int slot);
258 proto native bool IsPlaceholderEntity(notnull Object e);
260
261
268 proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc);
269
276 proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc);
283 proto native bool FindFreeLocationForEx(notnull EntityAI item, FindInventoryLocationType flags, notnull InventoryLocation exclude, out notnull InventoryLocation loc);
284
291 proto native bool FindFirstFreeLocationForNewEntity(string item_type, FindInventoryLocationType flags, out notnull InventoryLocation loc);
292
325 proto native int FindFreeLocationsFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull array<ref InventoryLocation> locs);
326
333 static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation);
341 static proto native EntityAI LocationCreateLocalEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation);
347 static proto native bool LocationCanAddEntity(notnull InventoryLocation inv_loc);
348
349 //Added script check to LocationCanAddEntity
350 static bool LocationCanAddEntityEx(notnull InventoryLocation inv_loc)
351 {
352 return LocationCanAddEntity(inv_loc);
353 }
354
360 static proto native bool LocationTestAddEntity(notnull InventoryLocation inv_loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check);
366 static proto native bool LocationCanRemoveEntity(notnull InventoryLocation inv_loc);
373 static proto native bool LocationCanMoveEntity(notnull InventoryLocation src, notnull InventoryLocation dst);
374
376 {
378 }
379
381 {
383 bool result = LocationCanMoveEntity(src, dst);
385 return result;
386
387 }
388
393 static proto native EntityAI LocationGetEntity(notnull InventoryLocation inv_loc);
394
395
398 {
401 if (lcn.GetType() == InventoryLocationType.CARGO)
402 {
403 return true;
404 }
405
406 return false;
407 }
408
411 {
414 if (lcn.GetType() == InventoryLocationType.ATTACHMENT)
415 {
416 return true;
417 }
418
419 return false;
420 }
421
424 {
427 while (ent)
428 {
429 if (ent.GetInventory().GetCurrentInventoryLocation(lcn) && lcn.IsValid())
430 {
431 if (lcn.GetType() == InventoryLocationType.CARGO || lcn.GetType() == InventoryLocationType.PROXYCARGO)
432 return true;
433 }
434
435 ent = ent.GetHierarchyParent();
436 }
437
438 return false;
439 }
440
443 {
445 if (ent)
446 return ent.AreChildrenAccessible();
447
448 #ifdef DEVELOPER
449 ErrorEx("no inventory owner found!");
450 #endif
451
452 return true; //just in case inventoy without owner exists somewhere (shouldn't!)
453 }
454
456 bool GetCurrentAttachmentSlotInfo(out int slot_id, out string slot_name)
457 {
458 slot_id = InventorySlots.INVALID;
459 slot_name = "";
462 if (lcn.GetType() == InventoryLocationType.ATTACHMENT)
463 {
464 slot_id = lcn.GetSlot();
465 slot_name = InventorySlots.GetSlotName(slot_id);
466 return true;
467 }
468 return false;
469 }
470
472 {
473 int tmp = -1;
474 ctx.Read(tmp);
475
476 int type = -1;
477 if (!ctx.Read(type))
478 return;
479
480 switch (type)
481 {
482 case InventoryCommandType.SYNC_MOVE:
483 {
486
487 src.ReadFromContext(ctx);
488 dst.ReadFromContext(ctx);
489 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + g_Game.GetTime() + "ms ServerInventoryCommand cmd=" + typename.EnumToString(InventoryCommandType, type) + " src=" + InventoryLocation.DumpToStringNullSafe(src) + " dst=" + InventoryLocation.DumpToStringNullSafe(dst));
490
491 if (!src.GetItem() || !dst.GetItem())
492 {
493 Error("[syncinv] ServerInventoryCommand (cmd=SYNC_MOVE) dropped, item not in bubble");
494 break; // not in bubble
495 }
496
497 LocationSyncMoveEntity(src, dst);
498 break;
499 }
500
501 case InventoryCommandType.HAND_EVENT:
502 {
503 HandEventBase e = HandEventBase.CreateHandEventFromContext(ctx);
504 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + g_Game.GetTime() + "ms ServerInventoryCommand cmd=" + typename.EnumToString(InventoryCommandType, type) + " event=" + e.DumpToString());
505
506 if (!e.GetSrcEntity())
507 {
508 Error("[syncinv] ServerInventoryCommand (cmd=HAND_EVENT) dropped, item not in bubble");
509 break; // not in bubble
510 }
511 e.m_Player.GetHumanInventory().ProcessHandEvent(e);
512 break;
513 }
514
515 case InventoryCommandType.FORCESWAP:
516 case InventoryCommandType.SWAP:
517 {
522 src1.ReadFromContext(ctx);
523 src2.ReadFromContext(ctx);
524 dst1.ReadFromContext(ctx);
525 dst2.ReadFromContext(ctx);
526
527 if (src1.IsValid() && src2.IsValid() && dst1.IsValid() && dst2.IsValid())
528 {
529 if (LogManager.IsSyncLogEnable()) syncDebugPrint("[syncinv] t=" + g_Game.GetTime() + "ms ServerInventoryCommand Swap src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
530
531 LocationSwap(src1, src2, dst1, dst2);
532 }
533 else
534 Error("ServerInventoryCommand - cannot swap, invalid location input: src1=" + InventoryLocation.DumpToStringNullSafe(src1) + " src2=" + InventoryLocation.DumpToStringNullSafe(src2) + " dst1=" + InventoryLocation.DumpToStringNullSafe(dst1) + " dst2=" + InventoryLocation.DumpToStringNullSafe(dst2));
535
536 break;
537 }
538 }
539 }
540
546 static proto native bool LocationAddEntity(notnull InventoryLocation inv_loc);
552 static proto native bool LocationRemoveEntity(notnull InventoryLocation inv_loc);
553
559 static proto native bool LocationMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc);
560
567 static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc);
568
574 static proto native bool LocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2);
575
581 static proto native bool ServerLocationMoveEntity(notnull EntityAI item, ParamsWriteContext ctx);
582
590 static proto native bool ServerLocationSyncMoveEntity(Man player, notnull EntityAI item, ParamsWriteContext ctx);
591
597 static proto native bool ServerLocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, ParamsWriteContext ctx);
598
604 static proto native bool ServerHandEvent(notnull Man player, notnull EntityAI item, ParamsWriteContext ctx);
605
615 static proto native bool PrepareDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix = false, int conflictCheckDepth = -1);
616 static proto native bool TestDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix = false, int conflictCheckDepth = -1);
617
628 static proto native bool CanSwapEntities(notnull EntityAI item1, notnull EntityAI item2);
629
630 static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
631 {
632 int slot;
635
636 item2.GetInventory().GetCurrentInventoryLocation(il2);
637 slot = il2.GetSlot();
638
639 if (item1.CanBeSplit() && item1.GetQuantity() > item1.GetTargetQuantityMax(slot))
640 return false;
641
642 item1.GetInventory().GetCurrentInventoryLocation(il1);
643 slot = il1.GetSlot();
644
645 if (item2.CanBeSplit() && item2.GetQuantity() > item2.GetTargetQuantityMax(slot))
646 return false;
647
648 if (!item1.CanSwapEntities(item2, il2, il1) || !item2.CanSwapEntities(item1, il1, il2))
649 {
650 return false;
651 }
652
653 return CanSwapEntities(item1,item2);
654 }
655
665 static proto native bool CanForceSwapEntities(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst);
666 static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
667 {
668 if (!CanForceSwapEntities(item1, item1_dst, item2, item2_dst) )
669 return false;
670
671 int slot;
673
674 if (!item1.CanBeFSwaped())
675 return false;
676
677 if ( item1_dst == null)
678 {
679 item2.GetInventory().GetCurrentInventoryLocation(il);
680 slot = il.GetSlot();
681 }
682 else
683 {
684 slot = item1_dst.GetSlot();
685 }
686
687 if ( item1.GetQuantity() > item1.GetTargetQuantityMax(slot) )
688 return false;
689
690 if ( item2_dst == null)
691 {
692 item1.GetInventory().GetCurrentInventoryLocation(il);
693 slot = il.GetSlot();
694 }
695 else
696 {
697 slot = item2_dst.GetSlot();
698 }
699
700 if (!item1.CanSwapEntities(item2, item2_dst, item1_dst) || !item2.CanSwapEntities(item1, item1_dst, item2_dst))
701 {
702 return false;
703 }
704
705 if ( item2.GetQuantity() > item2.GetTargetQuantityMax(slot) )
706 return false;
707
708 return true;
709 }
710
711 proto native bool CanAddSwappedEntity(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2);
712
716
717 static proto native bool AddInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms);
719 {
720 if (g_Game.IsMultiplayer() && g_Game.IsServer() )
721 return true;
722
723 bool ret_val = AddInventoryReservation(item, dst, timeout_ms);
724 #ifdef ENABLE_LOGGING
725 if ( LogManager.IsInventoryReservationLogEnable() )
726 {
727 DayZPlayer player = g_Game.GetPlayer();
728 if ( player )
729 {
730 if (item)
731 Debug.InventoryReservationLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "AddInventoryReservation", player.ToString() );
732 else
733 Debug.InventoryReservationLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "AddInventoryReservation", player.ToString() );
734 }
735 }
736 #endif
737 return ret_val;
738 }
739
740 static proto native bool ExtendInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms);
742 {
743 if (g_Game.IsMultiplayer() && g_Game.IsServer() )
744 return true;
745
746 bool ret_val = ExtendInventoryReservation(item,dst,timeout_ms);
747 #ifdef ENABLE_LOGGING
748 if ( LogManager.IsInventoryReservationLogEnable() )
749 {
750 DayZPlayer player = g_Game.GetPlayer();
751 if ( player )
752 {
753 if (item)
754 Debug.InventoryReservationLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "ExtendInventoryReservation", player.ToString() );
755 else
756 Debug.InventoryReservationLog("Reservation result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "ExtendInventoryReservation", player.ToString() );
757 }
758 }
759 #endif
760 return ret_val;
761 }
762
763 static proto native bool ClearInventoryReservation(EntityAI item, InventoryLocation dst);
765 {
766 if (g_Game.IsMultiplayer() && g_Game.IsServer() )
767 return true;
768
769 bool ret_val = ClearInventoryReservation(item,dst);
770 #ifdef ENABLE_LOGGING
771 if ( LogManager.IsInventoryReservationLogEnable() )
772 {
773 DayZPlayer player = g_Game.GetPlayer();
774 if ( player )
775 {
776 if (item)
777 Debug.InventoryReservationLog("Reservation cleared result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / " + item.ToString() + " / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "ClearInventoryReservation", player.ToString() );
778 else
779 Debug.InventoryReservationLog("Reservation cleared result: " + ret_val + " - STS = " + player.GetSimulationTimeStamp() + " / null / " + InventoryLocation.DumpToStringNullSafe(dst), "n/a" , "n/a", "ClearInventoryReservation", player.ToString() );
780 }
781 }
782 #endif
783 return ret_val;
784 }
785
787 static proto native bool HasInventoryReservation(EntityAI item, InventoryLocation dst);
789 static proto native bool HasInventoryReservationCanAdd(EntityAI item, InventoryLocation dst);
790
792 static proto native bool HasInventoryReservationEx(EntityAI item, InventoryLocation dst, FindInventoryReservationMode itemMode, FindInventoryReservationMode parentMode);
793 static proto native bool GetInventoryReservationCount(EntityAI item, InventoryLocation dst);
796
798 proto native bool CanLockInventoryWithKey(notnull EntityAI key);
799 proto native bool CanUnlockInventoryWithKey(notnull EntityAI key);
800 proto native void LockInventoryWithKey(notnull EntityAI key);
801 proto native void UnlockInventoryWithKey(notnull EntityAI key);
802 proto native bool HasKeys();
803
804 proto native void LockInventory(int lockType);
805 proto native void UnlockInventory(int lockType);
806 proto native int GetScriptLockCount();
807 proto native bool IsInventoryUnlocked();
808 proto native bool IsInventoryLocked();
809 proto native bool IsInventoryLockedForLockType(int lockType);
810 proto native bool SetSlotLock(int slot, bool locked);
811 proto native bool GetSlotLock(int slot);
813
815 const float c_MaxItemDistanceRadius = 2.5;
816 static proto native bool CheckRequestSrc(notnull Man requestingPlayer, notnull InventoryLocation src, float radius);
817 static proto native bool CheckDropRequest(notnull Man requestingPlayer, notnull InventoryLocation src, float radius);
818 static proto native bool CheckTakeItemRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius);
819 static proto native bool CheckMoveToDstRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius);
820 static proto native bool CheckSwapItemsRequest(notnull Man requestingPlayer, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius);
821 static proto native bool CheckManipulatedObjectsDistances(notnull EntityAI e0, notnull EntityAI e1, float radius);
823
827
831 void Init()
832 {
833 GetInventoryOwner().OnInventoryInit();
834 }
835
837 bool OnStoreLoad(ParamsReadContext ctx, int version)
838 {
839 return true;
840 }
844
845 void EEInit()
846 {
849 {
850 if (src.GetType() == InventoryLocationType.HANDS)
851 {
852 Man man = Man.Cast(src.GetParent());
853 if (man)
854 {
855 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("Inventory::EEInit - Man=" + man + " item=" + this);
856 man.GetHumanInventory().OnEntityInHandsCreated(src);
857 }
858 }
859 }
860 }
861
862 void EEDelete(EntityAI parent)
863 {
865 Man player = item.GetHierarchyRootPlayer();
866 if (player)
867 player.GetInventory().ClearInventoryReservationEx(item, null);
868 }
869
877 {
880 {
881 switch (loc.GetType())
882 {
883 case InventoryLocationType.ATTACHMENT:
884 return loc.GetParent().GetInventory().CreateAttachmentEx(type, loc.GetSlot());
885 case InventoryLocationType.CARGO:
886 return loc.GetParent().GetInventory().CreateEntityInCargoEx(type, loc.GetIdx(), loc.GetRow(), loc.GetCol(), loc.GetFlip());
887 default:
888 Error("CreateInInventory: unknown location for item");
889 break;
890 }
891 }
892
893 return null;
894 }
895
907 {
909 bool result = FindFreeLocationFor(item, flag, il);
910 return result;
911 }
912
927 {
929 bool result = FindFreeLocationFor(item, FindInventoryLocationType.ANY, il);
930 if (result)
931 return LocationAddEntity(il);
932
933 return result;
934 }
935
940 {
943 return LocationCanRemoveEntity(il);
944
945 return false;
946 }
947
948 // Script version of CanAddEntity* methods based on InventoryLocation
962 {
964 return FindFreeLocationFor(item, flags, loc) && !item.IsHologram();
965 }
966
971 {
972 return CanAddEntityInto(item, FindInventoryLocationType.ANY_CARGO | FindInventoryLocationType.ATTACHMENT);
973 }
974
979 {
981 }
982
989
991
1013 {
1014 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1015
1017 if (item.GetInventory().GetCurrentInventoryLocation(src))
1018 {
1020 if (FindFreeLocationFor(item, flags, dst))
1021 return TakeToDst(mode, src, dst);
1022
1023 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Warning - no room for item");
1024 return false;
1025 }
1026 Error("[inv] I::Take2Inv(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Error - src has no inventory location");
1027 return false;
1028 }
1029
1032 {
1033 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1034
1036 if (item.GetInventory().GetCurrentInventoryLocation(src))
1037 {
1039
1040 if (target.GetInventory().FindFreeLocationFor(item, flags, dst))
1041 return TakeToDst(mode, src, dst);
1042
1043 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") target=" + target + " item=" + item + " Warning - no room for item in target");
1044 return false;
1045 }
1046 Error("[inv] I::Take2Target(" + typename.EnumToString(InventoryMode, mode) + ") target=" + target + " item=" + item + " Error - src has no inventory location");
1047 return false;
1048 }
1049
1056 bool TakeToDst (InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
1057 {
1058 bool ret;
1059 switch (mode)
1060 {
1061 case InventoryMode.SERVER:
1062 ret = LocationSyncMoveEntity(src, dst);
1063 if (ret && dst.IsValid())
1064 InventoryInputUserData.SendServerMove(null, InventoryCommandType.SYNC_MOVE, src, dst);
1065 return ret;
1066 case InventoryMode.LOCAL:
1067 ret = LocationSyncMoveEntity(src, dst);
1068 return ret;
1069 default:
1070 return false;
1071 }
1072 return false;
1073 }
1074
1081 {
1082 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1083 return TakeEntityToInventory(mode, FindInventoryLocationType.CARGO, item);
1084 }
1085
1087 bool TakeEntityToTargetCargo(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
1088 {
1089 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetCgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + target);
1090 return TakeEntityToTargetInventory(mode, target, FindInventoryLocationType.CARGO, item);
1091 }
1092
1098 bool TakeEntityToCargoEx(InventoryMode mode, notnull EntityAI item, int idx, int row, int col)
1099 {
1100 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " row=" + row + " col=" + col);
1102 GameInventory itemInventory = item.GetInventory();
1103 if (itemInventory.GetCurrentInventoryLocation(src))
1104 {
1106 dst.SetCargo(GetInventoryOwner(), item, idx, row, col, itemInventory.GetFlipCargo());
1107
1108 return TakeToDst(mode, src, dst);
1109 }
1110 Error("[inv] I::Take2Cgo(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " row=" + row + " col=" + col + " Error - src has no inventory location");
1111 return false;
1112 }
1113
1115 bool TakeEntityToTargetCargoEx(InventoryMode mode, notnull CargoBase cargo, notnull EntityAI item, int row, int col)
1116 {
1117 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetCgoEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + cargo.GetCargoOwner() + " row=" + row + " col=" + col);
1119 if (item.GetInventory().GetCurrentInventoryLocation(src))
1120 {
1122 dst.SetCargoAuto(cargo, item, row, col, item.GetInventory().GetFlipCargo());
1123
1124 return TakeToDst(mode, src, dst);
1125 }
1126 Error("[inv] I::Take2TargetCgoEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + "to cargo of target=" + cargo.GetCargoOwner() + " row=" + row + " col=" + col);
1127 return false;
1128 }
1129
1130 bool TakeEntityAsAttachmentEx(InventoryMode mode, notnull EntityAI item, int slot)
1131 {
1132 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " slot=" + slot);
1133 return TakeEntityAsTargetAttachmentEx(mode, GetInventoryOwner(), item, slot);
1134 }
1135
1137 bool TakeEntityAsTargetAttachmentEx(InventoryMode mode, notnull EntityAI target, notnull EntityAI item, int slot)
1138 {
1139 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2TargetAttEx(" + typename.EnumToString(InventoryMode, mode) + ") as ATT of target=" + target + " item=" + item + " slot=" + slot);
1141 if (item.GetInventory().GetCurrentInventoryLocation(src))
1142 {
1143 EntityAI att = target.GetInventory().FindAttachment(slot);
1144 if (att)
1145 {
1146 if (mode == InventoryMode.SERVER)
1147 {
1148 att.CombineItemsEx(item, true);
1149 }
1150 else
1151 {
1152 att.CombineItemsClient(item, true);
1153 }
1154 return true;
1155 }
1156 else if (item.CanBeSplit() && item.GetTargetQuantityMax(slot) < item.GetQuantity())
1157 {
1158 if (mode == InventoryMode.SERVER)
1159 {
1160 item.SplitIntoStackMaxEx(target, slot);
1161 }
1162 else
1163 {
1164 item.SplitIntoStackMaxClient(target,slot);
1165 }
1166 return true;
1167 }
1168 else
1169 {
1171 dst.SetAttachment(target, item, slot);
1172 return TakeToDst(mode, src, dst);
1173 }
1174 }
1175 Error("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item + " Error - src has no inventory location");
1176 return false;
1177 }
1178
1180 {
1181 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2Att(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1182 return TakeEntityToInventory(mode, FindInventoryLocationType.ATTACHMENT, item);
1183 }
1184
1185 bool TakeEntityAsTargetAttachment(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
1186 {
1187 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Take2AttEx(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1188 return TakeEntityToTargetInventory(mode, target, FindInventoryLocationType.ATTACHMENT, item);
1189 }
1190
1192 static bool MakeDstForSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
1193 {
1194 if (dst1 == null)
1195 dst1 = new InventoryLocation();
1196
1197 dst1.Copy(src1);
1198 dst1.CopyLocationFrom(src2, false);
1199 dst1.SetFlip(src1.GetItem().GetInventory().GetFlipCargo()); // update flip flag from inventory item
1200
1201 if (dst2 == null)
1202 dst2 = new InventoryLocation();
1203
1204 dst2.Copy(src2);
1205 dst2.CopyLocationFrom(src1, false);
1206 dst2.SetFlip(src2.GetItem().GetInventory().GetFlipCargo()); // update flip flag from inventory item
1207 return true;
1208 }
1209
1211 static bool MakeSrcAndDstForSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
1212 {
1213 if (src1 == null)
1214 src1 = new InventoryLocation();
1215 if (src2 == null)
1216 src2 = new InventoryLocation();
1217 if (item1.GetInventory().GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
1218 return MakeDstForSwap(src1, src2, dst1, dst2);
1219 return false;
1220 }
1221
1223 static bool MakeSrcAndDstForForceSwap(notnull EntityAI item1, notnull EntityAI item2, out InventoryLocation src1, out InventoryLocation src2, out InventoryLocation dst1, notnull InventoryLocation dst2)
1224 {
1225 if (src1 == null)
1226 src1 = new InventoryLocation();
1227 if (src2 == null)
1228 src2 = new InventoryLocation();
1229
1230 if (item1.GetInventory().GetCurrentInventoryLocation(src1) && item2.GetInventory().GetCurrentInventoryLocation(src2))
1231 {
1232 // src1 -> dst_of(src2)
1233 if (dst1 == null)
1234 dst1 = new InventoryLocation();
1235
1236 dst1.Copy(src1);
1237 dst1.CopyLocationFrom(src2, false);
1238 dst1.SetFlip(dst1.GetItem().GetInventory().GetFlipCargo());
1239
1240 // src2 -> dst2 from user
1241 return true;
1242 }
1243
1244 return false;
1245 }
1246
1247 bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
1248 {
1249 return false;
1250 }
1251
1252 bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
1253 {
1254 return false;
1255 }
1256
1257 static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
1258 {
1259 vector m4[4];
1260 Math3D.MatrixIdentity4(m4);
1261 bool success = GameInventory.PrepareDropEntityPos(owner, item, m4, false, GameConstants.INVENTORY_ENTITY_DROP_OVERLAP_DEPTH);
1262 ground.SetGround(item, m4);
1263 return success;
1264 }
1265
1266 bool DropEntity(InventoryMode mode, EntityAI owner, notnull EntityAI item)
1267 {
1268 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1270 if (item.GetInventory().GetCurrentInventoryLocation(src))
1271 {
1273 if (!SetGroundPosByOwner(owner, item, dst))
1274 {
1275 OnInventoryFailure(InventoryCommandType.SYNC_MOVE, InventoryValidationReason.DROP_PREVENTED, src, dst);
1276 return false;
1277 }
1278
1279 return TakeToDst(mode, src, dst);
1280 }
1281
1282 Error("DropEntity - No inventory location");
1283 return false;
1284 }
1285
1286 static bool SetGroundPosByTransform(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector transform[4])
1287 {
1288 bool success = GameInventory.PrepareDropEntityPos(owner, item, transform, true, GameConstants.INVENTORY_ENTITY_DROP_OVERLAP_DEPTH);
1289 ground.SetGround(item, transform);
1290 return success;
1291 }
1292
1293 bool DropEntityWithTransform(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector transform[4])
1294 {
1295 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1297 if (item.GetInventory().GetCurrentInventoryLocation(src))
1298 {
1300 SetGroundPosByTransform(owner, item, dst, transform);
1301
1302 return TakeToDst(mode, src, dst);
1303 }
1304
1305 Error("DropEntityWithTransform - No inventory location");
1306 return false;
1307 }
1308
1309 static void SetGroundPosByOwnerBounds(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector halfExtents, float angle, float cosAngle, float sinAngle)
1310 {
1311 vector m4[4];
1312 owner.GetTransform(m4);
1313
1314 vector randomPos = Vector(Math.RandomFloat(-halfExtents[0], halfExtents[0]), 0, Math.RandomFloat(-halfExtents[2], halfExtents[2]));
1315 randomPos = vector.RotateAroundZero(randomPos, vector.Up, cosAngle, sinAngle);
1316
1317 float dist = randomPos[0] * m4[1][0] + randomPos[1] * m4[1][1] + randomPos[2] * m4[1][2];
1318
1319 m4[3][0] = m4[3][0] + randomPos[0];
1320 m4[3][1] = m4[3][1] - dist + halfExtents[1];
1321 m4[3][2] = m4[3][2] + randomPos[2];
1322
1323 item.PlaceOnSurfaceRotated(m4, Vector(m4[3][0], m4[3][1], m4[3][2]));
1324
1325 ground.SetGround(item, m4);
1326 }
1327
1328 bool DropEntityInBounds(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector halfExtents, float angle, float cosAngle, float sinAngle)
1329 {
1330 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::Drop(" + typename.EnumToString(InventoryMode, mode) + ") item=" + item);
1331
1333 if (item.GetInventory().GetCurrentInventoryLocation(src))
1334 {
1336
1337 SetGroundPosByOwnerBounds(owner, item, dst, halfExtents, angle, cosAngle, sinAngle);
1338
1339 return TakeToDst(mode, src, dst);
1340 }
1341
1342 Error("DropEntityInBounds - No inventory location");
1343 return false;
1344 }
1345
1346 bool LocalDestroyEntity(notnull EntityAI item)
1347 {
1348 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::LocalDestroyEntity inv item=" + item);
1350 if (item.GetInventory().GetCurrentInventoryLocation(src))
1351 {
1352 if (src.GetType() == InventoryLocationType.HANDS)
1353 Error("[inv] Source location == HANDS, player has to handle this");
1354
1355 g_Game.ObjectDelete(src.GetItem());
1356 return true;
1357 }
1358
1359 Error("LocalDestroyEntity: No inventory location");
1360 return false;
1361 }
1362
1364 {
1366 if (lambda.m_OldItem.GetInventory().GetCurrentInventoryLocation(src))
1367 {
1368 if (LogManager.IsInventoryMoveLogEnable()) inventoryDebugPrint("[inv] I::ReplaceItemWithNew executing lambda=" + lambda + "on old_item=" + lambda.m_OldItem);
1369 lambda.Execute();
1370 return true;
1371 }
1372
1373 Error("[inv] I::ReplaceItemWithNew - no inventory location");
1374 return false;
1375 }
1376
1377 proto native bool GetFlipCargo();
1378 proto native void SetFlipCargo(bool flip);
1379 proto native void FlipCargo();
1380 proto native void ResetFlipCargo();
1382}
void syncDebugPrint(string s)
Definition debug.c:1
void inventoryDebugPrint(string s)
Definition debug.c:23
InventoryJunctureType
Definition inventory.c:14
InventoryCommandType
Definition inventory.c:3
@ USER_RESERVATION_CANCEL
Clear user reserved inventory space.
Definition inventory.c:11
@ SYNC_MOVE
synchronous move. action is finished immeadiately, no animations involved
Definition inventory.c:5
@ HAND_EVENT
event for hands
Definition inventory.c:6
enum InventoryCheckContext EQUAL
Find an exact reservation for item and dst, item and dst required.
InventoryMode
NOTE: PREDICTIVE is not to be used at all in multiplayer.
Definition inventory.c:22
@ SERVER
'Server' mode operation is required if and only if the operation runs only on server (creates and/or ...
Definition inventory.c:26
@ PREDICTIVE
'Predictive' means that the operation uses Client-Side Prediction, i.e. the action runs the same code...
Definition inventory.c:23
enum InventoryCheckContext DST
Find a reservation for the dst EXCLUDING the item, item and dst required.
InventoryValidationResult
Definition inventory.c:30
@ JUNCTURE
'Juncture' operation is used whenever there is possibility of race condition, i.e....
Definition inventory.c:25
@ SUCCESS
Definition inventory.c:33
@ FAILED
Definition inventory.c:31
InventoryValidationReason
Definition inventory.c:37
@ DROP_PREVENTED
Definition inventory.c:40
enum InventoryCheckContext ITEM
Find a reservation for the item EXCLUDING the dst, item and dst required.
InventoryCheckContext
Definition inventory.c:60
@ SYNC_CHECK
Definition inventory.c:62
@ UNKNOWN
24 - Any other error. Can be returned from any call.
PlayerSpawnPreset slotName
represents base for cargo storage for entities
Definition cargo.c:7
Definition debug.c:2
script counterpart to engine's class Inventory
Definition inventory.c:81
proto native bool GetFlipCargo()
proto native int CountInventory()
almost identical to EnumerateInventory except it does not return items
static proto native bool LocationTestAddEntity(notnull InventoryLocation inv_loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
test if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
void OnAfterStoreLoad()
void OnServerInventoryCommand(ParamsReadContext ctx)
bool OnInputUserDataProcess(ParamsReadContext ctx)
synchronization
bool LocalDestroyEntity(notnull EntityAI item)
Definition inventory.c:1346
static proto native bool CheckManipulatedObjectsDistances(notnull EntityAI e0, notnull EntityAI e1, float radius)
static proto native bool AddInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms)
proto native EntityAI CreateEntityInCargoEx(string typeName, int idx, int row, int col, bool flip)
Create Entity of specified type in cargo of entity at coordinates (row, col).
proto native int GetAnyInventoryReservationCount()
proto native int GetAttachmentSlotsCount()
void Init()
script functions
Definition inventory.c:831
void EEDelete(EntityAI parent)
Definition inventory.c:862
proto native EntityAI CreateEntityInCargo(string typeName)
Create Entity of specified type in cargo of entity.
proto native bool CanAddEntityInCargoExLoc(InventoryLocation loc)
static proto native bool LocationSyncMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
synchronously removes item from current inventory location and adds it to destination no anims involv...
static proto native bool ServerLocationMoveEntity(notnull EntityAI item, ParamsWriteContext ctx)
removes item from current inventory location and adds it to destination + sync via inventory command
EntityAI CreateInInventory(string type)
creates entity somewhere in inventory
Definition inventory.c:876
proto native bool FindFirstFreeLocationForNewEntity(string item_type, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFirstFreeLocationForNewEntity.
void OnInventoryFailure(InventoryCommandType type, InventoryValidationReason reason, InventoryLocation src, InventoryLocation dst)
static proto native bool CanSwapEntities(notnull EntityAI item1, notnull EntityAI item2)
test if ordinary swap can be performed.
bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
Definition inventory.c:1247
proto native EntityAI GetAttachmentFromIndex(int index)
static proto native bool PrepareDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
Finds a transformation for the item to be dropped to If the initial transforation overlaps with anoth...
static proto native bool ServerHandEvent(notnull Man player, notnull EntityAI item, ParamsWriteContext ctx)
hand event to clients
proto native EntityAI CreateAttachment(string typeName)
Create Entity of specified type as attachment of entity.
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)
returns information about current item location
proto native EntityAI CreateAttachmentEx(string typeName, int slotId)
Create Entity of specified type as attachment of entity.
bool ExtendInventoryReservationEx(EntityAI item, InventoryLocation dst, int timeout_ms)
Definition inventory.c:741
static void SetGroundPosByOwnerBounds(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector halfExtents, float angle, float cosAngle, float sinAngle)
Definition inventory.c:1309
bool CanRemoveEntity()
Returns if entity can be removed from its current location.
Definition inventory.c:939
static proto native EntityAI LocationGetEntity(notnull InventoryLocation inv_loc)
proto native bool HasAttachment(notnull EntityAI e)
brief Returns True if entity is attached to this
proto native EntityAI FindPlaceholderForSlot(int slot)
Returns placeholder entity for slot (naked arms, legs etc).
bool TakeEntityToInventory(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)
Put item anywhere into this entity (as attachment or into cargo, recursively).
Definition inventory.c:1012
proto native bool EnumerateInventory(InventoryTraversalType tt, out array< EntityAI > items)
enumerate inventory using traversal type and filling items array
proto native CargoBase GetCargo()
cargo
bool IsAttachment()
Returns true if this Inventory owner is an attachment of something.
Definition inventory.c:410
proto native bool CanAddEntityInCargo(notnull EntityAI e, bool flip)
proto native bool HasAttachmentEx(notnull EntityAI e, int slot)
brief Returns True if entity is attached to this in slot
bool TakeEntityToTargetCargoEx(InventoryMode mode, notnull CargoBase cargo, notnull EntityAI item, int row, int col)
Put item into into cargo on specific cargo location of another entity.
Definition inventory.c:1115
static proto native bool CanForceSwapEntities(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
test if forced swap can be performed.
proto native CargoBase GetCargoFromIndex(int index)
bool TakeEntityToTargetInventory(InventoryMode mode, notnull EntityAI target, FindInventoryLocationType flags, notnull EntityAI item)
helper that finds location first, then moves the entity into it
Definition inventory.c:1031
bool DropEntityWithTransform(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector transform[4])
Definition inventory.c:1293
proto native void LockInventory(int lockType)
bool ClearInventoryReservationEx(EntityAI item, InventoryLocation dst)
Definition inventory.c:764
proto native bool HasInventorySlot(int slotId)
static proto native bool ServerLocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, ParamsWriteContext ctx)
swaps two entities
bool HasAttachmentSlot(int slotId)
Definition inventory.c:188
static int GetInventoryCheckContext()
Definition inventory.c:375
bool IsInCargo()
Returns true if this Inventory owner is in cargo of something.
Definition inventory.c:397
proto native bool CanRemoveAttachmentEx(EntityAI attachment, int slot)
proto native bool HasEntityInCargo(notnull EntityAI e)
bool CanAddEntityIntoHands(notnull EntityAI item)
Test if entity can be put into hands.
Definition inventory.c:978
const int c_InventoryReservationTimeoutShortMS
Definition inventory.c:715
bool TakeEntityToCargoEx(InventoryMode mode, notnull EntityAI item, int idx, int row, int col)
moves item on specific cargo location
Definition inventory.c:1098
proto native bool IsInventoryLocked()
proto native void UnlockInventory(int lockType)
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:1211
proto native bool IsInventoryUnlocked()
static proto native bool TestDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix=false, int conflictCheckDepth=-1)
static proto native bool ClearInventoryReservation(EntityAI item, InventoryLocation dst)
static proto native bool LocationMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)
removes item from current inventory location and adds it to destination
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
Definition inventory.c:630
proto native bool CanAddEntityInCargoEx(notnull EntityAI e, int idx, int row, int col, bool flip)
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:1223
proto native int FindFreeLocationsFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull array< ref InventoryLocation > locs)
searches inventory for suitable location for @item
static proto native EntityAI LocationCreateLocalEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new local item directly at location @NOTE: the item is created localy, i.e....
bool TakeToDst(InventoryMode mode, notnull InventoryLocation src, notnull InventoryLocation dst)
move src to dst
Definition inventory.c:1056
static proto native bool CheckTakeItemRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
proto native void LockInventoryWithKey(notnull EntityAI key)
bool TakeEntityAsTargetAttachment(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
Definition inventory.c:1185
proto native bool CanAddAttachment(notnull EntityAI e)
Check if attachment can be added to any slot.
static proto native bool GetInventoryReservationCount(EntityAI item, InventoryLocation dst)
static proto native bool ExtendInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms)
proto native bool IsPlaceholderEntity(notnull Object e)
bool AddEntityToInventory(notnull EntityAI item)
add entity somewhere in inventory
Definition inventory.c:926
bool CanAddEntityIntoInventory(notnull EntityAI item)
Test if entity can be put to the inventory (Cargo, ProxyCargo, Attachment).
Definition inventory.c:970
bool OnInventoryJunctureFromServer(ParamsReadContext ctx)
proto native bool HasEntityInCargoEx(notnull EntityAI e, int idx, int row, int col)
proto native bool GetSlotLock(int slot)
proto native EntityAI GetInventoryOwner()
Engine native functions.
static proto native EntityAI LocationCreateEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)
creates new item directly at location
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...
bool IsCargoInHiearchy()
Returns true if inventory owner or his hiearchy parents are in cargo.
Definition inventory.c:423
bool ReplaceItemWithNew(InventoryMode mode, ReplaceItemWithNewLambdaBase lambda)
Definition inventory.c:1363
static proto native bool HasInventoryReservationCanAdd(EntityAI item, InventoryLocation dst)
Internally: !HasInventoryReservationEx(item, dst, FindInventoryReservationMode.ITEM,...
static bool SetGroundPosByOwner(EntityAI owner, notnull EntityAI item, out InventoryLocation ground)
Definition inventory.c:1257
proto native int GetSlotId(int index)
attachments
bool GetCurrentAttachmentSlotInfo(out int slot_id, out string slot_name)
Returns true if the item is currently attached and outputs attachment slot id and name.
Definition inventory.c:456
proto native bool CanRemoveEntityInCargoEx(notnull EntityAI e, int idx, int row, int col)
const int c_InventoryReservationTimeoutMS
reservations
Definition inventory.c:714
static int m_inventory_check_context
Definition inventory.c:82
bool TakeEntityAsAttachment(InventoryMode mode, notnull EntityAI item)
Definition inventory.c:1179
void EEInit()
Definition inventory.c:845
static proto native bool LocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
swaps two entities
proto native bool CanRemoveEntityInCargo(notnull EntityAI e)
bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
Definition inventory.c:1252
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
Definition inventory.c:380
static void OnServerInventoryCommandStatic(ParamsReadContext ctx)
Definition inventory.c:471
static proto native bool HasInventoryReservation(EntityAI item, InventoryLocation dst)
Internally: HasInventoryReservationEx(item, dst, FindInventoryReservationMode.LEGACY,...
static proto native bool LocationAddEntity(notnull InventoryLocation inv_loc)
adds item to inventory location
proto native bool HasKeys()
static bool CanForceSwapEntitiesEx(notnull EntityAI item1, InventoryLocation item1_dst, notnull EntityAI item2, out InventoryLocation item2_dst)
Definition inventory.c:666
const float c_MaxItemDistanceRadius
anti-cheats
Definition inventory.c:815
proto native int AttachmentCount()
Returns count of attachments attached to this item.
proto native bool CanLockInventoryWithKey(notnull EntityAI key)
locks
bool AddInventoryReservationEx(EntityAI item, InventoryLocation dst, int timeout_ms)
Definition inventory.c:718
static bool SetGroundPosByTransform(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector transform[4])
Definition inventory.c:1286
static proto native bool LocationCanRemoveEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be removed from ground/attachment/cargo/hands/....
static proto native bool LocationCanAddEntity(notnull InventoryLocation inv_loc)
queries if the entity contained in inv_loc.m_item can be added to ground/attachment/cargo/hands/....
void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
static bool MakeDstForSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, out InventoryLocation dst1, out InventoryLocation dst2)
helper function for swap
Definition inventory.c:1192
proto native bool HasEntityInInventory(notnull EntityAI item)
query inventory if item is somewhere
proto native bool FindFreeLocationForEx(notnull EntityAI item, FindInventoryLocationType flags, notnull InventoryLocation exclude, out notnull InventoryLocation loc)
FindFreeLocationForEx.
bool TakeEntityToTargetCargo(InventoryMode mode, notnull EntityAI target, notnull EntityAI item)
Put item into into cargo of another entity.
Definition inventory.c:1087
bool AreChildrenAccessible()
Returns true if item is considered reachable within inventory.
Definition inventory.c:442
static proto native bool CheckDropRequest(notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
proto native void SetFlipCargo(bool flip)
proto native int GetSlotIdCount()
void OnStoreSave(ParamsWriteContext ctx)
db store hook
proto native bool TestAddEntityInCargoEx(notnull EntityAI e, int idx, int row, int col, bool flip, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
static proto native bool CheckSwapItemsRequest(notnull Man requestingPlayer, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
proto native int GetAttachmentSlotId(int index)
proto native void ResetFlipCargo()
proto native bool SetSlotLock(int slot, bool locked)
proto native EntityAI FindAttachmentByName(string slotName)
Returns attached entity in slot (you can use EntityAI.GetActionComponentName to get slot id).
bool CanAddEntityToInventory(notnull EntityAI item, int flag=FindInventoryLocationType.ANY)
ask inventory if item could be placed somewhere in inventory
Definition inventory.c:906
static proto native bool HasInventoryReservationEx(EntityAI item, InventoryLocation dst, FindInventoryReservationMode itemMode, FindInventoryReservationMode parentMode)
itemMode will iterate over item reservations, parentMode will iterate over parent reservations
bool TakeEntityAsAttachmentEx(InventoryMode mode, notnull EntityAI item, int slot)
Definition inventory.c:1130
proto native bool CanAddAttachmentEx(notnull EntityAI e, int slot)
Check if attachment can be added to slot @NOTE: Note that slot index IS NOT slot ID!...
static proto native bool CheckMoveToDstRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
proto native bool CanAddSwappedEntity(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
proto native void UnlockInventoryWithKey(notnull EntityAI key)
proto native bool IsInventoryLockedForLockType(int lockType)
proto native bool CanRemoveAttachment(EntityAI attachment)
proto native bool TestAddEntityInCargoExLoc(notnull InventoryLocation loc, bool do_resevation_check, bool do_item_check, bool do_lock_check, bool do_occupancy_test, bool do_script_check, bool do_script_load_check)
static proto native bool CheckRequestSrc(notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
static proto native bool ServerLocationSyncMoveEntity(Man player, notnull EntityAI item, ParamsWriteContext ctx)
synchronously removes item from current inventory location and adds it to destination + sync via inve...
bool DropEntityInBounds(InventoryMode mode, EntityAI owner, notnull EntityAI item, vector halfExtents, float angle, float cosAngle, float sinAngle)
Definition inventory.c:1328
proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)
FindFreeLocationFor.
proto native int GetScriptLockCount()
bool TakeEntityToCargo(InventoryMode mode, notnull EntityAI item)
moves item to cargo of this intentory
Definition inventory.c:1080
proto native void FlipCargo()
proto native EntityAI FindAttachment(int slot)
Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)...
static proto native bool LocationRemoveEntity(notnull InventoryLocation inv_loc)
removes item from inventory location
bool TakeEntityAsTargetAttachmentEx(InventoryMode mode, notnull EntityAI target, notnull EntityAI item, int slot)
put item as attachment of target
Definition inventory.c:1137
bool DropEntity(InventoryMode mode, EntityAI owner, notnull EntityAI item)
Definition inventory.c:1266
bool CanAddEntityInto(notnull EntityAI item, FindInventoryLocationType flags=FindInventoryLocationType.ANY)
Asks inventory if item could be placed in inventory, hands, etc.
Definition inventory.c:961
static bool LocationCanAddEntityEx(notnull InventoryLocation inv_loc)
Definition inventory.c:350
bool OnStoreLoad(ParamsReadContext ctx, int version)
db load hooks
Definition inventory.c:837
proto native bool CanUnlockInventoryWithKey(notnull EntityAI key)
Abstracted event, not to be used, only inherited.
InventoryLocation.
provides access to slot configuration
Definition enmath.c:7
base class for transformation operations (creating one item from another)
void Execute(HumanInventoryWithFSM fsm_to_notify=null)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
Serializer ParamsReadContext
Definition gameplay.c:15
InventoryTraversalType
tree traversal type, for more see http://en.wikipedia.org/wiki/Tree_traversal
Definition gameplay.c:6
Serializer ParamsWriteContext
Definition gameplay.c:16
@ MOVE
Definition gizmoapi.c:4
@ LOCAL
Definition gizmoapi.c:13
enum ChatChannelType LEGACY
Legacy version, UNDER but without proxy support.
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
@ DEFAULT
enum ShapeType ErrorEx
proto native vector Vector(float x, float y, float z)
Vector constructor from components.
bool IsAuthoritative()
Definition hand_events.c:55
JUNCTURE_DENIED
Definition hand_events.c:31
@ FORCESWAP
Definition hand_events.c:14
@ DESTROY
Definition hand_events.c:15
@ TAKE
Definition hand_events.c:9
@ REPLACE
Definition hand_events.c:18
@ SWAP
swapping from ground
Definition hand_events.c:13
void ClearInventoryReservation()
FindInventoryLocationType
flags for searching locations in inventory
InventoryLocationType
types of Inventory Location