Class Footprint

java.lang.Object
privbot.mechanics.Footprint

public final class Footprint extends Object
Square-footprint maths for big NPCs, on server tiles. An NPC of size covers swX..swX+size-1 by swY..swY+size-1.

What it proves: gap(int, int, int, int, int) is the number of tiles between a point and the footprint (Chebyshev), so 0 = under it, 1 = touching it (diagonals included, the conservative reading) and 2+ = clear. inMelee(int, int, int, int, int) is gap < SAFE_GAP.

Unreadable looks like: there is no unknown answer here; the caller must not call it with a tile it could not read. A size below 1 is treated as 1.

Thread rule: pure functions, safe on any thread.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    The smallest gap that a melee attack cannot reach.
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    gap(int x, int y, int swX, int swY, int size)
    Tiles between (x,y) and the footprint: 0 = under it, 1 = touching it (also diagonally), 2+ = clear.
    static boolean
    inMelee(int x, int y, int swX, int swY, int size)
    True when (x,y) is under or touching the footprint, so a melee hit can land.
    static boolean
    under(int x, int y, int swX, int swY, int size)
    True when (x,y) is inside the footprint.

    Methods inherited from class java.lang.Object

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

    • SAFE_GAP

      public static final int SAFE_GAP
      The smallest gap that a melee attack cannot reach.
      See Also:
  • Method Details

    • gap

      public static int gap(int x, int y, int swX, int swY, int size)
      Tiles between (x,y) and the footprint: 0 = under it, 1 = touching it (also diagonally), 2+ = clear.
    • inMelee

      public static boolean inMelee(int x, int y, int swX, int swY, int size)
      True when (x,y) is under or touching the footprint, so a melee hit can land.
    • under

      public static boolean under(int x, int y, int swX, int swY, int size)
      True when (x,y) is inside the footprint.