OnExit

From NWN Lexicon

Contents

[edit] OnExit

The script attached to this event fires when an area, trigger, or encounter boundry is exited. This can be used for such effects as slaying all the zombies that just animated to kill the intruding tomb robbing PC or removing the Holy Grail from the PC's inventory and triggering a series of encounters that send creatures after the PC. Area of effects also can have On Exit events defined when they are created.

[edit] Trigger

Something left the current area, encounter, trigger or area of effect (not neccessarily a PC).

[edit] Function(s)

GetExitingObject() returns the object that just left the area, encounter, or trigger.

[edit] Remarks

The OnExit event fires for an Area of Effect if it is dispelled or runs out of duration. For spells such as Acid Fog, it removes the slowing effect.

[edit] Known Bugs

The OnExit event for trigger nor area of effect doesn't fire for player exiting the game. Also, the area OnExit event doesn't fire for dead player exiting the game. To workaround this, you need to store trigger/area object in OnEnter with local object variable, read it in OnClientLeave and ExecuteScript on this object from there.

[edit] Example

// see the OnEnter event for the stage for the below script
// sends "HUNTER" home (aptly named "HUNTER_CAVE") if
// the PC leaves the area
void main()
{
     object oExiting = GetExitingObject();
     object oMonster = GetObjectByTag("HUNTER");
     object oCave = GetObjectByTag("HUNTER_CAVE");
     if (GetIsPC(oExiting))
     {
          SetLocalObject(OBJECT_SELF, "PC_Entered", OBJECT_INVALID);
     }
     // if "HUNTER" is leaving while giving chase, send him home
     if (oExiting == oMonster)
     {
          AssignCommand(oMonster, ClearAllActions());
          AssignCommand(oMonster, ActionMoveToObject(oCave));
     }
}

[edit] See Also

functions: 

GetExitingObject()


Personal tools
Categories