Class SafeTiles

java.lang.Object
privbot.mechanics.SafeTiles

public final class SafeTiles extends Object
Finds the nearest tile to step to that is out of every hazard and clear of every big NPC's footprint.

What it proves: the returned tile passed standable, reachable, is not dangerous in the HazardMap at nowTick and has Footprint.gap(int, int, int, int, int) at least minGap from every NPC in avoid. Nothing is read from the scene: the caller supplies both predicates, so "standable" and "reachable" mean whatever the caller's collision data says.

Unreadable looks like: the result is null when no tile within the radius qualifies, never the start tile. An avoid entry with no tile is skipped, and so is one on another plane than from (it has no footprint on this plane). An avoid entry whose size is unknown (NpcView.size() 0) is treated conservatively as 5x5 from its tile, which covers every NPC up to that size; see NpcView.tile() for how its tile is chosen in that case.

Thread rule: pure, safe on any thread, but the predicates are called on the caller's thread; make them cheap and thread-safe for that thread.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The edge length an avoid-NPC of unknown size (0) is treated as.
  • Method Summary

    Modifier and Type
    Method
    Description
    static net.runelite.api.coords.WorldPoint
    nearest(net.runelite.api.coords.WorldPoint from, int radius, Predicate<net.runelite.api.coords.WorldPoint> standable, Predicate<net.runelite.api.coords.WorldPoint> reachable, HazardMap hazards, int nowTick, List<NpcView> avoid, int minGap)
    Searches rings by Chebyshev radius 1..radius around from, skipping from itself.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • UNKNOWN_SIZE_ASSUMED

      public static final int UNKNOWN_SIZE_ASSUMED
      The edge length an avoid-NPC of unknown size (0) is treated as.
      See Also:
  • Method Details

    • nearest

      public static net.runelite.api.coords.WorldPoint nearest(net.runelite.api.coords.WorldPoint from, int radius, Predicate<net.runelite.api.coords.WorldPoint> standable, Predicate<net.runelite.api.coords.WorldPoint> reachable, HazardMap hazards, int nowTick, List<NpcView> avoid, int minGap)
      Searches rings by Chebyshev radius 1..radius around from, skipping from itself. The first ring with a qualifying tile decides: within it the smallest Euclidean distance wins, ties go to the smaller x and then the smaller y. The result is on from's plane.