Skip to content

EN API UO MoveXY

LIHACHTETAN edited this page Nov 28, 2026 · 3 revisions

UO.MoveXY

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

C# signatures

dynamic UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running);
int UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running, object? stepCallback);
int UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running, object? stepCallback, object? timeout);
int UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running, object? stepCallback, object? timeout, object? maxSteps);
int UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running, object? stepCallback, object? timeout, object? maxSteps, object? maxDistance);
int UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running, object? stepCallback, object? timeout, object? maxSteps, object? maxDistance, object? accuracyZ);
int UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running, object? stepCallback, object? timeout, object? maxSteps, object? maxDistance, object? accuracyZ, object? avoidMobiles);
int UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running, object? stepCallback, object? timeout, object? maxSteps, object? maxDistance, object? accuracyZ, object? avoidMobiles, object? openDoors);
int UO.MoveXY(object? xdst, object? ydst, object? optimized, object? accuracy, object? running, object? stepCallback, object? timeout, object? maxSteps, object? maxDistance, object? accuracyZ, object? avoidMobiles, object? openDoors, object? stopOnStuck);

Moves the character to X/Y with five required parameters and waits for the result. Up to eight optional arguments can follow the five required arguments in the order shown.

Parameters

  • xdst — World X coordinate of destination, 0..65535. This is not serial and not a position inside the gump.
  • ydst — World Y coordinate of destination, 0..65535.
  • optimized - true - normal mode of searching and checking the path forward; false - reduced heuristics and closest step checking. false does not disable obstacle avoidance.
  • accuracy — 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.
  • running - true/1 - run request, false/0 - step. Server motion delays persist; It's not a speed multiplier.
  • stepCallback — Name of a registered function to call after the position changes. Pass 0 or null, or omit the argument, to leave the callback disabled.
  • timeout — Optional wait limit in milliseconds; a missing argument, 0 and a negative value indicate the absence of this additional limit.
  • 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.
  • maxDistance — Optional limit on the initial distance max(abs(dx),abs(dy)) to the target. 0/absence disables it. This is not the allowed deviation during the traversal and not the length of the found path.
  • accuracyZ — Height tolerance: abs(actual Z - required Z), limited by 0..255. Zero requires a precise altitude; 255 essentially disables the Z limit. For MoveXY the target Z is equal to the character's Z when the function is called; default tolerance is 255.
  • 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.
  • stopOnStuck - true completes the movement with 0, if after planning approximately 1000 ms X/Y/Z have not changed. Active search and recalculation portions reset this timer; the separate timeout continues to operate. Default is false.

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

  • The complete A* route is built before the first step, in short portions between client updates. When Optimized=true the next 4 cells of the path are checked; when false is the nearest step. This is a check of the already calculated path, and not the distance of the entire route and not the detour sliders when moving the mouse.
  • Server failure DenyWalk or a new obstacle requests a recalculation from the current position after completing the queue of steps. The number of repetitions and recalculation frequency are limited; no path may end the movement with 0.
  • 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.

The step callback in C# is explicitly registered via RegisterStepCallback(name, Func<int,int,int,bool>) or Func<int,int,int,int>. The x/y/z coordinates are transmitted as int; false/0 stops the route, true/non-zero number continues. The registration is valid in the current execution and is released with it.

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.

object? result = UO.MoveXY(UO.GetX() + 2, UO.GetY(), true, 0, false);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Exact point on foot - direct script

Parameters and execution flow:

  • Xdst - two cells to the east; Ydst does not change.
  • Optimized=true, Accuracy=0, Running=false. The call returns the result when completed.
var ok = UO.MoveXY(UO.GetX() + 2, UO.GetY(), true, 0, false);
UO.Print(Convert.ToString(ok));

2. Approach object - script function

Parameters and execution flow:

  • Xdst/Ydst are read from the selected object; it must be an object of the world, not an object inside the container.
  • Accuracy=1 allows you to get close; Running=true. Heights are not limited to this challenge.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.Exists("lasttarget")))
    {
        var ok = UO.MoveXY(UO.GetX("lasttarget"), UO.GetY("lasttarget"), true, 1, true);
        UO.Print("Approach result: " + Convert.ToString(ok));
    }

    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. Temporarily set minimum endurance - scenario class

Parameters and execution flow:

  • Replace the target 1445/1690 with your own. The endurance threshold is set by a separate setting, not the sixth MoveXY parameter.
  • After a normal return, the original value is restored. If an abort occurs, no further lines are executed.

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.

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 previous = UO.moveCheckStamina();
        UO.moveCheckStamina(15);
        var ok = UO.MoveXY(1445, 1690, true, 0, false);
        UO.moveCheckStamina(previous);
        UO.Print(Convert.ToString(ok));
        return null;
    }
}

Example with a stamina check and timeout

using (global::ClassicUO.CSharp.CSharpScriptContext.Current.RegisterStepCallback(
    "AfterStep", (int x, int y, int z) => UO.Stamina() > 10))
{
    int arrived = UO.MoveXY(UO.GetX() + 2, UO.GetY(), true, 0, false, "AfterStep", 5000);
    UO.Print("MoveXY: " + Convert.ToString(arrived));
}

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.MoveXY(xdst, ydst, optimized, accuracy, running) — UO.MoveXY(Any,Any,Any,Any,Any)

Parameters: xdst (Any), ydst (Any), optimized (Any), accuracy (Any), running (Any)

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "movexy":

                    return new InjectionValue(MoveTo(Arg(0), Arg(1), bridge.GetZ(bridge.Self), Arg(3), Arg(4) != 0, 255, Arg(2) != 0));

Clone this wiki locally