AddItemProperty(int, itemproperty, object, float)

From NWN Lexicon
Jump to: navigation, search

Add an itemproperty to an item.

void AddItemProperty(
    int nDurationType,
    itemproperty ipProperty,
    object oItem,
    float fDuration = 0.0f
);

Parameters

nDurationType
A DURATION_TYPE_* constant.
ipProperty
Itemproperty to add.
oItem
Item to add the property to.
fDuration
Duration (if added temporarily). (Default: 0.0f)

Description

Adds an itemproperty to the specified item. Only temporary and permanent duration types are allowed.

Remarks

The itemproperty must first be created using one of the many ItemProperty functions. In this respect, it works much like effects, which must first be created, then applied.

It will often be a good idea to remove similar itemproperties from the item first. There's a command in the x2_inc_itemprop include file called IPSafeAddItemProperty() which will do that for you.

Version

1.61

Example

// Have the NPC upgrade the PC speaker's helmet to a Helmet of Undead Turning
void main()
{
    object oPC     = GetPCSpeaker();
    object oHelmet = GetItemInSlot(INVENTORY_SLOT_HEAD, oPC);
 
    if (!GetIsObjectValid(oHelmet))
        return;
 
    itemproperty ipAddFeat = ItemPropertyBonusFeat(FEAT_TURN_UNDEAD);
    AddItemProperty(DURATION_TYPE_PERMANENT, ipAddFeat, oHelmet);
}

See Also

functions:  IPSafeAddItemProperty
constants:  DURATION_TYPE_* Constants


author: Lilac Soul, editor: Charles Feduke