OnDeath

From NWN Lexicon
Jump to navigationJump to search

The script attached to this event fires when the object dies for any reason. It can be used to force the object to drop treasure, respawn at a new location, or cause a creature to spawn (or reincarnate!).

DestroyObject will not trigger this event, although DM kill will (with an invalid last killer).


Trigger

When the creature, door, or placeable object has been killed (normally by reduction to 0 or less hit points).

Unlike players an NPC instantly goes from 0 to -11HP - there is no OnDying style event for NPCs.

Remarks

Note a creature will be gibbed if the damage inflicted in the last attack was more than half it's maximum HP, and took them to -11 or more in one hit, and SetIsDestroyable/No Permanent Death on monster properties hasn't been used.

Henchmen associates added to a PCs party will call RemoveHenchman slightly after this event is called, you can re-add the now-dead member with another call to AddHenchman (although this can reorder the henchmen party). Bioware uses 0.1 seconds to do this.

Other associates - such as summons etc. - are also removed from the party if killed. There is further logic then destroying them more permanently done by the game engine, no need to script anything.


Function(s)

GetLastKiller() returns the object that killed OBJECT_SELF. Note there are some issues if the killer has died, if the killing object is a trap, and so forth. Make sure you test your killers.


See Also

functions:

GetLastKiller