Repository navigation
EN UO Topic combat
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Home · C# · IDE · UO API · A–Z · Examples · Languages
Attack, combat mode, weapon abilities and bandage healing. The client's request and the action taken by the server are different.
| Topic | Commands and explanations |
|---|---|
| Attack | UO.Attack |
| AttackNearest | UO.AttackNearest |
| LastAttack | UO.LastAttack |
| WarMode | UO.WarMode |
| WarTarget | UO.WarTargetID |
| Weapon Abilities | UO.GetWeaponAbilities · UO.GetAbilityID · UO.GetAbilityName · UO.GetActiveAbility |
| Primary Ability | UO.UsePrimaryAbility |
| Secondary Ability | UO.UseSecondaryAbility |
| Special Moves | UO.Specmove |
| BandageSelf | UO.BandageSelf |
UO.Attack · UO.AttackNearest · UO.LastAttack · UO.WarMode · UO.IsWarMode · UO.SetWarMode · UO.WarTargetID
UO.GetWeaponAbilities · UO.GetAbilityID · UO.GetAbilityName · UO.GetActiveAbility · UO.UseAbility · UO.UsePrimaryAbility · UO.UseSecondaryAbility · UO.Specmove
UO.SetClassMask · UO.ClearClassMask · UO.AttackNearest
The names of the groups and the types of items worn are specified by the script; the order of names through | specifies priority.
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.
Parameters, result and all scenarios
var selected = UO.LastTarget();
var allowed = UO.GetMobiles(10, "5|6", -1, 8, false, false, true, true);
var i = 0;
while (Truth(i < ArrayLength(allowed)))
{
if (Truth(allowed[i] == selected))
{
UO.Attack(selected);
return null;
}
i += 1;
}
UO.Print("Selected target does not pass the filters");
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;Parameters, result and all scenarios
var abilities = UO.GetWeaponAbilities();
UO.Print(UO.GetArrayLength(abilities));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.Attack(object? objID);Directs an attack request to a specific serial. Suitable when the target has already been selected by the user or found by another team; There is no independent search by clothing/distance here.
-
objID— Serial mobile: int, decimal/hex string, or resolvable object name (for example lasttarget or name AddObject). Not graphic/type and not class name. Required argument; 0 is not a combat stop command. To select a target without its ID use search or game target.
void - no value. Write UO.Attack(enemy) on a separate line, not var result=UO.Attack(...). Ending a call does not confirm hit, damage, or server acceptance.
- The challenge itself does not drop dead, distant, self, allies, empty serial, or items. Check the selected target; preferably filtered mobile from GetMobiles/FindMan.
- The standard GameActions is used.Attack: the question of a criminal attack with EnabledCriminalActionQuery is possible. In normal progress, LastAttack/NewTargetSystemSerial are updated and an attack request packet is sent.
- The command does not enable WarMode, does not double-click the mouse, does not plot a route, and does not start a repeated-attack loop. Combat mode and subsequent combat depend on the server.
- A resolution error may occur for a string with an unknown object name. The Exists check proves the presence of the object, but not that it is mobile; GetMobiles is given by mobiles.
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.
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.Attack");
UO.Attack(UO.LastTarget());Parameters and execution flow:
- lasttarget can be an item or a friendly character. The allowed list excludes these cases; Attack is called at most once.
var selected = UO.LastTarget();
var allowed = UO.GetMobiles(10, "5|6", -1, 8, false, false, true, true);
var i = 0;
while (Truth(i < ArrayLength(allowed)))
{
if (Truth(allowed[i] == selected))
{
UO.Attack(selected);
return null;
}
i += 1;
}
UO.Print("Selected target does not pass the filters");
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;Parameters and execution flow:
- FindMan returns serial and does not attack. The IsDead check is added separately because FindMan does not have aliveOnly.
return RunScenario();
object? RunScenario()
{
var enemy = UO.FindMan(5, 6, true, 4, -1, -1, false);
if (Truth(enemy == 0))
{
return null;
}
if (Truth(UO.IsDead(enemy) == 0))
{
UO.AddObject("enemy", enemy);
UO.Attack(enemy);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- GetMobiles is already ordered nearest=true. If there is a wall in front of the first target, the next one is checked; the presence of visibleOnly does not in itself replace CheckLOS. Server verification may vary.
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 targets = UO.GetMobiles(8, 5, -1, 10, true, false, true, true);
var i = 0;
while (Truth(i < ArrayLength(targets)))
{
var enemy = targets[i];
if (Truth(UO.CheckLOS(UO.GetX("self"), UO.GetY("self"), UO.GetZ("self"), UO.GetX(enemy), UO.GetY(enemy), UO.GetZ(enemy), UO.WorldNum())))
{
UO.Attack(enemy);
return null;
}
i += 1;
}
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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: objID (Any/Integer/String)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Attack:bridge.Attack(Arg(0)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0).
Internal implementation code; this is not a standalone script.
case "attack": bridge.Attack(Arg(0)); return InjectionValue.Unit;Parameters: objID (Any/Integer/String)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.Attack. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Attack:bridge.Attack(id).
Internal implementation code; this is not a standalone script.
public void Attack(int id) => bridge.Attack(id);Parameters: objID (Any/Integer/String)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.Attack. -
InjectionScript.Runtime.InjectionApiUO.Attack:Attack(GetObject(id)). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(id).
Internal implementation code; this is not a standalone script.
public void Attack(string id) => Attack(GetObject(id));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.AttackNearest(object? notoriety);
int UO.AttackNearest(object? notoriety, object? distance);
int UO.AttackNearest(object? notoriety, object? distance, object? body);
int UO.AttackNearest(object? notoriety, object? distance, object? body, object? maxZ);
int UO.AttackNearest(object? notoriety, object? distance, object? body, object? maxZ, object? nearest);
int UO.AttackNearest(object? notoriety, object? distance, object? body, object? maxZ, object? nearest, object? color);
int UO.AttackNearest(object? notoriety, object? distance, object? body, object? maxZ, object? nearest, object? color, object? classMask);
int UO.AttackNearest(object? notoriety, object? distance, object? body, object? maxZ, object? nearest, object? color, object? classMask, object? aliveOnly);
int UO.AttackNearest(object? notoriety, object? distance, object? body, object? maxZ, object? nearest, object? color, object? classMask, object? aliveOnly, object? visibleOnly);Selects one suitable combat target and passes it to the attack handler. Filters limit acceptable characters; custom classMask sets equipment and class priority, nearest — choice within a class.
-
notoriety— Relationship status to the character received from the server: 0 — unknown, 1 — Innocent, 2 — Ally, 3 — Gray, 4 — Criminal, 5 — Enemy, 6 — Murderer, 7 - Invulnerable. The number means one status; "5|6" or an array of numbers - any of the above. It's not the color of the clothes or the class. A negative number (usually -1), 0xFFFF, "any", an empty string or an empty array separately disables this filter. An invalid string without valid numbers does not find anyone. The order of statuses does not set priority. The 5 filter selects Enemy rather than automatically selecting any NPC/monster; actual values depend on the server. -
distance— Horizontal radius in cells inclusive: 5 allows distance 0..5. The distance is max(abs(dx),abs(dy)), so the adjacent diagonal is also 1. By default or if the number is negative, UO.FindDistance() is taken rather than unlimited search. 0 leaves the same X/Y cell. Not the length of the route; obstacles and floors are not checked by this parameter. -
body- Graphic of the character's body/NPC, not ID of a specific character and not type of the armor worn. A number, a hex string, the string "0x0190|0x0191" or an array of numbers. 0x0190 (400) - human male; 0x0191 (401) - female human. The mask unites both bodies. The list does not automatically include other races, ghosts, or transformations; table of standard graphic body types. A negative number (-1 by default), 0xFFFF, "any", an empty string or an empty array alone - any body. Unknown text without a valid number produces an empty result. -
maxZ— Maximum abs(target's Z - own character's Z), inclusive, in world Z units. This is not the number of floors or X/Y cells. maxZ=4 with Z player 10 allows Z target 6..14; 0 requires exactly the same height. By default/for a negative number, UO.FindVertical() is taken. On the stairs, an equal Z can eliminate the desired target. Even a small difference in Z does not prove the accessibility of the floor. -
nearest- true/1 by default selects the closest matching character; equal distance is allowed by smaller serial. false/0 keeps the first matching object in the client list order, does not select the furthest one. With classMask, class priority applies first, then intra-class distance. -
color— Hue of the mobile itself: int or numeric/hex string. Negative number (-1 by default) and 0xFFFF - any hue; 0 is precisely the hue of 0, and not any meaning. Not the color of the notoriety strip or the shade of the clothing. This parameter does not check the color of the item being worn. -
classMask— Names of rules predefined by UO.SetClassMask in the same script runtime. For example, "DTMH|hunter|spare" - priority from left to right; an array of strings is also allowed. Any names, case is not important. Line separators: |, comma or ;. Any unknown name/empty element inside the list deselects the entire selection: result 0, no attack. This is not a numeric bitmask: 7 does not mean three classes. A missing argument, -1, "-1", "any", "all", or the empty string separately disables the class filter. Mage/Tank/Archer are not built in: without registering such rules, there will be no matches. -
aliveOnly- true/1 excludes mobiles with IsDead != 0; false/0 does not add this condition by default. Not comparing HP to zero, not searching for corpse items, and not guaranteeing that the target will remain alive after being summoned. -
visibleOnly- true/1 requires IsVisible=1 according to the current state of ClassicUO; false/0 does not add a condition by default. This is the visibility of the loaded object to the client, not a wall/sight line check. For geometric checking there is a separate UO.CheckLOS with coordinates; the server may still reject the action.
int - serial selected mobile, or 0 when there is no suitable target or classMask is invalid. This is not a 1/0-flag, not a body/type, not a distance or confirmation of a strike. Check enemy != 0; enemy == true is not valid in C#: int does not compare to bool. If ID is non-zero, the ClassicUO handler can still show confirmation of the Innocent attack; the server may reject the action.
- Local search: only already downloaded mobiles. Ignore is taken into account; self is excluded, except for the explicit includeSelf=true in commands that support it. Containers and items are not mobiles.
- The conditions apply together (AND). Valid alternatives within body/notoriety are combined via OR. The search does not change FindItem, FindCount and GetFoundItems.
- In body/notoriety, a mask with valid numbers uses exactly these: "any|5" still limits it to the value 5. Blank/invalid elements next to valid numbers are ignored. For no restriction, pass -1 separately. Do not carry this rule to classMask: unknown class name rejects the entire list.
- Teams do not open an area of the world, do not run to the goal, and do not check the passability of the route. Between the selection and the server's processing, the state of the world may change.
- Passing true and 1 is equivalent for flags, false and 0 as well. Other non-zero numbers also convert to true, but 8/9 are not separate modes; use clear true/false.
- The name is a custom label, not a server profession. You can call the rule DTMH, my_group or any other word. The engine does not determine skills/class on the server by character name.
- In required, one type or flat array means at least one thing from the list. An array of groups means: you need at least one thing from EACH group. For example, [leather, staves] requires leather AND a staff. This is a set of alternatives, and not a requirement to wear the entire wardrobe listed.
- Any item worn from forbidden excludes the character from this rule, even if the required ones are met. Leather plus a prohibited chain does not pass the leather rule. Other rules continue to be tested.
- Only loaded items worn on layers 1..24 except for the backpack 21 are counted. The contents of the backpack/chest, mount 25, journal 26..28 and bank 29 are not considered clothing. Compares graphic/type; The serial, name and hue things are not used here.
- The list does not match without the appropriate equipment loaded. The absence of a prohibited item in local data does not prove its absence on the server if the server has not yet sent the equipment. The client does not guess hidden data.
- The rules belong to one runtime script, including its functions and Includes; are not transferred to other independent launches and are not saved in the profile. When starting again, define them again, for example by the general setup procedure. A repeated SetClassMask replaces the rule with the same name, only after the new data has been fully verified.
- Arrays are copied during registration. Changing the original array does not change the rule: repeat SetClassMask. Multiple matching rules are resolved by the order of the names in classMask. There are no standard server clothing tables.
- 1..9 positional arguments are supported. You can skip the tail; to set classMask the first six arguments must be passed. Use named var to see the meaning of each position.
- One target is selected and the attack is sent once. This is not an automatic combat cycle. Without classMask the equipment filter and item reading are not performed.
- First the general filters, then the priority from left to right, then the nearest. nearest=false still preserves class priority, but within the first matching class it selects the first mobile in the client list.
- The old attempt to search for a substring in a name/title has been replaced by equipment rules. Move such scripts to an explicit SetClassMask; The character's name no longer identifies him as a specific class.
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.
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.AttackNearest(5, 5);
UO.Print("AttackNearest: " + Convert.ToString(result));Parameters and execution flow:
- body=-1, maxZ=FindVertical(), nearest=true, color=-1, classMask disabled, aliveOnly=false, visibleOnly=false. To be sure to exclude dead people, use the full form below.
var enemy = UO.AttackNearest(5, 5);
if (Truth(enemy == 0))
{
return null;
}
UO.AddObject("combat_target", enemy);
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- maxZ=0 is useful for strict height comparisons, but may cut off the target at the step. visibleOnly does not check the wall. All nine arguments are signed; returns ID, not true.
return RunScenario();
object? RunScenario()
{
var status = "5|6";
var radius = 8;
var bodies = "0x0190|0x0191";
var heightTolerance = 0;
dynamic chooseNearest = true;
var bodyHue = -1;
var equipmentClasses = -1;
dynamic requireAlive = true;
dynamic requireVisible = true;
var enemy = UO.AttackNearest(status, radius, bodies, heightTolerance, chooseNearest, bodyHue, equipmentClasses, requireAlive, requireVisible);
if (Truth(enemy != 0))
{
UO.AddObject("enemy_same_height", enemy);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- DTMH is selected first; only if there are no suitable DTMH - heavy, then hunter. DTMH on 10 cells has priority over heavy on 2 cells. To reverse the order, change the line classMask. Of the two DTMH, the closest one is selected.
- Gear is a completely reduced user function C#, not a separate command UO. The two arrays in Gear(leather, staves) form two required groups. Adding a type to leather expands the alternatives; does not require wearing two leather items.
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 leather = Gear(0x13C4, 0x13C7);
var staves = Gear(0x0DF0, 0x0E81);
var chain = Gear(0x13BF, 0x13C0);
var plate = Gear(0x1415, 0x1411);
var bows = Gear(0x13B2, 0x0F50);
UO.SetClassMask("DTMH", Gear(leather, staves), chain);
UO.SetClassMask("охотник", bows);
UO.SetClassMask("тяжёлый", plate);
var notoriety = "5|6";
var distance = 12;
var body = -1;
var maxZ = 8;
dynamic nearest = true;
var color = -1;
var classMask = "DTMH|тяжёлый|охотник";
dynamic aliveOnly = true;
dynamic visibleOnly = true;
var enemy = UO.AttackNearest(notoriety, distance, body, maxZ, nearest, color, classMask, aliveOnly, visibleOnly);
if (Truth(enemy == 0))
{
UO.Print("No matching enemy; no attack sent");
return null;
}
UO.AddObject("selected_enemy", enemy);
return null;
}
dynamic Gear(params dynamic[] values)
{
return values;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}Parameters and execution flow:
- 10 is the radius, 4 is the permissible difference Z, both -1 after the flag disable color and classMask. The order of the client list is not guaranteed between world updates. For predictable proximity, use true.
dynamic sortByDistance = false;
var target = UO.AttackNearest(5, 10, -1, 4, sortByDistance, -1, -1, true, true);
if (Truth(target == 0))
{
return null;
}
UO.AddObject("current_enemy", target);
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- Only the order of the labels changes: no new clothing tables or names need to be added to the client. To prevent fallback on a heavy one, remove it from priority.
return RunScenario();
object? RunScenario()
{
var leather = Gear(0x13C4, 0x13C7);
var staves = Gear(0x0DF0, 0x0E81);
var chain = Gear(0x13BF, 0x13C0);
var plate = Gear(0x1415, 0x1411);
var bows = Gear(0x13B2, 0x0F50);
UO.SetClassMask("DTMH", Gear(leather, staves), chain);
UO.SetClassMask("охотник", bows);
UO.SetClassMask("тяжёлый", plate);
var priority = "охотник|DTMH|тяжёлый";
var enemy = UO.AttackNearest(5, 12, -1, 8, true, -1, priority, true, true);
if (Truth(enemy != 0))
{
UO.AddObject("priority_enemy", enemy);
}
return null;
}
dynamic Gear(params dynamic[] values)
{
return values;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: notoriety (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))Parameters: notoriety (Any), distance (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))Parameters: notoriety (Any), distance (Any), body (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))Parameters: notoriety (Any), distance (Any), body (Any), maxZ (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))Parameters: notoriety (Any), distance (Any), body (Any), maxZ (Any), nearest (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))
UO.AttackNearest(notoriety, distance, body, maxZ, nearest, color) — UO.AttackNearest(Any,Any,Any,Any,Any,Any)
Parameters: notoriety (Any), distance (Any), body (Any), maxZ (Any), nearest (Any), color (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))
UO.AttackNearest(notoriety, distance, body, maxZ, nearest, color, classMask) — UO.AttackNearest(Any,Any,Any,Any,Any,Any,Any)
Parameters: notoriety (Any), distance (Any), body (Any), maxZ (Any), nearest (Any), color (Any), classMask (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))
UO.AttackNearest(notoriety, distance, body, maxZ, nearest, color, classMask, aliveOnly) — UO.AttackNearest(Any,Any,Any,Any,Any,Any,Any,Any)
Parameters: notoriety (Any), distance (Any), body (Any), maxZ (Any), nearest (Any), color (Any), classMask (Any), aliveOnly (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))
UO.AttackNearest(notoriety, distance, body, maxZ, nearest, color, classMask, aliveOnly, visibleOnly) — UO.AttackNearest(Any,Any,Any,Any,Any,Any,Any,Any,Any)
Parameters: notoriety (Any), distance (Any), body (Any), maxZ (Any), nearest (Any), color (Any), classMask (Any), aliveOnly (Any), visibleOnly (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCompactSearchApi [AttackNearest]. -
InjectionScript.Runtime.InjectionApiUO.CompactAttackNearest:CompactAttackNearest(values).
The call executes the stored handler delegate. The registration method creates this delegate while building the API.
Internal implementation code; this is not a standalone script.
values => new InjectionValue(CompactAttackNearest(values))Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.BandageSelf();Places the character as UO.Wait-target and uses a bandage of type 0x0E21 selected from the backpack. The operation is sent by the client and executed asynchronously by the server.
There are no parameters.
void. The method does not return the treatment status and does not wait for bandaging to complete.
- Runtime sets the target
Self, then searches the backpack for the closest matching item of type0x0E21with any hue and uses it. If the bandage is not found, the search reports this to the system log; the search result is not returned to the calling script. The possibility and result of treatment depend on the server state of the character.
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.
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.BandageSelf");
UO.BandageSelf();Parameters and execution flow:
- Use the bandage found in the backpack on yourself once.
UO.BandageSelf();2. First check the connection, then dispatch the action; the call does not wait for the end of treatment. - script function
Parameters and execution flow:
- First check the connection, then dispatch the action; the call does not wait for the end of treatment.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.Connected()))
{
UO.BandageSelf();
}
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. The procedure only reports the use of the bandage and does not report the success of the treatment. - script class
Parameters and execution flow:
- The procedure only reports the use of the bandage and does not report the success of the treatment.
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()
{
ApplyBandage();
return null;
}
void ApplyBandage()
{
UO.BandageSelf();
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.BandageSelf. -
InjectionScript.Runtime.InjectionApiUO.FindType:FindType(new InjectionValue(0x0e21), new InjectionValue(0), new InjectionValue("my")). -
InjectionScript.Runtime.InjectionApiUO.WaitTargetSelf:WaitTargetSelf(). -
InjectionScript.Runtime.InjectionApiUO.UseObject:UseObject(foundBandages). -
InjectionScript.Runtime.InjectionApiUO.SystemMessage:SystemMessage("No bandages found.").
Internal implementation code; this is not a standalone script.
public void BandageSelf()
{
var foundBandages = FindType(new InjectionValue(0x0e21), new InjectionValue(0), new InjectionValue("my"));
if (foundBandages != string.Empty)
{
WaitTargetSelf();
UseObject(foundBandages);
}
else
SystemMessage("No bandages found.");
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.ClearClassMask();
int UO.ClearClassMask(object? name);Removes one custom equipment rule or all rules of the current script runtime. Useful before reconfiguring sets or disabling temporary priority.
-
name— Optional name passed to SetClassMask. Case is not important. Without arguments, all rules for this runtime are deleted. This is not a priority string: "mage|tank" is not allowed here; remove one at a time or call without arguments.
int — number of deleted rules. With the name 1 means deleted, 0 - there was no such rule. Without arguments, 0..N, not a boolean flag, is returned. Therefore, compare the overall result with > 0, and not with true.
- Does not cancel an attack that has already been sent and does not stop the script. Does not change character equipment.
- Once deleted, the name remains unknown to the next AttackNearest. Remove it from classMask as well or register it again; an unknown name blocks all selection.
- Other people's runtimes and their rules are not affected. For a regular search without classes, use classMask=-1 rather than the empty mandatory clothing set.
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.
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.ClearClassMask();
UO.Print("ClearClassMask: " + Convert.ToString(result));Parameters and execution flow:
- Removal does not switch weapons or end the fight. It only changes further classification.
UO.SetClassMask("временный", 0x13B2);
UO.SetClassMask("основной", 0x1415);
UO.ClearClassMask("временный");
var enemy = UO.AttackNearest(5, 10, -1, 8, true, -1, "основной", true, true);
if (Truth(enemy != 0))
{
UO.AddObject("main_enemy", enemy);
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- removed — number of removed rules. A new set is created in the same runtime, without restarting the client.
return RunScenario();
object? RunScenario()
{
UO.SetClassMask("старый_набор", 0x13B2);
var removed = UO.ClearClassMask();
UO.SetClassMask("новый_набор", 0x0F50);
var enemy = UO.AttackNearest(5, 8, -1, 4, true, -1, "новый_набор", true, true);
if (Truth(enemy != 0))
{
UO.AddObject("new_enemy", enemy);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- Do not pass the remote name: the result would be 0. -1 disables clothes only; other filters continue to work.
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.SetClassMask("по_одежде", 0x13C4);
UO.ClearClassMask();
var classes = -1;
var enemy = UO.AttackNearest(5, 5, -1, 4, true, -1, classes, true, true);
if (Truth(enemy != 0))
{
UO.AddObject("enemy_without_classes", enemy);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterClassMaskApi [ClearClassMask]. -
InjectionScript.Runtime.InjectionApiUO.ClearClassMask:ClearClassMask(null).
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.
args => new InjectionValue(ClearClassMask(null))Parameters: name (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterClassMaskApi [ClearClassMask]. -
InjectionScript.Runtime.InjectionApiUO.ClearClassMask:ClearClassMask(ReadClassName(args[0])). -
InjectionScript.Runtime.InjectionApiUO.ReadClassName:ReadClassName(args[0]).
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.
args => new InjectionValue(ClearClassMask(ReadClassName(args[0])))Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.GetAbilityID(object? abilityName);Resolves a weapon ability name or number string in the ID client directory.
-
abilityName- string: name AbilityData, enum Ability name or decimal ID. Spaces/punctuation are removed when comparing names and are not case sensitive.
int 1..AbilityData.Abilities.Length - known ability; 0 is an unknown name, an empty normalized string, or a numeric ID outside the directory.
- ResolveClassicUOAbilityId first parses the decimal int, then compares the normalized directory and enum names. The command does not activate the ability or check for compatibility with the current weapon.
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.
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.GetAbilityID("Armor Ignore");
UO.Print("GetAbilityID: " + Convert.ToString(result));Parameters and execution flow:
- The number represents the ID of the catalog, not the use of the ability.
var id = UO.GetAbilityID("Armor Ignore");
UO.Print(Convert.ToString(id));Parameters and execution flow:
- The line 1 traverses the resolver's numerical path.
return RunScenario();
object? RunScenario()
{
var id = UO.GetAbilityID("1");
UO.Print(Convert.ToString(id));
return null;
}Parameters and execution flow:
- A missing name returns 0.
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 id = UO.GetAbilityID("unknown-example-ability");
UO.Print(Convert.ToString(id));
return null;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: abilityName (String)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetAbilityID. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ResolveAbility:bridge.ResolveAbility(abilityName).
Internal implementation code; this is not a standalone script.
public int GetAbilityID(string abilityName) => bridge.ResolveAbility(abilityName);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
string UO.GetAbilityName(object? abilityId);Returns the name of a weapon's ability from its ID directory.
-
abilityId- int: indexing ID starts with 1; bridge reads AbilityData.Abilities[abilityId-1].
string directory name. For ID less than 1 or greater than the directory length, an empty string is returned.
- The reading is local and does not activate the ability. ID of the catalog does not mean that the ability is present in the current weapon.
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.
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.GetAbilityName(1);
UO.Print("GetAbilityName: " + Convert.ToString(result));Parameters and execution flow:
- ID 1 matches the first element of the directory.
var name = UO.GetAbilityName(1);
UO.Print(name);Parameters and execution flow:
- The name is returned based on ID found by the resolver.
return RunScenario();
object? RunScenario()
{
var id = UO.GetAbilityID("Armor Ignore");
if (Truth(id > 0))
{
UO.Print(UO.GetAbilityName(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;Parameters and execution flow:
- ID 0 returns a string of length 0.
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 name = UO.GetAbilityName(0);
UO.Print(Convert.ToString(Len(name)));
return null;
}
int Len(object? value) => Convert.ToString(value)?.Length ?? 0;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: abilityId (Integer)
Result: string / String.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetAbilityName. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetAbilityName:bridge.GetAbilityName(abilityId).
Internal implementation code; this is not a standalone script.
public string GetAbilityName(int abilityId) => bridge.GetAbilityName(abilityId);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.GetActiveAbility();Reads the name of your character's activated combat ability.
There are no parameters.
string is the English name of the activated ability, for example Armor Ignore. String "0" if no ability is activated or character is missing. This is not an int 0, nor a ID ability, nor is it a confirmation of a successful hit.
- The PrimaryAbility/SecondaryAbility flags of the current character are read. If both are active, the primary ability is chosen. The activity flag is removed from the number before the name is searched.
- Data is read locally; the getter itself does not activate the ability and does not consume mana. After the attack, the server can remove the activation.
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.
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.GetActiveAbility();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- There are no arguments; the character of the current client is read.
- If there is no activation, the string 0 is printed.
var name = UO.GetActiveAbility();
UO.Print(name);Parameters and execution flow:
- The comparison is made with the string 0. UsePrimaryAbility is called separately.
- This is an activation request, not proof of a successful strike. Availability depends on weapons and server rules.
return RunScenario();
object? RunScenario()
{
if (Truth(UO.GetActiveAbility() == "0"))
{
UO.UsePrimaryAbility();
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- GetAbilityID receives the name returned by the getter.
- ID ability is not a serial weapon or character. First, the absence of an active ability is ruled out.
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 name = UO.GetActiveAbility();
if (Truth(name != "0"))
{
var id = UO.GetAbilityID(name);
UO.Print("Ability ID: " + Convert.ToString(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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetActiveAbility:bridge.GetActiveAbility().
Internal implementation code; this is not a standalone script.
case "getactiveability": return new InjectionValue(bridge.GetActiveAbility());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.GetWeaponAbilities();Bridge reads Player.Abilities, applies ((byte)value & 0x7F), stores positive ID in original order.
There are no parameters.
Array of positive int ID abilities of the current weapon. The high flag 0x80 is removed; zero values are excluded. Without Player - an empty array.
- Bridge reads Player.Abilities, applies ((byte)value & 0x7F), stores positive ID in original order. Returns the available ID, not the fact of the active mode and not the names.
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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.
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.GetWeaponAbilities();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- Bridge reads Player.Abilities, applies ((byte)value & 0x7F), stores positive ID in original order.
var abilities = UO.GetWeaponAbilities();
UO.Print(UO.GetArrayLength(abilities));Parameters and execution flow:
- Bridge reads Player.Abilities, applies ((byte)value & 0x7F), stores positive ID in original order. Returns the available ID, not the fact of the active mode and not the names.
return RunScenario();
object? RunScenario()
{
var abilities = UO.GetWeaponAbilities();
if (Truth(UO.GetArrayLength(abilities) > 0))
{
UO.Print(UO.GetAbilityName(abilities[0]));
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 before = UO.GetWeaponAbilities();
UO.Wait(500);
var after = UO.GetWeaponAbilities();
UO.Print(before);
UO.Print(after);
return null;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.GetWeaponAbilities. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetWeaponAbilities:bridge.GetWeaponAbilities().
Internal implementation code; this is not a standalone script.
public InjectionValue GetWeaponAbilities() => new InjectionValue(
(bridge.GetWeaponAbilities() ?? Array.Empty<int>()).Select(value => new InjectionValue(value)).ToArray());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.IsWarMode(object? objID);Checks mobile's fighting stance.
-
objID— Mandatory serial/ID of a specific object: int, hex-string or alias self, backpack, lasttarget, lastobject, lastcontainer, laststatus, finditem, lastcorpse or name AddObject. This is not a graphic/type. Unspecified name resolves to 0; the command does not open any new target. The argument is required; for yourself, pass self.
int 1 — the loaded mobile has the attribute InWarMode. int 0 - the attribute is missing, the object is not mobile, unknown or deleted. Doesn't tell you who the character is attacking or turn on combat mode. Reading the foreign mode is limited to the data received from the server.
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.
- The local client model is read; There are no requests to the server, no waiting or moving.
- The result refers to the moment of reading. After UO.Wait or other action, the object and its flags may change.
- Doesn't tell you who the character is attacking or turn on combat mode. Reading the foreign mode is limited to the data received from the server.
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.
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.IsWarMode("self");
UO.Print("IsWarMode: " + Convert.ToString(result));Parameters and execution flow:
- The self argument explicitly selects its character. state - 1/0 only.
- Doesn't tell you who the character is attacking or turn on combat mode. Reading the foreign mode is limited to the data received from the server.
var state = UO.IsWarMode("self");
if (Truth(state))
{
UO.Print("Combat stance is active");
}
else
{
UO.Print("Combat stance is inactive");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- IsNpc excludes subject and unknown object. target stores one serial, not a live link to a changing lasttarget.
- The result refers to the field InWarMode. The data is updated only after the client receives the appropriate state.
return RunScenario();
object? RunScenario()
{
var target = UO.GetSerial("lasttarget");
if (Truth(UO.IsNPC(target)))
{
var state = UO.IsWarMode(target);
UO.Print("Selected mobile state 1/0: " + Convert.ToString(state));
}
else
{
UO.Print("No loaded mobile selected");
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- UO.Wait(500) — pause in milliseconds. After it, it is separately checked that mobile still exists.
- Two photographs are compared. Intermediate changes may be missed, and this is not a continuous subscription to server events.
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()
{
var target = UO.GetSerial("lasttarget");
if (Truth(UO.IsNPC(target)))
{
var before = UO.IsWarMode(target);
await Delay(500);
if (Truth(UO.IsNPC(target)))
{
var after = UO.IsWarMode(target);
if (Truth(before != after))
{
UO.Print("Flag changed: " + Convert.ToString(before) + " -> " + Convert.ToString(after));
}
}
else
{
UO.Print("Mobile left the local world");
}
}
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;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: objID (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.IsWarMode:bridge.IsWarMode(Arg(0)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0). -
InjectionScript.Runtime.InjectionApiUO.WarMode:WarMode().
Internal implementation code; this is not a standalone script.
case "iswarmode": return new InjectionValue(arguments.Length > 0 ? bridge.IsWarMode(Arg(0)) : WarMode());Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.LastAttack();Reads the serial of the last attack target.
There are no parameters.
int — saved serial; 0 means serial is not installed. It's not a bool or a graphic/type; a nonzero ID may no longer exist in the world.
- Field source: bridge.LastAttack. The command does not select, use, or attack the object.
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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.
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.LastAttack();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- Reads the serial of the last attack target.
var id = UO.LastAttack();
UO.Print(Hex(id));
string Hex(object? value) => Convert.ToInt64(value).ToString("X");Parameters and execution flow:
- Field source: bridge.LastAttack. The command does not select, use, or attack the object.
return RunScenario();
object? RunScenario()
{
var id = UO.LastAttack();
if (Truth(id != 0) && Truth(UO.Exists(id)))
{
UO.Print(UO.GetName(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;Parameters and execution flow:
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 before = UO.LastAttack();
UO.Wait(500);
var after = UO.LastAttack();
UO.Print(before = after);
return null;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.LastAttack:bridge.LastAttack.
Internal implementation code; this is not a standalone script.
case "lastattack":
case "wartargetid": return new InjectionValue(bridge.LastAttack);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.SetClassMask(object? name, object? required);
int UO.SetClassMask(object? name, object? required, object? forbidden);Creates or replaces a custom equipment class for classMask into UO.AttackNearest. You choose the name and graphic/type of things; built-in job titles are not required.
-
name— A non-empty string with your name, for example "DTMH", "my_group", "archer_with_shield". Case is not important, spaces around the edges are removed. | , ; prohibited: these are priority separators. any/all/-1 are reserved for disabling the filter. -
required— One type, flat array of alternatives or array of mandatory groups. Each group is a type or a flat array. You need at least one thing from each group; empty required groups are not allowed. Each type is an int/numeric/hex string 1..65534. Nesting deeper than an array of groups is not accepted. This is a graphic of things, not serial and not the body of a character. -
forbidden— Optional type or flat array of prohibited types. By default, there are no prohibited items; an empty array is also allowed. If any such item is worn, the rule does not match. The same boundaries 1..65534; -1/any are not accepted here. It is impossible to completely prohibit all alternatives to a mandatory group.
int 1 — the rule has been checked and written. An invalid type/name/empty required group/inconsistency causes a script error, which can be caught by try/CATCH; the previous rule remains. Does not return serial or found characters, does not start an attack.
- The name is a custom label, not a server profession. You can call the rule DTMH, my_group or any other word. The engine does not determine skills/class on the server by character name.
- In required, one type or flat array means at least one thing from the list. An array of groups means: you need at least one thing from EACH group. For example, [leather, staves] requires leather AND a staff. This is a set of alternatives, and not a requirement to wear the entire wardrobe listed.
- Any item worn from forbidden excludes the character from this rule, even if the required ones are met. Leather plus a prohibited chain does not pass the leather rule. Other rules continue to be tested.
- Only loaded items worn on layers 1..24 except for the backpack 21 are counted. The contents of the backpack/chest, mount 25, journal 26..28 and bank 29 are not considered clothing. Compares graphic/type; The serial, name and hue things are not used here.
- The list does not match without the appropriate equipment loaded. The absence of a prohibited item in local data does not prove its absence on the server if the server has not yet sent the equipment. The client does not guess hidden data.
- The rules belong to one runtime script, including its functions and Includes; are not transferred to other independent launches and are not saved in the profile. When starting again, define them again, for example by the general setup procedure. A repeated SetClassMask replaces the rule with the same name, only after the new data has been fully verified.
- Arrays are copied during registration. Changing the original array does not change the rule: repeat SetClassMask. Multiple matching rules are resolved by the order of the names in classMask. There are no standard server clothing tables.
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.
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.SetClassMask("simple_sword", 0x0F5E);
UO.Print("SetClassMask: " + Convert.ToString(result));Parameters and execution flow:
- DTMH - just your name. The values in myLeather/forbiddenChain are examples: replace/supplement with the real graphic of your server. A flat list means OR, not a full set.
var myLeather = Gear(0x13C4, 0x13C7);
var forbiddenChain = Gear(0x13BF, 0x13C0);
UO.SetClassMask("DTMH", myLeather, forbiddenChain);
var enemy = UO.AttackNearest(5, 10, -1, 8, true, -1, "DTMH", true, true);
if (Truth(enemy != 0))
{
UO.AddObject("leather_enemy", enemy);
}
dynamic Gear(params dynamic[] values)
{
return values;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- DTMH is selected first; only if there are no suitable DTMH - heavy, then hunter. DTMH on 10 cells has priority over heavy on 2 cells. To reverse the order, change the line classMask. Of the two DTMH, the closest one is selected.
- Gear is a completely reduced user function C#, not a separate command UO. The two arrays in Gear(leather, staves) form two required groups. Adding a type to leather expands the alternatives; does not require wearing two leather items.
return RunScenario();
object? RunScenario()
{
var leather = Gear(0x13C4, 0x13C7);
var staves = Gear(0x0DF0, 0x0E81);
var chain = Gear(0x13BF, 0x13C0);
var plate = Gear(0x1415, 0x1411);
var bows = Gear(0x13B2, 0x0F50);
UO.SetClassMask("DTMH", Gear(leather, staves), chain);
UO.SetClassMask("охотник", bows);
UO.SetClassMask("тяжёлый", plate);
var notoriety = "5|6";
var distance = 12;
var body = -1;
var maxZ = 8;
dynamic nearest = true;
var color = -1;
var classMask = "DTMH|тяжёлый|охотник";
dynamic aliveOnly = true;
dynamic visibleOnly = true;
var enemy = UO.AttackNearest(notoriety, distance, body, maxZ, nearest, color, classMask, aliveOnly, visibleOnly);
if (Truth(enemy == 0))
{
UO.Print("No matching enemy; no attack sent");
return null;
}
UO.AddObject("selected_enemy", enemy);
return null;
}
dynamic Gear(params dynamic[] values)
{
return values;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- declaring the variable required[1] creates two elements with indexes 0 and 1. The two nested groups require torso AND weapon; flat [torsoType,weaponType] would mean torso OR weapon.
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()
{
dynamic[] required = new dynamic[checked((int)(1) + 1)];
dynamic[] torso = new dynamic[checked((int)(0) + 1)];
dynamic[] weapon = new dynamic[checked((int)(0) + 1)];
torso[0] = 0x13C4;
weapon[0] = 0x0DF0;
required[0] = torso;
required[1] = weapon;
UO.SetClassMask("мой_комплект", required);
var enemy = UO.AttackNearest(5, 6, -1, 4, true, -1, "мой_комплект", true, true);
if (Truth(enemy != 0))
{
UO.AddObject("outfit_enemy", enemy);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}Parameters and execution flow:
- Re-registration replaces a copy of the rule. The old name remains the same, so there is no need to rewrite the priority line.
dynamic[] allowed = new dynamic[checked((int)(0) + 1)];
allowed[0] = 0x13B2;
UO.SetClassMask("приоритетный", allowed);
allowed[0] = 0x0F50;
UO.SetClassMask("приоритетный", allowed);
var enemy = UO.AttackNearest(5, 10, -1, 8, true, -1, "приоритетный", true, true);
if (Truth(enemy != 0))
{
UO.AddObject("updated_outfit", enemy);
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: name (Any), required (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterClassMaskApi [SetClassMask]. -
InjectionScript.Runtime.InjectionApiUO.SetClassMask:SetClassMask(args).
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.
args => new InjectionValue(SetClassMask(args))Parameters: name (Any), required (Any), forbidden (Any)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.RegisterClassMaskApi [SetClassMask]. -
InjectionScript.Runtime.InjectionApiUO.SetClassMask:SetClassMask(args).
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.
args => new InjectionValue(SetClassMask(args))Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.SetWarMode(object? value);Requests the character's combat or peaceful mode.
-
value- 0 - peaceful mode; any non-zero integer is combat mode.
void - no value. Call on a separate line; completion does not confirm the server's action.
- WarMode passes the mode to GameActions.ToggleWarMode: 0 disables, any non-zero value enables. Without Player there is no action.
- Bridge sends the request on the game thread. Server rules apply; There is no built-in waiting for confirmation.
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.
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.SetWarMode");
UO.SetWarMode(1);Parameters and execution flow:
- Requests the character's combat or peaceful mode.
UO.SetWarMode(1);Parameters and execution flow:
- WarMode passes the mode to GameActions.ToggleWarMode: 0 disables, any non-zero value enables. Without Player there is no action.
return RunScenario();
object? RunScenario()
{
UO.SetWarMode(0);
return null;
}Parameters and execution flow:
- Bridge sends the request on the game thread. Server rules apply; There is no built-in waiting for confirmation.
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()
{
ApplyMode(1);
return null;
}
void ApplyMode(dynamic mode)
{
UO.SetWarMode(mode);
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: value (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.WarMode:WarMode(Arg(0)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0).
Internal implementation code; this is not a standalone script.
case "setwarmode": WarMode(Arg(0)); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.Specmove(object? direction);
void UO.Specmove(object? direction, object? running);Sends one step request directly to the bridge.
-
direction— int; direction & 7 daët 0..7 N,NE,E,SE,S,SW,W,NW. -
running- Optional Numeric flag int: 0/none - walking, non-zero - running.
void - no value. Call on a separate line; completion does not confirm the server's action.
- ExecuteLegacyManualAlias calls bridge.Step(direction & 7, running != 0) and discards all result code 0/2/3/4/5/7; void is returned outside. This is one step/turn, not a route. Waiting within Step until 10000 ms is maintained, but the script does not receive an acknowledgment, failure, or timeout code.
- The branch does not fulfill the runtime conditions MoveCheckStamina/MoveExitOnDisconnect/MoveOpenDoor from UO.Step. Bridge/Player.Walk itself and the server still check the movement.
- QueueStep on the game thread checks the player, connection, direction, queue, tempo and local traffic. Before Player.Walk, each call separately records the Confirm/Deny generations of its sequence and Walker; then returns Result along with this snapshot. Step and pending StepControlled check only this stored pair, not the general fields of the next request; the replacement player/Walker ends the wait with a general refusal. Confirmation of another regular command does not confirm this step. Rotation without movement remains a separate case.
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.
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.Specmove");
UO.Specmove(0);Parameters and execution flow:
- Sends one step request directly to the bridge.
UO.Specmove(0);Parameters and execution flow:
- ExecuteLegacyManualAlias calls bridge.Step(direction&7,running!=0), then discards the returned 1/0. This is one step, not a path to a coordinate.
return RunScenario();
object? RunScenario()
{
UO.Specmove(2, 1);
return null;
}Parameters and execution flow:
- The branch does not fulfill the runtime conditions MoveCheckStamina/MoveExitOnDisconnect/MoveOpenDoor from UO.Step. Bridge/Player.Walk itself and the server still check the movement.
Minimum step interval: walking - walking 400 ms, running 200 ms; riding - walking 200 ms, running 100 ms.
These are standard client limits, not automatically defined settings for your shard. Server speed and flight modes are counted separately. Script timers can slow down movement, but do not reduce these limits.
Steps, Routes, Follow, Mouse/Key Controls, and Map all use the character's shared queue. Replacing the route, turning, or adjusting the position by the server does not cancel the remaining pause after the step request. After the delay, there is no fast burst to compensate for the dropped frames. Waiting for confirmation, obstacles and poor communication can slow down the movement.
return new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenario();
class ScriptScenario
{
private readonly global::ClassicUO.CSharp.CSharpGameApi UO;
private readonly Func<int, Task> WaitAsync;
private readonly string[] Args;
private readonly CancellationToken Cancellation;
private readonly Action Checkpoint;
public ScriptScenario(global::ClassicUO.CSharp.CSharpGameApi api, Func<int, Task> wait, string[] args, CancellationToken cancellation, Action checkpoint)
{
UO = api;
WaitAsync = wait;
Args = args;
Cancellation = cancellation;
Checkpoint = checkpoint;
}
public object? RunScenario()
{
var before = UO.GetX();
UO.Specmove(2, 0);
UO.Wait(500);
UO.Print(UO.GetX() - before);
return null;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: direction (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Step:bridge.Step(Arg(0) & 7, arguments.Length > 1 && Arg(1) != 0). -
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias::Arg:Arg(0).
Internal implementation code; this is not a standalone script.
case "specmove": bridge.Step(Arg(0) & 7, arguments.Length > 1 && Arg(1) != 0); break;Parameters: direction (Any), running (Any)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Step:bridge.Step(Arg(0) & 7, arguments.Length > 1 && Arg(1) != 0). -
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias::Arg:Arg(0).
Internal implementation code; this is not a standalone script.
case "specmove": bridge.Step(Arg(0) & 7, arguments.Length > 1 && Arg(1) != 0); break;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.UseAbility(object? abilityId);Requests the ability available to the current weapon.
-
abilityId— Ability name or int ID 1..AbilityData.Abilities.Length. Names are normalized: only letters/numbers are stored and compared in upper case. Numeric text means ID.
Numeric flag int: 1 - ID matches the current Player's primary/secondary ability and the corresponding GameActions is called; 0 - no Player, unknown ID/name or ability does not belong to the current weapon.
- The string form uses ResolveAbility; numeric immediately bridge.UseAbility. Bridge masks 0x80 from two current abilities and matches ID, then calls UsePrimaryAbility or UseSecondaryAbility.
- This is an acceptance of a local request, not confirmation of a hit, mana expenditure, or activation by the server. Available ID are read GetWeaponAbilities, active name is GetActiveAbility.
- GameActions toggles the ability selection bit 0x80. An ability already selected sends ID 0 and deselects it; otherwise, both selection bits are cleared, the selected ID is sent, then its bit is set locally. Therefore, calling it again may turn off the ability. A local change does not mean a successful hit or server confirmation.
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.
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.UseAbility("Armor Ignore");
UO.Print("UseAbility: " + Convert.ToString(result));Parameters and execution flow:
- Requests the ability available to the current weapon.
UO.Print(UO.UseAbility("Armor Ignore"));Parameters and execution flow:
- The string form uses ResolveAbility; numeric immediately bridge.UseAbility. Bridge masks 0x80 from two current abilities and matches ID, then calls UsePrimaryAbility or UseSecondaryAbility.
return RunScenario();
object? RunScenario()
{
var abilities = UO.GetWeaponAbilities();
if (Truth(UO.GetArrayLength(abilities) > 0))
{
UO.Print(UO.UseAbility(abilities[0]));
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;Parameters and execution flow:
- This is an acceptance of a local request, not confirmation of a hit, mana expenditure, or activation by the server. Available ID are read GetWeaponAbilities, active name is GetActiveAbility.
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 id = UO.GetAbilityID("Armor Ignore");
if (Truth(id > 0))
{
var accepted = UO.UseAbility(id);
UO.Print(accepted);
UO.Print(UO.GetActiveAbility());
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: abilityId (Integer/String)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.UseAbility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseAbility:bridge.UseAbility(abilityId).
Internal implementation code; this is not a standalone script.
public int UseAbility(int abilityId) => bridge.UseAbility(abilityId);Parameters: abilityId (Integer/String)
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.UseAbility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ResolveAbility:bridge.ResolveAbility(abilityName). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseAbility:bridge.UseAbility(abilityId).
Internal implementation code; this is not a standalone script.
public int UseAbility(string abilityName)
{
int abilityId = bridge.ResolveAbility(abilityName);
return abilityId > 0 ? bridge.UseAbility(abilityId) : 0;
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.UsePrimaryAbility();Summons the weapon's primary ability.
There are no parameters.
void - no value. Call on a separate line; completion does not confirm the server's action.
- UsePrimaryAbility transmits GameActions.UsePrimaryAbility(_world) via Invoke. There is no acceptance sign returned; active ability is checked separately.
- In the examples, UO.Wait specifies only a script pause; the end of the pause does not prove that the server has completed the request.
- GameActions toggles the ability selection bit 0x80. An ability already selected sends ID 0 and deselects it; otherwise, both selection bits are cleared, the selected ID is sent, then its bit is set locally. Therefore, calling it again may turn off the ability. A local change does not mean a successful hit or server confirmation.
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.
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.UsePrimaryAbility");
UO.UsePrimaryAbility();Parameters and execution flow:
- Summons the weapon's primary ability.
UO.UsePrimaryAbility();Parameters and execution flow:
- UsePrimaryAbility transmits GameActions.UsePrimaryAbility(_world) via Invoke. There is no acceptance sign returned; active ability is checked separately.
return RunScenario();
object? RunScenario()
{
UO.Print(UO.GetWeaponAbilities());
UO.UsePrimaryAbility();
return null;
}Parameters and execution flow:
- In the examples, UO.Wait specifies only a script pause; the end of the pause does not prove that the server has completed the request.
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.UsePrimaryAbility();
UO.Print(UO.GetActiveAbility());
return null;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UsePrimaryAbility:bridge.UsePrimaryAbility().
Internal implementation code; this is not a standalone script.
case "useprimaryability": bridge.UsePrimaryAbility(); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.UseSecondaryAbility();Summons an additional weapon ability.
There are no parameters.
void - no value. Call on a separate line; completion does not confirm the server's action.
- UseSecondaryAbility transmits GameActions.UseSecondaryAbility(_world) via Invoke. There is no acceptance sign returned; active ability is checked separately.
- In the examples, UO.Wait specifies only a script pause; the end of the pause does not prove that the server has completed the request.
- GameActions toggles the ability selection bit 0x80. An ability already selected sends ID 0 and deselects it; otherwise, both selection bits are cleared, the selected ID is sent, then its bit is set locally. Therefore, calling it again may turn off the ability. A local change does not mean a successful hit or server confirmation.
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.
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.UseSecondaryAbility");
UO.UseSecondaryAbility();Parameters and execution flow:
- Summons an additional weapon ability.
UO.UseSecondaryAbility();Parameters and execution flow:
- UseSecondaryAbility transmits GameActions.UseSecondaryAbility(_world) via Invoke. There is no acceptance sign returned; active ability is checked separately.
return RunScenario();
object? RunScenario()
{
UO.Print(UO.GetWeaponAbilities());
UO.UseSecondaryAbility();
return null;
}Parameters and execution flow:
- In the examples, UO.Wait specifies only a script pause; the end of the pause does not prove that the server has completed the request.
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.UseSecondaryAbility();
UO.Print(UO.GetActiveAbility());
return null;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseSecondaryAbility:bridge.UseSecondaryAbility().
Internal implementation code; this is not a standalone script.
case "usesecondaryability": bridge.UseSecondaryAbility(); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.WarMode();
void UO.WarMode(object? mode);Reads or queries the character's combat mode.
-
mode— Optional int: 0 disables, any non-zero value enables. The form without arguments only reads.
No arguments Numeric flag int: 1 - current Player in combat mode, 0 - peaceful mode/no Player. With mode - null, there is no result.
- WarMode() reads Player.InWarMode locally. WarMode(mode) calls GameActions.ToggleWarMode with the selected mode; without Player the request is not executed.
- Do not assign the result of a form with an argument to a variable. Immediate re-reading is not an online confirmation.
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.
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.WarMode();
UO.Print("WarMode: " + Convert.ToString(result));Parameters and execution flow:
- Reads or queries the character's combat mode.
var active = UO.WarMode();
UO.Print(active);Parameters and execution flow:
- WarMode() reads Player.InWarMode locally. WarMode(mode) calls GameActions.ToggleWarMode with the selected mode; without Player the request is not executed.
return RunScenario();
object? RunScenario()
{
UO.WarMode(1);
UO.Wait(250);
UO.Print(UO.WarMode());
return null;
}Parameters and execution flow:
- Do not assign the result of a form with an argument to a variable. Immediate re-reading is not an online confirmation.
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 before = UO.WarMode();
UO.WarMode(0);
UO.Print(before);
return null;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: int / Integer.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WarMode. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.WarMode:bridge.WarMode().
Internal implementation code; this is not a standalone script.
public int WarMode() => bridge.WarMode();Parameters: mode (Integer)
Result: void / Unit.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.WarMode. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.WarMode:bridge.WarMode(mode).
Internal implementation code; this is not a standalone script.
public void WarMode(int mode) => bridge.WarMode(mode);Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.WarTargetID();Reads the serial of the last attack target.
There are no parameters.
int — saved serial; 0 means serial is not installed. It's not a bool or a graphic/type; a nonzero ID may no longer exist in the world.
- Field source: bridge.LastAttack. The command does not select, use, or attack the object.
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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.
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.WarTargetID();
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));Parameters and execution flow:
- Reads the serial of the last attack target.
var id = UO.WarTargetID();
UO.Print(Hex(id));
string Hex(object? value) => Convert.ToInt64(value).ToString("X");Parameters and execution flow:
- Field source: bridge.LastAttack. The command does not select, use, or attack the object.
return RunScenario();
object? RunScenario()
{
var id = UO.WarTargetID();
if (Truth(id != 0) && Truth(UO.Exists(id)))
{
UO.Print(UO.GetName(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;Parameters and execution flow:
- Reads the current local state. There is no package, target or automatic update; individual reads may see different states.
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 before = UO.WarTargetID();
UO.Wait(500);
var after = UO.WarTargetID();
UO.Print(before = after);
return null;
}
}C# is case sensitive. Use the exact UO name. Compare numeric flags with 0; use bool only where the signature returns bool.
Parameters: No parameters.
Result: dynamic / Any.
During a call:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.LastAttack:bridge.LastAttack.
Internal implementation code; this is not a standalone script.
case "lastattack":
case "wartargetid": return new InjectionValue(bridge.LastAttack);ClassicUO — Bad Newbie & C# Scripts IDE