From 58fec31ea4c57283b05d21312996e83fa65d56c4 Mon Sep 17 00:00:00 2001 From: Arokha Sieyes Date: Sat, 29 Apr 2017 18:53:58 -0400 Subject: [PATCH] Allows 'escaping' sleepers, among other things Added some helper procs for stasis things, and also allows using grabs on sleepers like the advanced scanner because that inconsistency between the machines was bothering me. --- code/game/machinery/Sleeper.dm | 30 +++++++++++++++++-- .../mob/living/carbon/human/human_damage.dm | 14 +++++++++ code/modules/mob/living/carbon/human/life.dm | 17 ++++++----- code/modules/organs/blood.dm | 2 +- 4 files changed, 52 insertions(+), 11 deletions(-) diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm index e2f999b0da7..f54d069b9d4 100644 --- a/code/game/machinery/Sleeper.dm +++ b/code/game/machinery/Sleeper.dm @@ -197,7 +197,7 @@ if(href_list["chemical"] in available_chemicals) // Your hacks are bad and you should feel bad inject_chemical(usr, href_list["chemical"], text2num(href_list["amount"])) if(href_list["change_stasis"]) - var/new_stasis = input("Levels deeper than 50% metabolic rate will render the patient unconscious.","Stasis Level") as null|anything in stasis_choices + var/new_stasis = input("Levels deeper than 50% stasis level will render the patient unconscious.","Stasis Level") as null|anything in stasis_choices if(new_stasis && CanUseTopic(usr, default_state) == STATUS_INTERACTIVE) stasis_level = stasis_choices[new_stasis] @@ -205,7 +205,11 @@ /obj/machinery/sleeper/attackby(var/obj/item/I, var/mob/user) add_fingerprint(user) - if(default_deconstruction_screwdriver(user, I)) + if(istype(I, /obj/item/weapon/grab)) + var/obj/item/weapon/grab/G = I + if(G.affecting) + go_in(G.affecting, user) + else if(default_deconstruction_screwdriver(user, I)) return else if(default_deconstruction_crowbar(user, I)) return @@ -219,6 +223,28 @@ user << "\The [src] has a beaker already." return +/obj/machinery/sleeper/verb/move_eject() + set name = "Eject occupant" + set category = "Object" + set src in oview(1) + if(usr == occupant) + switch(usr.stat) + if(DEAD) + return + if(UNCONSCIOUS) + usr << "You struggle through the haze to hit the eject button. This will take a couple of minutes..." + sleep(2 MINUTES) + if(!src || !usr || !occupant || (occupant != usr)) //Check if someone's released/replaced/bombed him already + return + go_out() + if(CONSCIOUS) + go_out() + else + if(usr.stat != 0) + return + go_out() + add_fingerprint(usr) + /obj/machinery/sleeper/MouseDrop_T(var/mob/target, var/mob/user) if(user.stat || user.lying || !Adjacent(user) || !target.Adjacent(user)|| !ishuman(target)) return diff --git a/code/modules/mob/living/carbon/human/human_damage.dm b/code/modules/mob/living/carbon/human/human_damage.dm index 6237e43e0f9..c9a3a2d292f 100644 --- a/code/modules/mob/living/carbon/human/human_damage.dm +++ b/code/modules/mob/living/carbon/human/human_damage.dm @@ -159,6 +159,20 @@ else in_stasis = amount +/mob/living/carbon/human/proc/getStasis() + if((species.flags & NO_SCAN) || isSynthetic()) + return 0 + + return in_stasis + +//This determines if, RIGHT NOW, the life() tick is being skipped due to stasis +/mob/living/carbon/human/proc/inStasisNow() + var/stasisValue = getStasis() + if(stasisValue && (life_tick % stasisValue)) + return 1 + + return 0 + /mob/living/carbon/human/getCloneLoss() if((species.flags & NO_SCAN) || isSynthetic()) cloneloss = 0 diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 8308c35034d..a21073f9190 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -62,11 +62,12 @@ voice = GetVoice() - //No need to update all of these procs if the guy is dead. - if(stat != DEAD && (!in_stasis || life_tick % in_stasis == 1)) - if(in_stasis > 2) - Sleeping(10) + var/stasis = inStasisNow() + if(getStasis() > 2) + Sleeping(20) + //No need to update all of these procs if the guy is dead. + if(stat != DEAD && !stasis) //Updates the number of stored chemicals for powers handle_changeling() @@ -99,7 +100,7 @@ return 1 /mob/living/carbon/human/breathe() - if(!in_stasis || life_tick % in_stasis == 1) + if(!inStasisNow()) ..() // Calculate how vulnerable the human is to under- and overpressure. @@ -209,7 +210,7 @@ /mob/living/carbon/human/handle_mutations_and_radiation() - if(in_stasis && life_tick % in_stasis != 1) + if(inStasisNow()) return if(getFireLoss()) @@ -791,7 +792,7 @@ /mob/living/carbon/human/handle_chemicals_in_body() - if(in_stasis && life_tick % in_stasis != 1) + if(inStasisNow()) return if(reagents) @@ -1341,7 +1342,7 @@ if(!druggy && !seer) see_invisible = SEE_INVISIBLE_LIVING /mob/living/carbon/human/handle_random_events() - if(in_stasis && life_tick % in_stasis != 1) + if(inStasisNow()) return // Puke if toxloss is too high diff --git a/code/modules/organs/blood.dm b/code/modules/organs/blood.dm index 0f5ea190f26..c6670d2a30e 100644 --- a/code/modules/organs/blood.dm +++ b/code/modules/organs/blood.dm @@ -37,7 +37,7 @@ var/const/CE_STABLE_THRESHOLD = 0.5 // Takes care blood loss and regeneration /mob/living/carbon/human/handle_blood() - if(in_stasis) + if(inStasisNow()) return if(!should_have_organ(O_HEART))