GetItemsInInventory

From Dragon Age Toolset Wiki
Jump to: navigation, search

Gets all items in an object inventory

object[] GetItemsInInventory(
object oObject,
int nGetItemsOptions = GET_ITEMS_OPTION_ALL,
int nBaseItemType = 0,
string sTagFilter = "",
int bIgnorePlotItems = FALSE
);
Parameters:
oObject
A creature or placeable with an inventory
nGetItemsOptions
A GET_ITEMS_OPTION_* constant
nBaseItemType
Only return items with a matching base item type or 0 to disable this filter
sTagFilter
Only return items with a matching tag or "" to disable this filter
bIgnorePlotItems
Only return items which are NOT plot items or FALSE to disable this filter
Returns:

An array of all items in/on the object that match the specified filters

Source:

script.ldf

Description

Provides access to a creature's or placeable's inventory and equipped items.

Remarks

The nGetItemsOptions filter is not a bit field, i.e. you cannot use the bitwise or operator to combine options.

The nBaseItemType filter does not work on placeable's inventories.

Examples

// Remove all equipped items from a creature and put them in the creature's inventory.
void UnequipAllEquippedItems(object oCreature)
{
    int nItem;
 
    object[] oItems = GetItemsInInventory(oCreature, GET_ITEMS_OPTION_EQUIPPED);
    int nItems = GetArraySize(oItems);
 
    for(nItem = 0; nItem < nItems; nItem++)
    {
        UnequipItem(oCreature, oItems[nItem]);
    }
}