Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ClassicUO/classicuo-web/llms.txt

Use this file to discover all available pages before exploring further.

The Target class controls the in-game targeting cursor and is accessible globally as target. Use it to send target responses when the server opens a targeting cursor (e.g. after casting a spell or using a skill), or to create interactive queries that wait for the player to click a target.
// Cast Heal on yourself
player.cast(Spells.Heal);
target.wait();
target.self();
Always call target.wait() or one of the waitTarget* helpers before responding to a target — this ensures the targeting cursor is open before attempting to respond.

Properties

PropertyTypeDescription
lastundefined | Item | MobileThe last targeted Item or Mobile object.
lastObjectundefined | ItemThe last object double-clicked (used) by the player.
lastObjectSerialnumberSerial of the last double-clicked object.
lastSerialnumberSerial of the last target.
openbooleantrue if a targeting cursor is currently open.

Methods

cancel()

cancel(): void
Closes (cancels) the currently open target cursor.

clearQueue()

clearQueue(): void
Clears any queued target responses that haven’t fired yet.

entity()

entity(serial: SerialOrEntity): void
Responds to the currently open target cursor by targeting a specific Item or Mobile.
serial
SerialOrEntity
required
The entity to target. Accepts a serial number, Item, or Mobile.
player.cast(Spells.Heal);
target.wait();
target.entity(player);

self()

self(): void
Responds to the currently open target cursor by targeting your own character.
player.cast(Spells.Heal);
target.wait();
target.self();

wait()

wait(timeoutMs?: number): boolean
Waits for a targeting cursor to open. Returns true if the target opened within the timeout.
timeoutMs
number
Maximum time to wait in milliseconds. Defaults to 5000ms if not specified.
player.cast(Spells.Teleport);
target.wait(3000); // Wait up to 3 seconds
target.terrain(1203, 222, 0);

repeatLast()

repeatLast(): void
Repeats the last targeting action — entity, terrain, or position — based on what the cursor type was previously.
player.cast(Spells.Heal);
target.wait();
target.repeatLast(); // Re-target whatever was targeted last time

terrain()

terrain(x: number, y: number, z: number, graphic?: number): void
Targets a specific world tile or static at the given coordinates. When graphic is omitted, it defaults to targeting LAND.
x
number
required
World X coordinate.
y
number
required
World Y coordinate.
z
number
required
World Z coordinate.
graphic
number
Optional graphic/static ID to target. Defaults to LAND.
// Teleport to explicit coordinates
player.cast(Spells.Teleport);
target.wait();
target.terrain(1203, 222, 0);
// Teleport to a specific static graphic
player.cast(Spells.Teleport);
target.wait();
target.terrain(1203, 222, 0, 0x5a2);

terrainWithOffset()

terrainWithOffset(x: number, y: number, z: number, graphic?: number): void
Targets a tile at a position relative to the player — the x, y, z values are offsets from the player’s current location.
x
number
required
X offset from the player.
y
number
required
Y offset from the player.
z
number
required
Z offset from the player.
graphic
number
Optional static graphic ID.
player.cast(Spells.Teleport);
target.wait();
target.terrainWithOffset(-1, -2, 0); // Teleport 1 west, 2 north

terrainRelativeToEntity()

terrainRelativeToEntity(
  entity: SerialOrEntity,
  range: number,
  forward: boolean,
  graphic?: number
): void
Targets a tile at a relative distance from a specific entity. When forward is true the offset extends in the direction the entity is facing.
entity
SerialOrEntity
required
The reference entity.
range
number
required
Distance in tiles from the entity.
forward
boolean
required
true to extend in the entity’s facing direction.
graphic
number
Optional static graphic ID.
player.cast(Spells.Teleport);
target.wait();
target.terrainRelativeToEntity(mob, 5, true);

query()

query(isGround?: boolean): TargetInfo
Opens an interactive target cursor and waits for the player to click. Returns information about what they targeted.
isGround
boolean
If true, opens a ground/terrain target cursor.

waitTargetSelf()

waitTargetSelf(timeoutMs?: number): boolean
Waits for the target cursor to open, then automatically targets the player’s own character.
player.useType(0xe21); // Bandages
target.waitTargetSelf();

waitTargetEntity()

waitTargetEntity(entity: SerialOrEntity, timeoutMs?: number): boolean
Waits for the target cursor to open, then targets the specified entity.
entity
SerialOrEntity
required
The entity to target once the cursor opens.
timeoutMs
number
Optional timeout in milliseconds.

waitTargetType()

waitTargetType(graphic: number, hue?: number, timeoutMs?: number): boolean
Waits for the target cursor to open, then targets the first item of the specified graphic (and optional hue).
graphic
number
required
The graphic ID to match.
hue
number
Optional hue to match.
timeoutMs
number
Optional timeout in milliseconds.
player.useType(0xf9d); // Scissors
target.waitTargetType(0x1078); // Target nearest cloth

Common Patterns

Heal loop

while (true) {
  if (player.hits < player.maxHits) {
    player.useType(0xe21); // Bandage
    target.waitTargetSelf(5000);
    journal.waitForText('You heal', undefined, 8000);
  }
  sleep(500);
}

Cast and target an enemy

const enemy = client.selectEntity(
  SearchEntityOptions.Enemy,
  SearchEntityRangeOptions.Nearest,
  SearchEntityTypeOptions.Any,
  false
);

if (enemy) {
  player.castTo(Spells.Lightning, enemy);
}

Build docs developers (and LLMs) love