Reverts inertia based space movement (#95536)

## About The Pull Request

Reverts space movement being affected by inertia 

What is kept:

- Items have a varying force on your drift speed, ie heavier items will
move you faster through space, and smaller items, slower.
- Jetpacks can have varying force of impulse - the effect is applied
directly to the mob's `inertia_move_multiplier`
- Tethers are unreverted - they still stop you from drifting too far
from the tether point, however you can no longer 'swing' with them.

What is removed:

- Multiple impulses in the same angle/direction no longer speeds you up.
Only the fastest impulse in 1 direction is accounted for.
- An impulse in a different angle/direction will completely override any
existing impulses, even if they are faster.
- Jetpack stabilizers are once again perfectly capable of immediately
stopping any active impulses.

TL;DR

If you point yourself in a direction you will now go that direction

## Why It's Good For The Game

The concept was fun and had potential but the fight between impulses vs
tiles was very, very clunky and janky.
Multiple fixes were attempted to reduce the jank but it ultimately
nograv still acts very cumbersome and jetpacks are still very
unappealing to use.
Smartkar gave the go-ahead to revert this a while back so, o7. 

## Changelog

🆑 Melbert
del: Zero-gravity drifting is no longer affected by inertia, ie it has
been reverted to what it once was.
/🆑
This commit is contained in:
MrMelbert
2026-04-03 15:06:38 +01:00
committed by GitHub
parent ce9530cecf
commit 442ad835bc
13 changed files with 91 additions and 205 deletions
+55 -91
View File
@@ -21,27 +21,29 @@
var/effect_type
/// Drift force applied each movement tick
var/drift_force
/// Force that applied when stabiliziation is active and the player isn't moving in the same direction as the jetpack
var/stabilization_force
/// Our current user
var/mob/user
/// Last tick on which we triggered, to prevent double-dipping
var/last_force_tick
/// Last tick on which we stabilized
var/last_stabilization_tick
VAR_PRIVATE/active = FALSE
/**
* Arguments:
* * stabilize - If we should drift when we finish moving, or sit stable in space]
* * drift_force - How much force is applied whenever the user tries to move
* * stabilization_force - How much force is applied per tick when we try to stabilize the user
* * drift_force - How much force is applied whenever the user tries to move, applied as a multiplier to the user's inertia_move_multiplier.
* * activation_signal - Signal we activate on
* * deactivation_signal - Signal we deactivate on
* * return_flag - Flag to return if activation fails
* * check_on_move - Callback we call each time we attempt a move, we expect it to retun true if the move is ok, false otherwise. It expects an arg, TRUE if fuel should be consumed, FALSE othewise
* * effect_type - Type of trail_follow to spawn
*/
/datum/component/jetpack/Initialize(stabilize, drift_force = 1 NEWTONS, stabilization_force = 1 NEWTONS, activation_signal, deactivation_signal, return_flag, datum/callback/check_on_move, datum/callback/check_on_activation, datum/effect_system/trail_follow/effect_type)
/datum/component/jetpack/Initialize(
stabilize = FALSE,
drift_force = 1 NEWTONS,
activation_signal,
deactivation_signal,
return_flag,
datum/callback/check_on_move,
datum/callback/check_on_activation,
datum/effect_system/trail_follow/effect_type,
)
. = ..()
if(!isatom(parent))
return COMPONENT_INCOMPATIBLE
@@ -60,9 +62,8 @@
src.return_flag = return_flag
src.effect_type = effect_type
src.drift_force = drift_force
src.stabilization_force = stabilization_force
/datum/component/jetpack/InheritComponent(datum/component/component, original, stabilize, drift_force = 1 NEWTONS, stabilization_force = 1 NEWTONS, activation_signal, deactivation_signal, return_flag, datum/callback/check_on_move, datum/callback/check_on_activation, datum/effect_system/trail_follow/effect_type)
/datum/component/jetpack/InheritComponent(datum/component/component, original, stabilize, drift_force = 1 NEWTONS, activation_signal, deactivation_signal, return_flag, datum/callback/check_on_move, datum/callback/check_on_activation, datum/effect_system/trail_follow/effect_type)
UnregisterSignal(parent, src.activation_signal)
if(src.deactivation_signal)
UnregisterSignal(parent, src.deactivation_signal)
@@ -78,22 +79,18 @@
src.return_flag = return_flag
src.effect_type = effect_type
src.drift_force = drift_force
src.stabilization_force = stabilization_force
if(trail && trail.effect_type != effect_type)
setup_trail(trail.holder)
/datum/component/jetpack/Destroy(force)
if(trail)
QDEL_NULL(trail)
user = null
QDEL_NULL(trail)
check_on_move = null
check_on_activation = null
return ..()
/datum/component/jetpack/proc/setup_trail(mob/user)
if(trail)
QDEL_NULL(trail)
QDEL_NULL(trail)
trail = new effect_type(user)
trail.auto_process = FALSE
trail.start()
@@ -104,34 +101,50 @@
if(!isnull(check_on_activation) && !check_on_activation.Invoke())
return return_flag
user = new_user
RegisterSignal(user, COMSIG_MOVABLE_MOVED, PROC_REF(move_react))
RegisterSignal(user, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(pre_move_react))
RegisterSignal(user, COMSIG_MOB_CLIENT_MOVE_NOGRAV, PROC_REF(on_client_move))
RegisterSignal(user, COMSIG_MOB_ATTEMPT_HALT_SPACEMOVE, PROC_REF(on_pushoff))
RegisterSignal(user, COMSIG_MOVABLE_DRIFT_BLOCK_INPUT, PROC_REF(on_input_block))
last_stabilization_tick = world.time
START_PROCESSING(SSnewtonian_movement, src)
active = TRUE
RegisterSignal(new_user, COMSIG_MOVABLE_MOVED, PROC_REF(move_react))
RegisterSignal(new_user, COMSIG_MOVABLE_PRE_MOVE, PROC_REF(pre_move_react))
RegisterSignal(new_user, COMSIG_MOB_ATTEMPT_HALT_SPACEMOVE, PROC_REF(on_pushoff))
RegisterSignal(new_user, COMSIG_MOVABLE_DRIFT_BLOCK_INPUT, PROC_REF(on_input_block))
RegisterSignal(new_user, COMSIG_MOVABLE_SPACEMOVE, PROC_REF(stabilize))
if (effect_type)
setup_trail(user)
setup_trail(new_user)
new_user.inertia_move_multiplier /= drift_force // lower multiplier = faster drifting
/datum/component/jetpack/proc/deactivate(datum/source, mob/old_user)
SIGNAL_HANDLER
UnregisterSignal(old_user, list(COMSIG_MOVABLE_PRE_MOVE, COMSIG_MOVABLE_MOVED, COMSIG_MOB_CLIENT_MOVE_NOGRAV, COMSIG_MOB_ATTEMPT_HALT_SPACEMOVE, COMSIG_MOVABLE_DRIFT_BLOCK_INPUT))
STOP_PROCESSING(SSnewtonian_movement, src)
user = null
if(!active)
return
if(trail)
QDEL_NULL(trail)
active = FALSE
UnregisterSignal(old_user, list(
COMSIG_MOVABLE_PRE_MOVE,
COMSIG_MOVABLE_MOVED,
COMSIG_MOB_ATTEMPT_HALT_SPACEMOVE,
COMSIG_MOVABLE_DRIFT_BLOCK_INPUT,
COMSIG_MOVABLE_SPACEMOVE,
))
QDEL_NULL(trail)
old_user.inertia_move_multiplier *= drift_force
/datum/component/jetpack/proc/move_react(mob/source)
SIGNAL_HANDLER
if (!should_trigger(source))
return
if(source.client.intended_direction && check_on_move.Invoke(FALSE) && trail) //You use jet when press keys. yes.
trail.generate_effect()
if(source.client.intended_direction && check_on_move.Invoke(TRUE)) //You use jet when press keys. yes.
trail?.generate_effect()
/datum/component/jetpack/proc/stabilize(mob/source, movement_dir, continuous_move, backup)
SIGNAL_HANDLER
if(!continuous_move && movement_dir)
return COMSIG_MOVABLE_STOP_SPACEMOVE
// Check if we have the fuel to stop this. Do NOT consume any fuel, just check
// This is done because things other then us can use our fuel
if(stabilize && check_on_move.Invoke(FALSE))
return COMSIG_MOVABLE_STOP_SPACEMOVE
return NONE
/datum/component/jetpack/proc/should_trigger(mob/source)
if(!source || !source.client)//Don't allow jet self using
@@ -148,81 +161,32 @@
/datum/component/jetpack/proc/pre_move_react(mob/source)
SIGNAL_HANDLER
if(!trail)
return FALSE
trail.oldposition = get_turf(source)
/datum/component/jetpack/process(seconds_per_tick)
if (last_stabilization_tick == world.time)
return
last_stabilization_tick = world.time
if (!should_trigger(user) || !stabilize || !check_on_move.Invoke(FALSE) || isnull(user.drift_handler))
return
var/max_drift_force = MOVE_DELAY_TO_DRIFT(user.cached_multiplicative_slowdown)
user.drift_handler.stabilize_drift(user.client.intended_direction ? dir2angle(user.client.intended_direction) : null, user.client.intended_direction ? max_drift_force : 0, stabilization_force * (seconds_per_tick * 1 SECONDS))
trail?.oldposition = get_turf(source)
/datum/component/jetpack/proc/on_input_block(mob/source)
SIGNAL_HANDLER
if (!should_trigger(source))
return
return NONE
if (!check_on_move.Invoke(TRUE))
return
return NONE
return DRIFT_ALLOW_INPUT
/datum/component/jetpack/proc/on_client_move(mob/source, list/move_args)
SIGNAL_HANDLER
if (!should_trigger(source))
return
if (last_force_tick == world.time)
return
if (!check_on_move.Invoke(TRUE))
return
var/max_drift_force = MOVE_DELAY_TO_DRIFT(source.cached_multiplicative_slowdown)
var/applied_force = drift_force
var/move_dir = source.client.intended_direction
// Try to see if we can simulate pushing off a wall
var/atom/movable/backup = source.get_spacemove_backup(move_dir, FALSE, include_floors = TRUE)
if (backup && !(backup.dir & move_dir))
applied_force = max_drift_force
// We don't want to force the loop to fire before stabilizing if we're going to, otherwise its effects will be delayed until the next tick which is jank
var/force_stabilize = FALSE
if (last_stabilization_tick < world.time)
force_stabilize = TRUE
source.newtonian_move(dir2angle(move_dir), instant = TRUE, drift_force = applied_force, controlled_cap = max_drift_force, force_loop = !force_stabilize)
source.setDir(move_dir)
last_force_tick = world.time
if (force_stabilize)
// Newphys is an SS_TICKER subsystem and under ideal circumstances should be firing every tick, thus a period of world.tick_lag
// However, since our servers are jank, even SSinput can end up overtiming - which is also an SS_TICKER subsystem that just so
// happens to be what is calling this proc - so we can be assured that this is not above world.tick_lag, or at least should not be
process(world.tick_lag)
/datum/component/jetpack/proc/on_pushoff(mob/source, movement_dir, continuous_move, atom/backup)
SIGNAL_HANDLER
if (get_dir(source, backup) == movement_dir || source.loc == backup.loc)
return
return NONE
if (!source.client?.intended_direction || source.client.intended_direction == get_dir(source, backup))
return
return NONE
if (isnull(source.drift_handler))
return
return NONE
if (!should_trigger(source) || !check_on_move.Invoke(FALSE))
return
return NONE
return COMPONENT_PREVENT_SPACEMOVE_HALT
-7
View File
@@ -124,13 +124,6 @@
to_chat(source, span_warning("[tether_name] catches on [blocker] and prevents you from moving!"))
return COMPONENT_MOVABLE_BLOCK_PRE_MOVE
if (get_dist(anchor, new_loc) != cur_dist || !ismovable(source) || force_moving_target)
return
var/datum/drift_handler/handler = movable_source.drift_handler
if (handler)
handler.remove_angle_force(get_angle(anchor, source))
/// Try adjust the anchor's position to move closer to the target or regain LOS
/// true_source is an optional argument in case we're looking for a LOS/closer turf to a new location rather than the actual owner, and need to ignore them
/datum/component/tether/proc/try_adjust_position(atom/movable/anchor, atom/target, atom/true_source)
+32 -71
View File
@@ -3,7 +3,6 @@
///Alongside dealing with the post movement input blocking required to make things look nice
/datum/drift_handler
var/atom/movable/parent
var/atom/inertia_last_loc
var/old_dir
var/datum/move_loop/smooth_move/drifting_loop
///Should we ignore the next glide rate input we get?
@@ -25,7 +24,14 @@
if(instant)
flags |= MOVEMENT_LOOP_START_INSTANT
src.drift_force = drift_force
drifting_loop = GLOB.move_manager.smooth_move(moving = parent, angle = inertia_angle, delay = get_loop_delay(parent), subsystem = SSnewtonian_movement, priority = MOVEMENT_SPACE_PRIORITY, flags = flags)
drifting_loop = GLOB.move_manager.smooth_move(
moving = parent,
angle = inertia_angle,
delay = get_loop_delay(parent),
subsystem = SSnewtonian_movement,
priority = MOVEMENT_SPACE_PRIORITY,
flags = flags,
)
if(!drifting_loop)
qdel(src)
@@ -53,7 +59,6 @@
SSnewtonian_movement.fire_moveloop(drifting_loop)
/datum/drift_handler/Destroy()
inertia_last_loc = null
if(!QDELETED(drifting_loop))
qdel(drifting_loop)
drifting_loop = null
@@ -78,25 +83,36 @@
//It's ok if it's not, it's just important if it is.
mob_parent.client?.visual_delay = MOVEMENT_ADJUSTED_GLIDE_SIZE(visual_delay, SSnewtonian_movement.visual_delay)
/datum/drift_handler/proc/newtonian_impulse(inertia_angle, start_delay, additional_force, controlled_cap, force_loop = TRUE)
SIGNAL_HANDLER
inertia_last_loc = parent.loc
/**
* An impulse is being applied to this existing drift, react accordingly
*
* * inertia_angle - angle of the new impulse
* * start_delay - if the new impulse has a delay before it starts, this is it
* * additional_force - how much force the new impulse has
* force is not added onto additional force, it will either override it entirely (if larger or a different direction) or be ignored (if smaller and same direction)
* controlled_cap - the maximum amount of force this impulse can apply, regardless of input
* force_loop - should we force the loop to fire immediately to react to this change, or wait for the next visual tick?
* Generally, if the new impulse has a start delay, you should wait, otherwise it'll look really jank
*
* Return FALSE if the loop becomes invalid and should be replaced
* Return TRUE if the loop is still valid and should be kept
*/
/datum/drift_handler/proc/newtonian_impulse(inertia_angle, start_delay, additional_force, controlled_cap = INERTIA_FORCE_CAP, force_loop = TRUE)
// We've been told to move in the middle of deletion process, tell parent to create a new handler instead
if(!drifting_loop)
qdel(src)
return FALSE
var/applied_force = additional_force
var/new_force = clamp(additional_force / parent.inertia_force_weight, 0, controlled_cap)
if(new_force < drift_force && drifting_loop.angle == inertia_angle) // If we're already moving faster in this direction, don't change anything
return TRUE
var/force_x = sin(drifting_loop.angle) * drift_force + sin(inertia_angle) * applied_force / parent.inertia_force_weight
var/force_y = cos(drifting_loop.angle) * drift_force + cos(inertia_angle) * applied_force / parent.inertia_force_weight
drift_force = clamp(sqrt(force_x * force_x + force_y * force_y), 0, !isnull(controlled_cap) ? controlled_cap : INERTIA_FORCE_CAP)
drift_force = new_force
if(drift_force < 0.1) // Rounding issues
qdel(src)
return TRUE
drifting_loop.set_angle(delta_to_angle(force_x, force_y))
drifting_loop.set_angle(inertia_angle)
drifting_loop.set_delay(get_loop_delay(parent))
// We have to forcefully fire it here to avoid stuttering in case of server lag
if (drifting_loop.timer <= world.time && force_loop)
@@ -105,7 +121,6 @@
/datum/drift_handler/proc/drifting_start()
SIGNAL_HANDLER
inertia_last_loc = parent.loc
RegisterSignal(parent, COMSIG_MOVABLE_MOVED, PROC_REF(handle_move))
// We will use glide size to intuit how long to delay our loop's next move for
// This way you can't ride two movements at once while drifting, since that'd be dumb as fuck
@@ -137,7 +152,6 @@
glide_to_halt(visual_delay)
return
inertia_last_loc = parent.loc
ignore_next_glide = TRUE
/datum/drift_handler/proc/loop_death(datum/source)
@@ -203,63 +217,10 @@
SIGNAL_HANDLER
// Some things want to allow movement out of spacedrift, we should let them
if(SEND_SIGNAL(parent, COMSIG_MOVABLE_DRIFT_BLOCK_INPUT) & DRIFT_ALLOW_INPUT)
return
if(world.time < block_inputs_until)
return COMSIG_MOB_CLIENT_BLOCK_PRE_MOVE
/datum/drift_handler/proc/attempt_halt(movement_dir, continuous_move, atom/backup)
if ((backup.density || !backup.CanPass(parent, get_dir(backup, parent))) && (get_dir(parent, backup) == movement_dir || parent.loc == backup.loc))
return FALSE
if (drift_force < INERTIA_FORCE_SPACEMOVE_GRAB || isnull(drifting_loop))
return FALSE
if (ismob(parent))
var/mob/source_user = parent
if (!isnull(source_user.client) && source_user.client.intended_direction)
if ((source_user.client.intended_direction & movement_dir) && !(get_dir(source_user, backup) & movement_dir))
return FALSE
if (drift_force <= INERTIA_FORCE_SPACEMOVE_REDUCTION / parent.inertia_force_weight)
glide_to_halt(get_loop_delay(parent))
return TRUE
drift_force -= INERTIA_FORCE_SPACEMOVE_REDUCTION / parent.inertia_force_weight
drifting_loop.set_delay(get_loop_delay(parent))
return TRUE
return NONE
if(world.time >= block_inputs_until)
return NONE
return COMSIG_MOB_CLIENT_BLOCK_PRE_MOVE
/datum/drift_handler/proc/get_loop_delay(atom/movable/movable)
return (DEFAULT_INERTIA_SPEED / ((1 - INERTIA_SPEED_COEF) + drift_force * INERTIA_SPEED_COEF)) * movable.inertia_move_multiplier
/datum/drift_handler/proc/stabilize_drift(target_angle, target_force, stabilization_force)
/// We aren't drifting
if (isnull(drifting_loop))
return
/// Lack of angle means that we are trying to halt movement
if (isnull(target_angle))
// Going through newtonian_move ensures that all Process_Spacemove code runs properly, instead of directly adjusting forces
parent.newtonian_move(REVERSE_ANGLE(drifting_loop.angle), drift_force = min(drift_force, stabilization_force))
return
// Force required to be applied in order to get to the desired movement vector, with projection of current movement onto desired vector to ensure that we only compensate for excess
var/drift_projection = max(0, cos(target_angle - drifting_loop.angle)) * drift_force
var/force_x = sin(target_angle) * target_force - sin(drifting_loop.angle) * drift_force
var/force_y = cos(target_angle) * target_force - cos(drifting_loop.angle) * drift_force
var/force_angle = delta_to_angle(force_x, force_y)
var/applied_force = sqrt(force_x * force_x + force_y * force_y)
var/force_projection = max(0, cos(target_angle - force_angle)) * applied_force
force_x -= min(force_projection, drift_projection) * sin(target_angle)
force_x -= min(force_projection, drift_projection) * cos(target_angle)
applied_force = min(sqrt(force_x * force_x + force_y * force_y), stabilization_force)
parent.newtonian_move(force_angle, instant = TRUE, drift_force = applied_force)
/// Removes all force in a certain direction
/datum/drift_handler/proc/remove_angle_force(target_angle)
/// We aren't drifting
if (isnull(drifting_loop))
return
var/projected_force = max(0, cos(target_angle - drifting_loop.angle)) * drift_force
if (projected_force > 0)
parent.newtonian_move(REVERSE_ANGLE(target_angle), projected_force)