Class TagAllTracker

java.lang.Object
privbot.mechanics.TagAllTracker

public final class TagAllTracker extends Object
Spreads a first hit across every NPC in a group before finishing any, the tag-all-then-kill pattern.

What it proves: isTagged(int) is true only for an index the caller marked and has not since pruned. It does not see attacks; the caller marks an NPC after its own attack went out.

Unreadable looks like: nextTarget returns null when the list is null or empty. An NPC with no tile is treated as infinitely far away, so it is picked only when nothing else is left.

Thread rule: mutable, single-owner. Call from the thread that handles the game tick.

  • Constructor Details

    • TagAllTracker

      public TagAllTracker()
  • Method Details

    • nextTarget

      public NpcView nextTarget(List<NpcView> npcs, net.runelite.api.coords.WorldPoint player)
      The NPC to attack next: nearest untagged, else nearest overall, else null. Nearest is Chebyshev distance from player, ties to the lower index. The caller filters out dead or unwanted NPCs first.
      Returns:
      the chosen view from npcs (mark its index with markTagged(int) once your attack went out), or null
    • markTagged

      public void markTagged(int index)
    • isTagged

      public boolean isTagged(int index)
    • pruneTo

      public void pruneTo(Set<Integer> presentIndices)
      Forgets tags for NPCs that are no longer present. The server reuses NPC indices as things die and spawn, so without this a fresh NPC inheriting a dead one's index would look already tagged and be skipped. Call once per tick with every live index. A null set is ignored.
    • taggedCount

      public int taggedCount()
      How many indices are currently tagged (diagnostics).
    • reset

      public void reset()