GetLastKiller()

From NWN Lexicon
Jump to navigationJump to search

Get the object that killed the caller.

Description

Returns an object representing the object that killed the calling object.

Remarks

Only works when called from an NPC or creature in OnDeath. Does not work during the OnPlayerDeath event of a module (returns OBJECT_INVALID in this case).

Can be invalid in these cases:

  • PC applied damage who has now left

Untested cases but most likely invalid:

  • Does triggering a trap get the person who set the trap? (or does it return the trap object?)
  • Does the module or area applying damage set that as the killing object?
  • Losing constitution (EffectAbilityDecrease) who is the killer?
  • Losing constitution bonuses (eg; from EffectAbilityIncrease) who is the killer?
  • Negative levels being applied - does it identify the applier as the killer?

For the purposes of using this to determine who killed them for XP distribution or loot, getting the nearest enemy PC or nearest enemy creature (which may be a henchman or summon of a PC party) would be best.

Version

1.61

See Also

functions: 

GetLastOpener

events:

OnDeath



 author: John Shuell, editor: Charles Feduke, additional contributor(s): Eric Collazo