ItemPropertyOnHitProps(int, int, int)

From NWN Lexicon
Jump to navigationJump to search

Sets an OnHit itemproperty.

itemproperty ItemPropertyOnHitProps(
    int nProperty,
    int nSaveDC,
    int nSpecial = 0
);

Parameters

nProperty
IP_CONST_ONHIT_*
nSaveDC
IP_CONST_ONHIT_SAVEDC_*
nSpecial
Varies, see description. (Default: 0)


Description

Sets item property On hit do effect property. You must specify the on hit property constant ( IP_CONST_ONHIT_* ) and the save DC constant ( IP_CONST_ONHIT_SAVEDC_* ).

Some of the item properties require a special parameter as well. If the property does not require one you may leave out the last one. The list of the ones with 3 parameters are as follows:


Remarks

Though not mentioned by BioWare's description, the LEVELDRAIN and WOUNDING also require the special parameter of 1-5, being how many levels to drain / the amount of wounding.

The IP_CONST_ONHIT_* constant can be retrieved off this type of item property using GetItemPropertySubType. The IP_CONST_ONHIT_SAVEDC_* constant can be retrieved using GetItemPropertCostTableValue. There is no entry in itempropdef.2da for the param1 table, but I speculate that the nSpecial value can be retrieved by using GetItemPropertyParam1Value.

Note that ItemPropertyHolyAvenger has a special On Hit effect for dispel magic. It does not trigger the spells script and simply applies EffectDispelMagicAll(10) to the target hit (with a 50% chance).

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

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. Check IPSafeAddItemProperty for current bug report.


Version

1.61

Example

<nowiki>#include "x2_inc_itemprop"
</nowiki>//The include is for the IPSafeAddItemProperty function

//Makes the PC speaker's onhand weapon cause intelligence-decreasing
//poison OnHit of the target with a pretty rough DC.
void main()
{
object oPC = GetPCSpeaker();
object oItem = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
int nProperty = IP_CONST_ONHIT_ITEMPOISON;
int nSaveDC = IP_CONST_ONHIT_SAVEDC_26;
int nSpecial = IP_CONST_POISON_1D2_INTDAMAGE;
if (!GetIsObjectValid(oItem)) return; // nothing at hand

itemproperty ipAdd = ItemPropertyOnHitProps(nProperty, nSaveDC, nSpecial);

IPSafeAddItemProperty(oItem, ipAdd);
}

See Also

functions: 

ItemPropertyOnMonsterHitProperties ItemPropertyHolyAvenger

constants: 

IP_CONST_ONHIT_SAVEDC_* Constants



 author: Lilac Soul, editor: Peter Busby