Class Sustain
ctx.sustain. One call to maintain(privbot.task.PrivTaskContext, privbot.mechanics.SustainPlan) reads hitpoints, prayer
points, boosts and the inventory once, asks SustainPolicy what to do, does at most one consume, and says
what happened.
What a result proves. ACTED means the clicked item's carried count dropped within 1200 ms, so a
food, brew, restore or boost dose was really consumed. A call makes one consume, or two for a combo eat: when the
plan lists combo foods and one is carried (in another slot), its click is sent straight after the first food's
click, before any waiting, so both land in the same tick; the decision uses the hitpoints read before the first
Eat. One bounded wait then proves both: each item's count dropped. SustainOutcome.comboLanded() says
whether the combo food was consumed (the ACTED result is about the first food, which did land). A boost
dose also tells its
BoostDosePolicy: consumed when it landed, attempted (and recordFailure) when it did not,
and the observed boost is fed to observe on every call. A dose that was drunk but whose boost never
appeared makes the policy fail closed: further calls return FAILED ("boost never appeared") and drink nothing
until you call BoostDosePolicy.reset().
Unreadable. UNREADABLE is returned, and nothing is clicked, when the inventory, hitpoints or max hitpoints cannot be read. After a click, an inventory that cannot be read gives UNREADABLE too (the consume is unknown, so it is not counted as a failure). Prayer points that cannot be read only skip the prayer rule. A boost that cannot be read is never treated as expired and is not fed to its policy; when nothing else is due the call returns UNREADABLE (naming the skill) rather than NOTHING. An exception from a read, the click or the proof also gives UNREADABLE, never a thrown error.
Out of supplies. OUT_OF carries SustainOutcome.reason() "food" (hitpoints are low and
no food or brew is carried) or "boost" (a boost is due and no dose is carried), so a missing dose never
reads like being out of food.
Blocking cost. A call that clicks waits for its proof: up to 1200 ms (PROOF_MS), on the calling
thread. The plugin's other nodes do not run meanwhile. Call it from the node with the lowest latency need, and not
between two prayer switches that must land on consecutive ticks; a call that clicks nothing returns at once.
Thread. Call from the runner worker or a node. The reads marshal themselves as one batch through
GameThread.ensure(java.util.function.Supplier), the click goes through ctx.inventory.interact,
and the proof waits with PrivTaskContext.sleepUntil(java.util.function.BooleanSupplier, int). The plan's boost policies keep state: use one plan
from one worker thread.
-
Method Summary
Modifier and TypeMethodDescriptionmaintain(PrivTaskContext ctx, SustainPlan plan) Does whatplansays is needed right now, if anything.
-
Method Details
-
maintain
Does whatplansays is needed right now, if anything.- Parameters:
ctx- the task context (itssleepUntilruns the proof wait)plan- thresholds and item names; its boost policies are updated by this call- Returns:
- what happened; never null (see the class comment for every kind)
-