diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm
index b347ca6107bd..b8e7e9584159 100644
--- a/code/game/machinery/Sleeper.dm
+++ b/code/game/machinery/Sleeper.dm
@@ -1,3 +1,8 @@
+#define SLEEPER_TEND "Treat Injuries"
+#define SLEEPER_ORGANS "Repair Organs"
+#define SLEEPER_CHEMPURGE "Purge Toxins"
+#define SLEEPER_HEAL_RATE 2
+
/obj/machinery/sleep_console
name = "sleeper console"
icon = 'icons/obj/machines/sleeper.dmi'
@@ -13,19 +18,26 @@
state_open = TRUE
circuit = /obj/item/circuitboard/machine/sleeper
+ ///efficiency, used to increase the effect of some healing methods
var/efficiency = 1
- var/min_health = -25
- var/list/available_chems
+ ///maximum status stasis will activate at, occurs automatically
+ var/stasis_health = UNCONSCIOUS
+ ///treatments currently available for use
+ var/list/available_treatments
+ ///if the patient is able to use the sleeper's controls
var/controls_inside = FALSE
- var/list/possible_chems = list(
- list(/datum/reagent/medicine/epinephrine, /datum/reagent/medicine/morphine, /datum/reagent/medicine/perfluorodecalin, /datum/reagent/medicine/c2/libital, /datum/reagent/medicine/c2/aiuri),
- list(/datum/reagent/medicine/potass_iodide),
- list(/datum/reagent/medicine/charcoal, /datum/reagent/medicine/salbutamol),
- list(/datum/reagent/medicine/omnizine)
+ ///treatments unlocked by manipulator by tier
+ var/list/treatments = list(
+ list(SLEEPER_TEND),
+ list(SLEEPER_ORGANS),
+ list(SLEEPER_CHEMPURGE),
+ list()
)
- var/list/chem_buttons //Used when emagged to scramble which chem is used, eg: mutadone -> morphine
- var/scrambled_chems = FALSE //Are chem buttons scrambled? used as a warning
- var/enter_message = span_notice("You feel cool air surround you. You go numb as your senses turn inward.")
+ ///the current active treatment
+ var/active_treatment = null
+ ///if the sleeper puts its patient into stasis
+ var/stasis = FALSE
+ var/enter_message = "You feel cool air surround you. You go numb as your senses turn inward."
payment_department = ACCOUNT_MED
fair_market_price = 5
@@ -33,7 +45,6 @@
. = ..()
occupant_typecache = GLOB.typecache_living
update_icon()
- reset_chem_buttons()
/obj/machinery/sleeper/RefreshParts()
var/E
@@ -44,11 +55,12 @@
I += M.rating
efficiency = initial(efficiency)* E
- min_health = initial(min_health) * E
- available_chems = list()
+ available_treatments = list()
for(var/i in 1 to I)
- available_chems |= possible_chems[i]
- reset_chem_buttons()
+ if(!length(treatments[i]))
+ continue
+ available_treatments |= treatments[i]
+ stasis = (I >= 4)
/obj/machinery/sleeper/update_icon()
if(state_open)
@@ -71,6 +83,10 @@
/obj/machinery/sleeper/open_machine()
if(!state_open && !panel_open)
+ active_treatment = null
+ var/mob/living/mob_occupant = occupant
+ if(mob_occupant)
+ mob_occupant.remove_status_effect(STATUS_EFFECT_STASIS)
flick("[initial(icon_state)]-anim", src)
..()
@@ -81,6 +97,8 @@
var/mob/living/mob_occupant = occupant
if(mob_occupant && mob_occupant.stat != DEAD)
to_chat(occupant, "[enter_message]")
+ if(mob_occupant && stasis)
+ mob_occupant.ExtinguishMob()
/obj/machinery/sleeper/emp_act(severity)
. = ..()
@@ -89,6 +107,12 @@
if(is_operational() && occupant)
open_machine()
+/obj/machinery/particle_accelerator/control_box/emag_act(mob/user)
+ if(obj_flags & EMAGGED)
+ return
+ to_chat(user, span_danger("You disable the chemical injection inhibitors on the sleeper..."))
+ obj_flags |= EMAGGED
+
/obj/machinery/sleeper/MouseDrop_T(mob/target, mob/user)
if(user.stat || !Adjacent(user) || !user.Adjacent(target) || !iscarbon(target) || !user.IsAdvancedToolUser())
return
@@ -157,6 +181,42 @@
/obj/machinery/sleeper/process()
..()
check_nap_violations()
+ var/mob/living/carbon/C = occupant
+ if(C)
+ if(stasis && C.stat >= stasis_health)
+ C.apply_status_effect(STATUS_EFFECT_STASIS, null, TRUE)
+ else
+ C.remove_status_effect(STATUS_EFFECT_STASIS)
+ if(obj_flags & EMAGGED)
+ var/existing = C.reagents.get_reagent_amount(/datum/reagent/toxin/amanitin)
+ C.reagents.add_reagent(/datum/reagent/toxin/amanitin, max(0, 1 - existing)) //this should be enough that you immediately eat shit on exiting but not before
+ switch(active_treatment)
+ if(SLEEPER_TEND)
+ C.heal_bodypart_damage(SLEEPER_HEAL_RATE,SLEEPER_HEAL_RATE) //this is slow as hell, use the rest of medbay you chumps
+ if(SLEEPER_ORGANS)
+ var/heal_reps = efficiency * 2
+ var/list/organs = list(ORGAN_SLOT_EARS,ORGAN_SLOT_EYES,ORGAN_SLOT_LIVER,ORGAN_SLOT_LUNGS,ORGAN_SLOT_STOMACH,ORGAN_SLOT_HEART)
+ for(var/i in 1 to heal_reps)
+ organs = shuffle(organs)
+ for(var/o in organs)
+ var/healed = FALSE
+ var/obj/item/organ/heal_target = C.getorganslot(o)
+ if(heal_target?.damage >= 1)
+ var/organ_healing = C.stat == DEAD ? 0.05 : 0.2
+ heal_target.applyOrganDamage(-organ_healing)
+ healed = TRUE
+ if(healed)
+ break
+ if(SLEEPER_CHEMPURGE)
+ C.adjustToxLoss(-SLEEPER_HEAL_RATE)
+ var/purge_rate = 0.5 * efficiency
+ for(var/datum/reagent/R in C.reagents.reagent_list)
+ if(istype(R, /datum/reagent/toxin))
+ C.reagents.remove_reagent(R.type,purge_rate)
+ if(R.overdosed)
+ C.reagents.remove_reagent(R.type,purge_rate)
+ else
+ active_treatment = null
/obj/machinery/sleeper/nap_violation(mob/violator)
open_machine()
@@ -166,11 +226,16 @@
data["knowledge"] = IS_MEDICAL(user)
data["occupied"] = occupant ? 1 : 0
data["open"] = state_open
+ data["active_treatment"] = active_treatment
+ data["can_sedate"] = can_sedate()
- data["chems"] = list()
+ data["treatments"] = list()
+ for(var/T in available_treatments)
+ data["treatments"] += T
+ /*data["chems"] = list()
for(var/chem in available_chems)
var/datum/reagent/R = GLOB.chemical_reagents_list[chem]
- data["chems"] += list(list("name" = R.name, "id" = R.type, "allowed" = chem_allowed(chem), "desc" = R.description))
+ data["chems"] += list(list("name" = R.name, "id" = R.type, "allowed" = chem_allowed(chem), "desc" = R.description))*/
data["occupant"] = list()
var/mob/living/mob_occupant = occupant
@@ -216,48 +281,27 @@
else
open_machine()
. = TRUE
- if("inject")
- var/chem = text2path(params["chem"])
- if(!is_operational() || !mob_occupant || isnull(chem))
- return
- if(mob_occupant.health < min_health && chem != /datum/reagent/medicine/epinephrine)
+ if("set")
+ var/treatment = params["treatment"]
+ if(!is_operational() || !mob_occupant || isnull(treatment))
return
- if(inject_chem(chem, usr))
+ active_treatment = treatment
+ . = TRUE
+ if("sedate")
+ if(can_sedate())
+ mob_occupant.reagents.add_reagent(/datum/reagent/medicine/morphine, 10)
+ if(usr)
+ log_combat(usr,occupant, "injected morphine into", addition = "via [src]")
. = TRUE
- if(scrambled_chems && prob(5))
- to_chat(usr, span_warning("Chemical system re-route detected, results may not be as expected!"))
-
-/obj/machinery/sleeper/emag_act(mob/user)
- scramble_chem_buttons()
- to_chat(user, span_warning("You scramble the sleeper's user interface!"))
-
-/obj/machinery/sleeper/proc/inject_chem(chem, mob/user)
- if((chem in available_chems) && chem_allowed(chem))
- occupant.reagents.add_reagent(chem_buttons[chem], 10) //emag effect kicks in here so that the "intended" chem is used for all checks, for extra FUUU
- if(user)
- log_combat(user, occupant, "injected [chem] into", addition = "via [src]")
- return TRUE
-/obj/machinery/sleeper/proc/chem_allowed(chem)
+/obj/machinery/sleeper/proc/can_sedate()
var/mob/living/mob_occupant = occupant
if(!mob_occupant || !mob_occupant.reagents)
return
- var/amount = mob_occupant.reagents.get_reagent_amount(chem) + 10 <= 20 * efficiency
- var/occ_health = mob_occupant.health > min_health || chem == /datum/reagent/medicine/epinephrine
- return amount && occ_health
-
-/obj/machinery/sleeper/proc/reset_chem_buttons()
- scrambled_chems = FALSE
- LAZYINITLIST(chem_buttons)
- for(var/chem in available_chems)
- chem_buttons[chem] = chem
-
-/obj/machinery/sleeper/proc/scramble_chem_buttons()
- scrambled_chems = TRUE
- var/list/av_chem = available_chems.Copy()
- for(var/chem in av_chem)
- chem_buttons[chem] = pick_n_take(av_chem) //no dupes, allow for random buttons to still be correct
+ return mob_occupant.reagents.get_reagent_amount(/datum/reagent/medicine/morphine) + 10 <= 20
+/obj/machinery/sleeper/emag_act(mob/user)
+ to_chat(user, "You scramble the sleeper's user interface!")
/obj/machinery/sleeper/syndie
icon_state = "sleeper_s"
@@ -278,7 +322,9 @@
desc = "A large cryogenics unit built from brass. Its surface is pleasantly cool the touch."
icon_state = "sleeper_clockwork"
enter_message = "You hear the gentle hum and click of machinery, and are lulled into a sense of peace."
- possible_chems = list(list(/datum/reagent/medicine/epinephrine, /datum/reagent/medicine/salbutamol, /datum/reagent/medicine/bicaridine, /datum/reagent/medicine/kelotane, /datum/reagent/medicine/oculine, /datum/reagent/medicine/inacusiate, /datum/reagent/medicine/mannitol))
+ efficiency = 3
+ available_treatments = list(SLEEPER_TEND, SLEEPER_ORGANS, SLEEPER_CHEMPURGE)
+ stasis = TRUE
/obj/machinery/sleeper/clockwork/process()
if(occupant && isliving(occupant))
@@ -289,5 +335,13 @@
L.adjustFireLoss(-1)
L.adjustOxyLoss(-5)
+/obj/machinery/sleeper/clockwork/RefreshParts()
+ return
+
/obj/machinery/sleeper/old
icon_state = "oldpod"
+
+#undef SLEEPER_TEND
+#undef SLEEPER_ORGANS
+#undef SLEEPER_CHEMPURGE
+#undef SLEEPER_HEAL_RATE
diff --git a/tgui/packages/tgui/interfaces/Sleeper.js b/tgui/packages/tgui/interfaces/Sleeper.js
index a91a4e81c5bc..4ddbdff61412 100644
--- a/tgui/packages/tgui/interfaces/Sleeper.js
+++ b/tgui/packages/tgui/interfaces/Sleeper.js
@@ -10,9 +10,11 @@ export const Sleeper = (props, context) => {
open,
occupant = {},
occupied,
+ active_treatment,
+ can_sedate,
} = data;
- const chems = data.chems || [];
+ const treatments = data.treatments || [];
const damageTypes = [
{
@@ -86,7 +88,16 @@ export const Sleeper = (props, context) => {
)}
{!!occupied && (
-
+ act('sedate')} />
+ )} >
{occupant.reagents.map(reagent => (
{reagent.name} -
@@ -101,7 +112,7 @@ export const Sleeper = (props, context) => {
)}
{
content={open ? 'Open' : 'Closed'}
onClick={() => act('door')} />
)}>
- {chems.map(chem => (
+ {treatments.map(treatment => (