From b64a76ea569c09a85279f77561b446384bcdff1c Mon Sep 17 00:00:00 2001 From: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Date: Sat, 27 May 2023 14:33:28 -0700 Subject: [PATCH] Fixes moveloop shit (#75675) ## About The Pull Request I was using the step_x procs when I should have been using get_step_x and Move() This was causing some mob behavior to not properly respect things like gravity or potentially entered/exited signals. Also ensures we pass direction into Move consistently, and deletes a function that was meant to like, use step_to but with directions? Was never actually used properly I forgot to properly respect the "don't change dir" flag Closes #75673 :cl: fix: Mobs will fly around space... less /:cl: --- .../subsystem/movement/movement_types.dm | 42 +++++-------------- .../effects/decals/cleanable/aliens.dm | 2 +- .../effects/decals/cleanable/robots.dm | 2 +- 3 files changed, 12 insertions(+), 34 deletions(-) diff --git a/code/controllers/subsystem/movement/movement_types.dm b/code/controllers/subsystem/movement/movement_types.dm index c5dd5d3993a..340b41acea6 100644 --- a/code/controllers/subsystem/movement/movement_types.dm +++ b/code/controllers/subsystem/movement/movement_types.dm @@ -196,31 +196,6 @@ // Moving also can be null on occasion, if the move deleted it and therefor us return old_loc != moving?.loc ? MOVELOOP_SUCCESS : MOVELOOP_FAILURE -/** - * Like move(), but it uses byond's pathfinding on a step by step basis - * - * Returns TRUE if the loop sucessfully started, or FALSE if it failed - * - * Arguments: - * moving - The atom we want to move - * direction - The direction we want to move in - * delay - How many deci-seconds to wait between fires. Defaults to the lowest value, 0.1 - * timeout - Time in deci-seconds until the moveloop self expires. Defaults to infinity - * subsystem - The movement subsystem to use. Defaults to SSmovement. Only one loop can exist for any one subsystem - * priority - Defines how different move loops override each other. Lower numbers beat higher numbers, equal defaults to what currently exists. Defaults to MOVEMENT_DEFAULT_PRIORITY - * flags - Set of bitflags that effect move loop behavior in some way. Check _DEFINES/movement.dm - * -**/ -/datum/controller/subsystem/move_manager/proc/move_to_dir(moving, direction, delay, timeout, subsystem, priority, flags, datum/extra_info) - return add_to_loop(moving, subsystem, /datum/move_loop/move/move_to, priority, flags, extra_info, delay, timeout, direction) - -/datum/move_loop/move/move_to - -/datum/move_loop/move/move_to/move() - var/atom/old_loc = moving.loc - step_to(moving, get_step(moving, direction)) - return old_loc != moving?.loc ? MOVELOOP_SUCCESS : MOVELOOP_FAILURE - /** * Like move(), but we don't care about collision at all @@ -452,7 +427,7 @@ var/turf/next_step = movement_path[1] var/atom/old_loc = moving.loc - moving.Move(next_step, get_dir(moving, next_step)) + moving.Move(next_step, get_dir(moving, next_step), FALSE, !(flags & MOVEMENT_LOOP_NO_DIR_UPDATE)) . = (old_loc != moving?.loc) ? MOVELOOP_SUCCESS : MOVELOOP_FAILURE // this check if we're on exactly the next tile may be overly brittle for dense objects who may get bumped slightly @@ -519,7 +494,8 @@ if(!.) return var/atom/old_loc = moving.loc - step_to(moving, target) + var/turf/next = get_step_to(moving, target) + moving.Move(next, get_dir(moving, next), FALSE, !(flags & MOVEMENT_LOOP_NO_DIR_UPDATE)) return old_loc != moving?.loc ? MOVELOOP_SUCCESS : MOVELOOP_FAILURE /** @@ -552,7 +528,8 @@ if(!.) return var/atom/old_loc = moving.loc - step_away(moving, target) + var/turf/next = get_step_away(moving, target) + moving.Move(next, get_dir(moving, next), FALSE, !(flags & MOVEMENT_LOOP_NO_DIR_UPDATE)) return old_loc != moving?.loc ? MOVELOOP_SUCCESS : MOVELOOP_FAILURE @@ -654,7 +631,7 @@ if(y_ticker >= 1) y_ticker = MODULUS(x_ticker, 1) var/atom/old_loc = moving.loc - moving.Move(moving_towards, get_dir(moving, moving_towards)) + moving.Move(moving_towards, get_dir(moving, moving_towards), FALSE, !(flags & MOVEMENT_LOOP_NO_DIR_UPDATE)) //YOU FOUND THEM! GOOD JOB if(home && get_turf(moving) == get_turf(target)) @@ -736,7 +713,7 @@ /datum/move_loop/has_target/move_towards_budget/move() var/turf/target_turf = get_step_towards(moving, target) var/atom/old_loc = moving.loc - moving.Move(target_turf, get_dir(moving, target_turf)) + moving.Move(target_turf, get_dir(moving, target_turf), FALSE, !(flags & MOVEMENT_LOOP_NO_DIR_UPDATE)) return old_loc != moving?.loc ? MOVELOOP_SUCCESS : MOVELOOP_FAILURE /** @@ -809,7 +786,7 @@ var/testdir = pick(potential_dirs) var/turf/moving_towards = get_step(moving, testdir) var/atom/old_loc = moving.loc - moving.Move(moving_towards, testdir) + moving.Move(moving_towards, testdir, FALSE, !(flags & MOVEMENT_LOOP_NO_DIR_UPDATE)) if(old_loc != moving?.loc) //If it worked, we're done return MOVELOOP_SUCCESS potential_dirs -= testdir @@ -837,7 +814,8 @@ /datum/move_loop/move_to_rand/move() var/atom/old_loc = moving.loc - step_rand(moving) + var/turf/next = get_step_rand(moving) + moving.Move(next, get_dir(moving, next), FALSE, !(flags & MOVEMENT_LOOP_NO_DIR_UPDATE)) return old_loc != moving?.loc ? MOVELOOP_SUCCESS : MOVELOOP_FAILURE /** diff --git a/code/game/objects/effects/decals/cleanable/aliens.dm b/code/game/objects/effects/decals/cleanable/aliens.dm index 5084f9f75c3..473deb74489 100644 --- a/code/game/objects/effects/decals/cleanable/aliens.dm +++ b/code/game/objects/effects/decals/cleanable/aliens.dm @@ -45,7 +45,7 @@ break return - var/datum/move_loop/loop = SSmove_manager.move_to_dir(src, get_step(src, direction), delay = delay, timeout = range * delay, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) + var/datum/move_loop/loop = SSmove_manager.move(src, direction, delay = delay, timeout = range * delay, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) RegisterSignal(loop, COMSIG_MOVELOOP_POSTPROCESS, PROC_REF(spread_movement_effects)) /obj/effect/decal/cleanable/xenoblood/xgibs/proc/spread_movement_effects(datum/move_loop/has_target/source) diff --git a/code/game/objects/effects/decals/cleanable/robots.dm b/code/game/objects/effects/decals/cleanable/robots.dm index aaf15a9dc5c..9770baeb2ac 100644 --- a/code/game/objects/effects/decals/cleanable/robots.dm +++ b/code/game/objects/effects/decals/cleanable/robots.dm @@ -31,7 +31,7 @@ break return - var/datum/move_loop/loop = SSmove_manager.move_to_dir(src, get_step(src, direction), delay = delay, timeout = range * delay, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) + var/datum/move_loop/loop = SSmove_manager.move(src, direction, delay = delay, timeout = range * delay, priority = MOVEMENT_ABOVE_SPACE_PRIORITY) RegisterSignal(loop, COMSIG_MOVELOOP_POSTPROCESS, PROC_REF(spread_movement_effects)) /obj/effect/decal/cleanable/robot_debris/proc/spread_movement_effects(datum/move_loop/has_target/source)