[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
+45 -61
View File
@@ -12,18 +12,23 @@
var/on = FALSE
var/stabilizers = FALSE
var/full_speed = TRUE // If the jetpack will have a speedboost in space/nograv or not
var/datum/effect_system/trail_follow/ion/ion_trail
var/datum/callback/get_mover
var/datum/callback/check_on_move
/obj/item/tank/jetpack/Initialize(mapload)
. = ..()
ion_trail = new
ion_trail.auto_process = FALSE
ion_trail.set_up(src)
get_mover = CALLBACK(src, .proc/get_user)
check_on_move = CALLBACK(src, .proc/allow_thrust, 0.01)
refresh_jetpack()
/obj/item/tank/jetpack/Destroy()
QDEL_NULL(ion_trail)
get_mover = null
check_on_move = null
return ..()
/obj/item/tank/jetpack/proc/refresh_jetpack()
AddComponent(/datum/component/jetpack, stabilizers, COMSIG_JETPACK_ACTIVATED, COMSIG_JETPACK_DEACTIVATED, JETPACK_ACTIVATION_FAILED, get_mover, check_on_move, /datum/effect_system/trail_follow/ion)
/obj/item/tank/jetpack/item_action_slot_check(slot)
if(slot == ITEM_SLOT_BACK)
return TRUE
@@ -49,12 +54,11 @@
cycle(user)
else if(istype(action, /datum/action/item_action/jetpack_stabilization))
if(on)
stabilizers = !stabilizers
set_stabilizers(!stabilizers)
to_chat(user, span_notice("You turn the jetpack stabilization [stabilizers ? "on" : "off"]."))
else
toggle_internals(user)
/obj/item/tank/jetpack/proc/cycle(mob/user)
if(user.incapacitated())
return
@@ -70,83 +74,60 @@
to_chat(user, span_notice("You turn the jetpack off."))
update_action_buttons()
/obj/item/tank/jetpack/proc/set_stabilizers(new_stabilizers)
if(new_stabilizers == stabilizers)
return
stabilizers = new_stabilizers
refresh_jetpack()
/obj/item/tank/jetpack/proc/turn_on(mob/user)
if(!allow_thrust(0.01, user))
if(SEND_SIGNAL(src, COMSIG_JETPACK_ACTIVATED) & JETPACK_ACTIVATION_FAILED)
return FALSE
on = TRUE
icon_state = "[initial(icon_state)]-on"
ion_trail.start()
RegisterSignal(user, COMSIG_MOVABLE_MOVED, .proc/move_react)
RegisterSignal(user, COMSIG_MOVABLE_PRE_MOVE, .proc/pre_move_react)
RegisterSignal(user, COMSIG_MOVABLE_SPACEMOVE, .proc/spacemove_react)
if(full_speed)
user.add_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed)
return TRUE
/obj/item/tank/jetpack/proc/turn_off(mob/user)
SEND_SIGNAL(src, COMSIG_JETPACK_DEACTIVATED)
on = FALSE
stabilizers = FALSE
set_stabilizers(FALSE)
icon_state = initial(icon_state)
ion_trail.stop()
if(user)
UnregisterSignal(user, COMSIG_MOVABLE_MOVED)
UnregisterSignal(user, COMSIG_MOVABLE_PRE_MOVE)
UnregisterSignal(user, COMSIG_MOVABLE_SPACEMOVE)
user.remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed)
/obj/item/tank/jetpack/proc/move_react(mob/user)
SIGNAL_HANDLER
if(!on)//If jet dont work, it dont work
return
if(!user || !user.client)//Don't allow jet self using
return
if(!isturf(user.loc))//You can't use jet in nowhere or from mecha/closet
return
if(!(user.movement_type & FLOATING) || user.buckled)//You don't want use jet in gravity or while buckled.
return
if(user.pulledby)//You don't must use jet if someone pull you
return
if(user.throwing)//You don't must use jet if you thrown
return
if(length(user.client.keys_held & user.client.movement_keys))//You use jet when press keys. yes.
allow_thrust(0.01, user)
/obj/item/tank/jetpack/proc/pre_move_react(mob/user)
SIGNAL_HANDLER
ion_trail.oldposition = get_turf(src)
/obj/item/tank/jetpack/proc/spacemove_react(mob/user, movement_dir)
SIGNAL_HANDLER
if(on && (movement_dir || stabilizers))
return COMSIG_MOVABLE_STOP_SPACEMOVE
/obj/item/tank/jetpack/proc/allow_thrust(num, mob/living/user)
/obj/item/tank/jetpack/proc/allow_thrust(num, use_fuel = TRUE)
if((num < 0.005 || air_contents.total_moles() < num))
turn_off(user)
return
turn_off(get_user())
return FALSE
// We've got the gas, it's chill
if(!use_fuel)
return TRUE
var/datum/gas_mixture/removed = remove_air(num)
if(removed.total_moles() < 0.005)
turn_off(user)
return
turn_off(get_user())
return FALSE
var/turf/T = get_turf(user)
var/turf/T = get_turf(src)
T.assume_air(removed)
ion_trail.generate_effect()
return TRUE
// Gives the jetpack component the user it expects
/obj/item/tank/jetpack/proc/get_user()
if(!ismob(loc))
return null
return loc
/obj/item/tank/jetpack/suicide_act(mob/user)
if (istype(user, /mob/living/carbon/human/))
var/mob/living/carbon/human/H = user
H.say("WHAT THE FUCK IS CARBON DIOXIDE?")
H.visible_message(span_suicide("[user] is suffocating [user.p_them()]self with [src]! It looks like [user.p_they()] didn't read what that jetpack says!"))
return (OXYLOSS)
else
..()
if (!istype(user, /mob/living/carbon/human))
return ..()
var/mob/living/carbon/human/suffocater = user
suffocater.say("WHAT THE FUCK IS CARBON DIOXIDE?")
suffocater.visible_message(span_suicide("[user] is suffocating [user.p_them()]self with [src]! It looks like [user.p_they()] didn't read what that jetpack says!"))
return (OXYLOSS)
/obj/item/tank/jetpack/improvised
name = "improvised jetpack"
@@ -159,7 +140,10 @@
gas_type = null //it starts empty
full_speed = FALSE //moves at modsuit jetpack speeds
/obj/item/tank/jetpack/improvised/allow_thrust(num, mob/living/user)
/obj/item/tank/jetpack/improvised/allow_thrust(num)
var/mob/user = get_user()
if(!user)
return FALSE
if(rand(0,250) == 0)
to_chat(user, span_notice("You feel your jetpack's engines cut out."))
turn_off(user)
+2 -1
View File
@@ -369,7 +369,8 @@
playsound(src,'sound/effects/bamf.ogg',100,TRUE)
qdel(src)
/obj/effect/resin_container/newtonian_move(direction, instant = FALSE) // Please don't spacedrift thanks
// Please don't spacedrift thanks
/obj/effect/resin_container/newtonian_move(direction, instant = FALSE, start_delay = 0)
return TRUE
#undef EXTINGUISHER