mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 20:47:10 +01:00
Un-jank diagonal movement (#17872)
* Un-jank diagonal movement * grab fix
This commit is contained in:
+17
-17
@@ -181,45 +181,45 @@
|
||||
// The `&& moving_diagonally` checks are so that a forceMove taking
|
||||
// place due to a Crossed, Bumped, etc. call will interrupt
|
||||
// the second half of the diagonal movement, or the second attempt
|
||||
// at a first half if step() fails because we hit something.
|
||||
// at a first half if ..() fails because we hit something.
|
||||
if(direct & NORTH)
|
||||
if(direct & EAST)
|
||||
if(step(src, NORTH) && moving_diagonally)
|
||||
if(..(get_step(src, NORTH), NORTH) && moving_diagonally)
|
||||
first_step_dir = NORTH
|
||||
moving_diagonally = SECOND_DIAG_STEP
|
||||
. = step(src, EAST)
|
||||
else if(moving_diagonally && step(src, EAST))
|
||||
. = ..(get_step(src, EAST), EAST)
|
||||
else if(moving_diagonally && ..(get_step(src, EAST), EAST))
|
||||
first_step_dir = EAST
|
||||
moving_diagonally = SECOND_DIAG_STEP
|
||||
. = step(src, NORTH)
|
||||
. = ..(get_step(src, NORTH), NORTH)
|
||||
else if(direct & WEST)
|
||||
if(step(src, NORTH) && moving_diagonally)
|
||||
if(..(get_step(src, NORTH), NORTH) && moving_diagonally)
|
||||
first_step_dir = NORTH
|
||||
moving_diagonally = SECOND_DIAG_STEP
|
||||
. = step(src, WEST)
|
||||
else if(moving_diagonally && step(src, WEST))
|
||||
. = ..(get_step(src, WEST), WEST)
|
||||
else if(moving_diagonally && ..(get_step(src, WEST), WEST))
|
||||
first_step_dir = WEST
|
||||
moving_diagonally = SECOND_DIAG_STEP
|
||||
. = step(src, NORTH)
|
||||
. = ..(get_step(src, NORTH), NORTH)
|
||||
else if(direct & SOUTH)
|
||||
if(direct & EAST)
|
||||
if(step(src, SOUTH) && moving_diagonally)
|
||||
if(..(get_step(src, SOUTH), SOUTH) && moving_diagonally)
|
||||
first_step_dir = SOUTH
|
||||
moving_diagonally = SECOND_DIAG_STEP
|
||||
. = step(src, EAST)
|
||||
else if(moving_diagonally && step(src, EAST))
|
||||
. = ..(get_step(src, EAST), EAST)
|
||||
else if(moving_diagonally && ..(get_step(src, EAST), EAST))
|
||||
first_step_dir = EAST
|
||||
moving_diagonally = SECOND_DIAG_STEP
|
||||
. = step(src, SOUTH)
|
||||
. = ..(get_step(src, SOUTH), SOUTH)
|
||||
else if(direct & WEST)
|
||||
if(step(src, SOUTH) && moving_diagonally)
|
||||
if(..(get_step(src, SOUTH), SOUTH) && moving_diagonally)
|
||||
first_step_dir = SOUTH
|
||||
moving_diagonally = SECOND_DIAG_STEP
|
||||
. = step(src, WEST)
|
||||
else if(moving_diagonally && step(src, WEST))
|
||||
. = ..(get_step(src, WEST), WEST)
|
||||
else if(moving_diagonally && ..(get_step(src, WEST), WEST))
|
||||
first_step_dir = WEST
|
||||
moving_diagonally = SECOND_DIAG_STEP
|
||||
. = step(src, SOUTH)
|
||||
. = ..(get_step(src, SOUTH), SOUTH)
|
||||
if(moving_diagonally == SECOND_DIAG_STEP)
|
||||
if(!.)
|
||||
setDir(first_step_dir)
|
||||
|
||||
@@ -180,18 +180,23 @@
|
||||
if(mob.pulling)
|
||||
prev_pulling_loc = mob.pulling.loc
|
||||
|
||||
. = mob.SelfMove(n, direct, delay) // The actual movement
|
||||
if(!(direct & (direct - 1))) // cardinal direction
|
||||
. = mob.SelfMove(n, direct, delay)
|
||||
else // diagonal movements take twice as long
|
||||
. = mob.SelfMove(n, direct, delay * 2)
|
||||
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
|
||||
move_delay += delay
|
||||
|
||||
if(prev_pulling_loc && mob.pulling?.face_while_pulling && (mob.pulling.loc != prev_pulling_loc))
|
||||
mob.setDir(get_dir(mob, mob.pulling)) // Face welding tanks and stuff when pulling
|
||||
else
|
||||
mob.setDir(direct)
|
||||
|
||||
if((direct & (direct - 1)) && mob.loc == n) //moved diagonally successfully
|
||||
delay = mob.movement_delay() * 2 //Will prevent mob diagonal moves from smoothing accurately, sadly
|
||||
|
||||
move_delay += delay
|
||||
|
||||
for(var/obj/item/grab/G in mob)
|
||||
if(G.state == GRAB_NECK)
|
||||
mob.setDir(angle2dir((dir2angle(direct) + 202.5) % 365))
|
||||
|
||||
Reference in New Issue
Block a user