DIFF

class GameInventorySource

script counterpart to engine's class Inventory

Constants 3

Members 1

protected static int m_inventory_check_context = InventoryCheckContext.DEFAULT

Methods 152

proto native void DumpInventoryDebug()DEVELOPER

dump out failed inventory operations of the current inventory

static proto native void DumpStaticInventoryDebug()DEVELOPER

dump out a more global list of failed inventory operations

proto native int CountInventory()

almost identical to EnumerateInventory except it does not return items

Returns: number of items

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)

typeName
type to create
row
the row of cargo to be created at
col
the column of cargo to be created at
proto native bool HasEntityInCargoEx(notnull EntityAI e, int idx, int row, int col)
proto native bool CanAddEntityInCargoExLoc(InventoryLocation loc)
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)
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)
proto native bool CanRemoveEntityInCargo(notnull EntityAI e)
proto native bool CanRemoveEntityInCargoEx(notnull EntityAI e, int idx, int row, int col)
proto native int GetAttachmentSlotId(int index)
index
index of the slot for attachment (@see GetAttachmentSlotsCount)

Returns: slot for attachment

proto native bool HasInventorySlot(int slotId)

Returns: true if this entity has inventory slot with id=slotId

proto native int AttachmentCount()

Returns count of attachments attached to this item

proto native EntityAI GetAttachmentFromIndex(int index)

Returns: attached entity by attachment index @NOTE: index is not slot! for getting attachment by slot use FindAttachment

Referenced by ActionDetachPowerSourceFromPanel.Process(), ActionTargetsCursor.AttachmentsWithInventoryOrCargoCount(), Blowtorch.GetGasCanister()
Show 40 more, CachedEquipmentStorage.ProcessAttachments(), ContainerWithCargoAndAttachments.RecomputeContainers(), EntityAI.EEInit(), EntityAI.FixEntity(), EntityAI.GetAttachmentByConfigTypeName(), EntityAI.GetAttachmentByType(), EntityAI.GetInventoryAndCargoWeight(), Environment.ApplyDrynessToItemEx(), Environment.ApplyWetnessToItem(), Environment.BodyPartHeatProperties(), Environment.ProcessItemHierarchyRecursive(), Environment.ProcessItemsDryness(), Environment.ProcessItemsTemperature(), Environment.ProcessItemsWetness(), FireplaceBase.BurnItemsInFireplace(), FireplaceBase.GetFuelCount(), FireplaceBase.GetKindlingCount(), ImprovisedExplosive.EEHealthLevelChanged(), ImprovisedExplosive.OnActivatedByItem(), ImprovisedExplosive.OnDisarmed(), ItemBase.DamageItemAttachments(), ItemBase.GetNumberOfItems(), Magnum_Base.SetAttachmentsHealth(), MiscGameplayFunctions.ThrowAllItemsInInventory(), Plastic_Explosive.EEHealthLevelChanged(), Plastic_Explosive.OnDisarmed(), Plastic_Explosive.OnTriggerAttached(), PlayerBase.CalculateVisibilityForAI(), PlayerBase.FindCargoByBaseType(), PlayerBase.GetMagazineToReload(), PluginConfigScene.SaveSceneObjects(), PropertyModifiers.UpdateModifiers(), QuickBarBase.updateSlotsCount(), RadialQuickbarMenu.CheckForLightsAndNVG(), SceneObject.GetAttachments(), TrapBase.GetClosestCarWheel(), TrapSpawnBase.DetachAllAttachments(), TripwireTrap.SetInactive(), TripwireTrap.UpdateProxySelections(), and UniversalTemperatureSourceLambdaBaseImpl.UpdateVicinityTemperatureRecursive()
proto native EntityAI FindAttachment(int slot)

Returns attached entity in slot (you can use InventorySlots.GetSlotIdFromString(name) to get slot id)

proto native EntityAI FindAttachmentByName(string slotName)

Returns attached entity in slot (you can use EntityAI.GetActionComponentName to get slot id)

proto native bool HasAttachment(notnull EntityAI e)

brief Returns True if entity is attached to this

proto native bool HasAttachmentEx(notnull EntityAI e, int slot)

brief Returns True if entity is attached to this in slot

proto native bool CanRemoveAttachment(EntityAI attachment)
proto native bool CanRemoveAttachmentEx(EntityAI attachment, int slot)
proto native EntityAI FindPlaceholderForSlot(int slot)

Returns placeholder entity for slot (naked arms, legs etc)

proto native bool IsPlaceholderEntity(notnull Object e)
proto native bool GetCurrentInventoryLocation(out notnull InventoryLocation loc)

returns information about current item location

out loc
current InventoryLocation

Returns: true if current location retrieved (and is valid)

proto native bool FindFreeLocationFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull InventoryLocation loc)

FindFreeLocationFor

in item
item that would be placed in inventory
out loc
the InventoryLocation the item can be placed to

Returns: true if found any, false otherwise

proto native bool FindFreeLocationForEx(notnull EntityAI item, FindInventoryLocationType flags, notnull InventoryLocation exclude, out notnull InventoryLocation loc)

FindFreeLocationForEx

in item
item that would be placed in inventory
out loc
the InventoryLocation the item can be placed to

Returns: true if found any, false otherwise

proto native int FindFreeLocationsFor(notnull EntityAI item, FindInventoryLocationType flags, out notnull array<ref InventoryLocation> locs)

searches inventory for suitable location for @item

Example:

in item
item that would be placed in inventory
in flags
flags affecting selection ( @see FindInventoryLocation )
out locs
array of InventoryLocations the item can be placed to

Returns: number of suitable inventory locations

Entity bino = g_Game.CreateObject("Binoculars", "3312 0 854");
EntityAI bino2;
if (Class.CastTo(bino2, bino))
{
  array<ref InventoryLocation> a = new array<ref InventoryLocation>; // 1) allocate memory for array
  for (int i = 0; i < 10; ++i)
  {
    a.Insert(new InventoryLocation); // 2) pre-allocate inventorylocations from script. engine only fills them in, engine does not allocate memory to avoid mixing.
  }

  int sz = player.FindFreeLocationsFor(bino, FindInventoryLocationType.ANY_CARGO | FindInventoryLocationType.ATTACHMENT, a); // 3) ask engine to fill the locations
  if (sz > 0)
  {
    InventoryLocation src = new InventoryLocation;
    bino2.GetCurrentInventoryLocation(src); // 5) get current location

    InventoryLocation dst = a[0]; // 6) get first (this is only example)

    ... use src and dst
  }
}
static proto native EntityAI LocationCreateLocalEntity(notnull InventoryLocation inv_loc, string type, int iSetupFlags, int iRotation)

creates new <b>local</b> item directly at location @NOTE: the item is created localy, i.e. it's not registered to network

in type
item type to be placed in inventory

Returns: created entity, null otherwise

static bool LocationCanAddEntityEx(notnull InventoryLocation inv_loc)
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/...

Returns: true if can be added, false otherwise

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/...

Returns: true if can be added, false otherwise

static int GetInventoryCheckContext()
static bool LocationCanMoveEntitySyncCheck(notnull InventoryLocation src, notnull InventoryLocation dst)
static proto native EntityAI LocationGetEntity(notnull InventoryLocation inv_loc)

query the entity at the specific inventory location

Returns: entity at the location, null otherwise

bool IsCargoInHiearchy()

Returns true if inventory owner or his hiearchy parents are in cargo

static proto native bool LocationAddEntity(notnull InventoryLocation inv_loc)

adds item to inventory location

Returns: true if success, false otherwise

static proto native bool LocationRemoveEntity(notnull InventoryLocation inv_loc)

removes item from inventory location

Returns: true if success, false otherwise

static proto native bool LocationMoveEntity(notnull InventoryLocation src_loc, notnull InventoryLocation dst_loc)

removes item from current inventory location and adds it to destination

Returns: true if success, false otherwise

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 involved

Returns: true if success, false otherwise

Referenced by AttachNewMagazine.OnEntry(), ChamberMultiBullet.OnAbort(), ChamberMultiBullet.OnEntry()
Show 47 more, ChamberMultiBullet.OnExit(), DayZPlayerInventory.HandleTakeToDst(), DayZPlayerInventory.TakeToDst(), DayZPlayerInventory.ValidateSwap(), DayZPlayerInventory.ValidateSyncMove(), DayZPlayerUtils.HandleDropMagazine(), DetachOldMagazine.OnExit(), OnServerInventoryCommandStatic(), TakeToDst(), HandActionDrop.Action(), HandActionMoveTo.Action(), HandActionTake.Action(), HandActionThrow.Action(), HandAnimatedMoveToDst_W4T.OnEntry(), HandAnimatedMoveToDst_W4T_Basic.OnEntry(), HandTakingAnimated_Show.OnEntry(), LoopedChambering.OnAbort(), LoopedChambering.OnEntry(), LoopedChambering.OnExit(), LoopedChamberingCombineChamberInternalMagazine.OnAbort(), LoopedChamberingCombineChamberInternalMagazine.OnEntry(), LoopedChamberingCombineChamberInternalMagazine.OnExit(), LoopedChamberingEjectLast.OnAbort(), LoopedChamberingEjectLast.OnEntry(), LoopedChamberingEjectLast.OnExit(), PluginInventoryRepair.MoveItemToCorrectPosition(), PluginInventoryRepair.RepairItem(), RemoveNewMagazineFromInventory.OnEntry(), SwapOldAndNewMagazine.OnEntry(), WeaponAttachMagazine.OnAbort(), WeaponAttachMagazine.OnEntry(), WeaponAttachMagazineOpenBoltCharged.OnAbort(), WeaponAttachMagazineOpenBoltCharged.OnEntry(), WeaponChambering.OnAbort(), WeaponChambering.OnEntry(), WeaponChambering.OnExit(), WeaponDetachingMag_Store.OnExit(), WeaponDetachingMag_StoreRemoveChamberBullet.OnExit(), WeaponMagnumChambering.OnAbort(), WeaponMagnumChambering.OnEntry(), WeaponMagnumChambering.OnExit(), WeaponReplacingMagAndChamberNext.OnAbort(), WeaponReplacingMagAndChamberNext.OnEntry(), WeaponReplacingMagAndChamberNext.OnExit(), WeaponReplacingMagAndChamberNextOpenBoltCharged.OnAbort(), WeaponReplacingMagAndChamberNextOpenBoltCharged.OnEntry(), and WeaponReplacingMagAndChamberNextOpenBoltCharged.OnExit()
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

Returns: true if success, false otherwise

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 inventory command no anims involved

Returns: true if success, false otherwise

static proto native bool ServerLocationSwap(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, ParamsWriteContext ctx)

swaps two entities

Returns: true if success, false otherwise

static proto native bool ServerHandEvent(notnull Man player, notnull EntityAI item, ParamsWriteContext ctx)

hand event to clients

Returns: true if success, false otherwise

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 another conflicting entity (i.e. car) then the transform will be snapped to the nearest outer edge. If no valid snapping transformation could be found, then the output from 'PlaceOnSurface' is used

useValuesInMatrix
Is ignored if transformation overlaps with possible conflicting entity. If no valid transform is found and this is false then the transform at the owner is used for 'PlaceOnSurface'
conflictCheckDepth
If -1 then no conflict depth check is performed, if 0 then it only checks to see if it conflicts but doesn't perform snapping

Returns: true if valid transformation found near owner

static proto native bool TestDropEntityPos(EntityAI owner, notnull EntityAI item, out vector mat[4], bool useValuesInMatrix = false, int conflictCheckDepth = -1)
static proto native bool CanSwapEntities(notnull EntityAI item1, notnull EntityAI item2)

test if ordinary swap can be performed.

Ordinary in the sense that the two items has equal sizes and can be swapped without additional space.

[in] item1 first item
[in] item2 second item

Returns: true if can be swapped

Referenced by CanSwapEntitiesEx()
static bool CanSwapEntitiesEx(notnull EntityAI item1, notnull EntityAI item2)
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.

[in] item1 is the forced item (primary)
[in] item1_dst optional destination for item1 (null if item1 goes to place of item2)
[in] item2 second item that will be replaced by the item1. (secondary)
[out] item2_dst second item's potential destination (if null, search for item_dst2 is ommited). if (NOT null AND IsValid()), then it is tried first, without search to inventory

Returns: true if can be force swapped

proto native bool CanAddSwappedEntity(notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2)
static proto native bool AddInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms)
bool AddInventoryReservationEx(EntityAI item, InventoryLocation dst, int timeout_ms)
static proto native bool ExtendInventoryReservation(EntityAI item, InventoryLocation dst, int timeout_ms)
static proto native bool HasInventoryReservation(EntityAI item, InventoryLocation dst)

Internally: HasInventoryReservationEx(item, dst, FindInventoryReservationMode.LEGACY, FindInventoryReservationMode.LEGACY)

Referenced by ActionBase.InventoryReservation(), ActionManagerClient.HasHandInventoryReservation(), ActionRemoveSeed.InventoryReservation()
Show 42 more, ActionTakeArrow.InventoryReservation(), ActionTakeArrowToHands.InventoryReservation(), ActionTakeHybridAttachment.InventoryReservation(), ActionTakeItem.InventoryReservation(), AttachmentCategoriesRow.MouseClick(), ContainerWithCargoAndAttachments.MouseClick2(), DeferredForceSwapEntities.ReserveInventory(), DeferredSwapEntities.ReserveInventory(), DeferredTakeToDst.ReserveInventory(), EmoteManager.PlaySurrenderInOut(), EmoteManager.SetEmoteLockState(), FirearmActionAttachMagazine.InventoryReservation(), FirearmActionAttachMagazineQuick.InventoryReservation(), HandEventBase.ReserveInventory(), HandEventSwap.ReserveInventory(), HandsContainer.EquipItem(), HandsContainer.MouseClick2(), HandsContainer.TransferItem(), HandsContainer.TransferItemToVicinity(), HandStateEmpty.OnEntry(), HandStateEquipped.OnEntry(), Icon.DoubleClick(), Icon.MouseClick(), Icon.Swap(), Inventory.UpdateConsoleToolbar(), ItemBase.CanBeCombined(), ItemBase.OnRightClick(), ItemManager.EvaluateContainerDragabilityDefault(), PlayerBase.CanDropEntity(), PlayerBase.OnQuickBarSingleUse(), PlayerContainer.MouseClick(), VicinitySlotsContainer.DoubleClick(), VicinitySlotsContainer.Select(), WeaponManager.CanAttachMagazine(), WeaponManager.CanDetachMagazine(), WeaponManager.CanEjectBullet(), WeaponManager.CanLoadBullet(), WeaponManager.CanLoadMultipleBullet(), WeaponManager.CanSwapMagazine(), WeaponManager.CanUnjam(), WeaponManager.InventoryReservation(), and ZombieContainer.DoubleClick()
static proto native bool HasInventoryReservationCanAdd(EntityAI item, InventoryLocation dst)

Internally: !HasInventoryReservationEx(item, dst, FindInventoryReservationMode.ITEM, FindInventoryReservationMode.DST)

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

static proto native bool GetInventoryReservationCount(EntityAI item, InventoryLocation dst)
proto native int GetAnyInventoryReservationCount()
proto native bool CanLockInventoryWithKey(notnull EntityAI key)
proto native bool CanUnlockInventoryWithKey(notnull EntityAI key)
proto native void LockInventoryWithKey(notnull EntityAI key)
proto native void UnlockInventoryWithKey(notnull EntityAI key)
proto native bool HasKeys()
proto native int GetScriptLockCount()
proto native bool IsInventoryUnlocked()
static proto native bool CheckRequestSrc(notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
static proto native bool CheckDropRequest(notnull Man requestingPlayer, notnull InventoryLocation src, float radius)
static proto native bool CheckTakeItemRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
static proto native bool CheckMoveToDstRequest(notnull Man requestingPlayer, notnull InventoryLocation src, notnull InventoryLocation dst, float radius)
static proto native bool CheckSwapItemsRequest(notnull Man requestingPlayer, notnull InventoryLocation src1, notnull InventoryLocation src2, notnull InventoryLocation dst1, notnull InventoryLocation dst2, float radius)
static proto native bool CheckManipulatedObjectsDistances(notnull EntityAI e0, notnull EntityAI e1, float radius)
void Init()

called by engine right after creation of entity

bool OnStoreLoad(ParamsReadContext ctx, int version)

db load hooks

void OnAfterStoreLoad()
void OnStoreSave(ParamsWriteContext ctx)

db store hook

bool CanAddEntityToInventory(notnull EntityAI item, int flag = FindInventoryLocationType.ANY)

ask inventory if item could be placed somewhere in inventory

All available inventory locations (hands, cargo, attachments, proxycargo, ...) are traversed recursively from root to leafs.

in item
item to be placed in inventory

Returns: true if item can be added, false otherwise

bool AddEntityToInventory(notnull EntityAI item)

add entity somewhere in inventory

All available inventory locations (hands, cargo, attachments, proxycargo, ...) are traversed recursively from root to leafs.

@NOTE: AddEntityToInventory does not perform the checks the CanAddEntityToInventory does (script conditions for example). if not sure, always call CanAddEntityToInventory before AddEntityToInventory.

in item
item to be placed in inventory

Returns: true if item can be added, false otherwise

bool CanRemoveEntity()

Returns if entity can be removed from its current location

bool CanAddEntityInto(notnull EntityAI item, FindInventoryLocationType flags = FindInventoryLocationType.ANY)

Asks inventory if item could be placed in inventory, hands, etc.

Location is based on the flags parameter. This method is used in methods that are asking for if item can be placed in specific location, like CanAddEntityToInventory, CanAddEntityInHands, etc.

in item
item to be placed in inventory
in flags
FindInventoryLocationType

Returns: true if item can be added, false otherwise

bool CanAddEntityIntoInventory(notnull EntityAI item)

Test if entity can be put to the inventory (Cargo, ProxyCargo, Attachment)

bool OnInputUserDataProcess(ParamsReadContext ctx)
bool OnInventoryJunctureFromServer(ParamsReadContext ctx)
void OnInventoryJunctureFailureFromServer(ParamsReadContext ctx)
void OnServerInventoryCommand(ParamsReadContext ctx)
Referenced by DropEntity()
bool TakeEntityToInventory(InventoryMode mode, FindInventoryLocationType flags, notnull EntityAI item)

Put item anywhere into this entity (as attachment or into cargo, recursively)

@NOTE: Predictive.* / Local.* functions: a) 'Predictive' means that the operation uses Client-Side Prediction, i.e. the action runs the same code on both, client AND server.

b) 'Local' operation executes from where it is run, i.e. the operation from client is NOT sent to server, and only client performs the inventory operation (TakeEntityTo.*) this behaviour is necessary when inventory operations are ALREADY synchronized by another means, like Actions. For example @see ActionTakeItemToHands that performs OnCompleteServer and OnCompleteClient with synchronization set to false in order to avoid duplicate synchronization.

in mode
inventory mode
in flags
preferred location, @see FindInventoryLocationType
in item
item to be taken in inventory

Returns: true on success

bool TakeEntityToCargo(InventoryMode mode, notnull EntityAI item)

moves item to cargo of this intentory

in mode
inventory mode
in item
item to be put in this inventory as cargo
bool SwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2)
bool ForceSwapEntities(InventoryMode mode, notnull EntityAI item1, notnull EntityAI item2, notnull InventoryLocation item2_dst)
static bool SetGroundPosByTransform(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector transform[4])
static void SetGroundPosByOwnerBounds(EntityAI owner, notnull EntityAI item, out InventoryLocation ground, vector halfExtents, float angle, float cosAngle, float sinAngle)
Referenced by DropEntityInBounds()
proto native void SetFlipCargo(bool flip)
proto native void FlipCargo()
proto native void ResetFlipCargo()