Class Hazards
ctx.hazards. It owns no hazard data; you keep a HazardMap (tiles that hurt now) and ask
for the nearest tile you can walk to that is out of every hazard and clear of every big NPC.
What a result proves. A present tile passed three tests on one client-thread read: the scene's walking
collision says it is reachable from the player's own tile on the player's plane (the same reachable grid answers
both "can stand there" and "can walk there"), the HazardMap does not mark it dangerous on the current game
tick, and it is at least minGap tiles from every NPC footprint in the list you pass. It is never the
player's own tile. It is a tile, not a step: walking there and proving arrival is your job.
The tick clock. "The current game tick" is client.getTickCount(), the same clock as
ThreatSnapshot.tick(). Fill the HazardMap with snap.tick() values from
ctx.threats.snapshot(..); a map filled from another counter (your own tick count, wall-clock time) expires
hazards at the wrong moment or never.
The player's tile. On supported clients (Elorin, Impact and the other proxy-backed clients) the
search starts from the player's server tile, because the drawn tile trails it by up to a tick while walking. When
the server tile cannot be read, or on stock RuneLite, it starts from getWorldLocation().
Unreadable. Observed.unreadable(String) when the client is not logged in, the player or its tile
cannot be read, or the scene's collision data is not usable on the player's plane. That is not "no safe tile":
with no collision data every tile would look free, so nothing is guessed. Observed.absent(String) means the
read worked and no tile within radius qualifies.
Thread. Call from the runner worker or a node; it marshals its own read through
GameThread.ensure(java.util.function.Supplier). Do not wrap it in another client-thread read. The
HazardMap is not thread safe: feed and query it from the one worker thread that handles the game tick.
-
Method Summary
-
Method Details
-
newMap
- Returns:
- a new empty map of hazard tiles; keep it in the plugin's state and feed it once per tick
-
safeTile
public Observed<net.runelite.api.coords.WorldPoint> safeTile(HazardMap map, int radius, List<NpcView> avoid, int minGap) Finds the nearest tile out of every hazard.- Parameters:
map- the hazards that hurt now, filled withThreatSnapshot.tick()values (see the class comment)radius- how far to search, in tiles around the player (rings of 1 toradius)avoid- NPCs whose footprint to keep away from (may be empty or null)minGap- the smallest allowed gap from an NPC footprint (2 is out of melee reach)- Returns:
- the tile; absent when none qualifies; unreadable as described in the class comment; never null
-