Make diagonal movement faster (1.41x as long as cardinal, rather than 2x) (#17884)

* Make diagonal movement take 1.41 as long, rather than 2x

* define
This commit is contained in:
moxian
2022-05-30 18:19:03 +00:00
committed by GitHub
parent 6c57e06e2a
commit 1c216c4e10
2 changed files with 5 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
#define NUM_E 2.71828183
#define PI 3.1415
#define SQRT_2 1.41421356237
#define INFINITY 1e31 //closer than enough
#define SHORT_REAL_LIMIT 16777216
+4 -3
View File
@@ -182,14 +182,15 @@
if(!(direct & (direct - 1))) // cardinal direction
. = mob.SelfMove(n, direct, delay)
else // diagonal movements take twice as long
. = mob.SelfMove(n, direct, delay * 2)
else // diagonal movements take longer
var/diag_delay = delay * SQRT_2
. = mob.SelfMove(n, direct, diag_delay)
if(mob.loc == n)
// only incur the extra delay if the move was *actually* diagonal
// There would be a bit of visual jank if we try to walk diagonally next to a wall
// and the move ends up being cardinal, rather than diagonal,
// but that's better than it being jank on every *successful* diagonal move.
delay *= 2
delay = diag_delay
move_delay += delay
if(prev_pulling_loc && mob.pulling?.face_while_pulling && (mob.pulling.loc != prev_pulling_loc))