From NWN Lexicon
Jump to: navigation, search

Gets the last living, non plot creature that performed a hostile act against the object.

object GetLastHostileActor(
    object oVictim = OBJECT_SELF


The object whose current enemy you wish to return. (Default: OBJECT_SELF)


Get the last object that was sent as a GetLastAttacker, GetLastDamager,GetLastSpellCaster (for a hostile spell), or GetLastDisturbed (when a creature is pickpocketed).

Note: Return values may only ever be:

  • A Creature
  • Plot Characters will never have this value set
  • Area of Effect Objects will return the AOE creator if they are registered as this value, otherwise they will return OBJECT_INVALID
  • Traps will not return the creature that set the trap.
  • This value will never be overwritten by another non-creature object.
  • This value will never be a dead/destroyed creature


Very useful function. Sometimes you just want to know who is performing an act AGAINST the object without knowing what that act may be. It rolls up all the various Get Aggressor functions into one tight function call. Used mostly for combat targeting determination since it does not return non creatures (in other words it wont return an object representing a chest that sets off a trap, nor will it return the trap). Also, if a creature is marked as Plot, it will not return them, and since this function is exclusively used in the originally shipped AI, that makes Plot NPCs untargetable by other NPCs.

This is also extremely useful as the only way to get who killed the PC in the OnPlayerDeath event, under module properties (For, example, warning DM's that a PvP attack has just happened).

When damage is applied by a placeable using EffectDamage, this function returns OBJECT_INVALID, effectively clearing the last creature value. So, for example, on death, if this function returns an invalid creature, you can use GetLastDamager to identify the killer placeable. It is not known whether this works for traps.



See Also


RespondToShout GetLastAttacker GetLastDamager GetLastSpellCaster GetLastDisturbed

 author: John Shuell, editor: Jasperre