Class Footprint
java.lang.Object
privbot.mechanics.Footprint
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
FieldsModifier and TypeFieldDescriptionstatic final intThe smallest gap that a melee attack cannot reach. -
Method Summary
Modifier and TypeMethodDescriptionstatic intgap(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 booleaninMelee(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 booleanunder(int x, int y, int swX, int swY, int size) True when (x,y) is inside the footprint.
-
Field Details
-
SAFE_GAP
public static final int SAFE_GAPThe 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.
-