From 73a4acad9581cef3adf1bab614c91d2cdafff1d1 Mon Sep 17 00:00:00 2001 From: Gandalf Date: Fri, 26 Nov 2021 20:06:21 +0000 Subject: [PATCH] PORT: Makes diagonal movement euclidean (#63058) --- code/__DEFINES/maths.dm | 2 ++ code/modules/mob/mob_movement.dm | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/maths.dm b/code/__DEFINES/maths.dm index fa8994ff6b9..81349a59bf5 100644 --- a/code/__DEFINES/maths.dm +++ b/code/__DEFINES/maths.dm @@ -4,6 +4,8 @@ #define NUM_E 2.71828183 +#define SQRT_2 1.414214 //CLOSE ENOUGH! + #define PI 3.1416 #define INFINITY 1e31 //closer then enough diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 6d6653c42c5..f8a83282218 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -122,7 +122,7 @@ //We are now going to move var/add_delay = mob.cached_multiplicative_slowdown - mob.set_glide_size(DELAY_TO_GLIDE_SIZE(add_delay * ( (NSCOMPONENT(direct) && EWCOMPONENT(direct)) ? 2 : 1 ) )) // set it now in case of pulled objects + mob.set_glide_size(DELAY_TO_GLIDE_SIZE(add_delay * ( (NSCOMPONENT(direct) && EWCOMPONENT(direct)) ? SQRT_2 : 1 ) )) // set it now in case of pulled objects if(old_move_delay + (add_delay*MOVEMENT_DELAY_BUFFER_DELTA) + MOVEMENT_DELAY_BUFFER > world.time) move_delay = old_move_delay else @@ -144,7 +144,7 @@ . = ..() if((direct & (direct - 1)) && mob.loc == new_loc) //moved diagonally successfully - add_delay *= 2 + add_delay *= SQRT_2 mob.set_glide_size(DELAY_TO_GLIDE_SIZE(add_delay)) move_delay += add_delay if(.) // If mob is null here, we deserve the runtime