Class NpcView

java.lang.Object
privbot.mechanics.NpcView

public final class NpcView extends Object
One NPC reduced to what targeting and hazard maths need. Immutable.

What it proves: only that the caller read these values from a live NPC on one tick. tile() is the south-west corner of the footprint on every server (the server's tile, not the drawn centre of a big NPC); size() is its edge length in tiles.

Unreadable looks like: name(), tile() and overhead() are null when they could not be read. observedTargetsUs() and observedTargetsOther() are null when interaction data was unavailable; the legacy boolean accessors return false for that case. overhead() tells "not praying" apart from "unknown": it is NO_OVERHEAD ("NONE") when the read worked and no icon shows, and null only when it could not be read. size() is 0 when the size could not be read; it is never reported as 1 by guess. A null name never matches a TargetSpec; a null tile is never inside an area and is treated as infinitely far away.

Thread rule: pure value type, safe on any thread. Build it inside the same GameThread.ensure batch that read the NPC.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    overhead() when the overhead was read and the NPC shows none.
  • Constructor Summary

    Constructors
    Constructor
    Description
    NpcView(int id, int index, String name, int animation, int graphic, int healthRatio, int healthScale, int size, net.runelite.api.coords.WorldPoint tile, boolean targetsUs, boolean targetsOther, boolean dead, String overhead)
     
    NpcView(int id, int index, String name, int animation, int graphic, int healthRatio, int healthScale, int size, net.runelite.api.coords.WorldPoint tile, Boolean targetsUs, Boolean targetsOther, boolean dead, String overhead)
    Nullable targeting observations: null means the client's interaction data was unreadable.
  • Method Summary

    Modifier and Type
    Method
    Description
    int
     
    boolean
    True when the NPC is fighting someone else, so it is not ours to take.
    boolean
     
    boolean
     
    int
     
    int
     
    int
     
    int
     
    int
    id()
     
    int
     
     
     
     
    A HeadIcon name (for example "MAGIC"), NO_OVERHEAD when the read worked and the NPC shows no overhead, or null when it could not be read (unknown, not "not praying").
    int
    Edge length of the footprint in tiles, or 0 when it could not be read (unknown, not 1).
    boolean
    Legacy convenience: false also when unreadable; use observedTargetsOther for decisions.
    boolean
    Legacy convenience: false also when unreadable; use observedTargetsUs for decisions.
    net.runelite.api.coords.WorldPoint
    South-west corner of the footprint, or null when it could not be read.
     

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • NpcView

      public NpcView(int id, int index, String name, int animation, int graphic, int healthRatio, int healthScale, int size, net.runelite.api.coords.WorldPoint tile, boolean targetsUs, boolean targetsOther, boolean dead, String overhead)
    • NpcView

      public NpcView(int id, int index, String name, int animation, int graphic, int healthRatio, int healthScale, int size, net.runelite.api.coords.WorldPoint tile, Boolean targetsUs, Boolean targetsOther, boolean dead, String overhead)
      Nullable targeting observations: null means the client's interaction data was unreadable.
  • Method Details

    • id

      public int id()
    • index

      public int index()
    • name

      public String name()
    • animation

      public int animation()
    • graphic

      public int graphic()
    • healthRatio

      public int healthRatio()
    • healthScale

      public int healthScale()
    • size

      public int size()
      Edge length of the footprint in tiles, or 0 when it could not be read (unknown, not 1).
    • tile

      public net.runelite.api.coords.WorldPoint tile()
      South-west corner of the footprint, or null when it could not be read. When the size is unknown and only the drawn centre could be read (a supported client whose server tile is unreadable), it is the south-west corner a 5x5 NPC centred there would have, so a 5x5 footprint from it covers the NPC.
    • targetsUs

      public boolean targetsUs()
      Legacy convenience: false also when unreadable; use observedTargetsUs for decisions.
    • targetsOther

      public boolean targetsOther()
      Legacy convenience: false also when unreadable; use observedTargetsOther for decisions.
    • observedTargetsUs

      public Boolean observedTargetsUs()
    • observedTargetsOther

      public Boolean observedTargetsOther()
    • dead

      public boolean dead()
    • overhead

      public String overhead()
      A HeadIcon name (for example "MAGIC"), NO_OVERHEAD when the read worked and the NPC shows no overhead, or null when it could not be read (unknown, not "not praying").
    • busy

      public boolean busy()
      True when the NPC is fighting someone else, so it is not ours to take.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object