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
+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)