ZH TW UO Topic items Part 2 - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
家 · C# · IDE · UO API · A–Z · 範例 · Languages
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.MoveItem(object? id);
int UO.MoveItem(object? id, object? amount);
int UO.MoveItem(object? id, object? amount, object? targetContainer);
int UO.MoveItem(object? item, object? amount, object? container, object? x);
int UO.MoveItem(object? item, object? amount, object? container, object? x, object? y);
int UO.MoveItem(object? id, object? amount, object? targetContainer, object? x, object? y, object? z);
int UO.MoveItem(object? item, object? amount, object? container, object? x, object? y, object? z, object? timeout);
int UO.MoveItem(object? item, object? amount, object? container, object? x, object? y, object? z, object? timeout, object? waitConfirmation);透過serial運送一件特定的物品/堆疊:捕獲並丟進容器或地面上。
-
id— 特定項目/字元的序列:數字、十六進位/十進位字串、 self/backpack/lasttarget/lastobject/lastcontainer/lastcorpse/finditem/laststatus 或已儲存的名稱 AddObject。這不是 type。該物件必須已載入;行動前檢查 Exists. -
item— 特定項目/字元的序列:數字、十六進位/十進位字串、 self/backpack/lasttarget/lastobject/lastcontainer/lastcorpse/finditem/laststatus 或已儲存的名稱 AddObject。這不是 type。該物件必須已載入;行動前檢查 Exists. -
amount— 一堆內的單元數。 0或負值表示整個堆疊;積極的一面受到可用數量的限制。限制MassMove的不是堆疊的數量。預設為0。 -
targetContainer— 容器的序號或集名稱AddObject; backpack/self/my 選擇背包,receiving/catchbag - SetCatchBag,以及不帶背包的情況。 lastcontainer/lastobject/lasttarget/lastcorpse/finditem/laststatus 在解析到正確的容器時有效。 ground或0明確選擇土地; -1—相同的背包選擇器。未知或未指定的名稱會在捕獲項目之前導致錯誤。如果沒有目的地參數,則使用背包。 -
container— 容器的序號或集名稱AddObject; backpack/self/my 選擇背包,receiving/catchbag - SetCatchBag,以及不帶背包的情況。 lastcontainer/lastobject/lasttarget/lastcorpse/finditem/laststatus 在解析到正確的容器時有效。 ground或0明確選擇土地; -1—相同的背包選擇器。未知或未指定的名稱會在捕獲項目之前導致錯誤。如果沒有目的地參數,則使用背包。 -
x— 带有容器 — X 在口中,默认 65535(自动)。當在地面上時 - 世界 X,預設角色 X。 -
y— 阿甘或世界 Y 中的 Y;對於貨櫃,預設為 65535;對於陸地,預設為 Y 字元。 -
z— 高度,預設為容器中的0 或地面上角色的 Z 高度。 -
timeout— 第七個參數:最長等待時間(以毫秒為單位),預設為1000;負值相當於0。僅與第八個waitConfirmation=true 一起使用。 -
waitConfirmation— 第八個參數: true/1 包含對世界中觀察到的變化的期望; false/0(預設)回饋發送請求的結果。
int 1—客戶端接受捕獲並重設請求; 0—請求無法完成。當 waitConfirmation=true 時,還需要容器/座標發生可觀察的變化或原始堆疊的減少。這不是新堆疊的serial,也不是傳輸的項目數。伺服器可能會拒絕操作。
該命令的結果是一個數字標誌: 1 表示滿足條件, 0 - 未實現。後 var 結果=命令(...)檢查是否(結果!= 0) 或 if (結果 == 0)。儲存一次呼叫的結果:重複呼叫可以再次執行該操作或讀取已經變更的狀態。
- 支援從 1 到 8 的所有參數長度。給定 x,您可以省略 y/z:所描述的預設值用於它們。
- 已知的目標名稱在捕獲之前已解析。對於地面,明確使用ground/0;名稱中的拼字錯誤不應將物品扔到地板上。
- 該物品可以放在箱子、袋子或背包中:ground將目的地設置在地面上,無論原始容器是什麼。第一個參數指定物品本身的serial,而不是箱子或type。球隊自行鏟斷;無需先用滑鼠抓取該項目。
- 當DropCheckCoord打開時,超過兩個單元的傾倒到地面將被拒絕。伺服器還檢查空間的可用性。 X/Y 是地圖單元,而不是圖形像素; Z——所選曲面的高度,包括負值。對於容器來說,X/Y 仍然表示其口內的位置。
- 等待確認使用客戶端世界的狀態:對於部分堆疊 - 數量減少,對於整體 - 一個容器,對於地面另一個 X/Y/Z。在容器內,阿甘的確切位置並沒有被這個期望所證實;堆疊消失/合併會使驗證變得複雜。
- 這不是對單獨交易ID的確認。如果該物品已經在同一個容器中,則匹配該容器並不能證明阿甘中的新移動。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.MoveItem("lasttarget");
UO.Print("MoveItem: " + Convert.ToString(result));參數與執行流程:
- 戰利品 - 名稱AddObject;金額缺失且等於0,目的地是背包。
- 傳輸一個項目/堆疊,而不是給定類型的所有項目。
var ok = UO.MoveItem("loot");
UO.Print("Move request: " + Convert.ToString(ok));參數與執行流程:
- amount=10 一堆單位,chest 是容器名稱,gump 內 x/y=60/70,z=0。
- 此數量不具有MassMove採用的「十堆」值。
return RunScenario();
object? RunScenario()
{
var ok = UO.MoveItem("loot", 10, "chest", 60, 70, 0);
return null;
}參數與執行流程:
- ground 明確選擇ground;缺少的 X/Y/Z 取自角色。
- 對於另一個點,傳遞它的世界座標,同時考慮範圍和DropCheckCoord。
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 ok = UO.MoveItem("loot", 0, "ground");
return null;
}
}參數與執行流程:
- ground_item - 將所選項目的serial保存在打開的箱子中。原始箱子不作為單獨的參數傳遞。 amount=0 佔用整個堆疊;例如,10將佔用該堆疊的最多十個單位。
- ground 明確選擇地面。 x/y - 距字元 X 方向一格的單元格的絕對座標; z 取自角色,如果相鄰表面處於相同高度,則適用。在樓梯、桌子或其他地板上,設定所需表面的實際 Z 值。
- send=1表示客戶端發送請求;如果沒有第八個參數,則不需要伺服器確認。值0表示請求失敗。這是數字標誌int1/0:檢查已發送! =0或已發送==0;與bool的比較無效。
- 要直接在腳上重置,UO.MoveItem('ground_item', 0, 'ground')就足夠了:所有三個座標都將從角色中獲取。要將其放置在箱子內,請指定 serial/箱子的名稱及其口的座標,而不是ground。
UO.AddObject("ground_item");
var x = UO.GetX() + 1;
var y = UO.GetY();
var z = UO.GetZ();
var sent = UO.MoveItem("ground_item", 0, "ground", x, y, z);
if (Truth(sent == 1))
{
UO.Print("Ground move request sent");
}
else
{
UO.Print("Ground move request was not sent");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 使用 timeout=1500 ms,因為 waitConfirmation=true。 x/y=-1 — 自動放置。
- 0 可能表示已發送的請求逾時。切勿盲目重複轉帳;請先檢查該物品的當前狀況。
return RunScenario();
object? RunScenario()
{
var ok = UO.MoveItem("loot", 0, "backpack", -1, -1, 0, 1500, true);
if (Truth(ok == 0))
{
UO.Print("Move was rejected or not confirmed");
}
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。
參數: id (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.MoveItem. -
InjectionScript.Runtime.InjectionApiUO.CompactMoveItem:CompactMoveItem(new[] { id }).
內部實作程式碼,不能作為獨立腳本執行。
public int MoveItem(InjectionValue id)
=> CompactMoveItem(new[] { id });參數: id (Any), amount (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.MoveItem. -
InjectionScript.Runtime.InjectionApiUO.CompactMoveItem:CompactMoveItem(new[] { id, amount }).
內部實作程式碼,不能作為獨立腳本執行。
public int MoveItem(InjectionValue id, InjectionValue amount)
=> CompactMoveItem(new[] { id, amount });參數: id (Any), amount (Any), targetContainer (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.MoveItem. -
InjectionScript.Runtime.InjectionApiUO.CompactMoveItem:CompactMoveItem(new[] { id, amount, targetContainer }).
內部實作程式碼,不能作為獨立腳本執行。
public int MoveItem(InjectionValue id, InjectionValue amount, InjectionValue targetContainer)
=> CompactMoveItem(new[] { id, amount, targetContainer });參數: item (Any), amount (Any), container (Any), x (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Register [MoveItem]. -
InjectionScript.Runtime.InjectionApiUO.CompactMoveItem:CompactMoveItem(values).
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
values => new InjectionValue(CompactMoveItem(values))參數: item (Any), amount (Any), container (Any), x (Any), y (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Register [MoveItem]. -
InjectionScript.Runtime.InjectionApiUO.CompactMoveItem:CompactMoveItem(values).
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
values => new InjectionValue(CompactMoveItem(values))參數: id (Any), amount (Any), targetContainer (Any), x (Any), y (Any), z (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.MoveItem. -
InjectionScript.Runtime.InjectionApiUO.CompactMoveItem:CompactMoveItem(new[] { id, amount, targetContainer, x, y, z }).
內部實作程式碼,不能作為獨立腳本執行。
public int MoveItem(InjectionValue id, InjectionValue amount, InjectionValue targetContainer, InjectionValue x, InjectionValue y, InjectionValue z)
=> CompactMoveItem(new[] { id, amount, targetContainer, x, y, z });參數: item (Any), amount (Any), container (Any), x (Any), y (Any), z (Any), timeout (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Register [MoveItem]. -
InjectionScript.Runtime.InjectionApiUO.CompactMoveItem:CompactMoveItem(values).
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
values => new InjectionValue(CompactMoveItem(values))
UO.MoveItem(item, amount, container, x, y, z, timeout, waitConfirmation) — UO.MoveItem(Any,Any,Any,Any,Any,Any,Any,Any)
參數: item (Any), amount (Any), container (Any), x (Any), y (Any), z (Any), timeout (Any), waitConfirmation (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Register [MoveItem]. -
InjectionScript.Runtime.InjectionApiUO.CompactMoveItem:CompactMoveItem(values).
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
values => new InjectionValue(CompactMoveItem(values))Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
dynamic UO.MoveItems(object? container, object? itemsType, object? itemsColor, object? moveIntoID, object? x, object? y, object? z, object? delayMS);將所有合適的物品直接從一個容器轉移到另一個容器或轉移到地面。透過graphic和hue選擇項目;每個堆疊都被完全傳輸。這是攜帶東西,而不是角色行走或MassMove的交互激活。
-
container— 來源容器的序號,例如 backpack、「backpack」、名稱 AddObject 或十六進位-ID。內容必須已下載。 0 不是有效來源; ground 不選擇角色周圍的東西。對於背包,請使用backpack而不是self。 -
itemsType- 圖形物品,例如0x0EED - 金。不是ID事物,也不是mobile身體。負數或 0xFFFF - 所有型別。不接受數組/類型遮罩。 -
itemsColor— 色調事物。 -1(或其他負數)和0xFFFF - 任意; 0 - 僅hue 0。不是serial,也不是惡名。 -
moveIntoID— 目標容器或物件別名的序號。對於您的背包 - backpack。對於陸地 - 數字0(也有ground/“ground”/UO.Ground())。來源和目的地必須不同。 -1 不是此指令中backpack 的縮寫。 Self - serial mobile 而不是自動更換他的背包。 -
x— 對於非零容器,其 Gump 內部的位置; -1,-1將放置位置留給伺服器。在地面上 - 世界座標0..65535,兩者都是必需的且非負的。不是遊戲世界的螢幕像素,也不是路線的終點。 -
y— 對於非零容器,其 Gump 內部的位置; -1,-1將放置位置留給伺服器。在地面上 - 世界座標0..65535,兩者都是必需的且非負的。不是遊戲世界的螢幕像素,也不是路線的終點。 -
z— 世界平鋪在地面上時的高度;使用站點的實際海拔高度(協議範圍 -128..127)。在容器範例中,指示0。這不是設備層索引。 -
delayMS— 接受的請求之間的延遲(以毫秒為單位)。實際上,max(GrabDelay, max(0, DelayMS));最後一次傳輸發送後還有一段等待時間。 350並不代表350項目,且不保證在350毫秒內確認。
註冊object?如果至少有一個轉帳請求被接受,實際上回傳int1/true,否則回傳0/false。這不是一些項目,也不是所有比賽都會被結轉的保證。待伺服器回應後查看內容。緊急取消會中止程序,且不需要返回false。
- 所有八個參數都是必需的。原始容器的直接子級列表被建立一次;不存在遞歸遍歷。一旦某個包被包含在清單中,它就會作為一件物品與其內容一起移動,而不是被拆包。
- 取得每場比賽的整個當前堆疊。此指令不設定項目或單位數量的限制;對於此類場景,請參閱UO.MassMove。 Ignore 不用作此範例的附加過濾器。
- 在執行每個操作之前,它會重新檢查該項目是否仍在原始容器中。禁止在自身/後代中嵌套容器以及該項目不可用可能會導致跳過。佇列不是交易:已提交的操作不會回滾。
- 當來源=0時,相同的來源/目的地或負值X/Y回傳0並報告錯誤。伺服器決定分辨率、範圍、容量和最終結果。請勿同時對吊起的物品進行其他操作。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
object? result = UO.MoveItems("lasttarget", 0x0EED, -1, "backpack", -1, -1, 0, 350);
UO.Print(result is Array values ? "Count: " + values.Length : Convert.ToString(result));參數與執行流程:
- 0x0EED - type 金; -1 至 ItemsColor - 任何 hue。 backpack之後的-1、-1是在牙齦中的自動位置,而不是地面。 350 ms - 考慮GrabDelay 的情況下所需的最小延遲。所有直疊的金子都被完整拿走。
var source = Asc(UO.GetSerial("lasttarget"), 0);
if (Truth(source == 0) || Truth(source == UO.Backpack()) || !(Truth(UO.Exists(source))))
{
return null;
}
var sent = UO.MoveItems(source, 0x0EED, -1, "backpack", -1, -1, 0, 350);
if (Truth(Truth(sent) == false))
{
UO.Print("No gold transfer request was 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; }
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 0x0E21 - 繃帶,不是人體。 backpack是源,目的地是寶箱的serial。所有比賽均指向一分30,40;伺服器可以合併堆疊或調整位置。
return RunScenario();
object? RunScenario()
{
var destination = Asc(UO.GetSerial("lasttarget"), 0);
if (Truth(destination == 0) || Truth(destination == UO.Backpack()) || !(Truth(UO.Exists(destination))))
{
return null;
}
var sent = UO.MoveItems("backpack", 0x0E21, -1, destination, 30, 40, 0, 350);
if (Truth(sent != 0))
{
UO.Print("Transfer requested; verify the destination contents");
}
return null;
}
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;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- itemType指定類型,而非數量;它的所有直疊都裝在背包中。 X+1/Y/Z 是相同高度的相鄰點的範例:對於斜坡/牆壁,選擇正確的座標。世界模式需要0分配。 true 僅表示已接受請求,而不是釋放背包。
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(DropTypeBesideMe(0x0EED))))
{
UO.Print("No ground drop request was accepted");
}
return null;
}
dynamic DropTypeBesideMe(dynamic itemType)
{
if (!(Truth(UO.Connected())) || Truth(UO.Dead()))
{
return false;
}
var x = UO.GetX() + 1;
var y = UO.GetY();
var z = UO.GetZ();
return UO.MoveItems("backpack", itemType, -1, 0, x, y, z, 350);
}
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。
UO.MoveItems(container, itemsType, itemsColor, moveIntoID, x, y, z, delayMS) — UO.MoveItems(Any,Any,Any,Any,Any,Any,Any,Any)
參數: container (Any), itemsType (Any), itemsColor (Any), moveIntoID (Any), x (Any), y (Any), z (Any), delayMS (Any)
結果: dynamic / Any.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.MoveItems:bridge.MoveItems(Arg(0), ResolveType(arguments[1]), Arg(2), Arg(3), Arg(4), Arg(5), Arg(6), Arg(7)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0). -
InjectionScript.Runtime.InjectionApiUO.ResolveType:ResolveType(arguments[1]).
內部實作程式碼,不能作為獨立腳本執行。
case "moveitems": return new InjectionValue(bridge.MoveItems(Arg(0), ResolveType(arguments[1]), Arg(2), Arg(3), Arg(4), Arg(5), Arg(6), Arg(7)));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
string UO.Name();讀出角色的名字。
沒有參數。
string 是客戶已知的名稱。空字串意味著空/未知值或沒有物件。這不是 serial 或設定檔路徑。遊戲名稱/標題未依語言IDE翻譯。
- 讀取已經接收到的本地資料。該請求不會開啟狀態,也不會強制伺服器發送更新。死亡、地圖轉換或物件刪除後,兩次呼叫之間的值可能會改變。
- C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.Name();
UO.Print("Name: " + Convert.ToString(result));參數與執行流程:
- 沒有參數:讀取 self。
- 空字串被明確處理;這不是文字“0”。
var text = UO.Name();
if (Truth(text != ""))
{
UO.Print(text);
}
else
{
UO.Print("Text is unavailable");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 您的字元被讀取,值被儲存為一行。
-
- 運算子連接字串;此結果不需要 Convert.ToString。
return RunScenario();
object? RunScenario()
{
var text = UO.Name();
UO.Print("Player имя: " + text);
return null;
}參數與執行流程:
- 這兩個稱呼都指的是 self;UO.Wait 設定暫停1000 毫秒。
- 這種差異可能意味著更新資料或離開世界。此範例不會變更名稱或標題。
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 previous = UO.Name();
await Delay(1000);
var current = UO.Name();
if (Truth(previous != current))
{
UO.Print("Updated text: " + current);
}
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# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: 沒有參數。
結果: string / String.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.RegisterCharacterGetterAliases [Name]. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.GetName:bridge.GetName(bridge.Self). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Self:bridge.Self.
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
() => bridge.GetName(bridge.Self)建立 API: 這些函式負責註冊 API,不會在每次命令呼叫時重新執行。
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.Picking();檢查客戶端的遊標是否被拾取的項目佔據。
沒有參數。
int 1 - ItemHold.啟用集; 0 - 未安裝。這是客戶端狀態,而不是ID或伺服器傳送確認。考慮由滑鼠或其他腳本拾取的物件。
該命令的結果是一個數字標誌: 1 表示滿足條件, 0 - 未實現。後 var 結果=命令(...)檢查是否(結果!= 0) 或 if (結果 == 0)。儲存一次呼叫的結果:重複呼叫可以再次執行該操作或讀取已經變更的狀態。
- 閱讀不會拿起或放下物品。
- 對於您自己的轉賬,也請檢查結果Drag/DragItem;別人的遊標忙碌並不代表所需的項目已成功取得。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.Picking();
UO.Print("Picking: " + Convert.ToString(result));參數與執行流程:
- 沒有爭論。
- 顯示1或0。
UO.Print(Convert.ToString(UO.Picking()));參數與執行流程:
- 一個 Drag 參數意味著整個堆疊,超時=0。
- Picking 檢查客戶端的共用遊標。不要同時運行兩個獨立的遷移。
return RunScenario();
object? RunScenario()
{
if (Truth(UO.Picking() == 0))
{
if (Truth(UO.Drag("loot")))
{
var dropped = UO.DropItem("backpack", -1, -1, 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;參數與執行流程:
- 檢查重複最多二十次,暫停50毫秒。
- 該命令不會釋放遊標或取消其他人的移動。
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 tries = 0;
while (Truth(UO.Picking()) && Truth(tries < 20))
{
await Delay(50);
tries = tries + 1;
}
if (Truth(UO.Picking()))
{
UO.Print("Cursor is still occupied");
}
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# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: 沒有參數。
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Picking. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.Picking:bridge.Picking().
內部實作程式碼,不能作為獨立腳本執行。
public int Picking() => bridge.Picking();Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.ReceiveObjectName(object? id);
void UO.ReceiveObjectName(object? id, object? timeout);透過點選請求來請求物件的名稱。
-
id— 序列/ID 物件:int,數字/十六進位字串或已建立的別名,例如「lasttarget」。這不是graphic/type。在採取行動之前檢查裝載的物體。 -
timeout— 可選 int,毫秒;預設為0。負值不會增加預期。
void - 沒有值。使用單獨的線路撥打電話;完成並不確認伺服器的操作。
- Bridge.ReceiveObjectName呼叫Click(id),然後等待max(0,timeout)直到GetName(id)為空;暫停不超過 25 毫秒。一個已經眾所周知的名字立即結束了等待。
- 如果沒有逾時,則僅執行 Click。無回名:單獨讀取GetName;等待的結束可能意味著逾時。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.ReceiveObjectName");
UO.ReceiveObjectName("lasttarget");參數與執行流程:
- 透過點選請求來請求物件的名稱。
UO.ReceiveObjectName("lasttarget");參數與執行流程:
- Bridge.ReceiveObjectName呼叫Click(id),然後等待max(0,timeout)直到GetName(id)為空;暫停不超過 25 毫秒。一個已經眾所周知的名字立即結束了等待。
return RunScenario();
object? RunScenario()
{
if (Truth(UO.Exists("lasttarget")))
{
UO.ReceiveObjectName("lasttarget", 1000);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 如果沒有逾時,則僅執行 Click。無回名:單獨讀取GetName;等待的結束可能意味著逾時。
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.GetSerial("lasttarget");
if (Truth(UO.Exists(id)))
{
UO.ReceiveObjectName(id, 1000);
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;
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: id (Any)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ReceiveObjectName. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ReceiveObjectName:bridge.ReceiveObjectName(GetObject(id), 0). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(id).
內部實作程式碼,不能作為獨立腳本執行。
public void ReceiveObjectName(InjectionValue id) => bridge.ReceiveObjectName(GetObject(id), 0);參數: id (Any), timeout (Any)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ReceiveObjectName. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.ReceiveObjectName:bridge.ReceiveObjectName(GetObject(id), NumberConversions.ToInt(timeout)). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(id). -
InjectionScript.Runtime.NumberConversions.ToInt:NumberConversions.ToInt(timeout).
內部實作程式碼,不能作為獨立腳本執行。
public void ReceiveObjectName(InjectionValue id, InjectionValue timeout) => bridge.ReceiveObjectName(GetObject(id), NumberConversions.ToInt(timeout));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.TicksUse();讀取保存的標記TicksUse。
沒有參數。
int — 標記 UO.Timer 從運行時開始算起十分之一秒。 0 — 標記尚未設定或事件發生在前十分之一秒內;它不是毫秒或日曆時間。
- 返回字段ticksUse。由UseObject更新;它不是自動觀察所有手動/伺服器活動。命令本身不會更改標記。
- UO.Timer() - 此標記以十分之一秒為單位計算年齡。不比較不同運行時間之間的分數。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.TicksUse();
UO.Print("TicksUse: " + Convert.ToString(result));參數與執行流程:
- 讀取保存的標記TicksUse。
var stamp = UO.TicksUse();
UO.Print(stamp);參數與執行流程:
- 返回字段ticksUse。由UseObject更新;它不是自動觀察所有手動/伺服器活動。命令本身不會更改標記。
return RunScenario();
object? RunScenario()
{
var stamp = UO.TicksUse();
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.TicksUse();
UO.Wait(250);
var after = UO.TicksUse();
UO.Print(before = after);
return null;
}
}C# 區分大小寫。請使用正確的 UO 名稱。數值旗標應與 0 比較;只有回傳型別為 bool 時才使用 bool。
參數: 沒有參數。
結果: int / Integer.
呼叫時:
內部實作程式碼,不能作為獨立腳本執行。
public int TicksUse() => ticksUse;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.UpdateObject(object? id);請求更新已載入的物件。
-
id— 序列/ID 物件:int,數字/十六進位字串或已建立的別名,例如「lasttarget」。這不是graphic/type。在採取行動之前檢查裝載的物體。
void - 沒有值。使用單獨的線路撥打電話;完成並不確認伺服器的操作。
- 對於行動設備,呼叫 RequestMobileStatus(..., true),對於項目 - SingleClick。如果兩個本地表中都不存在serial,則不執行任何操作。這不是下載未知物件或確認更新。
- Bridge 在遊戲串流上發送請求。伺服器規則適用;沒有內建的等待確認。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.UpdateObject");
UO.UpdateObject(UO.GetSerial("lasttarget"));參數與執行流程:
- 請求更新已載入的物件。
var id = UO.GetSerial("lasttarget");
if (Truth(UO.Exists(id)))
{
UO.UpdateObject(id);
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 對於行動設備,呼叫 RequestMobileStatus(..., true),對於項目 - SingleClick。如果兩個本地表中都不存在serial,則不執行任何操作。這不是下載未知物件或確認更新。
return RunScenario();
object? RunScenario()
{
var id = UO.GetSerial("self");
if (Truth(UO.Exists(id)))
{
UO.UpdateObject(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;參數與執行流程:
- Bridge 在遊戲串流上發送請求。伺服器規則適用;沒有內建的等待確認。
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()
{
ApplyToLoaded(UO.GetSerial("lasttarget"));
return null;
}
void ApplyToLoaded(dynamic id)
{
if (Truth(UO.Exists(id)))
{
UO.UpdateObject(id);
}
}
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。
參數: id (Any)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UpdateObject. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UpdateObject:bridge.UpdateObject(GetObject(id)). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(id).
內部實作程式碼,不能作為獨立腳本執行。
public void UpdateObject(InjectionValue id) => bridge.UpdateObject(GetObject(id));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.UseFromGround(object? @type);
int UO.UseFromGround(object? @type, object? color);在地面/世界中搜尋給定graphic的物件並立即呼叫其應用程式。通常用於附近的物體,例如打開背包。此運行時的一個重要特點:搜尋是基於FindType,也可以找到具有相同body的mobile;這並不是嚴格意義上的僅項目選擇。對於具有明確半徑和最接近選擇的項目,請使用 UseType(..., ground, ...)。
-
type- 強制graphic。例如,0x0E75是背包。數字或數字十六進位字串;負數/0xFFFF — 任何graphic。 0x0190(男)、0x0191(女)等身材數值可以選擇mobile;不要用它們代替 type 項目。這種形式不會同時傳輸兩種類型。 -
color- 可選hue,預設 - 1(任意)。負數/0xFFFF - 任意,0 - 僅hue 0。沒有其他參數:container、distance、nearest 和 maxZ 未加入此命令。
找到的第一個物件的int - serial,傳遞給UseObject或0。這不是物件的數量,不是graphic,也不是true/false。可能會找到該對象,但伺服器可能不允許使用它。分別檢查id != 0和預期的遊戲效果。
- 使用當前的FindDistance和FindVertical,並考慮Ignore。搜尋容器固定為ground,不遍歷嵌套內容。手機不包括self;壽命/知名度/知名度沒有單獨的限制。
- 使用所有搜尋匹配項更新 FindItem/FindCount/GetFoundItems,但僅套用第一個結果。不保證最接近的;世界物件在行動裝置之前被檢查。
- 不拾取背包中的物品,不移動角色,不等待伺服器回應或目標結束。如果沒有匹配,則列印一條訊息。若要在不執行操作的情況下進行搜索,請使用 UO.FindType。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.UseFromGround(0x0E75);
UO.Print("UseFromGround: " + Convert.ToString(result));參數與執行流程:
- 僅type;任何hue。使用當前的FindDistance/FindVertical。 bag - 第一個結果的ID,不一定是最接近的。只有當伺服器允許時,內容才會開啟。
var bag = UO.UseFromGround(0x0E75);
if (Truth(bag != 0))
{
UO.AddObject("ground_bag", bag);
}
else
{
UO.Print("No loaded ground backpack matches the search settings");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 搜尋僅限於兩個單元格和相同的Z。以顏色0x0044為例:將其替換為您商品的hue。即使出現錯誤,設定也會恢復。
return RunScenario();
object? RunScenario()
{
var oldDistance = UO.FindDistance();
var oldZ = UO.FindVertical();
try
{
UO.FindDistance(2);
UO.FindVertical(0);
var bag = UO.UseFromGround(0x0E75, 0x0044);
if (Truth(bag != 0))
{
UO.AddObject("colored_ground_bag", bag);
}
}
finally
{
UO.FindDistance(oldDistance);
UO.FindVertical(oldZ);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- radius 指定 FindDistance 而非第三個參數 UseFromGround。 3000 ms — 查看範例的時間,而不是確認開啟的時間;視窗類型 3 - 容器。此搜尋的結果保留在 Find* 中。
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 selected = OpenGroundBagWithin(2);
if (Truth(selected != 0))
{
await Delay(3000);
UO.CloseClientUIWindow(3, selected);
}
return null;
}
dynamic OpenGroundBagWithin(dynamic radius)
{
var previous = UO.FindDistance();
try
{
UO.FindDistance(radius);
return UO.UseFromGround(0x0E75, -1);
}
finally
{
UO.FindDistance(previous);
}
}
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。
參數: type (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseFromGround. -
InjectionScript.Runtime.InjectionApiUO.UseFromGround:UseFromGround(type, new InjectionValue(-1)).
內部實作程式碼,不能作為獨立腳本執行。
public int UseFromGround(InjectionValue type) => UseFromGround(type, new InjectionValue(-1));參數: type (Any), color (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseFromGround. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.FindType:bridge.FindType(ResolveType(type), NumberConversions.ToInt(color), 1, -1, false). -
InjectionScript.Runtime.InjectionApiUO.ResolveType:ResolveType(type). -
InjectionScript.Runtime.NumberConversions.ToInt:NumberConversions.ToInt(color). -
InjectionScript.Runtime.InjectionApiUO.UseObject:UseObject(id). -
InjectionScript.Runtime.InjectionApiUO.SystemMessage:SystemMessage("No matching item found on ground.").
內部實作程式碼,不能作為獨立腳本執行。
public int UseFromGround(InjectionValue type, InjectionValue color)
{
int id = bridge.FindType(ResolveType(type), NumberConversions.ToInt(color), 1, -1, false);
if (id != 0)
UseObject(id);
else
SystemMessage("No matching item found on ground.");
return id;
}Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.UseItemOnMobile(object? itemSerial, object? targetSerial);準備角色的目標並使用該物品。
-
itemSerial— 序列/ID 物件:int,數字/十六進位字串或已建立的別名,例如「lasttarget」。這不是graphic/type。在採取行動之前檢查裝載的物體。 -
targetSerial— 序列/ID 物件:int,數字/十六進位字串或已建立的別名,例如「lasttarget」。這不是graphic/type。在採取行動之前檢查裝載的物體。
void - 沒有值。使用單獨的線路撥打電話;完成並不確認伺服器的操作。
- ExecuteClientApiCompatibility 先呼叫bridge.WaitTargetObject(TargetSerial),然後呼叫bridge.UseObject(ItemSerial)。參數不交換。這些直接橋接呼叫不會更新 TicksTarget/TicksUse 運行時。
- 不檢查目標/項目類型,也不等待遊標。在使用前準備目標可以防止錯過快速到達的目標,但伺服器仍會確定該操作是否有效。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.UseItemOnMobile");
UO.UseItemOnMobile("0x40001234", "self");參數與執行流程:
- 準備角色的目標並使用該物品。
UO.UseItemOnMobile("0x40001234", "self");參數與執行流程:
- ExecuteClientApiCompatibility 先呼叫bridge.WaitTargetObject(TargetSerial),然後呼叫bridge.UseObject(ItemSerial)。參數不交換。這些直接橋接呼叫不會更新 TicksTarget/TicksUse 運行時。
return RunScenario();
object? RunScenario()
{
var item = UO.GetSerial("lastobject");
var mobile = UO.GetSerial("lasttarget");
if (Truth(UO.Exists(item)) && Truth(UO.Exists(mobile)))
{
UO.UseItemOnMobile(item, mobile);
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 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 item = UO.GetSerial("lastobject");
if (Truth(UO.Exists(item)))
{
UO.UseItemOnMobile(item, "self");
UO.Print(UO.Waiting());
}
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。
參數: itemSerial (Any), targetSerial (Any)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.WaitTargetObject:bridge.WaitTargetObject(Arg(1)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(1). -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseObject:bridge.UseObject(Arg(0)).
內部實作程式碼,不能作為獨立腳本執行。
case "useitemonmobile": bridge.WaitTargetObject(Arg(1)); bridge.UseObject(Arg(0)); return InjectionValue.Unit;Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.UseObject(object? objID);請求serial使用物件。橋接呼叫GameActions.DoubleClick;未搜尋該項目type。
-
objID— 序列/ID 物件:int,數字/十六進位字串或已建立的別名,例如「lasttarget」。這不是graphic/type。在採取行動之前檢查裝載的物體。
void - 沒有值。使用單獨的線路撥打電話;完成並不確認伺服器的操作。
- GetObject允許別名;未知名稱給出-1。呼叫後,運行時將TicksUse更新為UO.Timer的值;這是請求的時刻,而不是伺服器確認的時刻。
- Bridge 在遊戲串流上發送請求。伺服器規則適用;沒有內建的等待確認。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.UseObject");
UO.UseObject(UO.GetSerial("lasttarget"));參數與執行流程:
- 請求serial使用物件。橋接呼叫GameActions.DoubleClick;未搜尋該項目type。
var id = UO.GetSerial("lasttarget");
if (Truth(UO.Exists(id)))
{
UO.UseObject(id);
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- GetObject允許別名;未知名稱給出-1。呼叫後,運行時將TicksUse更新為UO.Timer的值;這是請求的時刻,而不是伺服器確認的時刻。
return RunScenario();
object? RunScenario()
{
var id = UO.GetSerial("self");
if (Truth(UO.Exists(id)))
{
UO.UseObject(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;參數與執行流程:
- Bridge 在遊戲串流上發送請求。伺服器規則適用;沒有內建的等待確認。
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()
{
ApplyToLoaded(UO.GetSerial("lasttarget"));
return null;
}
void ApplyToLoaded(dynamic id)
{
if (Truth(UO.Exists(id)))
{
UO.UseObject(id);
}
}
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。
參數: objID (Any/Integer/String)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseObject:bridge.UseObject(Arg(0)). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(0).
內部實作程式碼,不能作為獨立腳本執行。
case "useobject": bridge.UseObject(Arg(0)); return InjectionValue.Unit;參數: objID (Any/Integer/String)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseObject. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseObject:bridge.UseObject(id). -
InjectionScript.Runtime.InjectionApiUO.Timer:Timer().
內部實作程式碼,不能作為獨立腳本執行。
public void UseObject(int id)
{
bridge.UseObject(id);
ticksUse = Timer();
}參數: objID (Any/Integer/String)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseObject. -
InjectionScript.Runtime.InjectionApiUO.UseObject:UseObject(GetObject(id)). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(id).
內部實作程式碼,不能作為獨立腳本執行。
public void UseObject(string id) => UseObject(GetObject(id));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
int UO.UseType(object? @type);
int UO.UseType(object? @type, object? color);
int UO.UseType(object? @type, object? color, object? container);
int UO.UseType(object? @type, object? color, object? container, object? distance);
int UO.UseType(object? @type, object? color, object? container, object? distance, object? nearest);
int UO.UseType(object? @type, object? color, object? container, object? distance, object? nearest, object? maxZ);找到所需的graphic/type中的一項並應用它。例如,喝背包中的藥水、打開附近的背包或使用選定容器中的物品。該指令不會搜尋或移動角色。如果某個項目需要範圍,則必須單獨準備目標。
-
type— 項目的圖形:數字或十六進位字串;例如,0x0F0C是一種治療藥水,0x0E75是一個背包。這不是 serial 或 body 字元。負數或0xFFFF允許任何type;對於有意義的行動,準確的graphic更好。 -
color— 項目的色調,預設 - 1(任意)。任何負數或0xFFFF都會刪除過濾器; 0 選擇未繪製的項目。不是惡名,也不是文字的顏色。 -
container— 預設 -1:你的背包和裝載的子容器。 「my」的意思是一樣的。 「backpack」或容器明確的serial指定遞歸遍歷的根。 ground/「ground」/UO.Ground(),數字0/1僅表示世界的物體。 Self 不是 backpack 的同義詞;使用明確的背包。未知/空物件別名可以解析為背包:首先使用Exists檢查傳輸的容器。 -
distance— 最大幾何 X/Y 範圍,而非路徑長度。預設或負參數是FindDistance。 0表示同一個單元格。對於容器中的物品,客戶會考慮與所有者的距離。 -
nearest— 預設true:選擇最接近的,如果相等,則選擇較小的serial。 false:首次在不排序的遍歷中找到。不是項目數量或運作模式。 -
maxZ— 世界高度 Z 與角色的最大絕對差。預設或負參數是FindVertical。 0 需要相同的Z。對於袋子中的物品,使用外容器離地面的高度或主人角色的高度;內部 Gump 座標不被視為世界座標。這是高度過濾器,而不是步行性或視線檢查。
int - 呼叫UseObject的項目的serial; 0 如果沒有匹配項。還用ReturnKindobject註冊?實際上返回一個數字。這不是 true/false 或伺服器的使用確認:檢查used != 0 而不是used == true。需要單獨檢查狀態、內容或日誌才能使效果成功。
- 從1到6爭論。要設定範圍,也要指定顏色和容器。若要指定 maxZ,請完成所有六個位置。数组type,掩模通过|此命令不接受其他目标。
- 常規形式使用int/string,擴展形式使用CompactUseType:僅項目、Ignore、距離和高度;容器會遞歸地遍歷已加載的內容。裝載容器不會自動開啟。 FindItem/FindCount/GetFoundItems 未由此分支更新。
- 每次呼叫都會計算一次共享所有者和容器的高度,以避免對每個堆疊重複遍歷。圓形或過深的容器鏈(128 未找到根的連結)不用作高度匹配。
- 維護了兩個object?的通用相容註冊:它將呼叫路由到網橋。 UseType使用背包上的FindType,更新Find*並選擇第一個結果。對於可預測的緊湊形式,請使用 int/string 而不是不適當值類型的隱式轉換。
- UseObject 發送施法動作,但該指令不會等待目標、治療、飲酒、開啟視窗或伺服器故障。搜尋範圍不擴展伺服器允許的使用範圍。
- 如果沒有匹配,緊湊形式將列印訊息並返回0。如果沒有角色/聯繫,則結果不應被視為允許採取行動。對於精確的ID,請使用UO.UseObject。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
將一次呼叫的結果輸出到日誌。數值不會轉換成 bool;若結果是陣列,則顯示元素數量。
var result = UO.UseType(0x0F0C);
UO.Print("UseType: " + Convert.ToString(result));參數與執行流程:
- 0x0F0C 是標準類型治療藥水的一個例子。伺服器可能會因字元條件、延遲或其自身規則而拒絕該操作。顏色和範圍未單獨指定:套用預設值。
if (!(Truth(UO.Connected())) || Truth(UO.Dead()))
{
return null;
}
var used = UO.UseType(0x0F0C);
if (Truth(used == 0))
{
UO.Print("No matching healing potion in the loaded backpack");
}
else
{
UO.Print("Potion use requested; check health and the game message");
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 0x0E75 — type 背包,-1 — 任何 hue,ground — 世界上的物体。 2 - 单元格X/Y,true - 最接近,4 - 差异Z。返回包 — ID。內容的存取由伺服器決定;團隊沒有拿起背包。
return RunScenario();
object? RunScenario()
{
var bag = UO.UseType(0x0E75, -1, "ground", 2, true, 4);
if (Truth(bag != 0))
{
UO.AddObject("nearby_bag", bag);
}
else
{
UO.Print("No suitable ground backpack within the selected bounds");
}
return null;
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- itemType — graphic 事物,源 — 單獨的 serial 容器。助手回傳 serial/0 與 UseType 相同。即使找到的項目也可能被伺服器禁止從其他人或遠端容器中使用。
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 source = Asc(UO.GetSerial("lasttarget"), 0);
if (Truth(source == 0) || !(Truth(UO.Exists(source))))
{
return null;
}
UO.AddObject("supply", source);
var used = UseFromNamedSupply(0x0F0C);
if (Truth(used == 0))
{
UO.Print("Supply item was not found with these filters");
}
return null;
}
dynamic UseFromNamedSupply(dynamic itemType)
{
var source = Asc(UO.GetSerial("supply"), 0);
if (Truth(source == 0) || !(Truth(UO.Exists(source))))
{
return 0;
}
return UO.UseType(itemType, 0, source, 2, false, 16);
}
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;
}
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。
參數: type (Integer/String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseType. -
InjectionScript.Runtime.InjectionApiUO.UseType:UseType(type, -1).
內部實作程式碼,不能作為獨立腳本執行。
public int UseType(int type) => UseType(type, -1);參數: type (Integer/String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseType. -
InjectionScript.Runtime.InjectionApiUO.UseType:UseType(ResolveType(type)). -
InjectionScript.Runtime.InjectionApiUO.ResolveType:ResolveType(type).
內部實作程式碼,不能作為獨立腳本執行。
public int UseType(string type) => UseType(ResolveType(type));參數: type (Any/Integer/String), color (Any/Integer/String)
結果: int / Any.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility. -
ClassicUO.Game.Managers.ClassicUOInjectionApiBridge.UseType:bridge.UseType(ResolveType(arguments[0]), arguments.Length > 1 ? Arg(1) : -1). -
InjectionScript.Runtime.InjectionApiUO.ResolveType:ResolveType(arguments[0]). -
InjectionScript.Runtime.InjectionApiUO.ExecuteClientApiCompatibility::Arg:Arg(1).
內部實作程式碼,不能作為獨立腳本執行。
case "usetype": return new InjectionValue(bridge.UseType(ResolveType(arguments[0]), arguments.Length > 1 ? Arg(1) : -1));參數: type (Any/Integer/String), color (Any/Integer/String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseType. -
InjectionScript.Runtime.InjectionApiUO.CompactUseType:CompactUseType(new[] { new InjectionValue(type), new InjectionValue(color) }).
內部實作程式碼,不能作為獨立腳本執行。
public int UseType(int type, int color) => CompactUseType(new[]
{
new InjectionValue(type),
new InjectionValue(color)
});參數: type (Any/Integer/String), color (Any/Integer/String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseType. -
InjectionScript.Runtime.InjectionApiUO.UseType:UseType(type, NumberConversions.ToInt(color)). -
InjectionScript.Runtime.NumberConversions.ToInt:NumberConversions.ToInt(color).
內部實作程式碼,不能作為獨立腳本執行。
public int UseType(int type, string color) => UseType(type, NumberConversions.ToInt(color));參數: type (Any/Integer/String), color (Any/Integer/String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseType. -
InjectionScript.Runtime.InjectionApiUO.UseType:UseType(ResolveType(type), color). -
InjectionScript.Runtime.InjectionApiUO.ResolveType:ResolveType(type).
內部實作程式碼,不能作為獨立腳本執行。
public int UseType(string type, int color) => UseType(ResolveType(type), color);參數: type (Any/Integer/String), color (Any/Integer/String)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UseType. -
InjectionScript.Runtime.InjectionApiUO.UseType:UseType(ResolveType(type), NumberConversions.ToInt(color)). -
InjectionScript.Runtime.InjectionApiUO.ResolveType:ResolveType(type). -
InjectionScript.Runtime.NumberConversions.ToInt:NumberConversions.ToInt(color).
內部實作程式碼,不能作為獨立腳本執行。
public int UseType(string type, string color) => UseType(ResolveType(type), NumberConversions.ToInt(color));參數: type (Any), color (Any), container (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Register [UseType]. -
InjectionScript.Runtime.InjectionApiUO.CompactUseType:CompactUseType(values).
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
values => new InjectionValue(CompactUseType(values))參數: type (Any), color (Any), container (Any), distance (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Register [UseType]. -
InjectionScript.Runtime.InjectionApiUO.CompactUseType:CompactUseType(values).
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
values => new InjectionValue(CompactUseType(values))參數: type (Any), color (Any), container (Any), distance (Any), nearest (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Register [UseType]. -
InjectionScript.Runtime.InjectionApiUO.CompactUseType:CompactUseType(values).
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
values => new InjectionValue(CompactUseType(values))參數: type (Any), color (Any), container (Any), distance (Any), nearest (Any), maxZ (Any)
結果: int / Integer.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.Register [UseType]. -
InjectionScript.Runtime.InjectionApiUO.CompactUseType:CompactUseType(values).
呼叫時執行已儲存的處理函式 delegate。註冊方法在建立 API 時建立此 delegate。
內部實作程式碼,不能作為獨立腳本執行。
values => new InjectionValue(CompactUseType(values))Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.UseWorldObject(object? serialOrName);啟用serialOrName到GetObject並呼叫UseObject。字串名稱是物件別名,而不是名稱graphic/type。
-
serialOrName— 序列/ID 物件:int,數字/十六進位字串或已建立的別名,例如「lasttarget」。這不是graphic/type。在採取行動之前檢查裝載的物體。
void - 沒有值。使用單獨的線路撥打電話;完成並不確認伺服器的操作。
- 直接在元資料中註冊到UserObject。這是serial的正常使用,而不是伺服器範圍的搜尋。
- Bridge 在遊戲串流上發送請求。伺服器規則適用;沒有內建的等待確認。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.UseWorldObject");
UO.UseWorldObject(UO.GetSerial("lasttarget"));參數與執行流程:
- 啟用serialOrName到GetObject並呼叫UseObject。字串名稱是物件別名,而不是名稱graphic/type。
var id = UO.GetSerial("lasttarget");
if (Truth(UO.Exists(id)))
{
UO.UseWorldObject(id);
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 直接在元資料中註冊到UserObject。這是serial的正常使用,而不是伺服器範圍的搜尋。
return RunScenario();
object? RunScenario()
{
var id = UO.GetSerial("self");
if (Truth(UO.Exists(id)))
{
UO.UseWorldObject(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;參數與執行流程:
- Bridge 在遊戲串流上發送請求。伺服器規則適用;沒有內建的等待確認。
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()
{
ApplyToLoaded(UO.GetSerial("lasttarget"));
return null;
}
void ApplyToLoaded(dynamic id)
{
if (Truth(UO.Exists(id)))
{
UO.UseWorldObject(id);
}
}
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。
參數: serialOrName (Any)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UserObject. -
InjectionScript.Runtime.InjectionApiUO.UseObject:UseObject(GetObject(serialOrName)). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(serialOrName).
內部實作程式碼,不能作為獨立腳本執行。
public void UserObject(InjectionValue serialOrName)
=> UseObject(GetObject(serialOrName));Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
void UO.UserObject(object? serialOrName);啟用serialOrName到GetObject並呼叫UseObject。字串名稱是物件別名,而不是名稱graphic/type。
-
serialOrName— 序列/ID 物件:int,數字/十六進位字串或已建立的別名,例如「lasttarget」。這不是graphic/type。在採取行動之前檢查裝載的物體。
void - 沒有值。使用單獨的線路撥打電話;完成並不確認伺服器的操作。
- 使用路徑與UO.UseWorldObject相同。此指令不會建立自訂物件或新增名稱 AddObject。
- Bridge 在遊戲串流上發送請求。伺服器規則適用;沒有內建的等待確認。
每個範例都可以儲存為單獨的檔案.csx並在IDE中運行。 UO物件和等待函數提供當前遊戲會話的主機。將演示 serial 名稱、座標和地址替換為您自己的。
將這段程式碼存為獨立的 .csx 檔案執行。參數直接出現在呼叫中;請將範例名稱、serial 和網址替換成自己的值。
指令是獨立的陳述式。前面的訊息表示呼叫開始,並非伺服器已完成動作的確認。
UO.Print("Calling UO.UserObject");
UO.UserObject(UO.GetSerial("lasttarget"));參數與執行流程:
- 啟用serialOrName到GetObject並呼叫UseObject。字串名稱是物件別名,而不是名稱graphic/type。
var id = UO.GetSerial("lasttarget");
if (Truth(UO.Exists(id)))
{
UO.UserObject(id);
}
bool Truth(object? value) => value is bool flag ? flag : value is string text ? !string.IsNullOrEmpty(text) : value != null && Convert.ToDouble(value) != 0;參數與執行流程:
- 使用路徑與UO.UseWorldObject相同。此指令不會建立自訂物件或新增名稱 AddObject。
return RunScenario();
object? RunScenario()
{
var id = UO.GetSerial("self");
if (Truth(UO.Exists(id)))
{
UO.UserObject(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;參數與執行流程:
- Bridge 在遊戲串流上發送請求。伺服器規則適用;沒有內建的等待確認。
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()
{
ApplyToLoaded(UO.GetSerial("lasttarget"));
return null;
}
void ApplyToLoaded(dynamic id)
{
if (Truth(UO.Exists(id)))
{
UO.UserObject(id);
}
}
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。
參數: serialOrName (Any)
結果: void / Unit.
呼叫時:
-
InjectionScript.Runtime.InjectionApiUO.UserObject. -
InjectionScript.Runtime.InjectionApiUO.UseObject:UseObject(GetObject(serialOrName)). -
InjectionScript.Runtime.InjectionApiUO.GetObject:GetObject(serialOrName).
內部實作程式碼,不能作為獨立腳本執行。
public void UserObject(InjectionValue serialOrName)
=> UseObject(GetObject(serialOrName));