ff_i_inventory
Inventory manipulation functions.
Helpers to iterate, count, copy, and move items between creatures, placeables, and the ground.
-
int GetIsInventoryEmpty(object oObject)
- Parameters:
oObject – An object with inventory.
Return TRUE if inventory is empty.
-
void DestroyInventory(object oTarget, float fDelay = 0.0f)
- Parameters:
oTarget – Target inventory
fDelay – Delay in seconds before each item is destroyed. Defaults to 0.0f.
Destroy oTarget inventory (irrevocably).
-
void IdentifyInventory(object oTarget)
- Parameters:
oTarget – An object with inventory.
Mark every item in oTarget’s inventory as identified.
Source code
// @code
// -----------------------------------------------------------------------------
//! @brief Return TRUE if inventory is empty
//! @param oObject An object with inventory.
int GetIsInventoryEmpty(object oObject);
int GetIsInventoryEmpty(object oObject)
{
object oItem = GetFirstItemInInventory(oObject);
return !GetIsObjectValid(oItem);
}
// -----------------------------------------------------------------------------
//! @brief Destroy oTarget inventory (irrevocably).
//! @param oTarget Target inventory
//! @param fDelay Delay in seconds before each item is destroyed. Defaults to 0.0f.
void DestroyInventory(object oTarget, float fDelay = 0.0f);
// Copy of the function from ff_i_object, to avoid #include headaches
object _DestroyObjectEx(object oObject, float fDelay = 0.0f)
{
if (GetHasInventory(oObject))
DestroyInventory(oObject, fDelay);
SetItemCursedFlag(oObject, FALSE);
SetPlotFlag(oObject, FALSE);
DestroyObject(oObject, fDelay);
return OBJECT_INVALID;
}
void DestroyInventory(object oTarget, float fDelay = 0.0f)
{
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem))
{
_DestroyObjectEx(oItem, fDelay);
oItem = GetNextItemInInventory(oTarget);
}
}
// -----------------------------------------------------------------------------
//! @brief Mark every item in oTarget's inventory as identified.
//! @param oTarget An object with inventory.
void IdentifyInventory(object oTarget)
{
object oItem = GetFirstItemInInventory(oTarget);
while (GetIsObjectValid(oItem))
{
SetIdentified(oItem, TRUE);
oItem = GetNextItemInInventory(oTarget);
}
}