IPSafeAddItemProperty

From NWN Lexicon
Jump to: navigation, search

IPSafeAddItemProperty(object, itemproperty, float, int, int, int)

Safely add an itemproperty to an item.

void IPSafeAddItemProperty(
    object oItem,
    itemproperty nip,
    float fDuration = 0.0f,
    X2_IP_ADDPROP_POLICY_REPLACE_EXISTING,
    int bIgnoreDurationType = FALSE,
    int bIgnoreSubType = FALSE
);

Parameters

oItem

Item to add property to

nip

Itemproperty to add

fDuration

0.0 for permanent, anything else is temporary (Default: 0.0f)

nAddItemPropertyPolicy

X2_IP_ADDPROP_POLICY_REPLACE_EXISTING )

bIgnoreDurationType

TRUE or FALSE (Default: FALSE)

bIgnoreSubType

TRUE or FALSE (Default: FALSE)


Description

Add an item property in a safe fashion, preventing unwanted stacking.

* Parameters:
* oItem - the item to add the property to
* ip - the itemproperty to add
* fDuration - set 0.0f to add the property permanent, anything else is temporary
* nAddItemPropertyPolicy - How to handle existing properties. Valid values are:
* X2_IP_ADDPROP_POLICY_REPLACE_EXISTING - remove any property of the same type, subtype, durationtype before adding;
* X2_IP_ADDPROP_POLICY_KEEP_EXISTING - do not add if any property with same type, subtype and durationtype already exists;
* X2_IP_ADDPROP_POLICY_IGNORE_EXISTING - add itemproperty in any case - Do not Use with OnHit or OnHitSpellCast props!
*
* bIgnoreDurationType - If set to TRUE, an item property will be considered identical even if the DurationType is different. Be careful when using this with X2_IP_ADDPROP_POLICY_REPLACE_EXISTING, as this could lead to a temporary item property removing a permanent one

* bIgnoreSubType - If set to TRUE an item property will be considered identical even if the SubType is different.



Remarks

The itemproperty commands are special constructors - they construct an itemproperty "object" which can then be, for instance, applied to an item using the AddItemProperty command. Much like effects need to be first constructed, then applied with ApplyEffectToObject.


Known Bugs

Uses RemoveItemProperty, which has an accumulator
bug that may give an erroneous Stacking error message or affect subsequent functions in the same script.- 1/16/04, NWN Toolset version vts026, game version 1.61.8042 English
See test code under ItemPropertyLimitUseByAlign. -PB


Requirements

#include " x2_inc_itemprop "

Version

1.61

See Also

functions: 

RemoveItemProperty

constants: 

X2_IP_ADDPROP_POLICY_* Constants



 author: Lilac Soul, editor: Peter Busby