From 6b1da44c8a55a7fe661cca74246ca7e84411fb2b Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Mon, 9 Nov 2020 09:42:53 +0100 Subject: [PATCH] [MIRROR] Mob stays vertical while in cryo (#1639) * Mob stays vertical while in cryo (#54800) Currently, mobs in cryo will turn horizontal in the cryotube when they fall unconscious. This should stop that. * Mob stays vertical while in cryo Co-authored-by: prodirus <44090982+prodirus@users.noreply.github.com> --- code/__DEFINES/traits.dm | 2 ++ code/_globalvars/traits.dm | 1 + .../machinery/components/unary_devices/cryo.dm | 7 +++---- code/modules/mob/living/init_signals.dm | 14 ++++++++++++++ code/modules/mob/living/living.dm | 2 +- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm index 99f0f5fa179..52cdda24ec3 100644 --- a/code/__DEFINES/traits.dm +++ b/code/__DEFINES/traits.dm @@ -82,6 +82,8 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define TRAIT_IMMOBILIZED "immobilized" /// Prevents voluntary standing or staying up on its own. #define TRAIT_FLOORED "floored" +/// Forces user to stay standing +#define TRAIT_FORCED_STANDING "forcedstanding" /// Prevents usage of manipulation appendages (picking, holding or using items, manipulating storage). #define TRAIT_HANDS_BLOCKED "handsblocked" /// Inability to access UI hud elements. Turned into a trait from [MOBILITY_UI] to be able to track sources. diff --git a/code/_globalvars/traits.dm b/code/_globalvars/traits.dm index 8d803f1cfbf..3e230283af1 100644 --- a/code/_globalvars/traits.dm +++ b/code/_globalvars/traits.dm @@ -8,6 +8,7 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_KNOCKEDOUT" = TRAIT_KNOCKEDOUT, "TRAIT_IMMOBILIZED" = TRAIT_IMMOBILIZED, "TRAIT_FLOORED" = TRAIT_FLOORED, + "TRAIT_FORCED_STANDING" = TRAIT_FORCED_STANDING, "TRAIT_HANDS_BLOCKED" = TRAIT_HANDS_BLOCKED, "TRAIT_RESTRAINED" = TRAIT_RESTRAINED, "TRAIT_INCAPACITATED" = TRAIT_INCAPACITATED, diff --git a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm index d7546653534..af6ced8710d 100644 --- a/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm +++ b/code/modules/atmospherics/machinery/components/unary_devices/cryo.dm @@ -30,8 +30,7 @@ if(occupant) vis_contents -= occupant REMOVE_TRAIT(occupant, TRAIT_IMMOBILIZED, CRYO_TRAIT) - if(occupant.resting || HAS_TRAIT(occupant, TRAIT_FLOORED)) - occupant.set_lying_down() + REMOVE_TRAIT(occupant, TRAIT_FORCED_STANDING, CRYO_TRAIT) occupant = new_occupant if(!occupant) @@ -41,8 +40,8 @@ vis_contents += occupant pixel_y = 22 ADD_TRAIT(occupant, TRAIT_IMMOBILIZED, CRYO_TRAIT) - occupant.set_body_position(STANDING_UP) - occupant.set_lying_angle(0) + // Keep them standing! They'll go sideways in the tube when they fall asleep otherwise. + ADD_TRAIT(occupant, TRAIT_FORCED_STANDING, CRYO_TRAIT) /// COMSIG_CRYO_SET_ON callback /atom/movable/visual/cryo_occupant/proc/on_set_on(datum/source, on) diff --git a/code/modules/mob/living/init_signals.dm b/code/modules/mob/living/init_signals.dm index 8bc89b7ce70..bb5165f9d85 100644 --- a/code/modules/mob/living/init_signals.dm +++ b/code/modules/mob/living/init_signals.dm @@ -12,6 +12,9 @@ RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_FLOORED), .proc/on_floored_trait_gain) RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_FLOORED), .proc/on_floored_trait_loss) + RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_FORCED_STANDING), .proc/on_forced_standing_trait_gain) + RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_FORCED_STANDING), .proc/on_forced_standing_trait_loss) + RegisterSignal(src, SIGNAL_ADDTRAIT(TRAIT_HANDS_BLOCKED), .proc/on_handsblocked_trait_gain) RegisterSignal(src, SIGNAL_REMOVETRAIT(TRAIT_HANDS_BLOCKED), .proc/on_handsblocked_trait_loss) @@ -78,6 +81,8 @@ SIGNAL_HANDLER if(buckled && buckled.buckle_lying != NO_BUCKLE_LYING) return // Handled by the buckle. + if(HAS_TRAIT(src, TRAIT_FORCED_STANDING)) + return // Don't go horizontal if mob has forced standing trait. mobility_flags &= ~MOBILITY_STAND on_floored_start() @@ -88,6 +93,15 @@ mobility_flags |= MOBILITY_STAND on_floored_end() +/// Called when [TRAIT_FORCED_STANDING] is added to the mob. +/mob/living/proc/on_forced_standing_trait_gain(datum/source) + set_body_position(STANDING_UP) + set_lying_angle(0) + +/// Called when [TRAIT_FORCED_STANDING] is removed from the mob. +/mob/living/proc/on_forced_standing_trait_loss(datum/source) + if(resting || HAS_TRAIT(src, TRAIT_FLOORED)) + set_lying_down() /// Called when [TRAIT_HANDS_BLOCKED] is added to the mob. /mob/living/proc/on_handsblocked_trait_gain(datum/source) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index a8c7fd92026..47b87cc474e 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -490,7 +490,7 @@ if(body_position == LYING_DOWN) if(!silent) to_chat(src, "You will now try to stay lying down on the floor.") - else if(buckled && buckled.buckle_lying != NO_BUCKLE_LYING) + else if(HAS_TRAIT(src, TRAIT_FORCED_STANDING) || (buckled && buckled.buckle_lying != NO_BUCKLE_LYING)) if(!silent) to_chat(src, "You will now lay down as soon as you are able to.") else