Skip to content

EN UO Topic targeting

Codex edited this page Oct 12, 2026 · 4 revisions

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

Targeting

Home · C# · IDE · UO API · A–Z · Examples · Languages

Manual response with target cursor and preset response WaitTarget. Setting an expected goal and performing an action are separate operations.

Sections

Topic Commands and explanations
Target UO.Target
TargetID UO.TargetID
TargetToObject UO.TargetToObject
TargetToTile UO.TargetToTile
TargetToXYZ UO.TargetToXYZ
TargetByResource UO.TargetByResource
WaitTarget UO.WaitTarget
WaitTargetObject UO.WaitTargetObject
WaitTargetType UO.WaitTargetType
WaitTargetTile UO.WaitTargetTile
WaitTargetXYZ UO.WaitTargetXYZ
WaitTargetSelf UO.WaitTargetSelf
LastTarget UO.LastTarget
CancelTarget UO.CancelTarget
Client Target Response UO.ClientRequestObjectTarget · UO.ClientRequestTileTarget · UO.WaitForClientTargetResponse · UO.ClientTargetResponse

All theme commands

Targets

UO.Target · UO.TargetID · UO.Targeting · UO.TargetPresent · UO.TargetToObject · UO.TargetToTile · UO.TargetToXYZ · UO.TargetByResource · UO.LastTarget · UO.LastTargetX · UO.LastTargetY · UO.LastTile · UO.TicksTarget

Waiting / Cancel

UO.WaitTarget · UO.WaitTargetObject · UO.WaitTargetType · UO.WaitTargetObjectType · UO.WaitTargetTile · UO.WaitTargetXYZ · UO.WaitTargetSelf · UO.WaitTargetGround · UO.WaitTargetLast · UO.WaitForTarget · UO.IsWaitTargetActive · UO.CancelTarget · UO.CancelWaitTarget

Client Target Response

UO.ClientRequestObjectTarget · UO.ClientRequestTileTarget · UO.ClientTargetResponse · UO.ClientTargetResponsePresent · UO.WaitForClientTargetResponse

Examples on the topic

Each command card has several independent scenarios: direct code, functions and classes. Below are selected short scenarios; restrictions and full analysis are in the cards.

UO.WaitTargetObject

Parameters, result and all scenarios

UO.CancelWaitTarget();
UO.WaitTargetObject("self");
UO.UseSkill("Anatomy");

UO.TargetToXYZ

Parameters, result and all scenarios

if (Truth(UO.TargetPresent()))
{
    UO.TargetToXYZ(1445, 1690, 0);
}

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

Complete command reference


UO.CancelTarget

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

C# signatures

void UO.CancelTarget();

Cancels the active cursor and clears prepared crosshair responses.

Parameters

There are no parameters.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • Replies already sent to the server are not recalled.
  • The local callback target is canceled; For an active server target, a target cancellation is sent.
  • The queue is common to the client: its clearing applies to the prepared responses of all procedures.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.CancelTarget");
UO.CancelTarget();

1. Unprepare - direct script

Parameters and execution flow:

  • There are no arguments.
  • The deferred response to self is removed.
UO.WaitTargetSelf();
UO.CancelTarget();

2. Replace a previously prepared point - script function

Parameters and execution flow:

  • 1445/1690/0 is an example of a new point in the world.
  • Old answers are removed before setting a new goal.
return  RunScenario();
 object? RunScenario()
{
    UO.CancelTarget();
    UO.WaitTargetXYZ(1445, 1690, 0);
    return null;
}

3. Refuse after timeout - script class

Parameters and execution flow:

  • UO.Wait=1000 ms is a limitation of this example.
  • The remaining queue is checked, not the success of the skill. If there is no server crosshair, the next foreign command will not receive the old response.
return await new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenarioAsync();
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;
    }

    async public Task<object?> RunScenarioAsync()
    {
        UO.WaitTargetSelf();
        UO.UseSkill("Anatomy");
        await Delay(1000);
        if (Truth(UO.IsWaitTargetActive()))
        {
            UO.CancelTarget();
        }

        return null;
    }

    Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
    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.CancelTarget() — UO.CancelTarget()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void CancelTarget()

        {

            var waitTargetQueue = bridge.GetWaitTargetQueue();

            if (waitTargetQueue.Length > 0 || bridge.IsTargeting() != 0)

            {

                bridge.CancelTarget();

                SystemMessage("Targeting cancelled");

            }

            else

                SystemMessage("Error: no target to cancel");

        }

UO.CancelWaitTarget

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

C# signatures

void UO.CancelWaitTarget();

Clears prepared crosshair responses.

Parameters

There are no parameters.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • Replies already sent to the server are not recalled.
  • The open cursor remains active; it can be processed manually later.
  • The queue is common to the client: its clearing applies to the prepared responses of all procedures.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.CancelWaitTarget");
UO.CancelWaitTarget();

1. Unprepare - direct script

Parameters and execution flow:

  • There are no arguments.
  • The deferred response to self is removed.
UO.WaitTargetSelf();
UO.CancelWaitTarget();

2. Replace a previously prepared point - script function

Parameters and execution flow:

  • 1445/1690/0 is an example of a new point in the world.
  • Old answers are removed before setting a new goal.
return  RunScenario();
 object? RunScenario()
{
    UO.CancelWaitTarget();
    UO.WaitTargetXYZ(1445, 1690, 0);
    return null;
}

3. Refuse after timeout - script class

Parameters and execution flow:

  • UO.Wait=1000 ms is a limitation of this example.
  • The remaining queue is checked, not the success of the skill. If there is no server crosshair, the next foreign command will not receive the old response.
return await new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenarioAsync();
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;
    }

    async public Task<object?> RunScenarioAsync()
    {
        UO.WaitTargetSelf();
        UO.UseSkill("Anatomy");
        await Delay(1000);
        if (Truth(UO.IsWaitTargetActive()))
        {
            UO.CancelWaitTarget();
        }

        return null;
    }

    Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
    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.CancelWaitTarget() — UO.CancelWaitTarget()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "cancelwaittarget": bridge.CancelWaitTarget(); return InjectionValue.Unit;

UO.ClientRequestObjectTarget

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

C# signatures

void UO.ClientRequestObjectTarget();

Opens a local crosshair for manually selecting an item or character.

Parameters

There are no parameters.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • The previous result of this runtime is reset. The command returns immediately, without waiting for a click.
  • The result is read ClientTargetResponse after WaitForClientTargetResponse or ClientTargetResponsePresent.
  • Stopping a running procedure removes the target cursor belonging to it in the nearest frame. If another request has already replaced the cursor, canceling it is not affected.
  • One client interface crosshair cannot be used simultaneously for two independent manual selections. Do not start a new request until the previous one has been processed.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.ClientRequestObjectTarget");
UO.ClientRequestObjectTarget();

1. Select an item or character - direct script

Parameters and execution flow:

  • 5000 — click waiting timeout in milliseconds. The new query resets the previous result.
  • An array of five fields indicates the selected object. result[0] is serial, not type.
UO.ClientRequestObjectTarget();
if (Truth(UO.WaitForClientTargetResponse(5000)))
{
    var result = UO.ClientTargetResponse();
    if (Truth(ArrayLength(result) == 5))
    {
        UO.Print("Serial: " + UO.Int2Hex(result[0]));
    }
    else
    {
        UO.Print("Selection cancelled");
    }
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

2. Cancel is a response, but not an object - script function

Parameters and execution flow:

  • CancelTarget cancels local selection; callback returns empty result.
  • ClientTargetResponsePresent gives 1, but the length of the array is 0. Do not access result[0] without checking the length.
return  RunScenario();
 object? RunScenario()
{
    UO.ClientRequestObjectTarget();
    UO.CancelTarget();
    if (Truth(UO.ClientTargetResponsePresent()))
    {
        var result = UO.ClientTargetResponse();
        UO.Print("Fields: " + Convert.ToString(ArrayLength(result)));
    }

    return null;
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Select Object and Save Named Reference - Script Class

Parameters and execution flow:

  • The response contains five fields; serial is in result[0]. Timeout and cancellation do not produce a usable serial.
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()
    {
        UO.ClientRequestObjectTarget();
        if (UO.WaitForClientTargetResponse(5000) == 0)
            return false;
        var result = UO.ClientTargetResponse();
        if (((object? [])result).Length != 5 || Convert.ToInt32(result[0]) == 0)
            return false;
        UO.AddObject("selected_object", result[0]);
        UO.Print($"Saved object: {UO.GetName(result[0])}");
        return true;
        return null;
    }
}

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.ClientRequestObjectTarget() — UO.ClientRequestObjectTarget()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "clientrequestobjecttarget": bridge.RequestClientTarget(false); return InjectionValue.Unit;

UO.ClientRequestTileTarget

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

C# signatures

void UO.ClientRequestTileTarget();

Opens a local crosshair for manually selecting a point/tile or object.

Parameters

There are no parameters.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • The previous result of this runtime is reset. The command returns immediately, without waiting for a click.
  • The result is read ClientTargetResponse after WaitForClientTargetResponse or ClientTargetResponsePresent.
  • Stopping a running procedure removes the target cursor belonging to it in the nearest frame. If another request has already replaced the cursor, canceling it is not affected.
  • One client interface crosshair cannot be used simultaneously for two independent manual selections. Do not start a new request until the previous one has been processed.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.ClientRequestTileTarget");
UO.ClientRequestTileTarget();

1. Read the coordinates of the selected tile - direct script

Parameters and execution flow:

  • result[1] - graphic, result[2]/[3]/[4] - X/Y/Z. The world tile has a serial result[0] equal to 0.
  • Type, coordinates and serial are separate fields. There is no static layer index in this array.
UO.ClientRequestTileTarget();
if (Truth(UO.WaitForClientTargetResponse(5000)))
{
    var result = UO.ClientTargetResponse();
    if (Truth(ArrayLength(result) == 5))
    {
        UO.Print("Type: " + UO.Int2Hex(result[1]));
        UO.Print(Convert.ToString(result[2]) + "," + Convert.ToString(result[3]) + "," + Convert.ToString(result[4]));
    }
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

2. Save the coordinates of the selected cell - script function

Parameters and execution flow:

  • For a cell, X/Y/Z are in the fields 2/3/4. Global stores strings; graphic and serial do not replace coordinates here.
return  RunScenario();
 object? RunScenario()
{
    UO.ClientRequestTileTarget();
    if (UO.WaitForClientTargetResponse(5000) == 0)
        return false;
    var selection = (object? [])UO.ClientTargetResponse();
    if (selection.Length != 5)
        return false;
    UO.SetGlobal("route.x", Convert.ToString(selection[2]));
    UO.SetGlobal("route.y", Convert.ToString(selection[3]));
    UO.SetGlobal("route.z", Convert.ToString(selection[4]));
    return true;
    return null;
}

3. Abort local cell selection - script class

Parameters and execution flow:

  • CancelTarget overrides the local cursor. The presence of a callback after cancellation does not mean the presence of a successful selection.
return await new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenarioAsync();
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;
    }

    async public Task<object?> RunScenarioAsync()
    {
        UO.ClientRequestTileTarget();
        await WaitAsync(1000);
        UO.CancelTarget();
        if (UO.ClientTargetResponsePresent() != 0)
        {
            var result = (object? [])UO.ClientTargetResponse();
            UO.Print($"Response after cancel: {result.Length} fields");
        }

        return null;
    }
}

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.ClientRequestTileTarget() — UO.ClientRequestTileTarget()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "clientrequesttiletarget": bridge.RequestClientTarget(true); return InjectionValue.Unit;

UO.ClientTargetResponse

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

C# signatures

dynamic UO.ClientTargetResponse();

Copies the result of the last local ClientRequest* to an array.

Parameters

There are no parameters.

Return value

Array of five int: [0]=serial object (0 near ground/static), [1]=graphic/type, [2]=X, [3]=Y, [4]=Z. An empty array is returned before selection, after being reset by a new request, or upon cancellation or inappropriate selection. Missing hue, map, static layer index and land/static attribute. This is not an object with named fields.

Behavior

  • Reading does not consume the result: it can be read again. The new ClientRequest* replaces it.
  • Always check ArrayLength(result)=5 before accessing indexes.

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.ClientTargetResponse();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Select an item or character - direct script

Parameters and execution flow:

  • 5000 — click waiting timeout in milliseconds. The new query resets the previous result.
  • An array of five fields indicates the selected object. result[0] is serial, not type.
UO.ClientRequestObjectTarget();
if (Truth(UO.WaitForClientTargetResponse(5000)))
{
    var result = UO.ClientTargetResponse();
    if (Truth(ArrayLength(result) == 5))
    {
        UO.Print("Serial: " + UO.Int2Hex(result[0]));
    }
    else
    {
        UO.Print("Selection cancelled");
    }
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

2. Read the coordinates of the selected tile - script function

Parameters and execution flow:

  • result[1] - graphic, result[2]/[3]/[4] - X/Y/Z. The world tile has a serial result[0] equal to 0.
  • Type, coordinates and serial are separate fields. There is no static layer index in this array.
return  RunScenario();
 object? RunScenario()
{
    UO.ClientRequestTileTarget();
    if (Truth(UO.WaitForClientTargetResponse(5000)))
    {
        var result = UO.ClientTargetResponse();
        if (Truth(ArrayLength(result) == 5))
        {
            UO.Print("Type: " + UO.Int2Hex(result[1]));
            UO.Print(Convert.ToString(result[2]) + "," + Convert.ToString(result[3]) + "," + Convert.ToString(result[4]));
        }
    }

    return null;
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Cancel is a response, but not an object - script class

Parameters and execution flow:

  • CancelTarget cancels local selection; callback returns empty result.
  • ClientTargetResponsePresent gives 1, but the length of the array is 0. Do not access result[0] without checking the length.
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()
    {
        UO.ClientRequestObjectTarget();
        UO.CancelTarget();
        if (Truth(UO.ClientTargetResponsePresent()))
        {
            var result = UO.ClientTargetResponse();
            UO.Print("Fields: " + Convert.ToString(ArrayLength(result)));
        }

        return null;
    }

    int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
    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.ClientTargetResponse() — UO.ClientTargetResponse()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "clienttargetresponse":

                    return new InjectionValue(bridge.ClientTargetResponse().Select(value => new InjectionValue(value)).ToArray());

UO.ClientTargetResponsePresent

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

C# signatures

dynamic UO.ClientTargetResponsePresent();

Checks whether a response was received to the last local select request.

Parameters

There are no parameters.

Return value

int 1 — callback has already responded, including cancellation; 0 - the new selection has not yet been completed. The value 1 does not guarantee the existence of the object: when canceled, ClientTargetResponse returns an empty Array.

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

  • Does not indicate the presence of a server sight and does not describe the WaitTarget queue.
  • Reading the result does not reset this flag; it is reset by the next ClientRequest*.

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.ClientTargetResponsePresent();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Cancel is a response, but not an object - straight script

Parameters and execution flow:

  • CancelTarget cancels local selection; callback returns empty result.
  • ClientTargetResponsePresent gives 1, but the length of the array is 0. Do not access result[0] without checking the length.
UO.ClientRequestObjectTarget();
UO.CancelTarget();
if (Truth(UO.ClientTargetResponsePresent()))
{
    var result = UO.ClientTargetResponse();
    UO.Print("Fields: " + Convert.ToString(ArrayLength(result)));
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

2. Check readiness after selecting an object - script function

Parameters and execution flow:

  • Both the readiness of the response and its content are checked. The sign 1 is not a serial object.
return  RunScenario();
 object? RunScenario()
{
    UO.ClientRequestObjectTarget();
    if (UO.WaitForClientTargetResponse(5000) == 0)
        return false;
    if (UO.ClientTargetResponsePresent() == 0)
        return false;
    var response = (object? [])UO.ClientTargetResponse();
    return response.Length == 5 && Convert.ToInt32(response[0]) != 0;
    return null;
}

3. Cell Selection Readiness Poll - Script Class

Parameters and execution flow:

  • Polling is limited to five seconds. If there is no response, the cursor is canceled; X/Y/Z fields are read only from the full response.
return await new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenarioAsync();
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;
    }

    async public Task<object?> RunScenarioAsync()
    {
        UO.ClientRequestTileTarget();
        for (int attempt = 0; attempt < 50; attempt++)
        {
            if (UO.ClientTargetResponsePresent() != 0)
            {
                var response = (object? [])UO.ClientTargetResponse();
                if (response.Length == 5)
                    UO.Print($"Selected tile: {response[2]},{response[3]},{response[4]}");
                return null;
            }

            await WaitAsync(100);
        }

        UO.CancelTarget();
        UO.Print("Selection timed out");
        return null;
    }
}

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.ClientTargetResponsePresent() — UO.ClientTargetResponsePresent()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "clienttargetresponsepresent": return new InjectionValue(bridge.ClientTargetResponsePresent());

UO.IsWaitTargetActive

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

C# signatures

dynamic UO.IsWaitTargetActive();

Checks whether prepared responses remain in the target queue.

Parameters

There are no parameters.

Return value

int 1 - there is an uncanceled deferred target of an object, tile or cancellation of the next sight; 0 - queue is empty. It's not having an open cursor; for the cursor use TargetPresent/Targeting.

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 entire client's queue is read. If several procedures are running simultaneously, the responses of each of them are taken into account.
  • Zero only means there is no response pending. It does not confirm the successful use of a skill or spell on the server.

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.IsWaitTargetActive();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Check preparation - direct script

Parameters and execution flow:

  • After WaitTargetSelf and before the server target 1 is expected.
  • CancelWaitTarget clears the queue; the next test gives 0.
UO.WaitTargetSelf();
UO.Print(Convert.ToString(UO.IsWaitTargetActive()));
UO.CancelWaitTarget();

2. Boundedly wait for response to be spent - script function

Parameters and execution flow:

  • The check has no parameters. UO.Wait=50 ms, maximum 20 expectations.
  • If the answer remains, it is cancelled. Add a check for the result of the server action separately.
return await RunScenarioAsync();
async Task<object?> RunScenarioAsync()
{
    var attempts = 0;
    while (Truth(UO.IsWaitTargetActive()) && Truth(attempts < 20))
    {
        await Delay(50);
        attempts = attempts + 1;
    }

    if (Truth(UO.IsWaitTargetActive()))
    {
        UO.CancelWaitTarget();
    }

    return null;
}

Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Show difference between queue and sight - script class

Parameters and execution flow:

  • The first line shows the deferred responses, the second - the state of the sight.
  • A queue without a cursor and a cursor without a queue are possible; these values ​​are not interchangeable.
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()
    {
        UO.Print("Queued: " + Convert.ToString(UO.IsWaitTargetActive()));
        UO.Print("Cursor: " + Convert.ToString(UO.TargetPresent()));
        return null;
    }
}

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.IsWaitTargetActive() — UO.IsWaitTargetActive()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "iswaittargetactive": return new InjectionValue(Waiting());

UO.LastTarget

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

C# signatures

int UO.LastTarget();

Reads serial of the last saved target object.

Parameters

There are no parameters.

Return value

int - serial/ID, not type and not bool. 0 means the absence of a goal-object; ground and static also have serial 0, although coordinates can be stored. All 32 bits are retained. To check for a non-zero ID, use != 0, not > 0, or == true.

Behavior

  • No parameters. Does not turn on the sight, does not select a new target, does not attack or send packets. LastTarget is different from LastAttack and LastStatus. The normal self choice does not replace the last target; an explicit ClientMarkChar can change it.
  • At SetEntity the known Entity.X/Y is preserved; for an item in a container, this could be the coordinates of the contents. SetLand/SetStatic save the world X/Y of the selected point. Subsequent movement/removal of the object does not change the saved coordinates. For the current position use GetX/GetY(serial).
  • Clear and World.Clear reset the entry, including when scripts are saved. Unknown serial in an explicit setting does not inherit the previous X/Y: they become 0. This does not guarantee that the target exists on the server.
  • Reading serial and X/Y with separate commands is not atomic. For a target object, LastTile stores network X/Y=65535; this is not a saved object position. For ground/static, LastTile(1)/(2) read the selected X/Y. lasttarget without parentheses is a built-in live value unless overridden by a variable.
  • World.Clear calls ClearWorldState: resets the active callback, saved target and replay packet. A normal Reset saves history. Internal TargetLast sends the stored packet only to the active server target; without history or for a local callback, it sends nothing and saves the target. An active client callback receives null once as a cancellation: ClientTargetResponsePresent becomes 1 when the response is empty. A completed selection is not notified again.

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.LastTarget();
UO.Print("LastTarget: " + Convert.ToString(result));

1. Read stored value - direct script

Parameters and execution flow:

  • value is the only result of the command; HEX shows ID, Convert.ToString is the coordinate. The call doesn't select anything.
var value = UO.LastTarget();
UO.Print("Saved value: " + Hex(value));

string Hex(object? value) => Convert.ToInt64(value).ToString("X");

2. Compare saved and current position - script function

Parameters and execution flow:

  • id — saved serial. Exists checks for the existence of an object before GetX/GetY. Saved coordinates and current ones may differ. With serial=0 the example prints the selected point, but 0 itself does not prove that the point was selected.
return  RunScenario();
 object? RunScenario()
{
    var id = UO.LastTarget();
    var x = UO.LastTargetX();
    var y = UO.LastTargetY();
    UO.Print("Saved XY: " + Convert.ToString(x) + "," + Convert.ToString(y));
    if (Truth(id != 0) && Truth(UO.Exists(id)))
    {
        UO.Print("Live XY: " + Convert.ToString(UO.GetX(id)) + "," + Convert.ToString(UO.GetY(id)));
    }

    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. Full Helper ReadTargetValue - Script Class

Parameters and execution flow:

  • minimum/maximum specifies the acceptable range of the assistant's result, not the API parameters. The assistant is completely defined; -1 is its own sign of going out of range. For ID, the test stores any non-zero serial, including the most significant bit, instead of the range.
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 value = ReadTargetValue();
        UO.Print("Checked value: " + Convert.ToString(value));
        return null;
    }

    dynamic ReadTargetValue()
    {
        var value = UO.LastTarget();
        if (Truth(value == 0))
        {
            return -1;
        }

        return value;
    }

    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.LastTarget() — UO.LastTarget()

Parameters: No parameters.

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

case "lasttarget": return new InjectionValue(bridge.LastTarget);

UO.LastTargetX

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

C# signatures

int UO.LastTargetX();

Reads the X coordinate saved when the last target was selected.

Parameters

There are no parameters.

Return value

int is the saved X coordinate, not a screen pixel. Before/after Clear or for an unknown object - 0; the real coordinate 0 is also acceptable. Is not bool. For ground/static it also works with LastTarget()=0.

Behavior

  • No parameters. Does not turn on the sight, does not select a new target, does not attack or send packets. LastTarget is different from LastAttack and LastStatus. The normal self choice does not replace the last target; an explicit ClientMarkChar can change it.
  • At SetEntity the known Entity.X/Y is preserved; for an item in a container, this could be the coordinates of the contents. SetLand/SetStatic save the world X/Y of the selected point. Subsequent movement/removal of the object does not change the saved coordinates. For the current position use GetX/GetY(serial).
  • Clear and World.Clear reset the entry, including when scripts are saved. Unknown serial in an explicit setting does not inherit the previous X/Y: they become 0. This does not guarantee that the target exists on the server.
  • Reading serial and X/Y with separate commands is not atomic. For a target object, LastTile stores network X/Y=65535; this is not a saved object position. For ground/static, LastTile(1)/(2) read the selected X/Y. lasttarget without parentheses is a built-in live value unless overridden by a variable.
  • World.Clear calls ClearWorldState: resets the active callback, saved target and replay packet. A normal Reset saves history. Internal TargetLast sends the stored packet only to the active server target; without history or for a local callback, it sends nothing and saves the target. An active client callback receives null once as a cancellation: ClientTargetResponsePresent becomes 1 when the response is empty. A completed selection is not notified again.

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.LastTargetX();
UO.Print("LastTargetX: " + Convert.ToString(result));

1. Read stored value - direct script

Parameters and execution flow:

  • value is the only result of the command; HEX shows ID, Convert.ToString is the coordinate. The call doesn't select anything.
var value = UO.LastTargetX();
UO.Print("Saved value: " + Convert.ToString(value));

2. Compare saved and current position - script function

Parameters and execution flow:

  • id — saved serial. Exists checks for the existence of an object before GetX/GetY. Saved coordinates and current ones may differ. With serial=0 the example prints the selected point, but 0 itself does not prove that the point was selected.
return  RunScenario();
 object? RunScenario()
{
    var id = UO.LastTarget();
    var x = UO.LastTargetX();
    var y = UO.LastTargetY();
    UO.Print("Saved XY: " + Convert.ToString(x) + "," + Convert.ToString(y));
    if (Truth(id != 0) && Truth(UO.Exists(id)))
    {
        UO.Print("Live XY: " + Convert.ToString(UO.GetX(id)) + "," + Convert.ToString(UO.GetY(id)));
    }

    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. Full Helper ReadTargetValue - Script Class

Parameters and execution flow:

  • minimum/maximum specifies the acceptable range of the assistant's result, not the API parameters. The assistant is completely defined; -1 is its own sign of going out of range. For ID, the test stores any non-zero serial, including the most significant bit, instead of the range.
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 value = ReadTargetValue(0, 65535);
        UO.Print("Checked value: " + Convert.ToString(value));
        return null;
    }

    dynamic ReadTargetValue(dynamic minimum, dynamic maximum)
    {
        var value = UO.LastTargetX();
        if (Truth(value < minimum) || Truth(value > maximum))
        {
            return -1;
        }

        return value;
    }

    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.LastTargetX() — UO.LastTargetX()

Parameters: No parameters.

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int LastTargetX() => bridge is ITargetSnapshotBridge snapshot ? snapshot.LastTargetX : bridge.GetX(bridge.LastTarget);

UO.LastTargetY

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

C# signatures

int UO.LastTargetY();

Reads the Y coordinate saved when the last target was selected.

Parameters

There are no parameters.

Return value

int is the saved Y coordinate, not a screen pixel. Before/after Clear or for an unknown object - 0; the real coordinate 0 is also acceptable. Is not bool. For ground/static it also works with LastTarget()=0.

Behavior

  • No parameters. Does not turn on the sight, does not select a new target, does not attack or send packets. LastTarget is different from LastAttack and LastStatus. The normal self choice does not replace the last target; an explicit ClientMarkChar can change it.
  • At SetEntity the known Entity.X/Y is preserved; for an item in a container, this could be the coordinates of the contents. SetLand/SetStatic save the world X/Y of the selected point. Subsequent movement/removal of the object does not change the saved coordinates. For the current position use GetX/GetY(serial).
  • Clear and World.Clear reset the entry, including when scripts are saved. Unknown serial in an explicit setting does not inherit the previous X/Y: they become 0. This does not guarantee that the target exists on the server.
  • Reading serial and X/Y with separate commands is not atomic. For a target object, LastTile stores network X/Y=65535; this is not a saved object position. For ground/static, LastTile(1)/(2) read the selected X/Y. lasttarget without parentheses is a built-in live value unless overridden by a variable.
  • World.Clear calls ClearWorldState: resets the active callback, saved target and replay packet. A normal Reset saves history. Internal TargetLast sends the stored packet only to the active server target; without history or for a local callback, it sends nothing and saves the target. An active client callback receives null once as a cancellation: ClientTargetResponsePresent becomes 1 when the response is empty. A completed selection is not notified again.

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.LastTargetY();
UO.Print("LastTargetY: " + Convert.ToString(result));

1. Read stored value - direct script

Parameters and execution flow:

  • value is the only result of the command; HEX shows ID, Convert.ToString is the coordinate. The call doesn't select anything.
var value = UO.LastTargetY();
UO.Print("Saved value: " + Convert.ToString(value));

2. Compare saved and current position - script function

Parameters and execution flow:

  • id — saved serial. Exists checks for the existence of an object before GetX/GetY. Saved coordinates and current ones may differ. With serial=0 the example prints the selected point, but 0 itself does not prove that the point was selected.
return  RunScenario();
 object? RunScenario()
{
    var id = UO.LastTarget();
    var x = UO.LastTargetX();
    var y = UO.LastTargetY();
    UO.Print("Saved XY: " + Convert.ToString(x) + "," + Convert.ToString(y));
    if (Truth(id != 0) && Truth(UO.Exists(id)))
    {
        UO.Print("Live XY: " + Convert.ToString(UO.GetX(id)) + "," + Convert.ToString(UO.GetY(id)));
    }

    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. Full Helper ReadTargetValue - Script Class

Parameters and execution flow:

  • minimum/maximum specifies the acceptable range of the assistant's result, not the API parameters. The assistant is completely defined; -1 is its own sign of going out of range. For ID, the test stores any non-zero serial, including the most significant bit, instead of the range.
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 value = ReadTargetValue(0, 65535);
        UO.Print("Checked value: " + Convert.ToString(value));
        return null;
    }

    dynamic ReadTargetValue(dynamic minimum, dynamic maximum)
    {
        var value = UO.LastTargetY();
        if (Truth(value < minimum) || Truth(value > maximum))
        {
            return -1;
        }

        return value;
    }

    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.LastTargetY() — UO.LastTargetY()

Parameters: No parameters.

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int LastTargetY() => bridge is ITargetSnapshotBridge snapshot ? snapshot.LastTargetY : bridge.GetY(bridge.LastTarget);

UO.LastTile

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

C# signatures

string UO.LastTile();
int UO.LastTile(object? index);

Reads the last saved tile target.

Parameters

  • index — Optional int 0..3: 0=graphic, 1=X, 2=Y, 3=Z. Out of range - 0. Without an index, the row of the entire record is returned.

Return value

No arguments string "graphic X Y Z" with decimal fields; with index - int of one field. The missing/short entry is padded with zeros.

Behavior

  • NormalizeLastTile completes the missing fields to four. The line does not contain map/hue/serial. The value 0 can mean a real graphic/coordinate or no field.
  • The command only reads the saved tile target; does not create a target or select a new cell. WaitTargetTile("lasttile") uses a separate record presence check.

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.LastTile();
UO.Print("LastTile: " + Convert.ToString(result));

1. Direct call - direct script

Parameters and execution flow:

  • Reads the last saved tile target.
UO.Print(UO.LastTile());

2. Explicit option - script function

Parameters and execution flow:

  • NormalizeLastTile completes the missing fields to four. The line does not contain map/hue/serial. The value 0 can mean a real graphic/coordinate or no field.
return  RunScenario();
 object? RunScenario()
{
    UO.Print(UO.LastTile(1));
    UO.Print(UO.LastTile(2));
    UO.Print(UO.LastTile(3));
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • The command only reads the saved tile target; does not create a target or select a new cell. WaitTargetTile("lasttile") uses a separate record presence check.
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 graphic = UO.LastTile(0);
        var x = UO.LastTile(1);
        var y = UO.LastTile(2);
        var z = UO.LastTile(3);
        UO.Print(Convert.ToString(graphic) + " " + Convert.ToString(x) + " " + Convert.ToString(y) + " " + Convert.ToString(z));
        return null;
    }
}

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.LastTile() — UO.LastTile()

Parameters: No parameters.

Result: string / String.

During a call:

Internal implementation code; this is not a standalone script.

public string LastTile()

        {

            int[] tileInfo = NormalizeLastTile(bridge.LastTile());



            return $"{tileInfo[0]} {tileInfo[1]} {tileInfo[2]} {tileInfo[3]}";

        }

UO.LastTile(index) — UO.LastTile(Any)

Parameters: index (Any)

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int LastTile(InjectionValue index)

        {

            var i = NumberConversions.ToInt(index);

            if (i < 0 || i > 3)

                return 0;



            return NormalizeLastTile(bridge?.LastTile())[i];



        }

UO.Target

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

C# signatures

void UO.Target();
void UO.Target(object? @object);
void UO.Target(object? targetKey, object? target);
void UO.Target(object? targetKey, object? target, object? targetType, object? @type, object? x, object? y, object? z);

Cancels/sets the expected target or sends an explicit target packet.

Parameters

  • object — One argument: serial/alias is put through WaitTargetObject. Without arguments - CancelTarget.
  • targetKey — In the 2/7 forms of the int arguments of the ID target query, usually UO.TargetID(). It is passed directly into the package and is not keypress.
  • target — Form 2: serial/alias or "lasttile". Form 7: serial object; "ground" leaves serial=0.
  • targetType - 7 form only: protocol type target, usually 0 object, 1 tile. Reduced to byte.
  • type - Only shape 7: graphic and world coordinates for tile/unknown object; graphic/X/Y are converted to ushort, Z to sbyte. For a known entity bridge, replaces them with the actual entity fields.
  • x - Only shape 7: graphic and world coordinates for tile/unknown object; graphic/X/Y are converted to ushort, Z to sbyte. For a known entity bridge, replaces them with the actual entity fields.
  • y - Only shape 7: graphic and world coordinates for tile/unknown object; graphic/X/Y are converted to ushort, Z to sbyte. For a known entity bridge, replaces them with the actual entity fields.
  • z - Only shape 7: graphic and world coordinates for tile/unknown object; graphic/X/Y are converted to ushort, Z to sbyte. For a known entity bridge, replaces them with the actual entity fields.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • Forms with no/one arguments go along ExecuteLegacyManualAlias and control the queue. Forms 2/7 call Target directly and send Send_TargetObject, not the next target's queue.
  • In the form 2 "lasttile" takes the graphic/X/Y/Z of the saved tile target; its absence displays a message. An unknown object alias also displays a message. The form 7 with targetType=0 attempts to resolve serial; other types leave serial=0.
  • Bridge.Target does not check active cursor/match targetKey; pass the current ID. Do not use the old key from the previous request. The call does not wait to be accepted by the server.
  • Explicit forms of the 2/7 arguments send the packet directly: negative serial becomes 0, targetKey is cast to uint; this branch does not clear the local cursor/queue or update TicksTarget. TargetToObject/TargetToTile use a different path for the client's active sight.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.Target");
UO.Target();

1. Direct call - direct script

Parameters and execution flow:

  • Cancels/sets the expected target or sends an explicit target packet.
UO.Target("self");
UO.Print(UO.Waiting());
UO.Target();

2. Explicit option - script function

Parameters and execution flow:

  • Forms with no/one arguments go along ExecuteLegacyManualAlias and control the queue. Forms 2/7 call Target directly and send Send_TargetObject, not the next target's queue.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.TargetPresent()))
    {
        UO.Target(UO.TargetID(), "self");
    }

    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. Full Helper Function - Script Class

Parameters and execution flow:

  • Bridge.Target does not check active cursor/match targetKey; pass the current ID. Do not use the old key from the previous request. The call does not wait to be accepted by the server.
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()
    {
        if (Truth(UO.TargetPresent()))
        {
            UO.Target(UO.TargetID(), "ground", 1, 0, UO.GetX(), UO.GetY(), 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;
}

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.Target() — UO.Target()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "target":

                    if (arguments.Length > 0) WaitTargetObject(arguments[0].ToString());

                    else CancelTarget();

                    break;

UO.Target(object) — UO.Target(Any)

Parameters: object (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "target":

                    if (arguments.Length > 0) WaitTargetObject(arguments[0].ToString());

                    else CancelTarget();

                    break;

UO.Target(targetKey, target) — UO.Target(Any,Any)

Parameters: targetKey (Any), target (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void Target(InjectionValue targetKey, InjectionValue target)

        {

            int key = NumberConversions.ToInt(targetKey);

            string selector = target.Kind == InjectionValueKind.String ? target.String : string.Empty;



            if (selector.Equals("lasttile", StringComparison.OrdinalIgnoreCase))

            {

                int[] tile = bridge.LastTile() ?? Array.Empty<int>();

                if (tile.Length >= 4)

                    bridge.Target(key, 0, 1, tile[0], tile[1], tile[2], tile[3]);

                else

                    SystemMessage("UO.Target: lasttile is unavailable");

                return;

            }



            if (TryGetObject(target, out int serial))

                bridge.Target(key, serial, 0, 0, 0, 0, 0);

            else

                SystemMessage($"UO.Target: invalid target '{selector}'");

        }

UO.Target(targetKey, target, targetType, type, x, y, z) — UO.Target(Any,Any,Any,Any,Any,Any,Any)

Parameters: targetKey (Any), target (Any), targetType (Any), type (Any), x (Any), y (Any), z (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void Target

        (

            InjectionValue targetKey,

            InjectionValue target,

            InjectionValue targetType,

            InjectionValue type,

            InjectionValue x,

            InjectionValue y,

            InjectionValue z

        )

        {

            int targetTypeValue = NumberConversions.ToInt(targetType);

            string selector = target.Kind == InjectionValueKind.String ? target.String : string.Empty;

            int serial = 0;



            if (targetTypeValue == 0 && !selector.Equals("ground", StringComparison.OrdinalIgnoreCase))

                TryGetObject(target, out serial);



            bridge.Target

            (

                NumberConversions.ToInt(targetKey),

                serial,

                targetTypeValue,

                ResolveType(type),

                NumberConversions.ToInt(x),

                NumberConversions.ToInt(y),

                NumberConversions.ToInt(z)

            );

        }

UO.TargetByResource

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

C# signatures

void UO.TargetByResource(object? objID, object? resource);

Searches for an item by graphic, prepares a given target and uses the found item.

Parameters

  • objID — Serial/ID object: int, numeric/hex string or set alias, for example "lasttarget". This is not a graphic/type. Check the loaded object before taking action.
  • resource — Graphic/type of item to search, ResolveType allowed; this is not the resource field number from Pascal API.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • In this implementation, FindType(ResolveType(Resource), -1, 0, -1, true) searches for an item. If found != 0, first bridge.WaitTargetObject(ObjID), then bridge.UseObject(found).
  • Nothing was found - nothing is installed or used. The command does not send a separate resource-target-packet; scope=0 selects items with RootContainer=Player.Serial, including inventory contents/equipment; recursive=true is passed to bridge, but this scope0 branch itself uses RootContainer.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.TargetByResource");
UO.TargetByResource("self", "0x0E21");

1. Direct call - direct script

Parameters and execution flow:

  • Searches for an item by graphic, prepares a given target and uses the found item.
UO.TargetByResource("self", "0x0E21");

2. Explicit option - script function

Parameters and execution flow:

  • In this implementation, FindType(ResolveType(Resource), -1, 0, -1, true) searches for an item. If found != 0, first bridge.WaitTargetObject(ObjID), then bridge.UseObject(found).
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.Exists("lasttarget")))
    {
        UO.TargetByResource("lasttarget", "0x0E21");
    }

    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. Full Helper Function - Script Class

Parameters and execution flow:

  • Nothing was found - nothing is installed or used. The command does not send a separate resource-target-packet; scope=0 selects items with RootContainer=Player.Serial, including inventory contents/equipment; recursive=true is passed to bridge, but this scope0 branch itself uses RootContainer.
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()
    {
        UO.TargetByResource("self", "0x0E21");
        UO.Print(UO.Waiting());
        UO.CancelWaitTarget();
        return null;
    }
}

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.TargetByResource(objID, resource) — UO.TargetByResource(Any,Any)

Parameters: objID (Any), resource (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "targetbyresource":

                {

                    int found = bridge.FindType(ResolveType(arguments[1]), -1, 0, -1, true);

                    if (found != 0) { bridge.WaitTargetObject(Arg(0)); bridge.UseObject(found); }

                    return InjectionValue.Unit;

                }

UO.TargetID

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

C# signatures

dynamic UO.TargetID();

Reads the ID of the current target cursor.

Parameters

There are no parameters.

Return value

int is the 32 bit ID of the cursor, not the serial of the last object. If there is no cursor, 0 is returned. If the most significant bit is set, int is negative; Int2Hex preserves its bits. Real cursorID=0 and local target cursor can also give 0: check TargetPresent to determine activity. In this client, the special non-null substitution for the null ID is not used.

Behavior

  • LastTarget/GetSerial("lasttarget") refer to the selected object, TargetID refers to the target request. These values ​​cannot be replaced with each other.

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.TargetID();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Print ID of the active cursor - direct script

Parameters and execution flow:

  • There are no arguments.
  • Int2Hex allows you to see all the bits of ID, including the most significant bit.
if (Truth(UO.TargetPresent()))
{
    UO.Print(UO.Int2Hex(UO.TargetID()));
}

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

2. Distinguish between two types ID - script function

Parameters and execution flow:

  • cursor — ID of the sight, object — serial of the object.
  • TargetToObject is passed an object, not a cursor.
return  RunScenario();
 object? RunScenario()
{
    var cursor = UO.TargetID();
    var targetSerial = UO.GetSerial("lasttarget");
    UO.Print("Cursor: " + UO.Int2Hex(cursor));
    UO.Print("Object: " + targetSerial);
    return null;
}

3. Check After Wait - Script Class

Parameters and execution flow:

  • 1000 — wait timeout in milliseconds.
  • The sign of occurrence is the result WaitForTarget; The cursor sign is not checked for this.
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()
    {
        if (Truth(UO.WaitForTarget(1000)))
        {
            var cursor = UO.TargetID();
            UO.Print("Request: " + UO.Int2Hex(cursor));
        }
        else
        {
            UO.Print("No cursor arrived");
        }

        return null;
    }

    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.TargetID() — UO.TargetID()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "targetid": return new InjectionValue(bridge.GetTargetCursorId());

UO.TargetPresent

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

C# signatures

dynamic UO.TargetPresent();

Checks for an active target selection cursor in the client.

Parameters

There are no parameters.

Return value

int 1 - TargetManager.IsTargeting set; 0 - no active cursor. The local callback target is also taken into account. This is not serial or the queue state WaitTarget.

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

  • Reads the state once; does not wait for the cursor to appear.
  • To wait for a server crosshair after a game action, use WaitForTarget. For the result of local ClientRequest* - WaitForClientTargetResponse.

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.TargetPresent();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Show status - direct script

Parameters and execution flow:

  • There are no arguments.
  • 1 or 0 is displayed.
UO.Print(Convert.ToString(UO.TargetPresent()));

2. Cancel open cursor - script function

Parameters and execution flow:

  • The condition is checked by the active cursor.
  • CancelTarget in this client also clears prepared responses.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.TargetPresent()))
    {
        UO.CancelTarget();
    }

    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. After requesting a game action - scenario class

Parameters and execution flow:

  • UseSkill requests the skill, WaitForTarget waits until 3000 ms.
  • TargetToObject responds only to the active server target; If there is a timeout, the branch is not executed.
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()
    {
        UO.UseSkill("Anatomy");
        if (Truth(UO.WaitForTarget(3000)))
        {
            if (Truth(UO.TargetPresent()))
            {
                UO.TargetToObject("self");
            }
        }

        return null;
    }

    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.TargetPresent() — UO.TargetPresent()

Parameters: No parameters.

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "targetpresent": return new InjectionValue(IsTargeting());

UO.TargetToObject

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

C# signatures

void UO.TargetToObject(object? objID);

Immediately responds to an already active server target serial object.

Parameters

  • objID — Serial/ID of an item or character, number or hex/decimal string, self/backpack/lasttarget/lastobject or saved name AddObject. This is not type. Before acting on a named object, check Exists; an unresolved alias gives serial 0.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • Without an active server cursor, it does nothing and does not create a deferred response. For preliminary preparation, use WaitTargetObject/WaitTargetTile/WaitTargetXYZ.
  • Local ClientRequest* and other callback sights are not processed by this command.
  • The server determines whether the target is valid. For serial not in memory, ID is sent with zero graphics/coordinate fields.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.TargetToObject");
UO.TargetToObject("self");

1. Reply to open sight - direct script

Parameters and execution flow:

  • The parameters define the character itself.
  • Nothing is added to the future target cursor queue.
if (Truth(UO.TargetPresent()))
{
    UO.TargetToObject("self");
}

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

2. First wait for sight - script function

Parameters and execution flow:

  • 3000 — maximum wait in milliseconds; The action that requested the sight must be performed previously.
  • The command is called only after the sight appears; the game action may then end in server failure.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.WaitForTarget(3000)))
    {
        UO.TargetToObject("self");
    }
    else
    {
        UO.Print("Target timeout");
    }

    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. Check for deferred response - script class

Parameters and execution flow:

  • CancelTarget closes the old sight and clears the queue.
  • In the absence of a new target cursor, the challenge does not create anticipation. The queue output remains 0 unless another script has changed it.
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()
    {
        UO.CancelTarget();
        UO.TargetToObject("self");
        UO.Print("Queued: " + Convert.ToString(UO.IsWaitTargetActive()));
        return null;
    }
}

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.TargetToObject(objID) — UO.TargetToObject(Any)

Parameters: objID (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "targettoobject": bridge.TargetToObject(Arg(0)); return InjectionValue.Unit;

UO.TargetToTile

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

C# signatures

void UO.TargetToTile(object? tile, object? x, object? y, object? z);

Immediately responds to an already active server target with tile coordinates.

Parameters

  • tile — Graphic/type tile, 0..65535, not serial. Zero indicates a coordinate target with no specified graphics.
  • x — World X coordinate on the current map, 0..65535. This is not a screen pixel or gump coordinate.
  • y — World Y coordinate on the current map, 0..65535.
  • z - Height of the game point, for a network target use -128..127. This is not a floor or a layer of equipment.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • Without an active server cursor, it does nothing and does not create a deferred response. For preliminary preparation, use WaitTargetObject/WaitTargetTile/WaitTargetXYZ.
  • Local ClientRequest* and other callback sights are not processed by this command.
  • A target with graphic=0 requires a crosshair; The object sight does not accept the ground.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.TargetToTile");
UO.TargetToTile(0x0CCA, 1445, 1690, 0);

1. Reply to open sight - direct script

Parameters and execution flow:

  • The parameters set an example of a real point: replace the coordinates and graphic with the desired values.
  • Nothing is added to the future target cursor queue.
if (Truth(UO.TargetPresent()))
{
    UO.TargetToTile(0x0CCA, 1445, 1690, 0);
}

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

2. First wait for sight - script function

Parameters and execution flow:

  • 3000 — maximum wait in milliseconds; The action that requested the sight must be performed previously.
  • The command is called only after the sight appears; the game action may then end in server failure.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.WaitForTarget(3000)))
    {
        UO.TargetToTile(0x0CCA, 1445, 1690, 0);
    }
    else
    {
        UO.Print("Target timeout");
    }

    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. Check for deferred response - script class

Parameters and execution flow:

  • CancelTarget closes the old sight and clears the queue.
  • In the absence of a new target cursor, the challenge does not create anticipation. The queue output remains 0 unless another script has changed it.
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()
    {
        UO.CancelTarget();
        UO.TargetToTile(0x0CCA, 1445, 1690, 0);
        UO.Print("Queued: " + Convert.ToString(UO.IsWaitTargetActive()));
        return null;
    }
}

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.TargetToTile(tile, x, y, z) — UO.TargetToTile(Any,Any,Any,Any)

Parameters: tile (Any), x (Any), y (Any), z (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "targettotile":

                    bridge.TargetToTile(Arg(0), Arg(1), Arg(2), Arg(3)); return InjectionValue.Unit;

UO.TargetToXYZ

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

C# signatures

void UO.TargetToXYZ(object? x, object? y, object? z);

Immediately responds to an already active server target with tile coordinates.

Parameters

  • x — World X coordinate on the current map, 0..65535. This is not a screen pixel or gump coordinate.
  • y — World Y coordinate on the current map, 0..65535.
  • z - Height of the game point, for a network target use -128..127. This is not a floor or a layer of equipment.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • Without an active server cursor, it does nothing and does not create a deferred response. For preliminary preparation, use WaitTargetObject/WaitTargetTile/WaitTargetXYZ.
  • Local ClientRequest* and other callback sights are not processed by this command.
  • A target with graphic=0 requires a crosshair; The object sight does not accept the ground.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.TargetToXYZ");
UO.TargetToXYZ(1445, 1690, 0);

1. Reply to open sight - direct script

Parameters and execution flow:

  • The parameters set an example of a real point: replace the coordinates and graphic with the desired values.
  • Nothing is added to the future target cursor queue.
if (Truth(UO.TargetPresent()))
{
    UO.TargetToXYZ(1445, 1690, 0);
}

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

2. First wait for sight - script function

Parameters and execution flow:

  • 3000 — maximum wait in milliseconds; The action that requested the sight must be performed previously.
  • The command is called only after the sight appears; the game action may then end in server failure.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.WaitForTarget(3000)))
    {
        UO.TargetToXYZ(1445, 1690, 0);
    }
    else
    {
        UO.Print("Target timeout");
    }

    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. Check for deferred response - script class

Parameters and execution flow:

  • CancelTarget closes the old sight and clears the queue.
  • In the absence of a new target cursor, the challenge does not create anticipation. The queue output remains 0 unless another script has changed it.
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()
    {
        UO.CancelTarget();
        UO.TargetToXYZ(1445, 1690, 0);
        UO.Print("Queued: " + Convert.ToString(UO.IsWaitTargetActive()));
        return null;
    }
}

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.TargetToXYZ(x, y, z) — UO.TargetToXYZ(Any,Any,Any)

Parameters: x (Any), y (Any), z (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "targettoxyz":

                    bridge.TargetToTile(0, Arg(0), Arg(1), Arg(2)); return InjectionValue.Unit;

UO.Targeting

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

C# signatures

int UO.Targeting();

Checks for an active target selection cursor in the client.

Parameters

There are no parameters.

Return value

int 1 - TargetManager.IsTargeting set; 0 - no active cursor. The local callback target is also taken into account. This is not serial or the queue state WaitTarget.

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

  • Reads the state once; does not wait for the cursor to appear.
  • To wait for a server crosshair after a game action, use WaitForTarget. For the result of local ClientRequest* - WaitForClientTargetResponse.

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.Targeting();
UO.Print("Targeting: " + Convert.ToString(result));

1. Show status - direct script

Parameters and execution flow:

  • There are no arguments.
  • 1 or 0 is displayed.
UO.Print(Convert.ToString(UO.Targeting()));

2. Cancel open cursor - script function

Parameters and execution flow:

  • The condition is checked by the active cursor.
  • CancelTarget in this client also clears prepared responses.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.Targeting()))
    {
        UO.CancelTarget();
    }

    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. After requesting a game action - scenario class

Parameters and execution flow:

  • UseSkill requests the skill, WaitForTarget waits until 3000 ms.
  • TargetToObject responds only to the active server target; If there is a timeout, the branch is not executed.
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()
    {
        UO.UseSkill("Anatomy");
        if (Truth(UO.WaitForTarget(3000)))
        {
            if (Truth(UO.Targeting()))
            {
                UO.TargetToObject("self");
            }
        }

        return null;
    }

    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.Targeting() — UO.Targeting()

Parameters: No parameters.

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int IsTargeting() => bridge.IsTargeting();

UO.TicksTarget

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

C# signatures

int UO.TicksTarget();

Reads the target's last provisioning timestamp via WaitTargetObject/WaitTargetTile and their calling shells.

Parameters

There are no parameters.

Return value

int — the value of UO.Timer at the time of preparation, in tenths of a second from the start of runtime. Before the first such training - 0. This is a mark, not a wait duration, not a millisecond, and not a ID target.

Behavior

  • Immediate TargetToObject/TargetToTile/TargetToXYZ do not prepare the queue and do not update this mark.
  • Some search commands put the answer directly through the bridge; TicksTarget is not the universal time of any target change.

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.TicksTarget();
UO.Print("TicksTarget: " + Convert.ToString(result));

1. Remember the moment of preparation - direct script

Parameters and execution flow:

  • There are no arguments; WaitTargetSelf updates the elevation.
  • stamp is measured in tenths of a second.
UO.WaitTargetSelf();
var stamp = UO.TicksTarget();
UO.Print(Convert.ToString(stamp));
UO.CancelWaitTarget();

2. Calculate Elapsed Time - Script Function

Parameters and execution flow:

  • UO.Wait=250 milliseconds.
  • Due to the discrete nature of the mark, elapsed is usually 2 or 3 rather than 250.
return await RunScenarioAsync();
async Task<object?> RunScenarioAsync()
{
    UO.WaitTargetObject("self");
    await Delay(250);
    var elapsed = UO.Timer() - UO.TicksTarget();
    UO.Print("Tenths: " + Convert.ToString(elapsed));
    UO.CancelWaitTarget();
    return null;
}

Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));

3. Ensure the same time for numeric serial - script class

Parameters and execution flow:

  • selfId — int serial of your character.
  • The numeric form updates the mark like the string form; TicksTarget has no parameters.
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 selfId = UO.Hex2Int(UO.GetSerial("self"));
        UO.WaitTargetObject(selfId);
        UO.Print(Convert.ToString(UO.TicksTarget()));
        UO.CancelWaitTarget();
        return null;
    }
}

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.TicksTarget() — UO.TicksTarget()

Parameters: No parameters.

Result: int / Integer.

During a call:

Internal implementation code; this is not a standalone script.

public int TicksTarget() => ticksTarget;

UO.WaitForClientTargetResponse

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

C# signatures

dynamic UO.WaitForClientTargetResponse(object? maxWaitTimeMS);

Waits for local selection ClientRequestObjectTarget/ClientRequestTileTarget to complete.

Parameters

  • maxWaitTimeMS — Maximum time in milliseconds. 0 and negative values ​​give one check, without waiting indefinitely.

Return value

int 1 - response has already been received, including cancellation; 0 - timeout has expired. For 1, still check the length of ClientTargetResponse. With 0 the cursor itself does not close automatically.

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 wait occurs in the script thread at intervals of up to 25 ms and is interrupted by stopping the script.
  • Without the previous ClientRequest* the new selection does not start.

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.WaitForClientTargetResponse(5000);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Select an item or character - direct script

Parameters and execution flow:

  • 5000 — click waiting timeout in milliseconds. The new query resets the previous result.
  • An array of five fields indicates the selected object. result[0] is serial, not type.
UO.ClientRequestObjectTarget();
if (Truth(UO.WaitForClientTargetResponse(5000)))
{
    var result = UO.ClientTargetResponse();
    if (Truth(ArrayLength(result) == 5))
    {
        UO.Print("Serial: " + UO.Int2Hex(result[0]));
    }
    else
    {
        UO.Print("Selection cancelled");
    }
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

2. Read the coordinates of the selected tile - script function

Parameters and execution flow:

  • result[1] - graphic, result[2]/[3]/[4] - X/Y/Z. The world tile has a serial result[0] equal to 0.
  • Type, coordinates and serial are separate fields. There is no static layer index in this array.
return  RunScenario();
 object? RunScenario()
{
    UO.ClientRequestTileTarget();
    if (Truth(UO.WaitForClientTargetResponse(5000)))
    {
        var result = UO.ClientTargetResponse();
        if (Truth(ArrayLength(result) == 5))
        {
            UO.Print("Type: " + UO.Int2Hex(result[1]));
            UO.Print(Convert.ToString(result[2]) + "," + Convert.ToString(result[3]) + "," + Convert.ToString(result[4]));
        }
    }

    return null;
}

int ArrayLength(object? value) => value is System.Array array ? array.Length : 0;
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;

3. Separate timeout from full response structure - script class

Parameters and execution flow:

  • The timeout is specified in milliseconds. A successful wait means a response, the content of which must be checked separately.
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()
    {
        UO.ClientRequestTileTarget();
        int ready = UO.WaitForClientTargetResponse(3000);
        if (ready == 0)
        {
            UO.CancelTarget();
            UO.Print("Selection timed out");
            return false;
        }

        var response = (object? [])UO.ClientTargetResponse();
        if (response.Length != 5)
            return false;
        UO.Print($"Tile coordinates: {response[2]}, {response[3]}, {response[4]}");
        return true;
        return null;
    }
}

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.WaitForClientTargetResponse(maxWaitTimeMS) — UO.WaitForClientTargetResponse(Any)

Parameters: maxWaitTimeMS (Any)

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "waitforclienttargetresponse": return new InjectionValue(bridge.WaitForClientTargetResponse(Arg(0)));

UO.WaitForTarget

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

C# signatures

dynamic UO.WaitForTarget(object? maxWaitTimeMS);

Waits for the active target cursor to appear within the timeout.

Parameters

  • maxWaitTimeMS — Maximum wait in milliseconds. Zero and negative values ​​give one immediate check; It's not an endless wait.

Return value

int 1 — the cursor was active during verification; 0 - timeout without cursor. The local callback target also satisfies this test. This is not confirmation of the use of the prepared WaitTarget: the automatic response may already have used up the cursor before checking.

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 check is performed with pauses of up to 25 ms in the script thread and can be interrupted by stopping it.
  • The method itself does not create a crosshair or select a target.

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.WaitForTarget(3000);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));

1. Wait for skill sight - direct script

Parameters and execution flow:

  • MaxWaitTimeMS=3000, then self is selected.
  • WaitTargetSelf is not preset: this example answers explicitly.
UO.UseSkill("Anatomy");
if (Truth(UO.WaitForTarget(3000)))
{
    UO.TargetToObject("self");
}

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

2. One check - script function

Parameters and execution flow:

  • MaxWaitTimeMS=0.
  • ready - 1 or 0; There is no long pause.
return  RunScenario();
 object? RunScenario()
{
    var ready = UO.WaitForTarget(0);
    UO.Print(Convert.ToString(ready));
    return null;
}

3. Handle Timeout - Script Class

Parameters and execution flow:

  • 500 - half a second.
  • The absence of a sight may mean that the action has failed or is being processed automatically: check the game log.
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()
    {
        if (Truth(UO.WaitForTarget(500) == 0))
        {
            UO.CancelWaitTarget();
            UO.Print("Cursor did not arrive");
        }

        return null;
    }

    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.WaitForTarget(maxWaitTimeMS) — UO.WaitForTarget(Any)

Parameters: maxWaitTimeMS (Any)

Result: dynamic / Any.

During a call:

Internal implementation code; this is not a standalone script.

case "waitfortarget": return new InjectionValue(bridge.WaitUntilTargeting(Arg(0)));

UO.WaitTarget

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

C# signatures

void UO.WaitTarget(object? target);
void UO.WaitTarget(object? target, object? @type);
void UO.WaitTarget(object? target, object? @type, object? color);
void UO.WaitTarget(object? target, object? @type, object? color, object? distance);
void UO.WaitTarget(object? target, object? @type, object? color, object? distance, object? notoriety);
void UO.WaitTarget(object? target, object? @type, object? color, object? distance, object? notoriety, object? nearest);
void UO.WaitTarget(object? target, object? @type, object? color, object? distance, object? notoriety, object? nearest, object? maxZ);

Places serial in the queue of the next target request, or selects a target using filters.

Parameters

  • target — A positive allowed serial/alias is set directly, other parameters are ignored. 0 or -1 enables search; another numeric sentinel cancels the next target.
  • type - Optional graphic/type or type mask; -1 without limitation. Named types are resolved by ResolveType/ParseTypeMask.
  • color - Optional hue: -1 or 0xFFFF without limitation.
  • distance — Optional maximum distance in cells; default is GetFindDistance. Parsing ResolveCompactDistance allows special values ​​according to the search setting.
  • notoriety - Optional number/mask notoriety. A non-empty mask restricts Mobile candidates; without it, mobiles and world items are considered.
  • nearest - Optional bool, default true: sorts by distance, then serial.
  • maxZ — Optional maximum abs(Z-selfZ), default GetFindVertical.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • When searching, excludes self, serial=0, regular ignore list and selected named type filters; duplicates are removed. Direct positive serial does not pass these filters.
  • The search only reads loaded objects. No matches/invalid sentinel - message and CancelNextTarget. A successful selection calls WaitTargetObject and updates TicksTarget. WaitTarget itself does not use the item, does not open the target and does not wait for the server to process 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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTarget");
UO.WaitTarget("self");

1. Direct call - direct script

Parameters and execution flow:

  • Places serial in the queue of the next target request, or selects a target using filters.
UO.WaitTarget("self");

2. Explicit option - script function

Parameters and execution flow:

  • When searching, excludes self, serial=0, regular ignore list and selected named type filters; duplicates are removed. Direct positive serial does not pass these filters.
return  RunScenario();
 object? RunScenario()
{
    UO.WaitTarget(0, -1, -1, 10, 3, true, 20);
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • The search only reads loaded objects. No matches/invalid sentinel - message and CancelNextTarget. A successful selection calls WaitTargetObject and updates TicksTarget. WaitTarget itself does not use the item, does not open the target and does not wait for the server to process it.
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()
    {
        UO.WaitTarget("lasttarget");
        UO.Print(UO.Waiting());
        UO.CancelWaitTarget();
        return null;
    }
}

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.WaitTarget(target) — UO.WaitTarget(Any)

Parameters: target (Any)

Result: void / Unit.

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 =>

                    {

                        CompactWaitTarget(values);

                        return InjectionValue.Unit;

                    }

UO.WaitTarget(target, type) — UO.WaitTarget(Any,Any)

Parameters: target (Any), type (Any)

Result: void / Unit.

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 =>

                    {

                        CompactWaitTarget(values);

                        return InjectionValue.Unit;

                    }

UO.WaitTarget(target, type, color) — UO.WaitTarget(Any,Any,Any)

Parameters: target (Any), type (Any), color (Any)

Result: void / Unit.

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 =>

                    {

                        CompactWaitTarget(values);

                        return InjectionValue.Unit;

                    }

UO.WaitTarget(target, type, color, distance) — UO.WaitTarget(Any,Any,Any,Any)

Parameters: target (Any), type (Any), color (Any), distance (Any)

Result: void / Unit.

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 =>

                    {

                        CompactWaitTarget(values);

                        return InjectionValue.Unit;

                    }

UO.WaitTarget(target, type, color, distance, notoriety) — UO.WaitTarget(Any,Any,Any,Any,Any)

Parameters: target (Any), type (Any), color (Any), distance (Any), notoriety (Any)

Result: void / Unit.

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 =>

                    {

                        CompactWaitTarget(values);

                        return InjectionValue.Unit;

                    }

UO.WaitTarget(target, type, color, distance, notoriety, nearest) — UO.WaitTarget(Any,Any,Any,Any,Any,Any)

Parameters: target (Any), type (Any), color (Any), distance (Any), notoriety (Any), nearest (Any)

Result: void / Unit.

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 =>

                    {

                        CompactWaitTarget(values);

                        return InjectionValue.Unit;

                    }

UO.WaitTarget(target, type, color, distance, notoriety, nearest, maxZ) — UO.WaitTarget(Any,Any,Any,Any,Any,Any,Any)

Parameters: target (Any), type (Any), color (Any), distance (Any), notoriety (Any), nearest (Any), maxZ (Any)

Result: void / Unit.

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 =>

                    {

                        CompactWaitTarget(values);

                        return InjectionValue.Unit;

                    }

UO.WaitTargetGround

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

C# signatures

void UO.WaitTargetGround(object? @type);
void UO.WaitTargetGround(object? @type, object? color);

Searches for an item by graphic/hue and puts it in the queue for the next target.

Parameters

  • type — Graphic/type int, hex string or specified named type. This is not a serial item.
  • color — Optional int hue; default -1 - any color.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • Area: ground/container selector 1 without recursive search. Bridge.FindType returns the found serial; with serial>0 bridge.WaitTargetObject is called. These methods do not directly update runtime TicksTarget.
  • No item - message and CancelNextTarget. The search may change the general FindItem/FoundItems; The command does not use the found item and does not wait for cursor.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTargetGround");
UO.WaitTargetGround("0x0E21");

1. Direct call - direct script

Parameters and execution flow:

  • Searches for an item by graphic/hue and puts it in the queue for the next target.
UO.WaitTargetGround("0x0E21");

2. Explicit option - script function

Parameters and execution flow:

  • Area: ground/container selector 1 without recursive search. Bridge.FindType returns the found serial; with serial>0 bridge.WaitTargetObject is called. These methods do not directly update runtime TicksTarget.
return  RunScenario();
 object? RunScenario()
{
    UO.WaitTargetGround("0x0E21", -1);
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • No item - message and CancelNextTarget. The search may change the general FindItem/FoundItems; The command does not use the found item and does not wait for cursor.
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()
    {
        UO.WaitTargetGround("0x0E21", -1);
        UO.Print(UO.Waiting());
        UO.CancelWaitTarget();
        return null;
    }
}

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.WaitTargetGround(type) — UO.WaitTargetGround(Any)

Parameters: type (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetGround(InjectionValue type) => WaitTargetGround(type, new InjectionValue(-1));

UO.WaitTargetGround(type, color) — UO.WaitTargetGround(Any,Any)

Parameters: type (Any), color (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetGround(InjectionValue type, InjectionValue color)

        {

            int item = bridge.FindType(ResolveType(type), NumberConversions.ToInt(color), 1, -1, false);

            if (item <= 0)

            {

                SystemMessage("No ground item found. Next target request will be canceled");

                bridge.CancelNextTarget();

            }

            else

                bridge.WaitTargetObject(item);

        }

UO.WaitTargetLast

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

C# signatures

void UO.WaitTargetLast();

Prepares a response to the next server target via the alias lasttarget.

Parameters

There are no parameters.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • The team only prepares a response: it does not use the item, skill or spell itself. The next server target receives the prepared target when processing the client frame.
  • Consecutive calls form a common client queue. Objects and coordinate targets are processed one at a time; local selection windows ClientRequest*/Info/container do not consume it.
  • CancelWaitTarget clears the queue. TerminateAll cleans it entirely; stopping a procedure that is still running also invalidates its own pending responses. Completing a short procedure normally does not cancel the prepared target.
  • Sending a response does not guarantee action on the server: it checks the range, accessibility of the object, visibility and action rules. To control, use the game result and log.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTargetLast");
UO.WaitTargetLast();

1. Prepare target - direct script

Parameters and execution flow:

  • There are no arguments; lasttarget is used.
  • The command does not open the sight and perform the action itself.
UO.WaitTargetLast();

2. Check for presence of selected object - script function

Parameters and execution flow:

  • lasttarget must resolve to the loaded character for this skill.
  • The Exists check filters out an unknown object; the choice of object type and skill validity remain script conditions.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.Exists("lasttarget")))
    {
        UO.CancelWaitTarget();
        UO.WaitTargetLast();
        UO.UseSkill("Anatomy");
    }

    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. Cancel Prepared Target - Script Class

Parameters and execution flow:

  • IsWaitTargetActive checks the response queue.
  • CancelWaitTarget unpreps without closing the already open custom crosshair.
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()
    {
        UO.WaitTargetLast();
        if (Truth(UO.IsWaitTargetActive()))
        {
            UO.CancelWaitTarget();
        }

        return null;
    }

    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.WaitTargetLast() — UO.WaitTargetLast()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetLast() => WaitTargetObject("lasttarget");

UO.WaitTargetObject

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

C# signatures

void UO.WaitTargetObject(object? objID);
void UO.WaitTargetObject(object? id1, object? id2);

Prepares one or two sequential serial responses to server sights.

Parameters

  • objID / id1 / id2 — Serial/ID of an item or character, number or hex/decimal string, self/backpack/lasttarget/lastobject or saved name AddObject. This is not type. Before acting on a named object, check Exists; an unresolved alias gives serial 0. A single argument specifies one goal. The numeric and string forms update TicksTarget in the same way.
  • objID — Serial/ID of an item or character, number or hex/decimal string, self/backpack/lasttarget/lastobject or saved name AddObject. This is not type. Before acting on a named object, check Exists; an unresolved alias gives serial 0. A single argument specifies one goal. The numeric and string forms update TicksTarget in the same way.
  • id1 — Serial/ID of an item or character, number or hex/decimal string, self/backpack/lasttarget/lastobject or saved name AddObject. This is not type. Before acting on a named object, check Exists; an unresolved alias gives serial 0. The first goal of the form is with two lines.
  • id2 — Serial/ID of an item or character, number or hex/decimal string, self/backpack/lasttarget/lastobject or saved name AddObject. This is not type. Before acting on a named object, check Exists; an unresolved alias gives serial 0. The second purpose of the form is with two lines; applies to the next individual target cursor.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • The team only prepares a response: it does not use the item, skill or spell itself. The next server target receives the prepared target when processing the client frame.
  • Consecutive calls form a common client queue. Objects and coordinate targets are processed one at a time; local selection windows ClientRequest*/Info/container do not consume it.
  • CancelWaitTarget clears the queue. TerminateAll cleans it entirely; stopping a procedure that is still running also invalidates its own pending responses. Completing a short procedure normally does not cancel the prepared target.
  • Sending a response does not guarantee action on the server: it checks the range, accessibility of the object, visibility and action rules. To control, use the game result and log.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTargetObject");
UO.WaitTargetObject("self");

1. Pre-select yourself for a skill - direct script

Parameters and execution flow:

  • id="self" - serial of your character. CancelWaitTarget removes previously prepared answers.
  • UseSkill requests a skill; his server sight receives a prepared target.
UO.CancelWaitTarget();
UO.WaitTargetObject("self");
UO.UseSkill("Anatomy");

2. Select known object by numeric serial - script function

Parameters and execution flow:

  • objectId - example serial: replace with yours. This is not a graphic/type.
  • Here the target has just been prepared. The next step of the script should call an action that actually expects target.
return  RunScenario();
 object? RunScenario()
{
    var objectId = 0x40001234;
    if (Truth(UO.Exists(objectId)))
    {
        UO.WaitTargetObject(objectId);
        UO.Print("Object target prepared");
    }

    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. Two sights: the first object and the second object - the script class

Parameters and execution flow:

  • source and destination are predefined names AddObject. GetSerial returns rows matching the form id1/id2.
  • The first server sight uses first, the second - second. Only suitable for action with two sequential sights; Clear an unnecessary second target before taking another action.
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 first = UO.GetSerial("source");
        var second = UO.GetSerial("destination");
        if (Truth(UO.Exists(first)) && Truth(UO.Exists(second)))
        {
            UO.CancelWaitTarget();
            UO.WaitTargetObject(first, second);
        }

        return null;
    }

    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.WaitTargetObject(objID) — UO.WaitTargetObject(Any)

Parameters: objID (Any/String)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "waittargetobject": WaitTargetObject(Arg(0)); return InjectionValue.Unit;

UO.WaitTargetObject(objID) — UO.WaitTargetObject(String)

Parameters: objID (Any/String)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetObject(string id) => WaitTargetObject(GetObject(id));

UO.WaitTargetObject(id1, id2) — UO.WaitTargetObject(String,String)

Parameters: id1 (String), id2 (String)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetObject(string id1, string id2) => WaitTargetObject(GetObject(id1), GetObject(id2));

UO.WaitTargetObjectType

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

C# signatures

void UO.WaitTargetObjectType(object? id, object? @type);
void UO.WaitTargetObjectType(object? id, object? @type, object? color);

Prepares two sequential targets: a given object and a found object on the ground.

Parameters

  • id — Serial/ID object: int, numeric/hex string or set alias, for example "lasttarget". This is not a graphic/type. Check the loaded object before taking action.
  • type — Graphic/type of the second item, int/hex/named type.
  • color - Optional hue of the second item; -1 by default any.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • Allows first serial via GetObject; the second looks for FindType(type,color,1,-1,false). If both are positive, calls bridge.WaitTargetObject(first,second). The order of the targets is maintained.
  • If at least one goal is missing/non-positive - message and CancelNextTarget, both goals are not set. The branch does not update TicksTarget and does not use the item.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTargetObjectType");
UO.WaitTargetObjectType("self", "0x0E21");

1. Direct call - direct script

Parameters and execution flow:

  • Prepares two sequential targets: a given object and a found object on the ground.
UO.WaitTargetObjectType("self", "0x0E21");

2. Explicit option - script function

Parameters and execution flow:

  • Allows first serial via GetObject; the second looks for FindType(type,color,1,-1,false). If both are positive, calls bridge.WaitTargetObject(first,second). The order of the targets is maintained.
return  RunScenario();
 object? RunScenario()
{
    UO.WaitTargetObjectType("lasttarget", "0x0E21", -1);
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • If at least one goal is missing/non-positive - message and CancelNextTarget, both goals are not set. The branch does not update TicksTarget and does not use the item.
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()
    {
        UO.WaitTargetObjectType("self", "0x0E21", -1);
        UO.Print(UO.Waiting());
        UO.CancelWaitTarget();
        return null;
    }
}

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.WaitTargetObjectType(id, type) — UO.WaitTargetObjectType(Any,Any)

Parameters: id (Any), type (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetObjectType(InjectionValue id, InjectionValue type)

            => WaitTargetObjectType(id, type, new InjectionValue(-1));

UO.WaitTargetObjectType(id, type, color) — UO.WaitTargetObjectType(Any,Any,Any)

Parameters: id (Any), type (Any), color (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetObjectType(InjectionValue id, InjectionValue type, InjectionValue color)

        {

            int first = GetObject(id);

            int second = bridge.FindType(ResolveType(type), NumberConversions.ToInt(color), 1, -1, false);

            if (first <= 0 || second <= 0)

            {

                SystemMessage("UO.WaitTargetObjectType: object or ground item not found");

                bridge.CancelNextTarget();

                return;

            }

            bridge.WaitTargetObject(first, second);

        }

UO.WaitTargetSelf

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

C# signatures

void UO.WaitTargetSelf();

Prepares a response to the next server target via the alias self.

Parameters

There are no parameters.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • The team only prepares a response: it does not use the item, skill or spell itself. The next server target receives the prepared target when processing the client frame.
  • Consecutive calls form a common client queue. Objects and coordinate targets are processed one at a time; local selection windows ClientRequest*/Info/container do not consume it.
  • CancelWaitTarget clears the queue. TerminateAll cleans it entirely; stopping a procedure that is still running also invalidates its own pending responses. Completing a short procedure normally does not cancel the prepared target.
  • Sending a response does not guarantee action on the server: it checks the range, accessibility of the object, visibility and action rules. To control, use the game result and log.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTargetSelf");
UO.WaitTargetSelf();

1. Prepare target - direct script

Parameters and execution flow:

  • There are no arguments; self is used.
  • The command does not open the sight and perform the action itself.
UO.WaitTargetSelf();

2. Check for presence of selected object - script function

Parameters and execution flow:

  • self must resolve to the loaded character for this skill.
  • The Exists check filters out an unknown object; the choice of object type and skill validity remain script conditions.
return  RunScenario();
 object? RunScenario()
{
    if (Truth(UO.Exists("self")))
    {
        UO.CancelWaitTarget();
        UO.WaitTargetSelf();
        UO.UseSkill("Anatomy");
    }

    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. Cancel Prepared Target - Script Class

Parameters and execution flow:

  • IsWaitTargetActive checks the response queue.
  • CancelWaitTarget unpreps without closing the already open custom crosshair.
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()
    {
        UO.WaitTargetSelf();
        if (Truth(UO.IsWaitTargetActive()))
        {
            UO.CancelWaitTarget();
        }

        return null;
    }

    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.WaitTargetSelf() — UO.WaitTargetSelf()

Parameters: No parameters.

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetSelf() => WaitTargetObject("self");

UO.WaitTargetTile

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

C# signatures

void UO.WaitTargetTile(object? selector);
void UO.WaitTargetTile(object? x, object? y, object? z);
void UO.WaitTargetTile(object? @type, object? x, object? y, object? z);

Prepares a coordinate target with optional tile graphics.

Parameters

  • selector - Only in one-argument form: the string "lasttile" repeating the stored point.
  • type — Graphic/type tile, 0..65535, not serial. Zero indicates a coordinate target with no specified graphics. Present in four-argument form; in the form x/y/z is equal to 0.
  • x — World X coordinate on the current map, 0..65535. This is not a screen pixel or gump coordinate.
  • y — World Y coordinate on the current map, 0..65535.
  • z - Height of the game point, for a network target use -128..127. This is not a floor or a layer of equipment.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • The team only prepares a response: it does not use the item, skill or spell itself. The next server target receives the prepared target when processing the client frame.
  • Consecutive calls form a common client queue. Objects and coordinate targets are processed one at a time; local selection windows ClientRequest*/Info/container do not consume it.
  • CancelWaitTarget clears the queue. TerminateAll cleans it entirely; stopping a procedure that is still running also invalidates its own pending responses. Completing a short procedure normally does not cancel the prepared target.
  • Sending a response does not guarantee action on the server: it checks the range, accessibility of the object, visibility and action rules. To control, use the game result and log.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTargetTile");
UO.WaitTargetTile("lasttile");

1. Coordinates without graphic - direct script

Parameters and execution flow:

  • x=1445, y=1690, z=0; the missing type is 0.
  • This is the point of the world. The command does not move the character or place the item in the gump.
UO.CancelWaitTarget();
UO.WaitTargetTile(1445, 1690, 0);

2. Explicitly specify the graphic of the tile - script function

Parameters and execution flow:

  • type=0x0CCA — example graphics; use the actual type of the selected tile. x/y/z is its world position.
  • Graphic and coordinates must describe the desired map object; the server checks the validity of the target.
return  RunScenario();
 object? RunScenario()
{
    UO.CancelWaitTarget();
    UO.WaitTargetTile(0x0CCA, 1445, 1690, 0);
    return null;
}

3. Repeat saved point of last target - script class

Parameters and execution flow:

  • selector only allows the lasttile string, not case sensitive. Another string or number in one-argument form causes an error.
  • The last fields of the tile in TargetManager are used. Before the first choice, they can be zero: first select the desired point in the game. Three or four arguments allow you to set it explicitly.
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()
    {
        UO.WaitTargetTile("lasttile");
        return null;
    }
}

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.WaitTargetTile(selector) — UO.WaitTargetTile(Any)

Parameters: selector (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetTile(InjectionValue selector)

        {

            string name = selector.Kind == InjectionValueKind.String

                ? (selector.String ?? string.Empty).Trim()

                : string.Empty;

            if (!name.Equals("lasttile", StringComparison.OrdinalIgnoreCase))

                throw new NativeSubrutineException("UO.WaitTargetTile(one argument) accepts only 'lasttile'.");



            int[] tile = bridge.LastTile() ?? Array.Empty<int>();

            if (tile.Length < 4)

            {

                SystemMessage("UO.WaitTargetTile: lasttile is unavailable; next target request canceled.");

                bridge.CancelNextTarget();

                return;

            }

            bridge.WaitTargetTile(tile[0], tile[1], tile[2], tile[3]);

            ticksTarget = Timer();

        }

UO.WaitTargetTile(x, y, z) — UO.WaitTargetTile(Any,Any,Any)

Parameters: x (Any), y (Any), z (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetTile(InjectionValue x, InjectionValue y, InjectionValue z)

            => WaitTargetTile(new InjectionValue(0), x, y, z);

UO.WaitTargetTile(type, x, y, z) — UO.WaitTargetTile(Any,Any,Any,Any)

Parameters: type (Any), x (Any), y (Any), z (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetTile(InjectionValue type, InjectionValue x, InjectionValue y, InjectionValue z)

        {

            bridge.WaitTargetTile(ResolveType(type), NumberConversions.ToInt(x), NumberConversions.ToInt(y), NumberConversions.ToInt(z));

            ticksTarget = Timer();

        }

UO.WaitTargetType

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

C# signatures

void UO.WaitTargetType(object? @type);
void UO.WaitTargetType(object? @type, object? color);

Searches for an item by graphic/hue and puts it in the queue for the next target.

Parameters

  • type — Graphic/type int, hex string or specified named type. This is not a serial item.
  • color — Optional int hue; default -1 - any color.

Return value

void - no value. Call on a separate line; completion does not confirm the server's action.

Behavior

  • Scope: Backpack with recursive search. Bridge.FindType returns the found serial; with serial>0 bridge.WaitTargetObject is called. These methods do not directly update runtime TicksTarget.
  • No item - message and CancelNextTarget. The search may change the general FindItem/FoundItems; The command does not use the found item and does not wait for cursor.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTargetType");
UO.WaitTargetType("0x0E21");

1. Direct call - direct script

Parameters and execution flow:

  • Searches for an item by graphic/hue and puts it in the queue for the next target.
UO.WaitTargetType("0x0E21");

2. Explicit option - script function

Parameters and execution flow:

  • Scope: Backpack with recursive search. Bridge.FindType returns the found serial; with serial>0 bridge.WaitTargetObject is called. These methods do not directly update runtime TicksTarget.
return  RunScenario();
 object? RunScenario()
{
    UO.WaitTargetType("0x0E21", -1);
    return null;
}

3. Full Helper Function - Script Class

Parameters and execution flow:

  • No item - message and CancelNextTarget. The search may change the general FindItem/FoundItems; The command does not use the found item and does not wait for cursor.
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()
    {
        UO.WaitTargetType("0x0E21", -1);
        UO.Print(UO.Waiting());
        UO.CancelWaitTarget();
        return null;
    }
}

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.WaitTargetType(type) — UO.WaitTargetType(Any)

Parameters: type (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetType(InjectionValue type) => WaitTargetType(ResolveType(type), -1);

UO.WaitTargetType(type, color) — UO.WaitTargetType(Any,Any)

Parameters: type (Any), color (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

public void WaitTargetType(InjectionValue type, InjectionValue color)

            => WaitTargetType(ResolveType(type), NumberConversions.ToInt(color));

UO.WaitTargetXYZ

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

C# signatures

void UO.WaitTargetXYZ(object? x, object? y, object? z);

Prepares a coordinate target with graphic=0 for the next server sight.

Parameters

  • x — World X coordinate on the current map, 0..65535. This is not a screen pixel or gump coordinate.
  • y — World Y coordinate on the current map, 0..65535.
  • z - Height of the game point, for a network target use -128..127. This is not a floor or a layer of equipment.

Return value

void - no return value. Call on a separate line; do not use as true/false, serial or type. Metadata object? for compatible forms does not change the actual result of void.

Behavior

  • The team only prepares a response: it does not use the item, skill or spell itself. The next server target receives the prepared target when processing the client frame.
  • Consecutive calls form a common client queue. Objects and coordinate targets are processed one at a time; local selection windows ClientRequest*/Info/container do not consume it.
  • CancelWaitTarget clears the queue. TerminateAll cleans it entirely; stopping a procedure that is still running also invalidates its own pending responses. Completing a short procedure normally does not cancel the prepared target.
  • Sending a response does not guarantee action on the server: it checks the range, accessibility of the object, visibility and action rules. To control, use the game result and log.

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 command is a separate statement. The message before it marks the start of the call; it does not confirm a server action.

UO.Print("Calling UO.WaitTargetXYZ");
UO.WaitTargetXYZ(1445, 1690, 0);

1. Specify a point in the world - direct script

Parameters and execution flow:

  • X=1445, Y=1690, Z=0. Graphic is equal to 0.
  • The response will be sent when the server coordinate sight appears.
UO.WaitTargetXYZ(1445, 1690, 0);

2. Use dot under character - script function

Parameters and execution flow:

  • X/Y/Z are read from your own character.
  • This is a coordinate target, not an object target on the serial character. For the latter you need WaitTargetSelf.
return  RunScenario();
 object? RunScenario()
{
    var x = UO.GetX();
    var y = UO.GetY();
    var z = UO.GetZ();
    UO.WaitTargetXYZ(x, y, z);
    return null;
}

3. Prepare Tool Point - Script Class

Parameters and execution flow:

  • Replace the coordinates with the extraction point. UseType is looking for a shovel type=0x0F39 of any color in the backpack.
  • If a suitable tool is not available, remove the preparation via CancelWaitTarget before moving on to another action.
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()
    {
        UO.CancelWaitTarget();
        UO.WaitTargetXYZ(1445, 1690, 0);
        UO.UseType(0x0F39, -1);
        return null;
    }
}

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.WaitTargetXYZ(x, y, z) — UO.WaitTargetXYZ(Any,Any,Any)

Parameters: x (Any), y (Any), z (Any)

Result: void / Unit.

During a call:

Internal implementation code; this is not a standalone script.

case "waittargetxyz": WaitTargetTile(new InjectionValue(0), arguments[0], arguments[1], arguments[2]); return InjectionValue.Unit;

Clone this wiki locally