itemproperty

From NWN Lexicon
Jump to: navigation, search

Contains information which defines the various property which an item has. It essentially is a special engine-only struct which you edit or get information from using different functions. It can be an existing item property or a newly created one ready for being applied to an item temporarily or permanently.

Invalid Item Properties

Note that since you can pass itemproperty around in functions there is no equivalent to OBJECT_INVALID for item properties. Instead if you wish to pass an invalid one, such as a return value if a certain property isn't found, just define an empty one and return that. For instance the example function will return an invalid item property that can be checked with GetIsItemPropertyValid by anything calling it.

Example

// Gets the first item property, if any, matching nSpellID and returns it, or an invalid item property if none matching are found
itemproperty GetFirstItemPropertyOnItemWithSpell(int nSpellID, object oItem)
{
    int nItemSpell;
    itemproperty ipInvalid;
    itemproperty ip = GetFirstItemProperty(oItem);
    while (GetIsItemPropertyValid(ip))
    {
        if (GetItemPropertyType(ip) == ITEM_PROPERTY_CAST_SPELL)
        {
            // This returns an ID from iprp_spells - ie; it is a spell, but the level / spell ID is codified in another 2DA. So look it up.
            nItemSpell = StringToInt(Get2DAString("iprp_spells","SpellIndex",GetItemPropertySubType(ip)));
 
            // Check if matches
            if(nItemSpell == nSpellID)
            {
                return ip;
            }
        }
        ip = GetNextItemProperty(oItem);
    }
    return ipInvalid;
}

See Also

See any ItemProperty related functions on the lexicon. Alas no setup category for all of them yet.