NWNWiki
Advertisement
NWNWiki
3,718
pages

The JumpToObject() NWScript command causes the caller – who must be a living creature – to instantly move (teleport) to the indicated object. This occurs immediately, ignoring the action queue. In order to cause a creature other than the caller to move, this command must be assigned via AssignCommand().

It is common for the target object to be a waypoint, although any type of object that has a location will work as the target (i.e. any object other than areas and the module itself). If the destination is occupied by a creature or is not walkable, then the caller will jump as close as possible to the indicated target.

Since this command interrupts the action queue, it is often a good idea to call ClearAllActions() first.

Definition[]

void JumpToObject (object oToJumpTo, int nWalkStraightLineToPoint=1)

object oToJumpTo
The object to which to jump.
int nWalkStraightLineToPoint
This parameter seems to be ignored.

The oJumpTo parameter is often obtained via GetWaypointByTag() or GetObjectByTag(). If this parameter is not valid, the command has no effect.

If the destination is in the same area as the caller, associates of the caller will not automatically follow. In order to avoid separating a master from its associates in this case, each associate must be found (see GetAssociate()) and individually jumped.

Example[]

A simple portal can be made by using the following as a placeable's OnUsed event handler, where "WP_ARRIVE" is the (example) tag of the waypoint that marks the exit of the portal.

// It is good practice to call ClearAllActions() and JumpToObject() from the same
// function, rather than assigning each individually.
void ClearAndJump(object oTarget)
{
    ClearAllActions();
    JumpToObject(oTarget);
}

void main()
{
    object oUser = GetLastUsedBy(); // Get the creature to jump.
    object oDest = GetWaypointByTag("WP_ARRIVE"); // Get the destination.
    AssignCommand(oUser, ClearAndJump(oDest));
}

See also[]

Advertisement