Neverwinter Nights 2

File information

Last updated

Original upload

Created by

Dann Pigdon

Uploaded by

DannJ

Virus scan

Safe to use

Tags for this mod

About this mod

A tag-based OnHit script that causes throwing weapons (or ammo) to return on a successful hit.

Permissions and credits
The tag-based OnHit script below can be used in conjunction with the "Unique Power (On Hit)" item property to cause thrown weapons (axes or darts) to return on a successful hit.

The script also works on ammo, but the returning visual effect doesn't fire. Missed attacks result in the stack decreasing as usual.

Give a stack of throwing weapons or ammo the "On Hit Cast Spell: Unique Power (On Hit)" item property, give the stack a unique tag, then name the script i_itemtag_hc (where 'itemtag' is replaced with the unique tag you gave the stack).

--

// i_itemtag_hc
// Tag-based OnHit script for thrown weapons
// that return on a successful hit
void main()
{
object oItemHit = GetSpellCastItem();
if (!GetIsObjectValid(oItemHit)) return;

object oTarget = GetSpellTargetObject();
object oPC = GetItemPossessor(oItemHit);
location lPC = GetLocation(oPC);
location lTarget = GetLocation(oTarget);

SetItemStackSize(oItemHit, GetItemStackSize(oItemHit)+1, FALSE);
SpawnItemProjectile(oTarget, oPC, lTarget, lPC, GetBaseItemType(oItemHit), PROJECTILE_PATH_TYPE_HOMING, OVERRIDE_ATTACK_RESULT_PARRIED, 0);
}