ItemPropertyOnHitCastSpell ... On Different Weapon Types (Resolved!)

I started looking into this item property, as I was hoping to allow buffing of various ammo types with the bless spell. The spell does already have a bonus of sorts, but I was considering adding some others …


I note that this supposedly adds the “ONHIT_SlayRakshasa” property from the iprp_onhitspell.2da. This in turn is supposed to fire the spell index 689, which fires the x2_s3_slayraks script.

I copied the redundant script from NWN1 data and edited it to fire debug.

Here is the problem … When trying to add this property to a bunch of arrows, it did not appear to take hold. HOWEVER, if I add the property at build time to the arrows, then my debug script does indeed fire!

So, it appears I can add On Hit Cast properties to arrows, but currently, only directly from the toolset, as this ItemPropertyOnHitCastSpell property does not appear to work with ammo. Now, it may work with normal weapons, I guess, but I have not had time to test it yet.

Anyway, does anyone know if this function can add On Hit Cast properties to “normal” weapons (not ammo), and/or, should this also have worked with ammo?

I suppose I can do some kind of item replacement upon casting if need be, but I’d rather simply add the property if possible. i.e. Switch the target stack with a stack with the property already on them. And I believe I should be able to address the “badstref” where the old 2da line is left blank (because there are no official Rakshasa’s in NWN2).

I would just like to know if anyone has been able to ascertain the limitations (or not) when it comes to applying this property to weapon items.

Thanks in advance. Must sleep now. :sleeping:

before I go, here is a snippet of the Bless spell script I was playing around with …

if(GetObjectType(oTarget) == OBJECT_TYPE_ITEM)
		int AmmoType = GetBaseItemType(oTarget);
        if (AmmoType == 20 || AmmoType == 25 || AmmoType == 27)
			SendMessageToAllPCs(GetName(oCaster) + " blesses the ammunition.");
			itemproperty ipBonusDamage = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_PIERCING, IP_CONST_DAMAGEBONUS_1);
			if(AmmoType == 27){ipBonusDamage = ItemPropertyDamageBonus(IP_CONST_DAMAGETYPE_BLUDGEONING, IP_CONST_DAMAGEBONUS_1);}
		   	IPSafeAddItemProperty(oTarget, ipBonusDamage, fDuration, X2_IP_ADDPROP_POLICY_KEEP_EXISTING);
			if(AmmoType != 27)
            	IPSafeAddItemProperty(oTarget, ItemPropertyOnHitCastSpell(123,1), fDuration, X2_IP_ADDPROP_POLICY_KEEP_EXISTING );
				SendMessageToAllPCs(GetName(oCaster) + " ADDED PROPERTY TO AMMO.");
   		   	SignalEvent(GetItemPossessor(oTarget), EventSpellCastAt(OBJECT_SELF, SPELL_BLESS, FALSE));
			ApplyEffectToObject(nDurType, eVis, GetItemPossessor(oTarget), fDuration);

temyankee and i were trying to apply OnHitCastSpell to a weapon without much luck …

Mage Tome and Kaedrin - #24 by kevL_s

(that post is mine after i made a quick attempt that failed, scroll up and down to get a better gist of what we were trying to do)

basically, all bets are off atm imo. Although this sounds a bit hopeful →

It might be like trying to add DamageReduction to an item (itemproperty, not effect) – it can be added ok in the toolset, but not scripted on …

1 Like


Just took a look at that post. I had not realised it covered similar aspects. :+1:

I had a nasty feeling you may come to that conclusion. I noticed you referenced the same various spell scripts that I also found with the function in them … And all curiously steering away from its use.

I’ll try taking another look when/if I can get some sleep. Worst case scenario, I’ll try the item exchange approach. It’s just a little disappointing that it seems we may not be able to simply use the function.

1 Like


OK, I reinstated the “Name” tlk for the iprp_onhitspell.2da (83565) and cast the Bless on both arrows and bolts, and the function now worked!

I am going to see if having any tlk value in place allows the function to work, or if it is somehow checking a specific value. (After all, I don’t want “bolt” as part of an arrow description. I am looking at a generic term, like “Blessed Ammunition” rather than any creature specific.)

I’ll report my findings back here … UPDATE: The script did fire fine as well! i.e. I cast the Bless of “arrows” and the spell script fired the On Hit property.

UPDATE: I was able to use a custom tlk value and the function still fired the script fine! Yeh!

So that’s solved!



All i had to do was add a valid strref under “Name” in iprp_OnHitSpell.2da

(#127 OnHIT_Darkfire)

and its “SpellIndex” #703 OnHitDarkfire script fired right up!

(the ip also appears on the weapon, a Dwarfen Waraxe, ok)

good job, Lance :)




Exactly … :slight_smile:

(I also just updated the post above to make it clear that it was the tlk value under “Name” that I had reinstated. Good job about clarifying that. :+1:)

Who would have thought that simply returning the tlk value under “Name” would have fixed that?

I mean I only initially did what I did because the Bad Streff in the description was annoying me, and then the function worked as expected.

It’s good to know the fix appears universal. I did note that NWN2 had the Darkfire script already, so at least that did not need the extra spell script as well.

As you mention it, I wonder if the issue is the same for the DamageReduction addition script we were considering a while back? (i.e. Do you recall if there was a 2da involved with a **** in the name section?)

Being able to call our script from an item on hit has managed to open up quite an interesting potential set of game ideas … editing from a single script to say what has been hit by said items is straightforward too. I also carried a variable across via the item that stored the spell level, so we can tell, as an example, what level the Bless cast on the ammo was in my case … which not only determined how long the effect stays on the item, but what effect it has on hitting said creature.

Hopefully, others can make some interesting use of this moving forward too. :slight_smile:


not sure, but I’m pretty (really) certain that DR cannot be scripted as an itemproperty

(note how DR has become its own thing, in the toolset, on each item’s Properties page – but OnHitCastSpell is still, as in Nwn1, a good old itemproperty)