itemproperty
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;
}
Item Property Engine Workings
Item properties are technically in engine just slightly different effects. Generally item properties which apply some kind of effect (for instance ItemPropertyDamageReduction) get the right values from the 2das and then apply the right effect (in this example EffectDamageReduction) with a hidden internally-defined engine duration of "DURATION_TYPE_EQUIPPED" that is hidden from being returned by GetFirstEffect.
The data structures are so similar this is worth noting mainly if you are dealing with NWNX and can see/edit them.
| GetEffectInteger equivalent | Item Property Function | ItemEffectCustom parameter |
|---|---|---|
| 0 | GetItemPropertyType | nType |
| 1 | GetItemPropertySubType | nSubType |
| 2 | GetItemPropertyCostTable | |
| 3 | GetItemPropertyCostTableValue | nCostTableValue |
| 4 | GetItemPropertyParam1 | |
| 5 | GetItemPropertyParam1Value | nParam1Value |
See Also
See any ItemProperty related functions on the lexicon.