Class PrayerPlanner

java.lang.Object
privbot.mechanics.PrayerPlanner

public final class PrayerPlanner extends Object
Protection-prayer planner for several simultaneous attackers. It tracks each NPC's last animation by index, detects the idle-to-attack edge, schedules a prayer switch delayTicks later, and when several attack at once the freshest due edge wins and is held. Attackers whose animations are listed as settle animations are prayed from the tick the animation first shows and kept until their hit is decided, settleTicks later.

What it proves: the style it returns is the one a declared attack cue demanded, scheduled and held by the rules above. Animations the AttackCues do not know never produce a style.

Unreadable looks like: null from plan(java.util.Map<java.lang.Integer, java.lang.Integer>, int) means nothing has been prayed yet. Callers must pass a map only for NPCs they could actually read, because an index missing from the map is treated as despawned and its pending switch is dropped.

Thread rule: pure and deterministic. It has no client access and no clock; the caller passes the current npcIndex -> animationId map and the current game tick. It is not thread-safe: use one instance from one thread (normally the game-tick handler).

  • Constructor Details

  • Method Details

    • plan

      public CombatStyle plan(Map<Integer,Integer> animationByNpcIndex, int tick)
      Returns:
      the protection style to hold this tick, or null if nothing has been prayed yet.

      Settle animations (when configured): a hit is blocked when the prayer shows by settle = the tick its animation first showed + settleTicks, and a switch made now shows next tick at the earliest. So the prayer held is the style of the earliest settle hit not yet settled, from the animation tick itself.

    • reset

      public void reset()
      Forget every tracked animation, pending switch and held prayer.