OnEnter

The script attached to this event fires when a certain area boundry has been violated allowing you to throw a custom event, update the PC's journal, or a variety of other things. Area of effects also can have On Enter events defined when they are created, for example an Acid Fog cloud in a spell.


Trigger

Something has entered the area, encounter, or trigger (not neccessarily a PC).


Function(s)

GetEnteringObject() returns the object that has entered the area, encounter, or trigger.


Remarks

Polymorphing a PC causes them to trigger the OnExit and OnEnter events (in that order), for the area they are currently in. Area of effects can have a On Enter script to apply effects while in the effect. When the Area of Effect is removed, or runs out, it does fire its OnExit event for all creatures currently in it.


Example

// notifies a monster tagged "HUNTER" that a PC has entered
// the area this script is attached to; also set a local variable
// that can be checked later to see if the PC went into an area
// to prevent an event from occuring again to the same PC
// (until another PC comes along and triggers this event that is).
// "HUNTER" can also use the object (oEntering) stored on the
// event to help track down the trespassing PC.
void main()
{
     object oEntering = GetEnteringObject();
     // make sure its a PC
     if (GetIsPC(oEntering))
     {
          // prevent "HUNTER" from coming again
          if (!(GetLocalObject(OBJECT_SELF, "PC_Entered") == oEntering))
          {
               object oMonster = GetObjectByTag("HUNTER");
               // set a local variable on the Area
               SetLocalObject(OBJECT_SELF, "PC_Entered", oEntering);
               // tell "HUNTER" to come and eat
               SignalEvent(oMonster, EventUserDefined(100));
          }
     }
}

See Also

Objects with Events | Area | Encounter | Trigger
functions: GetEnteringObject