[NO GBP] Jetpack and spacedrift: Fixes and niceties (#66628)

* Jetpack and spacedrift: Fixes and niceties

Ok so when I ported spacemovement onto movement loop,
I neglected to port this behavior that existed to support jetpacks.

Basically, if something that lets you move while spacedrifing
completes a move while you're spacedrifting, the
drift should "disable" to let it complete, and then later restart.

I neglected to add support for that, so that's what this does.

There's some other stuff going on here, mostly things to let jetpacks
ignore some of drift's extra behavior, since when a jetpack is not on
stablized, we want both to coexist.

It's a bit of a mess, I'm sorry about that.

Oh and at temporal's suggestion I've moved the visual_delay set from
newtonian move to an istype on the drift component, that was a good
idea, thanks quiet

* Makes dropping a pull while drifting carry the momentum into the pulled thing\

* Adds some extra context to Process_Spacemove, fixes a bunch of stupid
space bugs

It used to be, if you called Process_Spacemove with a direction, it
assumed you were an "action", so a client or mob trying to move in a
direction.

Unfortuantely for it, I needed to be able to use direction to make mob
pull drifting work. So we now actually pass in a second variable
called continuous_move, which tracks if this Process_Spacemove is on
behalf of a continuous move or not

In addition to this, I've added logic to bumping "off" someone to
prevent backbumping if that makes sense, since the bump is in the form
of a newtonian move that's run before the thing that's bumping actually
moves, we need some way to exclude it from holding the other object in
place.

* Adds a jetpack component, uses it to unify all three versions of
jetpacking

I hate you fikou
There were three copies of the same behavior, which made it hard to fix
stuff. Let's just componentize it

* Fixes jetpacks stabalizing even without fuel

This is mildly hacky. The real fix is to do this with events, but I
really don't wanna bend my brain like that. This'll do

* Ensures turn_off always has a user)

* Shut pu

* Bulky drags no longer effect your movespeed in space, fixing a consistency issue between them and all other forms of drags

* Removes some redundant code, cleans up some messy stuff

* Removes redundant safety checking from jetpack code

* see above

* Removes redundant signals
This commit is contained in:
LemonInTheDark
2022-05-20 00:54:00 -07:00
committed by GitHub
parent 1095f90664
commit 7e9ff85f2a
31 changed files with 494 additions and 262 deletions
+1 -1
View File
@@ -992,7 +992,7 @@ This is the proc mobs get to turn into a ghost. Forked from ghostize due to comp
// Ghosts have no momentum, being massless ectoplasm
/mob/dead/observer/Process_Spacemove(movement_dir)
/mob/dead/observer/Process_Spacemove(movement_dir, continuous_move = FALSE)
return TRUE
/mob/dead/observer/vv_edit_var(var_name, var_value)
@@ -34,7 +34,7 @@
if(shoes && body_position == STANDING_UP && loc == NewLoc && has_gravity(loc))
SEND_SIGNAL(shoes, COMSIG_SHOES_STEP_ACTION)
/mob/living/carbon/human/Process_Spacemove(movement_dir = 0)
/mob/living/carbon/human/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
if(movement_type & FLYING || HAS_TRAIT(src, TRAIT_FREE_FLOAT_MOVEMENT))
return TRUE
return ..()
+1 -1
View File
@@ -232,7 +232,7 @@
if(delold)
qdel(src)
/mob/living/silicon/pai/Process_Spacemove(movement_dir = 0)
/mob/living/silicon/pai/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
. = ..()
if(!.)
add_movespeed_modifier(/datum/movespeed_modifier/pai_spacewalk)
@@ -1,4 +1,4 @@
/mob/living/silicon/robot/Process_Spacemove(movement_dir = 0)
/mob/living/silicon/robot/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
. = ..()
if(.)
return TRUE
@@ -677,7 +677,7 @@ GLOBAL_LIST_INIT(strippable_corgi_items, create_strippable_list(list(
. = ..()
ADD_TRAIT(src, TRAIT_AI_BAGATTACK, INNATE_TRAIT)
/mob/living/simple_animal/pet/dog/corgi/puppy/void/Process_Spacemove(movement_dir = 0)
/mob/living/simple_animal/pet/dog/corgi/puppy/void/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
return 1 //Void puppies can navigate space.
@@ -282,7 +282,7 @@
if(ranged) //We ranged? Shoot at em
if(!target.Adjacent(target_from) && ranged_cooldown <= world.time) //But make sure they're not in range for a melee attack and our range attack is off cooldown
OpenFire(target)
if(!Process_Spacemove()) //Drifting
if(!Process_Spacemove(0)) //Drifting
SSmove_manager.stop_looping(src)
return 1
if(retreat_distance != null) //If we have a retreat distance, check if we need to run from our target
@@ -366,7 +366,7 @@ GLOBAL_LIST_INIT(strippable_parrot_items, create_strippable_list(list(
icon_state = icon_living
drop_held_item(0)
/mob/living/simple_animal/parrot/Process_Spacemove()
/mob/living/simple_animal/parrot/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
if(!stat) //Birds can fly, fun fact. No I don't care that space doesn't have air. Space parrots bitch
return TRUE
return ..()
@@ -262,16 +262,23 @@
/mob/living/simple_animal/proc/handle_automated_movement()
set waitfor = FALSE
if(!stop_automated_movement && wander)
if((isturf(loc) || allow_movement_on_non_turfs) && (mobility_flags & MOBILITY_MOVE)) //This is so it only moves if it's not inside a closet, gentics machine, etc.
turns_since_move++
if(turns_since_move >= turns_per_move)
if(!(stop_automated_movement_when_pulled && pulledby)) //Some animals don't move when pulled
var/anydir = pick(GLOB.cardinals)
if(Process_Spacemove(anydir))
Move(get_step(src, anydir), anydir)
turns_since_move = 0
return 1
if(stop_automated_movement || !wander)
return
if(!isturf(loc) && !allow_movement_on_non_turfs)
return
if(!(mobility_flags & MOBILITY_MOVE)) //This is so it only moves if it's not inside a closet, gentics machine, etc.
return TRUE
turns_since_move++
if(turns_since_move < turns_per_move)
return TRUE
if(stop_automated_movement_when_pulled && pulledby) //Some animals don't move when pulled
return TRUE
var/anydir = pick(GLOB.cardinals)
if(Process_Spacemove(anydir))
Move(get_step(src, anydir), anydir)
turns_since_move = 0
return TRUE
/mob/living/simple_animal/proc/handle_automated_speech(override)
set waitfor = FALSE
@@ -221,7 +221,7 @@
Atkcool = TRUE
addtimer(VARSET_CALLBACK(src, Atkcool, FALSE), 4.5 SECONDS)
/mob/living/simple_animal/slime/Process_Spacemove(movement_dir = 0)
/mob/living/simple_animal/slime/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
return 2
/mob/living/simple_animal/slime/get_status_tab_items()
+30 -19
View File
@@ -262,7 +262,6 @@
L.setDir(direct)
return TRUE
/**
* Handles mob/living movement in space (or no gravity)
*
@@ -272,23 +271,34 @@
*
* You can move in space if you have a spacewalk ability
*/
/mob/Process_Spacemove(movement_dir = 0)
/mob/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
. = ..()
if(. || HAS_TRAIT(src, TRAIT_SPACEWALK))
return TRUE
var/atom/movable/backup = get_spacemove_backup(movement_dir)
if(backup)
if(istype(backup) && movement_dir && !backup.anchored)
if(backup.newtonian_move(turn(movement_dir, 180), instant = TRUE)) //You're pushing off something movable, so it moves
to_chat(src, span_info("You push off of [backup] to propel yourself."))
// FUCK OFF
if(buckled)
return TRUE
return FALSE
var/atom/movable/backup = get_spacemove_backup(movement_dir, continuous_move)
if(!backup)
return FALSE
if(continuous_move || !istype(backup) || !movement_dir || backup.anchored)
return TRUE
// last pushoff exists for one reason
// to ensure pushing a mob doesn't just lead to it considering us as backup, and failing
last_pushoff = world.time
if(backup.newtonian_move(turn(movement_dir, 180), instant = TRUE)) //You're pushing off something movable, so it moves
// We set it down here so future calls to Process_Spacemove by the same pair in the same tick don't lead to fucky
backup.last_pushoff = world.time
to_chat(src, span_info("You push off of [backup] to propel yourself."))
return TRUE
/**
* Finds a target near a mob that is viable for pushing off when moving.
* Takes the intended movement direction as input.
* Takes the intended movement direction as input, alongside if the context is checking if we're allowed to continue drifting
*/
/mob/get_spacemove_backup(moving_direction)
/mob/get_spacemove_backup(moving_direction, continuous_move)
for(var/atom/pushover as anything in range(1, get_turf(src)))
if(pushover == src)
continue
@@ -313,8 +323,17 @@
var/pass_allowed = rebound.CanPass(src, get_dir(rebound, src))
if(!rebound.density && pass_allowed)
continue
if(moving_direction == get_dir(src, pushover) && !pass_allowed) // Can't push "off" of something that you're walking into
//Sometime this tick, this pushed off something. Doesn't count as a valid pushoff target
if(rebound.last_pushoff == world.time)
continue
if(continuous_move && !pass_allowed)
var/datum/move_loop/move/rebound_engine = SSmove_manager.processing_on(rebound, SSspacedrift)
// If you're moving toward it and you're both going the same direction, stop
if(moving_direction == get_dir(src, pushover) && rebound_engine && moving_direction == rebound_engine.direction)
continue
else if(!pass_allowed)
if(moving_direction == get_dir(src, pushover)) // Can't push "off" of something that you're walking into
continue
if(rebound.anchored)
return rebound
if(pulling == rebound)
@@ -331,14 +350,6 @@
var/turf/turf = get_turf(src)
return !isgroundlessturf(turf) && HAS_TRAIT(src, TRAIT_NEGATES_GRAVITY)
/mob/newtonian_move(direction, instant = FALSE)
. = ..()
if(!.) //Only do this if we're actually going somewhere
return
if(!client)
return
client.visual_delay = MOVEMENT_ADJUSTED_GLIDE_SIZE(inertia_move_delay, SSspacedrift.visual_delay) //Make sure moving into a space move looks like a space move
/// Called when this mob slips over, override as needed
/mob/proc/slip(knockdown_amount, obj/O, lube, paralyze, force_drop)
mind?.add_memory(MEMORY_SLIPPED, list(DETAIL_WHAT_BY = O, DETAIL_PROTAGONIST = src), story_value = STORY_VALUE_OKAY)