Repository navigation
ZH TW UO Topic magic
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
家 · C# · IDE · UO API · A–Z · 範例 · Languages
法術、能力和魔法移動。對於有針對性的行動,請提前設定目標並檢查應用條件。
| 主題 | 命令與解釋 |
|---|---|
| Cast | UO.Cast |
| CastToObject | UO.CastToObject |
| CastAbility | UO.CastAbility |
| Active Spell Ability | UO.IsActiveSpellAbility |
| Spell Timers | UO.TicksSpell |
UO.Cast · UO.CastToObject · UO.CastAbility · UO.IsActiveSpellAbility · UO.TicksSpell
每個命令卡都有幾個獨立的場景:直接程式碼、函數和類別。以下是精選的簡短場景;限制和全面分析是有可能的。
UO.CancelWaitTarget();
if (Truth(UO.Cast("Cure")))
{
UO.Print("Choose the character with the spell cursor");
}
else
{
UO.Print("Cure request rejected");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;var accepted = UO.CastToObject("Heal", "self");
UO.Print(Convert.ToString(accepted));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.AddGate(object? bookSerial);-
bookSerial是相容腳本儲存為舊清單條目的識別碼值。在目前運行時,該值被序列化為字串;該命令不會檢查世界中是否存在物件。
void。該團隊未確認該書的可用性或遊戲入口網站的創建。
- 該值被加入到目前運行時狀態的清單
AddGate中。在 ClassicUO 中,此相容性清單不會觸發遊戲操作,並且沒有記錄的公共 getter 可供讀取。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.AddGate");
UO.AddGate("0x40012345");參數與執行流程:
- 將 ID 儲存為遺留數據,無需打開大門。
UO.AddGate("0x40012345");參數與執行流程:
- 使用傳遞給相容腳本的字串中的值。
return RunScenario();
object? RunScenario()
{
var bookSerial = "0x40012345";
UO.AddGate(bookSerial);
return null;
}參數與執行流程:
- 將值寫入運行時列表AddGate。
- 呼叫儲存相容性資料;他在世界上不使用這本書。
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()
{
RememberGateBook("0x40012345");
return null;
}
void RememberGateBook(dynamic bookSerial)
{
UO.AddGate(bookSerial);
}
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: bookSerial (Any)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias. -
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias::LegacyList:LegacyList(name). -
InjectionScript.Runtime.InjectionValue.ToString:value.ToString().
內部實作程式碼,不能作為獨立腳本執行。
case "adddir":
case "addfindlist":
case "addgate":
case "addrecall":
case "addstep":
LegacyList(name).Add(string.Join("|", arguments.Select(value => value.ToString())));
break;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.AddRecall(object? bookSerial);-
bookSerial是相容腳本儲存為舊清單條目的識別碼值。運行時將傳遞的值序列化為字串。
void。該呼叫不會傳回結果,也不會確認該書是否存在。
- 該值被加入到目前運行時狀態的清單
AddRecall中。在 ClassicUO 中,此相容性清單本身不會發送遊戲命令,並且沒有記錄的公共 getter 可供讀取。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.AddRecall");
UO.AddRecall("0x40012345");參數與執行流程:
- 將值儲存為相容性數據,不執行 Recall。
UO.AddRecall("0x40012345");參數與執行流程:
- 透過字串變數傳遞標識符。
return RunScenario();
object? RunScenario()
{
var bookSerial = "0x40012345";
UO.AddRecall(bookSerial);
return null;
}參數與執行流程:
- 每個呼叫都會在目前運行時的AddRecall新增一個單獨的條目。
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.AddRecall("0x40012345");
UO.AddRecall("0x40012346");
return null;
}
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: bookSerial (Any)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias. -
InjectionScript.Runtime.InjectionApiUO.ExecuteLegacyManualAlias::LegacyList:LegacyList(name). -
InjectionScript.Runtime.InjectionValue.ToString:value.ToString().
內部實作程式碼,不能作為獨立腳本執行。
case "adddir":
case "addfindlist":
case "addgate":
case "addrecall":
case "addstep":
LegacyList(name).Add(string.Join("|", arguments.Select(value => value.ToString())));
break;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.Cast(object? spellName);請求使用名字咒語。恰好一個參數:spellName,例如UO.Cast("Heal")。單獨選擇目標:使用滑鼠使用出現的十字線或經過WaitTargetObject之前的Cast。接受請求並不確認效果成功。
-
spellName- 必填行 - 引號中的法術英文名稱:「Heal」、「Cure」、「Greater Heal」。名稱不隨介面一起翻譯。該字典還可以識別內建別名和拼字單字。數字ID(包括字串「29」)、目標、距離、惡名、maxZ 和等待不是 Cast 參數。 所有姓名和學校。
int: 1/true——客戶端接受了請求;0/false - 名稱無法識別或請求被本地拒絕。你可以寫 if UO.Cast("Heal") { ... } 或與 1/true 比較。這些不是 ID 法術或治療/傷害的證明。缺少或額外的參數會導致錯誤。該命令並不期望咒語能夠瞄準並完成。
- 單一形式:UO.Cast(spellName)。沒有第二個或後續的參數。搜尋目標、準備回應、等待和清除是透過單獨的命令執行的。
- 若要手動選擇,請清除先前的佇列CancelWaitTarget,呼叫Cast並用十字線點選所需的物件。 Cast 本身不會清除佇列:腳本可以提前準備好。
- 對於自動目標,先呼叫 WaitTargetObject(serial/alias),然後呼叫 Cast(name)。這個指令可以讓你快速回應伺服器的瞄準。對於沒有範圍的法術,不要準備答案。
- 伺服器決定法術的可用性、資源、有效目標、範圍和效果。正面的結果僅確認當地接受了請求。
- 如果伺服器發生故障,準備好的佇列可能會保持無人值守。在有限等待或本地故障後刪除它CancelWaitTarget。不要與目標並行運行其他腳本。
- 接受的請求更新TicksSpell。 Cast不會等待HP被動畫化、治癒或改變。目錄ID解釋了內部協議,但不取代參數中的名稱。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.Cast("Cure");
UO.Print("Cast: " + Convert.ToString(result));參數與執行流程:
- 治癒是Cast的唯一論點。啟動後,使用遊戲瞄準器選擇角色。檢查伺服器故障和遊戲結果。
UO.CancelWaitTarget();
if (Truth(UO.Cast("Cure")))
{
UO.Print("Choose the character with the spell cursor");
}
else
{
UO.Print("Cure request rejected");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- self — 參數WaitTargetObject;治癒是Cast的唯一論點。 3000 - 在這個例子中瞄準三秒,並不能保證治療完成。最後刪除剩餘的回應並失敗。
return await RunScenarioAsync();
async Task<object?> RunScenarioAsync()
{
UO.CancelWaitTarget();
try
{
UO.WaitTargetObject("self");
if (Truth(UO.Cast("Heal")))
{
await Delay(3000);
}
}
finally
{
UO.CancelWaitTarget();
}
return null;
}
Task Delay(object? milliseconds) => WaitAsync(checked((int)Convert.ToDouble(milliseconds)));
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- spellName,目標,cleanupDelayMs - 函數CastAtObject的參數,而非重載UO.Cast。在內部,Cast 僅接受 spellName。 ASC 將字串ID 轉換為數字; 4000 — 佇列清除延遲。 true 表示接受請求,而不是治療成功。
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 = Asc(UO.GetSerial("lasttarget"), 0);
if (Truth(await CastAtObject("Greater Heal", target, 4000)))
{
UO.Print("Request sent; verify healing in the game");
}
return null;
}
async Task<dynamic> CastAtObject(dynamic spellName, dynamic target, dynamic cleanupDelayMs)
{
if (!(Truth(UO.Connected())) || Truth(UO.Dead()) || Truth(target <= 0) || !(Truth(UO.Exists(target))))
{
return false;
}
dynamic accepted = false;
UO.CancelWaitTarget();
try
{
UO.WaitTargetObject(target);
accepted = UO.Cast(spellName);
if (Truth(accepted))
{
await Delay(cleanupDelayMs);
}
}
finally
{
UO.CancelWaitTarget();
}
return accepted;
}
int Asc(object? value, int fallback = 0)
{
string text = Convert.ToString(value) ?? "";
if (text.StartsWith("0x", StringComparison.OrdinalIgnoreCase))
return int.TryParse(text[2..], System.Globalization.NumberStyles.HexNumber, System.Globalization.CultureInfo.InvariantCulture, out int hex) ? hex : fallback;
return int.TryParse(text, out int number) ? number : fallback;
}
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# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: spellName (String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Cast. -
InjectionScript.Runtime.NumberConversions.TryStr2Int:NumberConversions.TryStr2Int((spellName ?? string.Empty).Trim(), out _). -
InjectionScript.Runtime.InjectionApiUO.SystemMessage:SystemMessage("UO.Cast: use one spell name, for example UO.Cast(\"Heal\")."). -
InjectionScript.Runtime.InjectionApiUO.CastCore:CastCore(spellName).
內部實作程式碼,不能作為獨立腳本執行。
public int Cast(string spellName)
{
if (NumberConversions.TryStr2Int((spellName ?? string.Empty).Trim(), out _))
{
SystemMessage("UO.Cast: use one spell name, for example UO.Cast(\"Heal\").");
return 0;
}
return CastCore(spellName) ? 1 : 0;
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.CastAbility(object? abilityId);透過切換當前武器的選定能力 UseAbility:再次呼叫已選擇的能力會刪除選擇。
-
abilityId— 由ResolveClassicUOAbilityId解析的技能名稱或數字字串;未知值給出0。
int 1 — 客戶端呼叫目前的主要/次要能力; 0 - 無角色,未知ID或能力與目前武器不符。
- 1 描述了客戶端請求的接受,而不是伺服器成功命中或註銷資源。 ID不是目前的主/輔能力,即使它在目錄中也會回傳0。
- GameActions.UsePrimaryAbility/UseSecondaryAbility 檢查0x80 位。當該位元關閉時,取消選擇其他選項並傳送所選能力;當已啟用時,發送 ID 0 停用。然後該位被切換。返回 1 確認對此客戶端分支的調用,包括關閉。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.CastAbility(UO.GetAbilityID("Armor Ignore"));
UO.Print("CastAbility: " + Convert.ToString(result));參數與執行流程:
- 目錄中的可用性與武器相符是分開的。
var id = UO.GetAbilityID("Armor Ignore");
if (Truth(id > 0))
{
var accepted = UO.CastAbility(id);
UO.Print(Convert.ToString(accepted));
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 該名稱解析為 ID 並根據當前武器進行檢查。
return RunScenario();
object? RunScenario()
{
var accepted = UO.CastAbility("Armor Ignore");
UO.Print(Convert.ToString(accepted));
return null;
}參數與執行流程:
- 零在目錄之外,返回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 accepted = UO.CastAbility(0);
UO.Print(Convert.ToString(accepted));
return null;
}
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: abilityId (Integer/String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseAbility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseAbility:bridge.UseAbility(abilityId).
內部實作程式碼,不能作為獨立腳本執行。
public int UseAbility(int abilityId) => bridge.UseAbility(abilityId);參數: abilityId (Integer/String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseAbility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ResolveAbility:bridge.ResolveAbility(abilityName). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseAbility:bridge.UseAbility(abilityId).
內部實作程式碼,不能作為獨立腳本執行。
public int UseAbility(string abilityName)
{
int abilityId = bridge.ResolveAbility(abilityName);
return abilityId > 0 ? bridge.UseAbility(abilityId) : 0;
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.CastToObject(object? spellName, object? objID);放置一個等待的物體目標並按名稱或數字ID發送咒語。
-
spellName- string 帶有咒語名稱,包括下劃線而不是空格,或數字 ID 表示橋接。 Cast。 -
objID— 物件的序號或支援的 self/backpack/lasttarget/saved 物件名稱;數字字串和 0x 字串由執行時間解析。
int/boolean result 1 — 用戶端接受了 Cast 請求; 0 — 請求被拒絕。伺服器未確認該咒語是否成功。
- 字串形式經過CastAtTarget;數字形式先放WaitTargetObject,然後橋接.Cast。如果Cast失敗,則取消待處理的目標。接受後,ticksSpell 就會更新。
- 橋拒絕非正spellId、無連接和死字符。計時器標記發送,而不是發送結束;對物件的影響結果取決於伺服器。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
object? result = UO.CastToObject("Heal", "self");
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));參數與執行流程:
- Heal 使 self 成為下一個伺服器遊標的目標。
var accepted = UO.CastToObject("Heal", "self");
UO.Print(Convert.ToString(accepted));參數與執行流程:
- 數位形式將 ID 4傳遞給客戶端;1表示發送請求。
return RunScenario();
object? RunScenario()
{
var accepted = UO.CastToObject(4, UO.Self());
UO.Print(Convert.ToString(accepted));
return null;
}參數與執行流程:
- 本地存在檢查有助於避免使用丟失的lasttarget。
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 target = UO.LastTarget();
if (Truth(UO.Exists(target)))
{
var accepted = UO.CastToObject("Greater Heal", target);
UO.Print(Convert.ToString(accepted));
}
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# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: spellName (Any), objID (Any)
結果: dynamic / Any.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.CastAtTarget:CastAtTarget(arguments[0], arguments[1]). -
InjectionScript.Runtime.InjectionApiUO.WaitTargetObject:WaitTargetObject(Arg(1)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(1). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Cast:bridge.Cast(Arg(0)). -
InjectionScript.Runtime.InjectionApiUO.Timer:Timer(). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.CancelTarget:bridge.CancelTarget().
內部實作程式碼,不能作為獨立腳本執行。
case "casttoobject":
if (arguments[0].Kind == InjectionValueKind.String)
return CastAtTarget(arguments[0], arguments[1]) != 0 ? InjectionValue.True : InjectionValue.False;
WaitTargetObject(Arg(1));
int castAccepted = bridge.Cast(Arg(0));
if (castAccepted != 0)
{
ticksSpell = Timer();
return InjectionValue.True;
}
bridge.CancelTarget();
return InjectionValue.False;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.IsActiveSpellAbility(object? spellName);检查服务器是否已报告所选能力/法术的活动状态。在重新激活引導能力之前很有用。它不会打开任何东西,不会施放或选择目标。
-
spellName- 唯一必要的參數:法術目錄中的英文名稱或整個ID。例如,「Confidence」和402代表同一個武士道咒語。大小寫並不重要;名稱中的底線替換為空格。數軸也被識別。不要傳遞ID角色、type物品或技能編號。
int: 1 - 伺服器報告此ID的活動狀態; 0 - 現在沒有這樣的活動狀態。在 C# 中檢查數值結果:if (UO.IsActiveSpellAbility(402) != 0) { ... }。這是邏輯符號,而不是上次施法的次數、時間或結果。未知名稱,1…65535之外的ID並且沒有結果狀態也給出0。
- 此清單更新伺服器套件0xBF/0x25:啟用新增ID,停用則刪除它。無需圖形視窗和螢幕上的拼字按鈕即可運作。關閉視窗保存狀態;斷開連線會將其清除。答案0並不能證明該角色無法施展該咒語。伺服器應發送此狀態;這並不是對所有增益的通用檢查。對於即時治療/召回,這樣的例子並不能確認施法是否成功。法術的持續時間、剩餘法力、可用性和成功率並不由該命令決定。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
object? result = UO.IsActiveSpellAbility(402);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));參數與執行流程:
- 402 - ID 信心。活動變數包含1或0; true 這裡相當於1。該訊息描述了接收到的狀態,而不是投射嘗試的結果。
var active = UO.IsActiveSpellAbility(402);
if (Truth(Truth(active) == true))
{
UO.Print("Confidence is active");
}
else
{
UO.Print("No active Confidence state received");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 「信心」-同樣的ID402。 Cast 僅接受名稱。如果沒有active狀態則發送一次請求;它不保證在伺服器上成功。不要在快速循環中運行此程式碼片段;伺服器回應可能會延遲。
return RunScenario();
object? RunScenario()
{
if (Truth(UO.IsActiveSpellAbility("Confidence") == 0))
{
UO.Cast("Confidence");
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 拼字 - 姓名或 ID;預期 - true 表示啟用, false 表示停用; timeoutMs — 等待限制(以毫秒為單位)。 Main 等待 500 毫秒,每隔 25 毫秒檢查一次,且不投射任何內容。如果符合則該函數傳回 true,否則傳回 false。這是當地國家的有限期望,並不是其改變原因的證明;如果腳本暫停或負載不足,實際時間可能會增加。
return new ScriptScenario(UO, WaitAsync, Args, Cancellation, Checkpoint).RunScenario();
class ScriptScenario
{
private readonly global::ClassicUO.CSharp.CSharpGameApi UO;
private readonly Func<int, Task> WaitAsync;
private readonly string[] Args;
private readonly CancellationToken Cancellation;
private readonly Action Checkpoint;
public ScriptScenario(global::ClassicUO.CSharp.CSharpGameApi api, Func<int, Task> wait, string[] args, CancellationToken cancellation, Action checkpoint)
{
UO = api;
WaitAsync = wait;
Args = args;
Cancellation = cancellation;
Checkpoint = checkpoint;
}
public object? RunScenario()
{
if (Truth(WaitAbilityState("Confidence", true, 500)))
{
UO.Print("Active state received");
}
else
{
UO.Print("No active state before timeout");
}
return null;
}
dynamic WaitAbilityState(dynamic spell, dynamic expected, dynamic timeoutMs)
{
var elapsed = 0;
while (Truth(elapsed < timeoutMs))
{
if (Truth((UO.IsActiveSpellAbility(spell) == 1) == expected))
{
return true;
}
UO.Wait(25);
elapsed = elapsed + 25;
}
return Truth((UO.IsActiveSpellAbility(spell) == 1) == expected);
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: spellName (Any)
結果: dynamic / Any.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
InjectionScript.Runtime.InjectionApiUO.ConvertSpellName:ConvertSpellName(Text(0).Replace('_', ' ')). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Text:Text(0). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.IsActiveSpell:bridge.IsActiveSpell(spellId.Value).
內部實作程式碼,不能作為獨立腳本執行。
case "isactivespellability":
{
int? spellId = arguments[0].Kind == InjectionValueKind.String
? ConvertSpellName(Text(0).Replace('_', ' '))
: (int?)Arg(0);
return new InjectionValue(spellId.HasValue ? bridge.IsActiveSpell(spellId.Value) : 0);
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.TicksSpell();讀取保存的標記TicksSpell。
沒有參數。
int — 標記 UO.Timer 從運行時開始算起十分之一秒。 0 — 標記尚未設定或事件發生在前十分之一秒內;它不是毫秒或日曆時間。
- 返回字段ticksSpell。由成功受理的Cast/CastAtTarget更新;它不是自動觀察所有手動/伺服器活動。命令本身不會更改標記。
- UO.Timer() - 此標記以十分之一秒為單位計算年齡。不比較不同運行時間之間的分數。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.TicksSpell();
UO.Print("TicksSpell: " + Convert.ToString(result));參數與執行流程:
- 讀取保存的標記TicksSpell。
var stamp = UO.TicksSpell();
UO.Print(stamp);參數與執行流程:
- 返回字段ticksSpell。由成功受理的Cast/CastAtTarget更新;它不是自動觀察所有手動/伺服器活動。命令本身不會更改標記。
return RunScenario();
object? RunScenario()
{
var stamp = UO.TicksSpell();
var ageTenths = UO.Timer() - stamp;
UO.Print(ageTenths);
return null;
}參數與執行流程:
- UO.Timer() - 此標記以十分之一秒為單位計算年齡。不比較不同運行時間之間的分數。
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.TicksSpell();
UO.Wait(250);
var after = UO.TicksSpell();
UO.Print(before = after);
return null;
}
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: 沒有參數。
結果: int / Integer.
呼叫時:
內部實作程式碼,不能作為獨立腳本執行。
public int TicksSpell() => ticksSpell;ClassicUO — Bad Newbie & C# Scripts IDE