Class Loadouts

java.lang.Object
privbot.hooks.Loadouts

public final class Loadouts extends Object
Gear setups and 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.restock to go home and equip in one call;
  • every other server: UNSUPPORTED (false and one [PrivBot API] line). Elorin re-gears through a bank preset, which ctx.restock runs.
The preset press is blocking (it sleeps between key presses): call from a TaskNode's execute on the script worker, never on the EDT or from an event handler. True is dispatch acceptance; verify the gear changed.
  • Method Details

    • captureWorn

      public Observed<GearSetup> 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, which equip(GearSetup) refuses as a target.
      Returns:
      the worn setup, or UNREADABLE
    • captureCarried

      public Observed<GearSetup> captureCarried()
      Reads what is carried, one entry per item id, with the role of each. UNREADABLE when the inventory cannot be read or is internally inconsistent.
      Returns:
      the carried setup, or UNREADABLE
    • save

      public boolean save(String name, GearSetup setup)
      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 name
      setup - the setup
      Returns:
      whether it was saved and verified
    • load

      public Observed<GearSetup> load(String name)
      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

      public List<String> names()
      Returns:
      this account's saved setup names (lower case, sorted); empty when the account is unknown or the store cannot be read. Disk IO: call on a worker thread.
    • delete

      public boolean delete(String name)
      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

      public Job equip(GearSetup worn)
      Starts a job that puts on every missing worn piece of worn, 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 (from captureWorn() or load(java.lang.String))
      Returns:
      a new job
    • switchTo

      public SwitchResult switchTo(GearSetup worn)
      Puts on every missing worn piece of worn in this one call: a same-tick gear switch. No wait and no proof; feed the next ticks' worn diff to a SwitchCheck to 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 in SwitchResult.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 in SwitchResult.notCarried() and the others still go out; a refused or throwing click, or an item with no wear action, is in SwitchResult.failed(). An unreadable equipment, inventory, or name needed for a fallback sends nothing and is SwitchResult.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 (from captureWorn() or load(java.lang.String))
      Returns:
      a non-null result; when readable, verify using SwitchResult.verificationSetup()
      Throws:
      IllegalArgumentException - when worn is null or not a worn setup
    • equip

      @Deprecated public boolean equip(int number)
      Deprecated.
      an Impact-only preset press with no proof; use equip(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