Class Loadouts
ctx.loadouts.
Gear setups (every server). captureWorn() and captureCarried() read what the player has
into a GearSetup; save(java.lang.String, privbot.mechanics.GearSetup), load(java.lang.String), names() and delete(java.lang.String) keep named setups per
logged-in account and server; equip(GearSetup) puts a worn setup on, one proved piece per step. An unreadable
container or account is UNREADABLE, never "empty" or "no such setup".
Presets (equip(int), deprecated).
- Impact: the in-game loadout presets 1..6 (equip preset n: Ctrl+G twice, then
F<n>). Impact loadouts only work at home; use
ctx.restockto go home and equip in one call; - every other server: UNSUPPORTED (false and one
[PrivBot API]line). Elorin re-gears through a bank preset, whichctx.restockruns.
execute on the script
worker, never on the EDT or from an event handler. True is dispatch acceptance; verify the gear changed.-
Method Summary
Modifier and TypeMethodDescriptionReads what is carried, one entry per item id, with the role of each.Reads what is worn, by slot.booleanbooleanequip(int number) Deprecated.Starts a job that puts on every missing worn piece ofworn, one proved piece per step (at most one click, then up to 1800 ms waiting for that piece's slot to hold its item).Loads a saved setup.names()booleanSaves a setup under a name for the logged-in account on this server.Puts on every missing worn piece ofwornin this one call: a same-tick gear switch.
-
Method Details
-
captureWorn
Reads what is worn, by slot. Proves the equipment was readable at that moment; a stack (ammunition) is wanted at any count. UNREADABLE (never an empty setup) when the equipment cannot be read; a readable empty body is an empty setup, whichequip(GearSetup)refuses as a target.- Returns:
- the worn setup, or UNREADABLE
-
captureCarried
-
save
Saves a setup under a name for the logged-in account on this server. True means the file was written and read back equal. Names are folded to lower case and may hold letters, digits, '_' and '-' (up to 56). False for another name, a null setup, an unknown account, an unknown server or an IO error. Setups are per server: item ids differ between servers, so a setup saved on Elorin is never seen on Impact, even for the same account name. Disk IO: call on a worker thread.- Parameters:
name- the setup namesetup- the setup- Returns:
- whether it was saved and verified
-
load
Loads a saved setup. Absent when this account has no setup of that name on this server; UNREADABLE when the account or the server is unknown, the file was saved on another server ("saved on <other> server"), or it cannot be read or parsed (never "absent"). Disk IO: call on a worker thread.- Parameters:
name- the setup name- Returns:
- the setup, absent, or UNREADABLE
-
names
-
delete
- Parameters:
name- the setup name- Returns:
- true when a saved setup was removed; false when there was none, the account is unknown or the delete failed
-
equip
Starts a job that puts on every missing worn piece ofworn, one proved piece per step (at most one click, then up to 1800 ms waiting for that piece's slot to hold its item).What it proves: DONE ("worn") only after a readable equipment read shows every entry's slot holding its item. A piece that is not carried ends the job FAILED "not carried: name"; a slot that did not fill three times ends it FAILED "name did not go on". An unreadable read keeps it RUNNING and fails it after 5 in a row ("equipment unreadable"). A click that throws is not a strike; five in a row end it FAILED "could not click name". After 20 equip clicks (pieces that knock each other off, e.g. a two-handed weapon and a shield) it ends FAILED "setup cannot all be worn at once (e.g. two-handed + shield)". An empty (or non-worn) setup ends it FAILED at once, never DONE.
Close the bank first: on Elorin and SpawnPK an open bank covers the inventory, so the wear clicks miss.
Thread rule: step it from a node on the script worker; the proof waits through
PrivTaskContext.sleepUntil(java.util.function.BooleanSupplier, int). Not thread-safe.- Parameters:
worn- a worn setup (fromcaptureWorn()orload(java.lang.String))- Returns:
- a new job
-
switchTo
Puts on every missing worn piece ofwornin this one call: a same-tick gear switch. No wait and no proof; feed the next ticks' worn diff to aSwitchCheckto verify it.What it does: reads the equipment and the inventory in one client-thread batch, diffs the setup against what is worn, and for each missing entry finds the carried item by id, or by name (
GearNames.choose(java.lang.String, java.util.List<java.lang.String>), so a glory (3) stands in for a (4)) when no carried item has the setup's id; a name match is listed inSwitchResult.byName(). Each carried item is used for one entry only. Then it clicks Wield, Wear or Equip (the first the item has) on every piece found, one after another in this call: on Elorin the clicks queue on the client's hand and go out in order a beat apart; nothing here waits for them.What the result says:
SwitchResult.sent()lists the accepted clicks (accepted, not worn). A piece not carried is inSwitchResult.notCarried()and the others still go out; a refused or throwing click, or an item with no wear action, is inSwitchResult.failed(). An unreadable equipment, inventory, or name needed for a fallback sends nothing and isSwitchResult.unreadable(), never "nothing missing". An empty setup, or one already worn, sends nothing and is readable with empty lists.Close the bank first: on Elorin and SpawnPK an open bank covers the inventory, so the wear clicks miss. Thread rule: call from a node on the script worker; never inside another client-thread read.
- Parameters:
worn- a worn setup (fromcaptureWorn()orload(java.lang.String))- Returns:
- a non-null result; when readable, verify using
SwitchResult.verificationSetup() - Throws:
IllegalArgumentException- whenwornis null or not a worn setup
-
equip
Deprecated.an Impact-only preset press with no proof; useequip(GearSetup), which works on every server and proves each worn slot- Parameters:
number- the loadout number (Impact: 1..6)- Returns:
- true when the loadout keys were sent
-
equip(GearSetup), which works on every server and proves each worn slot