ItemPropertyOnHitCastSpell

From NWN Lexicon
Jump to: navigation, search

ItemPropertyOnHitCastSpell(int, int)

Sets an "on hit cast spell" item property.

itemproperty ItemPropertyOnHitCastSpell(
    int nSpell,
    int nLevel
);

Parameters

nSpell

IP_CONST_ONHIT_CASTSPELL_*

nLevel

Level at which to cast the spell


Description

Creates an item property that (when applied to a weapon item) causes a spell to be cast when a successful strike is made, or (when applied to armor) when it is struck by an opponent.

nSpell uses the IP_CONST_ONHIT_CASTSPELL_* constants.



Remarks

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.

The IP_CONST_ONHIT_CASTSPELL_* constant can be retrieved off this type of item property using GetItemPropertySubType. The spell level can be retrieved using GetItemPropertCostTableValue.


Version

1.61

Example

#include "x2_inc_itemprop"
//The include is for the IPSafeAddItemProperty function
 
//Makes the PC speaker's armor cast daze when hit, at level 5
void main()
{
    object oPC = GetPCSpeaker();
    object oItem = GetItemInSlot(INVENTORY_SLOT_CHEST, oPC);
    if (!GetIsObjectValid(oItem)) return;
 
    itemproperty ipAdd = ItemPropertyOnHitCastSpell(IP_CONST_ONHIT_CASTSPELL_DAZE, 5);
 
    IPSafeAddItemProperty(oItem, ipAdd);
}

See Also

functions: 

ItemPropertyOnMonsterHitProperties

constants: 

IP_CONST_ONHIT_CASTSPELL_* Constants



 author: Lilac Soul, editor: Peter Busby