AddItemProperty(int, itemproperty, object, float)

From NWN Lexicon
Jump to navigationJump to 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.

An item can have a maximum of 254 properties. Unlike the toolset there are less restrictions (eg: you can add more than 8 ItemPropertyCastSpell ones that can be cast)


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 (reason being is they might not work well together, only the first being used or whatever). There's a command in the x2_inc_itemprop include file called IPSafeAddItemProperty() which will do that for you.

DURATION_TYPE_PERMANENT is for permanent itemproperties, and DURATION_TYPE_TEMPORARY for temporary itemproperties.

Duration of the item property can affect if it is automatically removed - temporary ones applied from a creature who then rests are removed. Permanent ones last like any other usual toolset applied item property and essentially don't have a creator.

Effect Subtype overview:

Effect Subtype Duration Type Dispellable Removed by Resting if effect on self Removed by Resting if effect cast by self (on any object) Removed by Dying if effect on self
Magical Any ✓ ✓ ✓ ✓
Extraordinary Any ✖ ✓ ✖ ✓
Supernatural Temporary ✖ ✓ ✖ ✓
Supernatural Permanent ✖ ✖ ✖ ✓
Unyielding Any ✖ ✖ ✖ ✖
Item Properties Temporary ✖ ✖ ✓ ✖
Item Properties Permanent ✖ ✖ ✖ ✖


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(IP_CONST_FEAT_KNOCKDOWN);
    AddItemProperty(DURATION_TYPE_PERMANENT, ipAddFeat, oHelmet);
}

See Also

functions:  IPSafeAddItemProperty
constants:  DURATION_TYPE_* Constants



author: Lilac Soul, editor: Charles Feduke