Class ThreatSnapshot

java.lang.Object
privbot.mechanics.ThreatSnapshot

public final class ThreatSnapshot extends Object
A detached copy of one tick of a fight: the local player, the NPCs, projectiles and graphics around them, and the prayers that were checked. Immutable, so it can be kept, compared with the next tick's and passed to the pure planners (PrayerPlanner, ShotTracker, CueTimeline) on any thread.

It is produced by ctx.threats.snapshot(..), which reads everything in one client-thread batch. A snapshot that exists proves the player's tile, the NPC, projectile and graphics lists were read. Hitpoints, prayer points and individual prayers that could not be read are reported as null / unreadablePrayers() rather than as 0 or off; a list that could not be read yields an unreadable Observed instead of a snapshot with empty lists.

Pure data: no client calls, safe on any thread.

  • Constructor Details

    • ThreatSnapshot

      public ThreatSnapshot(int tick, int cycle, net.runelite.api.coords.WorldPoint player, Integer hp, Integer maxHp, Integer prayerPoints, int currentTargetIndex, List<NpcView> npcs, List<ShotView> shots, List<GraphicView> graphics, Set<String> activePrayers, Set<String> unreadablePrayers)
      Parameters:
      tick - the client's tick count
      cycle - the client's game cycle
      player - the local player's world tile
      hp - current hitpoints, or null when they could not be read
      maxHp - real hitpoints level, or null when it could not be read
      prayerPoints - current prayer points, or null when they could not be read
      currentTargetIndex - the index of the NPC the player is interacting with, or -1
      npcs - the NPCs kept by the query
      shots - the projectiles still in flight
      graphics - the graphics still drawn
      activePrayers - the checked prayers that read active
      unreadablePrayers - the checked prayers whose state could not be read
  • Method Details

    • tick

      public int tick()
      Returns:
      the client's tick count when read
    • cycle

      public int cycle()
      Returns:
      the client's game cycle when read
    • player

      public net.runelite.api.coords.WorldPoint player()
      Returns:
      the local player's world tile
    • hp

      public Integer hp()
      Returns:
      current hitpoints, or null when they could not be read (null is not 0)
    • maxHp

      public Integer maxHp()
      Returns:
      real hitpoints level, or null when it could not be read (null is not 0)
    • prayerPoints

      public Integer prayerPoints()
      Returns:
      current prayer points, or null when they could not be read (null is not 0)
    • currentTargetIndex

      public int currentTargetIndex()
      Returns:
      the index of the NPC the player is interacting with, or -1 for none
    • npcs

      public List<NpcView> npcs()
      Returns:
      the NPCs the query kept (unmodifiable)
    • shots

      public List<ShotView> shots()
      Returns:
      the projectiles in flight, none with zero cycles left (unmodifiable)
    • graphics

      public List<GraphicView> graphics()
      Returns:
      the graphics still drawn (unmodifiable)
    • activePrayers

      public Set<String> activePrayers()
      Returns:
      the checked prayers that read active. A prayer the query named is in exactly one of this set, unreadablePrayers(), or neither (it read as off); prayers the query did not name are never listed
    • unreadablePrayers

      public Set<String> unreadablePrayers()
      Returns:
      the checked prayers whose state could not be read this tick. They are unknown, not off: do not treat absence from activePrayers() as "off" for a prayer listed here
    • find

      public NpcView find(int index)
      Parameters:
      index - an NPC index
      Returns:
      that NPC in this snapshot, or null when the snapshot has none with that index
    • toString

      public String toString()
      Overrides:
      toString in class Object