Skip to content

EN API UO MoveXYZ

LIHACHTETAN edited this page Nov 28, 2026 · 3 revisions

UO.MoveXYZ

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

C# signatures

int UO.MoveXYZ(object? x, object? y, object? z, object? accuracyXY, object? accuracyZ, object? running);
int UO.MoveXYZ(object? x, object? y, object? z, object? accuracyXY, object? accuracyZ, object? running, object? timeout);
int UO.MoveXYZ(object? x, object? y, object? z, object? accuracyXY, object? accuracyZ, object? running, object? timeout, object? maxSteps);
int UO.MoveXYZ(object? x, object? y, object? z, object? accuracyXY, object? accuracyZ, object? running, object? timeout, object? maxSteps, object? avoidMobiles);
int UO.MoveXYZ(object? x, object? y, object? z, object? accuracyXY, object? accuracyZ, object? running, object? timeout, object? maxSteps, object? avoidMobiles, object? openDoors);

Moves the character to a point in the world with separate horizontal and vertical tolerances.

Parameters

  • x — Required int: the world X coordinate of the destination, 0..65535, on the current map. Not the gump coordinate.
  • y — Required int: the world Y coordinate of the destination, 0..65535, on the current map.
  • z — Required int: target world height -128..127. This is the surface height, not the floor number.
  • accuracyXY — Required int. Tolerance for X and Y in cells: both deviations must fit within it. The value is limited to the range 0..20; 0 requires precise X/Y.
  • accuracyZ — Required int. Height tolerance: abs(actual Z - required Z), limited by 0..255. Zero requires a precise altitude; 255 virtually disables the Z limit.
  • running — Mandatory Boolean flag. true/1 — run request, false/0 — step. Server motion delays persist; It's not a speed multiplier.
  • timeout — Optional wait limit in milliseconds; a missing argument, 0 and a negative value indicate the absence of this additional limit. The countdown begins after the route is accepted for execution; this is not a hard limit on the duration of the entire call along with route preparation.
  • maxSteps — Optional limit of observed position changes, not network packets. 0/negative/absent - without this limit. There may be several steps between polls, so this is not an accurate cell counter.
  • avoidMobiles — Optional flag: true prohibits passing through the characters being taken into account; false allows the attempt. Without an argument, moveThroughNPC is used. The server may still deny access.
  • openDoors — Optional flag for opening doors along the way. Without an argument, moveOpenDoor is used; true does not provide access to locked doors.

Return value

int 1 - at the end of the check the character is in the given X/Y/Z tolerance, including when he was already there before the challenge. int 0 - invalid coordinates, trigger failure, unreached point, or triggered stop condition. This is not a number of steps or serial; In case of emergency cancellation, the procedure is aborted instead of returning normally 0.

The result of the command is a numeric flag: 1 means a fulfilled condition, 0 means an unfulfilled one. After var result = command(...) check if (result != 0) or if (result == 0). Save the result of one call: a repeated call can perform the action again or read the state that has already changed.

Behavior

  • How it works, step 1: checks coordinates, configured connection and endurance conditions. If the character is already within accuracyXY and accuracyZ, immediately returns 1 without a new route.
  • Step 2: builds a route on the current map taking into account the surface height, obstacles and selected passage conditions. Optimized mode is enabled within the command here; There is no need to pass such a parameter to MoveXYZ.
  • Step 3: starts walking or running along the route and waits for the result in the current procedure. The line after the call is executed after it completes; the client interface continues to work.
  • Step 4: If a step fails or a new obstacle occurs, the client can recalculate the route from the current position. Attempts are limited. When a timeout occurs or the limit of observable movements beyond the target is reached, the movement stops with 0.
  • Step 5: After the movement ends, compares the client's actual X/Y/Z with the target. Both abs(X-x)<=accuracyXY, abs(Y-y)<=accuracyXY and abs(Z-z)<=accuracyZ are required. For example, for the target 1279/540/20 with tolerances 1 and 2 X=1278..1280, Y=539..541 are suitable, Z=18..22.
  • The minimal form contains six arguments: UO.MoveXYZ(1279,540,20,1,2,true). Additional arguments are added to the right in the order timeout, maxSteps, avoidMobiles, openDoors. To specify openDoors, the previous positions must also be passed; blank spaces between commas are not supported.
  • The route belongs to the procedure that started it: its emergency stop cancels the remaining automatic path. If another run or user has already replaced the route, canceling the previous owner does not affect the new route. Steps already sent are not recalled.
  • SetBadLocation and SetBadObject are used as a snapshot of the current runtime's prohibitions when the route is started. They are saved during its internal recalculation. Changing or clearing lists affects the next route, rather than overwriting one already in progress.
  • UO.LimitMove controls destination distance: default 2000, zero unlimited. There are no hidden 4096-step/node or 10000-node caps. Work is sliced and can be stopped. GetPathArray respects the numeric moveThroughNPC stamina threshold and moveOpenDoor.
  • timeout is counted after the request is accepted and includes subsequent portions of search and recalculation. stopOnStuck does not consider a running search to be a character stuck; After planning is completed, no position changes are taken into account again. The final 1/0 checks the actual coordinates, not just the readiness of the path.
  • The result takes into account the local position of the client; subsequent server correction is still possible. Running competing movement commands from different routines changes the character's overall route.
  • The settings moveCheckStamina, moveExitOnDisconnect, moveOpenDoor, moveThroughCorner, moveThroughNPC, moveHeuristicMult, moveTurnCost and moveBetweenTwoCorners affect the performance. Explicit avoidMobiles/openDoors override the corresponding values ​​for this call.
  • Result 0 does not indicate the exact cause. Check coordinates, connection, stamina and log; do not repeat the movement endlessly without UO.Wait and a limit of attempts.
  • The main bridge records the request number, player/Pathfinder/map instances, and map index. A new request, context change, or final refusal gives 0; the check is repeated after reading the coordinates and the last callback. Timeout, maxSteps and callback=0 only stop the saved request, not a new foreign route. Temporary Blocked, while recovery is still active, does not lose possession: the wait continues. For external legacy-bridge without IApiMovementOwnershipBridge, the previous compatible mechanism is retained.
  • The general Pathfinder stores up to 8 temporary X/Y/Z directional prohibitions for 2000 ms, only on rejected movement of the corresponding active request. Rotation, unknown sequence, resynchronization and old/foreign request do not create such a prohibition. A new external request and loss of map/player context clears them. Loaded geometry search attempts to bypass the transition; it's not knowing all the server obstacles. Without changing the player's X/Y/Z, up to 8 internal recalculations are allowed with a pause of at least 40 ms. There is no complete path or this budget has been exhausted - the route ends. The coordinate task then completes after processing the submitted steps; mobile-Follow may try again due to its delay.

Standalone C# scripts

Each example can be saved as a separate file .csx and run in IDE. The UO object and wait functions provide the host of the current game session. Replace demo serial names, coordinates and addresses with your own.

Simple example

Run this code as a separate .csx file. Arguments appear directly in the call; replace demonstration names, serials and addresses with your own.

The result of one call is printed in the journal. A number is not converted to bool; an array is displayed as its element count.

var result = UO.MoveXYZ(UO.GetX() + 1, UO.GetY(), UO.GetZ(), 0, 0, false);
UO.Print("MoveXYZ: " + Convert.ToString(result));

1. Neighboring cell at the same height - direct script

Parameters and execution flow:

  • x/y/z is the target point. accuracyXY=0 and accuracyZ=0 require precise position.
  • running=false - walking. If the adjacent surface has a different height, the result may be 0.
var ok = UO.MoveXYZ(UO.GetX() + 1, UO.GetY(), UO.GetZ(), 0, 0, false);
UO.Print(Convert.ToString(ok));

2. Approach a point at the required height and check the result - script function

Parameters and execution flow:

  • Preparation: the character must be in the game, and the point must exist on the current map. 1279/540/20 are training coordinates: replace them with your available point, including the actual height of the surface.
    1. destinationX=1279 is the first argument, the X world coordinate of the target.
    1. destinationY=540 is the second argument, the Y world coordinate of the target.
    1. destinationZ=20 — third argument, height. The team must find a passage or staircase; the value 20 by itself does not transfer to the floor.
    1. accuracyXY=1 allows you to finish within one cell along each horizontal coordinate. The diagonally adjacent cell is also suitable.
    1. accuracyZ=2 allows heights from 18 to 22 inclusive. An X/Y match on another floor is not enough for success.
    1. running=true requests running. For walking, replace true with false.
    1. timeout=8000 limits the wait after the route starts to eight seconds. After this time, while the movement is still in progress, the command stops it and returns 0.
    1. maxSteps=100 limits the number of position changes observed. This is not the exact number of squares traversed; multiple steps may occur between polls.
    1. avoidMobiles=true prohibits passing through the characters taken into account when calculating the route.
    1. openDoors=true allows attempts to open doors along the way. This flag does not bypass a locked door or server restrictions.
  • reached receives int 1 or 0 after the call ends. if reached == 1 executes success branch; else handles failure to achieve the goal without endlessly repeating the command.
  • The last line prints the current X/Y/Z for checking. If the procedure aborts, no further lines, including this output, are executed.
return  RunScenario();
 object? RunScenario()
{
    var destinationX = 1279;
    var destinationY = 540;
    var destinationZ = 20;
    var accuracyXY = 1;
    var accuracyZ = 2;
    dynamic running = true;
    var timeout = 8000;
    var maxSteps = 100;
    dynamic avoidMobiles = true;
    dynamic openDoors = true;
    var reached = UO.MoveXYZ(destinationX, destinationY, destinationZ, accuracyXY, accuracyZ, running, timeout, maxSteps, avoidMobiles, openDoors);
    if (Truth(reached == 1))
    {
        UO.Print("Destination reached");
    }
    else
    {
        UO.Print("Destination not reached; check the path and limits");
    }

    UO.Print("Position: " + Convert.ToString(UO.GetX()) + "," + Convert.ToString(UO.GetY()) + "," + Convert.ToString(UO.GetZ()));
    return null;
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Running with limits and a ban on opening doors - scenario class

Parameters and execution flow:

  • x/y/z=1445/1690/0; accuracyXY=1, accuracyZ=3; running=true.
  • timeout=5000, maxSteps=60 of observed movements, avoidMobiles=true and openDoors=false.
return  new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenario();
class ScriptScenario
{
    private readonly global::ClassicUO.CSharp.CSharpGameApi UO;
    private readonly Func<int, Task> WaitAsync;
    private readonly string[] Args;
    private readonly CancellationToken Cancellation;
    private readonly Action Checkpoint;
    public ScriptScenario(global::ClassicUO.CSharp.CSharpGameApi api, Func<int, Task> wait, string[] args, CancellationToken cancellation, Action checkpoint)
    {
        UO = api;
        WaitAsync = wait;
        Args = args;
        Cancellation = cancellation;
        Checkpoint = checkpoint;
    }

     public object? RunScenario()
    {
        var ok = UO.MoveXYZ(1445, 1690, 0, 1, 3, true, 5000, 60, true, false);
        UO.Print("Result: " + Convert.ToString(ok));
        return null;
    }
}

4. Ready-made function with comments inside the script - direct script

Parameters and execution flow:

  • Lines with # are C# comments: they are saved during copying and are not executed. The example contains both necessary parts: the function GoToPoint and the runnable procedure Main.
  • All six parameters GoToPoint are passed to MoveXYZ without modification. Four additional parameters are specified within the function: 8000 ms, 100 observed position changes, character traversal, and door opening.
  • For the purpose 1279/540/20 with tolerances 1/2 X=1278..1280, Y=539..541, Z=18..22 are suitable. A point at another altitude beyond 18..22 is not considered to be reached.
  • This is a wrapper around the real command, and not a second implementation of pathfinding in the script. It doesn't call an extra GetPathArray and doesn't trigger endless retries. If not achieved, the calling procedure receives 0 and chooses further action.

Standard driving speed

Minimum step interval: walking - walking 400 ms, running 200 ms; riding - walking 200 ms, running 100 ms.

These are standard client limits, not automatically defined settings for your shard. Server speed and flight modes are counted separately. Script timers can slow down movement, but do not reduce these limits.

Steps, Routes, Follow, Mouse/Key Controls, and Map all use the character's shared queue. Replacing the route, turning, or adjusting the position by the server does not cancel the remaining pause after the step request. After the delay, there is no fast burst to compensate for the dropped frames. Waiting for confirmation, obstacles and poor communication can slow down the movement.

var reached = GoToPoint(1279, 540, 20, 1, 2, true);
if (Truth(Truth(reached) == true))
{
    UO.Print("Destination reached");
}
else
{
    UO.Print("Destination not reached");
}

dynamic GoToPoint(dynamic x, dynamic y, dynamic z, dynamic accuracyXY, dynamic accuracyZ, dynamic running)
{
    var timeout = 8000;
    var maxSteps = 100;
    dynamic avoidMobiles = true;
    dynamic openDoors = true;
    var reached = UO.MoveXYZ(x, y, z, accuracyXY, accuracyZ, running, timeout, maxSteps, avoidMobiles, openDoors);
    return reached;
}

bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

Command implementation

C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.

UO.MoveXYZ(x, y, z, accuracyXY, accuracyZ, running) — UO.MoveXYZ(Any,Any,Any,Any,Any,Any)

Parameters: x (Any), y (Any), z (Any), accuracyXY (Any), accuracyZ (Any), running (Any)

Result: int / Integer.

During a call:

The call executes the stored handler delegate. The registration method creates this delegate while building the API.

Internal implementation code; this is not a standalone script.

values => new InjectionValue(CompactMoveXYZ(values))

UO.MoveXYZ(x, y, z, accuracyXY, accuracyZ, running, timeout) — UO.MoveXYZ(Any,Any,Any,Any,Any,Any,Any)

Parameters: x (Any), y (Any), z (Any), accuracyXY (Any), accuracyZ (Any), running (Any), timeout (Any)

Result: int / Integer.

During a call:

The call executes the stored handler delegate. The registration method creates this delegate while building the API.

Internal implementation code; this is not a standalone script.

values => new InjectionValue(CompactMoveXYZ(values))

UO.MoveXYZ(x, y, z, accuracyXY, accuracyZ, running, timeout, maxSteps) — UO.MoveXYZ(Any,Any,Any,Any,Any,Any,Any,Any)

Parameters: x (Any), y (Any), z (Any), accuracyXY (Any), accuracyZ (Any), running (Any), timeout (Any), maxSteps (Any)

Result: int / Integer.

During a call:

The call executes the stored handler delegate. The registration method creates this delegate while building the API.

Internal implementation code; this is not a standalone script.

values => new InjectionValue(CompactMoveXYZ(values))

UO.MoveXYZ(x, y, z, accuracyXY, accuracyZ, running, timeout, maxSteps, avoidMobiles) — UO.MoveXYZ(Any,Any,Any,Any,Any,Any,Any,Any,Any)

Parameters: x (Any), y (Any), z (Any), accuracyXY (Any), accuracyZ (Any), running (Any), timeout (Any), maxSteps (Any), avoidMobiles (Any)

Result: int / Integer.

During a call:

The call executes the stored handler delegate. The registration method creates this delegate while building the API.

Internal implementation code; this is not a standalone script.

values => new InjectionValue(CompactMoveXYZ(values))

UO.MoveXYZ(x, y, z, accuracyXY, accuracyZ, running, timeout, maxSteps, avoidMobiles, openDoors) — UO.MoveXYZ(Any,Any,Any,Any,Any,Any,Any,Any,Any,Any)

Parameters: x (Any), y (Any), z (Any), accuracyXY (Any), accuracyZ (Any), running (Any), timeout (Any), maxSteps (Any), avoidMobiles (Any), openDoors (Any)

Result: int / Integer.

During a call:

The call executes the stored handler delegate. The registration method creates this delegate while building the API.

Internal implementation code; this is not a standalone script.

values => new InjectionValue(CompactMoveXYZ(values))

Clone this wiki locally