From NWN Lexicon
Jump to: navigation, search

Gets the associated transitional target.

object GetTransitionTarget(
    object oTransition


Transitional object to return the target of.


Returns the destination (a waypoint or a door) for a trigger or a door.

Returns OBJECT_INVALID if oTransition is not a valid trigger or door.


If you place a script in the OnAreaTransitionClick of a door or the OnClick of a transition trigger, that script will override the transition. You can then use GetTransitionTarget to get the destination target of the transition, without having to hardcode it in the script (for instance, you might change the destination of a door, and then you won't have to remember to update the script as well).

The target is the object declared in the properties of the trigger/door, which normally is added via. a wizard and map system included there.

How this function works in regards to DestroyArea() (these remarks can be ignored if not using CopyArea/CreateArea/DestroyArea):

  • The function will, if no stored object is found, use a tag stored by the properties of oTransition and do a GetObjectByTag() to look up that object. This is then stored in the transition as the target going forwards (as if SetTransitionTarget was called).
  • Therefore, if you DestroyArea() where the transition target object was, this now will return an OBJECT_INVALID reference, and not go get a new target. The tranistion effectively breaks.
  • To fix this use SetTransitionTarget to fix the destination when an area is created/copied/destroyed, or replace the function usage in the OnAreaTransitionClick/OnClick with a custom function looking up the destination, eg: by tag.

Known Bugs

NWN:EE 80.8193.14 - Fixes GetTransitionTarget() returning a "valid" target when DestroyArea is called on the parent area.

1.64: Fixed problem with GetTransitionTarget() scripting command returning a random valid object ID if the destination on the trigger did not exist. It will now return OBJECT_INVALID in this case.




// We float some text - the next name of the area the target of this
// door is in, before delaying moving them to the target.
void main()
    // Declare who is moving, and the target.
    object oClicker = GetClickingObject();
    object oTarget = GetTransitionTarget(OBJECT_SELF);
    // Float the name of the target's area above the PC's head
    FloatingTextStringOnCreature(GetName(GetArea(oTarget)), oClicker, FALSE);
    // Delay moving them to the target
    DelayCommand(3.0, AssignCommand(oClicker, JumpToObject(oTarget)));

See Also

functions: DestroyArea() CopyArea() CreateArea() SetTransitionTarget()

 author: Charles Feduke, editor: Jasperre, additional contributor(s): Jeremy Sager, Lilac Soul, Jasperre