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
| Property | Type | Description |
|---|
last | undefined | Item | Mobile | The last targeted Item or Mobile object. |
lastObject | undefined | Item | The last object double-clicked (used) by the player. |
lastObjectSerial | number | Serial of the last double-clicked object. |
lastSerial | number | Serial of the last target. |
open | boolean | true if a targeting cursor is currently open. |
Methods
cancel()
Closes (cancels) the currently open target cursor.
clearQueue()
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.
The entity to target. Accepts a serial number, Item, or Mobile.
player.cast(Spells.Heal);
target.wait();
target.entity(player);
self()
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.
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()
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.
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 offset from the player.
Y offset from the player.
Z offset from the player.
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.
Distance in tiles from the entity.
true to extend in the entity’s facing direction.
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.
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.
The entity to target once the cursor opens.
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).
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);
}