From 24bc5aaddec5ceb62b39041e78f5c020972395c8 Mon Sep 17 00:00:00 2001 From: Crazylemon Date: Fri, 23 Oct 2015 15:22:56 -0700 Subject: [PATCH 1/5] First test of the sleeper UI. This will probably summon 50 demons --- code/game/machinery/Sleeper.dm | 43 +++++++++++++- nano/templates/sleeper.tmpl | 104 +++++++++++++++++++++++++++++++++ 2 files changed, 144 insertions(+), 3 deletions(-) create mode 100644 nano/templates/sleeper.tmpl diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm index 2459e1cc121..58e700f94e6 100644 --- a/code/game/machinery/Sleeper.dm +++ b/code/game/machinery/Sleeper.dm @@ -7,6 +7,8 @@ icon = 'icons/obj/Cryogenic2.dmi' icon_state = "console" var/obj/machinery/sleeper/connected = null + var/ui_title = "Sleeper" + anchored = 1 //About time someone fixed this. density = 1 var/orient = "LEFT" @@ -165,6 +167,40 @@ onclose(user, "sleeper") return +/obj/machinery/sleep_console/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) + var/data[0] + var/mob/living/carbon/human/occupant = connected.occupant + data["hasOccupant"] = occupant ? 1 : 0 + var/occupantData[0] + if (occupant) + occupantData["name"] = occupant.name + occupantData["stat"] = occupant.stat + occupantData["health"] = occupant.health + occupantData["maxHealth"] = occupant.maxHealth + occupantData["minHealth"] = config.health_threshold_dead + occupantData["bruteLoss"] = occupant.getBruteLoss() + occupantData["oxyLoss"] = occupant.getOxyLoss() + occupantData["toxLoss"] = occupant.getToxLoss() + occupantData["fireLoss"] = occupant.getFireLoss() + occupantData["bodyTemperature"] = occupant.bodytemperature + data["occupant"] = occupantData + data["maxchem"] = connected.max_chem + data["minhealth"] = connected.min_health + + var/chemicals[0] + for (var/re in connected.injection_chems) + var/datum/reagent/temp = chemical_reagents_list[re] + if(temp) + chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("chemical" = temp.id), "occ_amount" = occupant.reagents.get_reagent_amount(temp)))) + data["chemicals"] = chemicals + + ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) + if (!ui) + // Test values for window size right now + ui = new(user, src, ui_key, "sleeper.tmpl", ui_title, 390, 655) + ui.set_initial_data(data) + ui.open() + /obj/machinery/sleep_console/Topic(href, href_list) if(..()) return 1 @@ -219,7 +255,7 @@ var/amounts = list(5, 10) var/obj/item/weapon/reagent_containers/glass/beaker = null var/filtering = 0 - var/efficiency + var/max_chem var/initial_bin_rating = 1 var/min_health = 25 var/injection_chems = list() @@ -271,7 +307,7 @@ I += M.rating injection_chems = possible_chems[I] - efficiency = E + max_chem = E * 20 min_health = -E * 25 /obj/machinery/sleeper/process() @@ -412,6 +448,7 @@ go_out() ..(severity) +// ??? /obj/machinery/sleeper/alter_health(mob/living/M as mob) if (M.health > 0) if (M.getOxyLoss() >= 10) @@ -449,7 +486,7 @@ /obj/machinery/sleeper/proc/inject_chemical(mob/living/user as mob, chemical, amount) if(src.occupant) if(src.occupant.reagents) - if(src.occupant.reagents.get_reagent_amount(chemical) + amount <= 20 * efficiency) + if(src.occupant.reagents.get_reagent_amount(chemical) + amount <= max_chem) src.occupant.reagents.add_reagent(chemical, amount) user << "Occupant now has [src.occupant.reagents.get_reagent_amount(chemical)] units of [chemical] in his/her bloodstream." return diff --git a/nano/templates/sleeper.tmpl b/nano/templates/sleeper.tmpl new file mode 100644 index 00000000000..d39309821b0 --- /dev/null +++ b/nano/templates/sleeper.tmpl @@ -0,0 +1,104 @@ + +

Sleeper Status

+ +
+ {{if !data.hasOccupant}} +
Sleeper Unoccupied
+ {{else}} +
+ {{:data.occupant.name}} =>  + {{if data.occupant.stat == 0}} + Conscious + {{else data.occupant.stat == 1}} + Unconscious + {{else}} + DEAD + {{/if}} +
+ + {{if data.occupant.stat < 2}} +
+
Health:
+ {{if data.occupant.health >= 0}} + {{:helper.displayBar(data.occupant.health, 0, data.occupant.maxHealth, 'good')}} + {{else}} + {{:helper.displayBar(data.occupant.health, 0, data.occupant.minHealth, 'average alignRight')}} + {{/if}} +
{{:helper.round(data.occupant.health)}}
+
+ +
+
=> Brute Damage:
+ {{:helper.displayBar(data.occupant.bruteLoss, 0, data.occupant.maxHealth, 'bad')}} +
{{:helper.round(data.occupant.bruteLoss)}}
+
+ +
+
=> Resp. Damage:
+ {{:helper.displayBar(data.occupant.oxyLoss, 0, data.occupant.maxHealth, 'bad')}} +
{{:helper.round(data.occupant.oxyLoss)}}
+
+ +
+
=> Toxin Damage:
+ {{:helper.displayBar(data.occupant.toxLoss, 0, data.occupant.maxHealth, 'bad')}} +
{{:helper.round(data.occupant.toxLoss)}}
+
+ +
+
=> Burn Severity:
+ {{:helper.displayBar(data.occupant.fireLoss, 0, data.occupant.maxHealth, 'bad')}} +
{{:helper.round(data.occupant.fireLoss)}}
+
+ {{/if}} + {{/if}} +
+ +

Sleeper Operation

+
+
+ Sleeper Status: +
+
+ {{:helper.link('Eject Occupant', 'arrowreturnthick-1-s', {'ejectify' : 1}, data.hasOccupant ? null : 'disabled')}} +
+
+
 
+
+
+ Beaker: +
+
+ {{if data.isBeakerLoaded}} + {{:data.beakerLabel ? data.beakerLabel : 'No label'}}
+ {{if data.beakerVolume}} + {{:data.beakerVolume}} units remaining
+ {{else}} + Beaker is empty + {{/if}} + {{else}} + No beaker loaded + {{/if}} +
+
+ {{:helper.link('Eject Beaker', 'eject', {'ejectBeaker' : 1}, data.isBeakerLoaded ? null : 'disabled')}} +
+
+
+ {{if data.hasOccupant}} +
+ Chemicals: +
+ {{for data.chemicals}} +  {{:value.title}} : + {{:helper.displayBar(value.occ_amount, 0, data.maxchem, 'good')}} +
{{:helper.round(value.occ_amount)}}/{{:data.maxchem}}
+
+ {{:helper.link('5', 'gear', {'chemical' : value.id, 'amount' : 5}, (value.occ_amount + 5 > data.maxchem) ? 'disabled' : null)}} + {{:helper.link('10', 'gear', {'chemical' : value.id, 'amount' : 10}, ((value.occ_amount + 10) > data.maxchem) ? 'disabled' : null)}} + {{/for}} + {{/if}} +
From 9e0e68a8b67167d44b1e841676eca972c8eb0a91 Mon Sep 17 00:00:00 2001 From: Crazylemon64 Date: Sun, 25 Oct 2015 10:35:39 -0700 Subject: [PATCH 2/5] Sleepers now use NanoUI Also cuts out a few points of weirdness; No dialysis on bloodless races like IPCs, and dialysis on simple_animals is no longer possible through the interface or through href twiddling, as that caused a runtime. Also, prevents href tweaking to dispense chemicals the sleeper doesn't have. --- code/game/machinery/Sleeper.dm | 99 +++++++++++++------ .../mob/living/carbon/human/human_defines.dm | 1 + code/modules/reagents/Chemistry-Readme.dm | 3 + .../modules/reagents/newchem/newchem_procs.dm | 8 ++ nano/templates/sleeper.tmpl | 81 +++++++++++---- 5 files changed, 140 insertions(+), 52 deletions(-) diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm index 58e700f94e6..bc7e13343e6 100644 --- a/code/game/machinery/Sleeper.dm +++ b/code/game/machinery/Sleeper.dm @@ -8,7 +8,7 @@ icon_state = "console" var/obj/machinery/sleeper/connected = null var/ui_title = "Sleeper" - + anchored = 1 //About time someone fixed this. density = 1 var/orient = "LEFT" @@ -41,10 +41,6 @@ /obj/machinery/sleep_console/RefreshParts() /obj/machinery/sleep_console/process() - if(stat & (NOPOWER|BROKEN)) - return - src.updateUsrDialog() - return /obj/machinery/sleep_console/ex_act(severity) switch(severity) @@ -118,6 +114,8 @@ findsleeper() if (src.connected) + ui_interact(user) + /* var/mob/living/occupant = src.connected.occupant var/dat = "Occupant Statistics:
" if (occupant) @@ -165,6 +163,7 @@ dat += text("

Close", user) user << browse(dat, "window=sleeper;size=400x500") onclose(user, "sleeper") + */ return /obj/machinery/sleep_console/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) @@ -172,6 +171,7 @@ var/mob/living/carbon/human/occupant = connected.occupant data["hasOccupant"] = occupant ? 1 : 0 var/occupantData[0] + var/crisis = 0 if (occupant) occupantData["name"] = occupant.name occupantData["stat"] = occupant.stat @@ -183,57 +183,87 @@ occupantData["toxLoss"] = occupant.getToxLoss() occupantData["fireLoss"] = occupant.getFireLoss() occupantData["bodyTemperature"] = occupant.bodytemperature + occupantData["paralysis"] = occupant.paralysis + occupantData["hasBlood"] = 0 + crisis = (occupant.health < connected.min_health) + // I'm not sure WHY you'd want to put a simple_animal in a sleeper, but precedent is precedent + // Runtime is aptly named, isn't she? + if (ishuman(occupant) && !(occupant.species.flags & NO_BLOOD) && occupant.vessel) + occupantData["hasBlood"] = 1 + occupantData["bloodLevel"] = round(occupant.vessel.get_reagent_amount("blood")) + occupantData["bloodMax"] = occupant.max_blood + occupantData["bloodPercent"] = round(100*(occupant.vessel.get_reagent_amount("blood")/occupant.max_blood), 0.01) + data["occupant"] = occupantData data["maxchem"] = connected.max_chem data["minhealth"] = connected.min_health + data["dialysis"] = connected.filtering + if (connected.beaker) + data["isBeakerLoaded"] = 1 + data["beakerFreeSpace"] = round(connected.beaker.reagents.maximum_volume - connected.beaker.reagents.total_volume) var/chemicals[0] for (var/re in connected.injection_chems) var/datum/reagent/temp = chemical_reagents_list[re] if(temp) - chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("chemical" = temp.id), "occ_amount" = occupant.reagents.get_reagent_amount(temp)))) + var/reagent_amount = 0 + var/pretty_amount + var/injectable = occupant ? 1 : 0 + var/overdosing = 0 + var/caution = 0 // To make things clear that you're coming close to an overdose + if (crisis && !(temp.id in connected.emergency_chems)) + injectable = 0 + + if (occupant && occupant.reagents) + reagent_amount = occupant.reagents.get_reagent_amount(temp.id) + // If they're mashing the highest concentration, they get one warning + if (temp.overdose_threshold && reagent_amount + 10 > temp.overdose_threshold) + caution = 1 + if (temp.id in occupant.reagents.overdose_list()) + overdosing = 1 + + // Because I don't know how to do this on the nano side + pretty_amount = round(reagent_amount, 0.1) + + chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("chemical" = temp.id), "occ_amount" = reagent_amount, "pretty_amount" = pretty_amount, "injectable" = injectable, "overdosing" = overdosing, "od_warning" = caution))) data["chemicals"] = chemicals ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open) if (!ui) - // Test values for window size right now - ui = new(user, src, ui_key, "sleeper.tmpl", ui_title, 390, 655) + ui = new(user, src, ui_key, "sleeper.tmpl", ui_title, 550, 655) ui.set_initial_data(data) ui.open() + ui.set_auto_update(1) /obj/machinery/sleep_console/Topic(href, href_list) + if(!connected | usr == connected.occupant) + return 0 + if(..()) return 1 if(panel_open) usr << "Close the maintenance panel first." - return 1 + return 0 if ((usr.contents.Find(src) || ((get_dist(src, usr) <= 1) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon/ai))) - usr.set_machine(src) if (href_list["chemical"]) if (src.connected) if (src.connected.occupant) if (src.connected.occupant.stat == DEAD) usr << "\red \b This person has no life for to preserve anymore. Take them to a department capable of reanimating them." - else if(src.connected.occupant.health > src.connected.min_health || href_list["chemical"] == "epinephrine") + else if(src.connected.occupant.health > src.connected.min_health || (href_list["chemical"] in connected.emergency_chems)) src.connected.inject_chemical(usr,href_list["chemical"],text2num(href_list["amount"])) else usr << "\red \b This person is not in good enough condition for sleepers to be effective! Use another means of treatment, such as cryogenics!" - src.updateUsrDialog() - if (href_list["refresh"]) - src.updateUsrDialog() if (href_list["removebeaker"]) src.connected.remove_beaker() - src.updateUsrDialog() if (href_list["togglefilter"]) src.connected.toggle_filter() - src.updateUsrDialog() if (href_list["ejectify"]) src.connected.eject() - src.updateUsrDialog() src.add_fingerprint(usr) - return + return 1 ///////////////////////////////////////// // THE SLEEPER ITSELF @@ -252,6 +282,7 @@ list("epinephrine", "ether", "salbutamol", "styptic_powder", "oculine"), list("epinephrine", "ether", "salbutamol", "styptic_powder", "oculine", "charcoal", "mutadone", "mannitol"), list("epinephrine", "ether", "salbutamol", "styptic_powder", "oculine", "charcoal", "mutadone", "mannitol", "pen_acid", "omnizine")) + var/emergency_chems = list("epinephrine") // Desnowflaking var/amounts = list(5, 10) var/obj/item/weapon/reagent_containers/glass/beaker = null var/filtering = 0 @@ -264,12 +295,12 @@ light_color = LIGHT_COLOR_CYAN - power_change() - ..() - if(!(stat & (BROKEN|NOPOWER))) - set_light(2) - else - set_light(0) +/obj/machinery/sleeper/power_change() + ..() + if(!(stat & (BROKEN|NOPOWER))) + set_light(2) + else + set_light(0) /obj/machinery/sleeper/New() ..() @@ -313,10 +344,14 @@ /obj/machinery/sleeper/process() if(filtering > 0) if(beaker) + // To prevent runtimes from drawing blood from runtime, and to prevent getting IPC blood. + if(!istype(occupant) || !occupant.dna || (occupant.species && occupant.species.flags & NO_BLOOD)) + filtering = 0 + return + if(beaker.reagents.total_volume < beaker.reagents.maximum_volume) src.occupant.vessel.trans_to(beaker, 1) for(var/datum/reagent/x in src.occupant.reagents.reagent_list) - // world << "FILTERING CHEMS" src.occupant.reagents.trans_to(beaker, 3) src.occupant.vessel.trans_to(beaker, 1) src.updateDialog() @@ -342,7 +377,6 @@ beaker = G G.forceMove(src) user.visible_message("[user] adds \a [G] to \the [src]!", "You add \a [G] to \the [src]!") - src.updateUsrDialog() return else @@ -484,11 +518,14 @@ return /obj/machinery/sleeper/proc/inject_chemical(mob/living/user as mob, chemical, amount) + if (!(chemical in injection_chems)) + user << "The sleeper does not offer that chemical!" + return + if(src.occupant) if(src.occupant.reagents) if(src.occupant.reagents.get_reagent_amount(chemical) + amount <= max_chem) src.occupant.reagents.add_reagent(chemical, amount) - user << "Occupant now has [src.occupant.reagents.get_reagent_amount(chemical)] units of [chemical] in his/her bloodstream." return else user << "You can not inject any more of this chemical." @@ -532,7 +569,7 @@ /obj/machinery/sleeper/verb/eject() set name = "Eject Sleeper" - set category = null + set category = "Object" set src in oview(1) if(usr.stat != 0) return @@ -543,7 +580,7 @@ /obj/machinery/sleeper/verb/remove_beaker() set name = "Remove Beaker" - set category = null + set category = "Object" set src in oview(1) if(usr.stat != 0) return @@ -557,7 +594,7 @@ /obj/machinery/sleeper/MouseDrop_T(atom/movable/O as mob|obj, mob/user as mob) if(O.loc == user) //no you can't pull things out of your ass return - if(user.restrained() || user.stat || user.weakened || user.stunned || user.paralysis || user.resting) //are you cuffed, dying, lying, stunned or other + if(user.incapacitated()) //are you cuffed, dying, lying, stunned or other return if(get_dist(user, src) > 1 || get_dist(user, O) > 1 || user.contents.Find(src)) // is the mob anchored, too far away from you, or are you too far away from the source return @@ -620,7 +657,7 @@ /obj/machinery/sleeper/verb/move_inside() set name = "Enter Sleeper" - set category = null + set category = "Object" set src in oview(1) if(usr.stat != 0 || !(ishuman(usr))) return diff --git a/code/modules/mob/living/carbon/human/human_defines.dm b/code/modules/mob/living/carbon/human/human_defines.dm index eb53f62a774..c6513be0799 100644 --- a/code/modules/mob/living/carbon/human/human_defines.dm +++ b/code/modules/mob/living/carbon/human/human_defines.dm @@ -73,6 +73,7 @@ var/mob/remoteview_target = null var/meatleft = 3 //For chef item var/decaylevel = 0 // For rotting bodies + var/max_blood = 560 // For stuff in the vessel var/slime_color = "blue" //For slime people this defines their color, it's blue by default to pay tribute to the old icons var/check_mutations=0 // Check mutations on next life tick diff --git a/code/modules/reagents/Chemistry-Readme.dm b/code/modules/reagents/Chemistry-Readme.dm index 77921d0ab07..61e2a0c82a0 100644 --- a/code/modules/reagents/Chemistry-Readme.dm +++ b/code/modules/reagents/Chemistry-Readme.dm @@ -98,6 +98,9 @@ About the Holder: Returns the amount of the matching reagent inside the holder. Returns 0 if the reagent is missing. + overdose_list() + Returns a list of all the chemical IDs in the reagent holder that are overdosing + Important variables: total_volume diff --git a/code/modules/reagents/newchem/newchem_procs.dm b/code/modules/reagents/newchem/newchem_procs.dm index b2d6edc0995..faf530f6b3e 100644 --- a/code/modules/reagents/newchem/newchem_procs.dm +++ b/code/modules/reagents/newchem/newchem_procs.dm @@ -82,6 +82,14 @@ datum/reagents/proc/metabolize(var/mob/M) addiction_tick++ update_total() +/datum/reagents/proc/overdose_list() + var/od_chems[0] + for(var/datum/reagent/R in reagent_list) + if(R.overdosed) + od_chems.Add(R.id) + return od_chems + + datum/reagents/proc/reagent_on_tick() for(var/datum/reagent/R in reagent_list) R.on_tick() diff --git a/nano/templates/sleeper.tmpl b/nano/templates/sleeper.tmpl index d39309821b0..6b480301393 100644 --- a/nano/templates/sleeper.tmpl +++ b/nano/templates/sleeper.tmpl @@ -19,13 +19,16 @@ Used In File(s): \code\game\machinery\Sleeper.dm {{/if}}
- {{if data.occupant.stat < 2}}
Health:
- {{if data.occupant.health >= 0}} + {{if data.occupant.health >= data.occupant.maxHealth}} {{:helper.displayBar(data.occupant.health, 0, data.occupant.maxHealth, 'good')}} - {{else}} + {{else data.occupant.health > 0}} + {{:helper.displayBar(data.occupant.health, 0, data.occupant.maxHealth, 'average')}} + {{else data.occupant.health >= data.minhealth}} {{:helper.displayBar(data.occupant.health, 0, data.occupant.minHealth, 'average alignRight')}} + {{else}} + {{:helper.displayBar(data.occupant.health, 0, data.occupant.minHealth, 'bad alignRight')}} {{/if}}
{{:helper.round(data.occupant.health)}}
@@ -53,7 +56,29 @@ Used In File(s): \code\game\machinery\Sleeper.dm {{:helper.displayBar(data.occupant.fireLoss, 0, data.occupant.maxHealth, 'bad')}}
{{:helper.round(data.occupant.fireLoss)}}
- {{/if}} + {{if data.occupant.hasBlood}} + +
+
+
Blood Level:
+ {{if data.occupant.bloodPercent <= 60}} + {{:helper.displayBar(data.occupant.bloodLevel, 0, data.occupant.bloodMax, 'bad')}} +
+ {{:data.occupant.bloodPercent}}%, {{:data.occupant.bloodLevel}}cl +
+ {{else data.occupant.bloodPercent <= 90}} + {{:helper.displayBar(data.occupant.bloodLevel, 0, data.occupant.bloodMax, 'average')}} +
+ {{:data.occupant.bloodPercent}}%, {{:data.occupant.bloodLevel}}cl +
+ {{else}} + {{:helper.displayBar(data.occupant.bloodLevel, 0, data.occupant.bloodMax, 'good')}} +
+ {{:data.occupant.bloodPercent}}%, {{:data.occupant.bloodLevel}}cl +
+ {{/if}} +
+ {{/if}} {{/if}} @@ -69,36 +94,50 @@ Used In File(s): \code\game\machinery\Sleeper.dm
 
- Beaker: + Dialysis Beaker:
- {{if data.isBeakerLoaded}} - {{:data.beakerLabel ? data.beakerLabel : 'No label'}}
- {{if data.beakerVolume}} - {{:data.beakerVolume}} units remaining
- {{else}} - Beaker is empty - {{/if}} + {{if data.isBeakerLoaded}} + {{:helper.round(data.beakerFreeSpace)}} units of space remaining
{{else}} - No beaker loaded + No Dialysis Output Beaker Loaded {{/if}}
- {{:helper.link('Eject Beaker', 'eject', {'ejectBeaker' : 1}, data.isBeakerLoaded ? null : 'disabled')}} + {{:helper.link('Eject Beaker', 'eject', {'removebeaker' : 1}, data.isBeakerLoaded ? null : 'disabled')}} + {{if data.isBeakerLoaded}} +
+
+ {{:helper.link('On', 'power', {'togglefilter' : 1}, data.occupant.hasBlood ? (data.dialysis ? 'selected' : null) : 'disabled')}}{{:helper.link('Off', 'close', {'togglefilter' : 1}, data.dialysis ? null : 'selected')}} +
+
+ {{/if}}
- {{if data.hasOccupant}}
Chemicals:
+ {{for data.chemicals}} -  {{:value.title}} : +
+ {{:value.title}}: + {{if value.overdosing}} + {{:helper.displayBar(value.occ_amount, 0, data.maxchem, 'bad')}} + {{else value.od_warning}} + {{:helper.displayBar(value.occ_amount, 0, data.maxchem, 'average')}} + {{else}} {{:helper.displayBar(value.occ_amount, 0, data.maxchem, 'good')}} -
{{:helper.round(value.occ_amount)}}/{{:data.maxchem}}
-
- {{:helper.link('5', 'gear', {'chemical' : value.id, 'amount' : 5}, (value.occ_amount + 5 > data.maxchem) ? 'disabled' : null)}} - {{:helper.link('10', 'gear', {'chemical' : value.id, 'amount' : 10}, ((value.occ_amount + 10) > data.maxchem) ? 'disabled' : null)}} + {{/if}} +
{{:value.pretty_amount}}/{{:data.maxchem}}
+
+
+
+ {{:helper.link('5', 'gear', {'chemical' : value.id, 'amount' : 5}, (!value.injectable || ((value.occ_amount + 5) > data.maxchem)) ? 'disabled' : null)}} + {{:helper.link('10', 'gear', {'chemical' : value.id, 'amount' : 10}, (!value.injectable || ((value.occ_amount + 10) > data.maxchem)) ? 'disabled' : null)}} +
+
{{/for}} - {{/if}}
+ From a2669d6791c324f4c768effffbc86d941ea5d65e Mon Sep 17 00:00:00 2001 From: Crazylemon64 Date: Sun, 25 Oct 2015 14:09:03 -0700 Subject: [PATCH 3/5] Sleeper now has a temperature and pulse readout --- code/game/machinery/Sleeper.dm | 87 +++++++++++++--------------------- nano/css/shared.css | 25 ++++++++++ nano/templates/sleeper.tmpl | 58 +++++++++++++++++++++++ 3 files changed, 117 insertions(+), 53 deletions(-) diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm index bc7e13343e6..3d645492681 100644 --- a/code/game/machinery/Sleeper.dm +++ b/code/game/machinery/Sleeper.dm @@ -115,56 +115,6 @@ if (src.connected) ui_interact(user) - /* - var/mob/living/occupant = src.connected.occupant - var/dat = "Occupant Statistics:
" - if (occupant) - var/t1 - switch(occupant.stat) - if(0) - t1 = "Conscious" - if(1) - t1 = "Unconscious" - if(2) - t1 = "*dead*" - else - dat += text("[]\tHealth %: [] ([])
", (occupant.health > 50 ? "" : ""), occupant.health, t1) - if(iscarbon(occupant)) - var/mob/living/carbon/C = occupant - dat += text("[]\t-Pulse, bpm: []
", (C.pulse == PULSE_NONE || C.pulse == PULSE_THREADY ? "" : ""), C.get_pulse(GETPULSE_TOOL)) - dat += text("[]\t-Brute Damage %: []
", (occupant.getBruteLoss() < 60 ? "" : ""), occupant.getBruteLoss()) - dat += text("[]\t-Respiratory Damage %: []
", (occupant.getOxyLoss() < 60 ? "" : ""), occupant.getOxyLoss()) - dat += text("[]\t-Toxin Content %: []
", (occupant.getToxLoss() < 60 ? "" : ""), occupant.getToxLoss()) - dat += text("[]\t-Burn Severity %: []
", (occupant.getFireLoss() < 60 ? "" : ""), occupant.getFireLoss()) - dat += text("
Paralysis Summary %: [] ([] seconds left!)
", occupant.paralysis, round(occupant.paralysis / 4)) - if(occupant.reagents) - for(var/chemical in connected.injection_chems) - var/datum/reagent/C = chemical_reagents_list[chemical] - dat += "[C.name]: [occupant.reagents.get_reagent_amount(chemical)] units
" - dat += "Refresh Meter Readings
" - if(src.connected.beaker) - dat += "
Remove Beaker
" - if(src.connected.filtering) - dat += "Stop Dialysis
" - dat += text("Output Beaker has [] units of free space remaining

", src.connected.beaker.reagents.maximum_volume - src.connected.beaker.reagents.total_volume) - else - dat += "
Start Dialysis
" - dat += text("Output Beaker has [] units of free space remaining

", src.connected.beaker.reagents.maximum_volume - src.connected.beaker.reagents.total_volume) - else - dat += "
No Dialysis Output Beaker is present.

" - for(var/chemical in connected.injection_chems) - var/datum/reagent/C = chemical_reagents_list[chemical] - dat += "Inject [C.name]: " - for(var/amount in connected.amounts) - dat += "[amount] units
" - dat += "
Eject Patient" - else - dat += "The sleeper is empty." - dat += text("

Close", user) - user << browse(dat, "window=sleeper;size=400x500") - onclose(user, "sleeper") - */ - return /obj/machinery/sleep_console/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1) var/data[0] @@ -182,13 +132,44 @@ occupantData["oxyLoss"] = occupant.getOxyLoss() occupantData["toxLoss"] = occupant.getToxLoss() occupantData["fireLoss"] = occupant.getFireLoss() - occupantData["bodyTemperature"] = occupant.bodytemperature occupantData["paralysis"] = occupant.paralysis occupantData["hasBlood"] = 0 + occupantData["bodyTemperature"] = occupant.bodytemperature + occupantData["maxTemp"] = 1000 // If you get a burning vox armalis into the sleeper, congratulations + // Because we can put simple_animals in here, we need to do something tricky to get things working nice + occupantData["temperatureSuitability"] = 0 // 0 is the baseline + if (ishuman(occupant) && occupant.species) + // I wanna do something where the bar gets bluer as the temperature gets lower + // For now, I'll just use the standard format for the temperature status + var/datum/species/sp = occupant.species + if (occupant.bodytemperature < sp.cold_level_3) + occupantData["temperatureSuitability"] = -3 + else if (occupant.bodytemperature < sp.cold_level_2) + occupantData["temperatureSuitability"] = -2 + else if (occupant.bodytemperature < sp.cold_level_1) + occupantData["temperatureSuitability"] = -1 + else if (occupant.bodytemperature > sp.heat_level_3) + occupantData["temperatureSuitability"] = 3 + else if (occupant.bodytemperature > sp.heat_level_2) + occupantData["temperatureSuitability"] = 2 + else if (occupant.bodytemperature > sp.heat_level_1) + occupantData["temperatureSuitability"] = 1 + else if (istype(occupant, /mob/living/simple_animal)) + var/mob/living/simple_animal/silly = occupant + if (silly.bodytemperature < silly.minbodytemp) + occupantData["temperatureSuitability"] = -3 + else if (silly.bodytemperature > silly.maxbodytemp) + occupantData["temperatureSuitability"] = 3 + // Blast you, imperial measurement system + occupantData["btCelsius"] = occupant.bodytemperature - T0C + occupantData["btFaren"] = ((occupant.bodytemperature - T0C) * (9.0/5.0))+ 32 + + crisis = (occupant.health < connected.min_health) // I'm not sure WHY you'd want to put a simple_animal in a sleeper, but precedent is precedent // Runtime is aptly named, isn't she? - if (ishuman(occupant) && !(occupant.species.flags & NO_BLOOD) && occupant.vessel) + if (ishuman(occupant) && occupant.vessel && !(occupant.species && occupant.species.flags & NO_BLOOD)) + occupantData["pulse"] = occupant.get_pulse(GETPULSE_TOOL) occupantData["hasBlood"] = 1 occupantData["bloodLevel"] = round(occupant.vessel.get_reagent_amount("blood")) occupantData["bloodMax"] = occupant.max_blood @@ -223,7 +204,7 @@ overdosing = 1 // Because I don't know how to do this on the nano side - pretty_amount = round(reagent_amount, 0.1) + pretty_amount = round(reagent_amount, 0.05) chemicals.Add(list(list("title" = temp.name, "id" = temp.id, "commands" = list("chemical" = temp.id), "occ_amount" = reagent_amount, "pretty_amount" = pretty_amount, "injectable" = injectable, "overdosing" = overdosing, "od_warning" = caution))) data["chemicals"] = chemicals diff --git a/nano/css/shared.css b/nano/css/shared.css index 786b577e615..b9ceac02814 100644 --- a/nano/css/shared.css +++ b/nano/css/shared.css @@ -606,4 +606,29 @@ th.misc { .Pearl { color: #C6CACB; +} + +/* Status bar colors for sleeper temperatures */ +.cold1 { + color: #94B8FF; +} + +.cold2 { + color: #6699FF; +} + +.cold3 { + color: #293D66; +} + +.hot1 { + color: #FF9966; +} + +.hot2 { + color: #993D00; +} + +.hot3 { + color: #FF6600; } \ No newline at end of file diff --git a/nano/templates/sleeper.tmpl b/nano/templates/sleeper.tmpl index 6b480301393..efe73830ea9 100644 --- a/nano/templates/sleeper.tmpl +++ b/nano/templates/sleeper.tmpl @@ -56,9 +56,67 @@ Used In File(s): \code\game\machinery\Sleeper.dm {{:helper.displayBar(data.occupant.fireLoss, 0, data.occupant.maxHealth, 'bad')}}
{{:helper.round(data.occupant.fireLoss)}}
+ +
+
+ +
Patient Temperature:
+ {{if data.occupant.temperatureSuitability == -3}} + {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'bad')}} +
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+ {{else data.occupant.temperatureSuitability == -2}} + {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'average')}} +
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+ {{else data.occupant.temperatureSuitability == -1}} + {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'average')}} +
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+ {{else data.occupant.temperatureSuitability == 0}} + {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'good')}} +
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+ {{else data.occupant.temperatureSuitability == 1}} + {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'average')}} +
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+ {{else data.occupant.temperatureSuitability == 2}} + {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'average')}} +
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+ {{else data.occupant.temperatureSuitability == 3}} + {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'bad')}} +
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+ {{/if}} +
+ + {{if data.occupant.hasBlood}}
+
+
Pulse:
{{:data.occupant.pulse}} bpm
+
Blood Level:
{{if data.occupant.bloodPercent <= 60}} From f822d37f63e06727fc605efc398e724fc3d73562 Mon Sep 17 00:00:00 2001 From: Crazylemon Date: Sun, 25 Oct 2015 20:54:47 -0700 Subject: [PATCH 4/5] I like spans! I hate old crusty unused functions that use text()! --- code/game/machinery/Sleeper.dm | 63 +++++++++------------------------- 1 file changed, 17 insertions(+), 46 deletions(-) diff --git a/code/game/machinery/Sleeper.dm b/code/game/machinery/Sleeper.dm index 3d645492681..0035170d4dd 100644 --- a/code/game/machinery/Sleeper.dm +++ b/code/game/machinery/Sleeper.dm @@ -232,11 +232,11 @@ if (src.connected) if (src.connected.occupant) if (src.connected.occupant.stat == DEAD) - usr << "\red \b This person has no life for to preserve anymore. Take them to a department capable of reanimating them." + usr << "This person has no life for to preserve anymore. Take them to a department capable of reanimating them." else if(src.connected.occupant.health > src.connected.min_health || (href_list["chemical"] in connected.emergency_chems)) src.connected.inject_chemical(usr,href_list["chemical"],text2num(href_list["amount"])) else - usr << "\red \b This person is not in good enough condition for sleepers to be effective! Use another means of treatment, such as cryogenics!" + usr << "This person is not in good enough condition for sleepers to be effective! Use another means of treatment, such as cryogenics!" if (href_list["removebeaker"]) src.connected.remove_beaker() if (href_list["togglefilter"]) @@ -269,7 +269,7 @@ var/filtering = 0 var/max_chem var/initial_bin_rating = 1 - var/min_health = 25 + var/min_health = -25 var/injection_chems = list() idle_power_usage = 1250 active_power_usage = 2500 @@ -361,7 +361,7 @@ return else - user << "\red The sleeper has a beaker already." + user << "The sleeper has a beaker already." return if (istype(G, /obj/item/weapon/screwdriver)) @@ -393,12 +393,12 @@ if(istype(G, /obj/item/weapon/grab)) if(panel_open) - user << "\blue Close the maintenance panel first." + user << "Close the maintenance panel first." return if(!ismob(G:affecting)) return if(src.occupant) - user << "\blue The sleeper is already occupied!" + user << "The sleeper is already occupied!" return for(var/mob/living/carbon/slime/M in range(1,G:affecting)) if(M.Victim == G:affecting) @@ -409,7 +409,7 @@ if(do_after(user, 20, target = G:affecting)) if(src.occupant) - user << "\blue The sleeper is already occupied!" + user << "The sleeper is already occupied!" return if(!G || !G:affecting) return var/mob/M = G:affecting @@ -419,7 +419,7 @@ M.forceMove(src) src.occupant = M src.icon_state = "sleeper" - M << "\blue You feel cool air surround you. You go numb as your senses turn inward." + M << "You feel cool air surround you. You go numb as your senses turn inward." src.add_fingerprint(user) qdel(G) @@ -464,6 +464,7 @@ ..(severity) // ??? +// This looks cool, although mildly broken, should it be included again? /obj/machinery/sleeper/alter_health(mob/living/M as mob) if (M.health > 0) if (M.getOxyLoss() >= 10) @@ -518,36 +519,6 @@ user << "There's no occupant in the sleeper!" return - -/obj/machinery/sleeper/proc/check(mob/living/user as mob) - if(src.occupant) - user << text("\blue Occupant ([]) Statistics:", src.occupant) - var/t1 - switch(src.occupant.stat) - if(0.0) - t1 = "Conscious" - if(1.0) - t1 = "Unconscious" - if(2.0) - t1 = "*dead*" - else - user << text("[]\t Health %: [] ([])", (src.occupant.health > 50 ? "\blue " : "\red "), src.occupant.health, t1) - user << text("[]\t -Core Temperature: []°C ([]°F)

", (src.occupant.bodytemperature > 50 ? "" : ""), src.occupant.bodytemperature-T0C, src.occupant.bodytemperature*1.8-459.67) - user << text("[]\t -Brute Damage %: []", (src.occupant.getBruteLoss() < 60 ? "\blue " : "\red "), src.occupant.getBruteLoss()) - user << text("[]\t -Respiratory Damage %: []", (src.occupant.getOxyLoss() < 60 ? "\blue " : "\red "), src.occupant.getOxyLoss()) - user << text("[]\t -Toxin Content %: []", (src.occupant.getToxLoss() < 60 ? "\blue " : "\red "), src.occupant.getToxLoss()) - user << text("[]\t -Burn Severity %: []", (src.occupant.getFireLoss() < 60 ? "\blue " : "\red "), src.occupant.getFireLoss()) - user << "\blue Expected time till occupant can safely awake: (note: If health is below 20% these times are inaccurate)" - user << text("\blue \t [] second\s (if around 1 or 2 the sleeper is keeping them asleep.)", src.occupant.paralysis / 5) - if(src.beaker) - user << text("\blue \t Dialysis Output Beaker has [] of free space remaining.", src.beaker.reagents.maximum_volume - src.beaker.reagents.total_volume) - else - user << "\blue No Dialysis Output Beaker loaded." - else - user << "\blue There is no one inside!" - return - - /obj/machinery/sleeper/verb/eject() set name = "Eject Sleeper" set category = "Object" @@ -590,10 +561,10 @@ if(!istype(user.loc, /turf) || !istype(O.loc, /turf)) // are you in a container/closet/pod/etc? return if(panel_open) - user << "\blue Close the maintenance panel first." + user << "Close the maintenance panel first." return if(occupant) - user << "\blue The sleeper is already occupied!" + user << "The sleeper is already occupied!" return /* if(isrobot(user)) if(!istype(user:module, /obj/item/weapon/robot_module/medical)) @@ -603,7 +574,7 @@ if(!istype(L) || L.buckled) return if(L.abiotic()) - user << "\blue Subject cannot have abiotic items on." + user << "Subject cannot have abiotic items on." return for(var/mob/living/carbon/slime/M in range(1,L)) if(M.Victim == L) @@ -616,7 +587,7 @@ if(do_after(user, 20, target = L)) if(src.occupant) - user << "\blue The sleeper is already occupied!" + user << ">The sleeper is already occupied!" return if(!L) return @@ -626,7 +597,7 @@ L.forceMove(src) src.occupant = L src.icon_state = "sleeper" - L << "\blue You feel cool air surround you. You go numb as your senses turn inward." + L << "You feel cool air surround you. You go numb as your senses turn inward." src.add_fingerprint(user) if(user.pulling == L) user.pulling = null @@ -643,10 +614,10 @@ if(usr.stat != 0 || !(ishuman(usr))) return if(src.occupant) - usr << "\blue The sleeper is already occupied!" + usr << "The sleeper is already occupied!" return if (panel_open) - usr << "\blue Close the maintenance panel first." + usr << "Close the maintenance panel first." return if(usr.restrained() || usr.stat || usr.weakened || usr.stunned || usr.paralysis || usr.resting) //are you cuffed, dying, lying, stunned or other return @@ -657,7 +628,7 @@ visible_message("[usr] starts climbing into the sleeper.") if(do_after(usr, 20, target = usr)) if(src.occupant) - usr << "\blue The sleeper is already occupied!" + usr << "The sleeper is already occupied!" return usr.stop_pulling() usr.client.perspective = EYE_PERSPECTIVE From a78d8a00442b00ec23deeaba7ed7f07e7bfaead9 Mon Sep 17 00:00:00 2001 From: Crazylemon Date: Sun, 25 Oct 2015 23:26:00 -0700 Subject: [PATCH 5/5] Sleeper now has fancy little degree symbols for temperature --- nano/templates/sleeper.tmpl | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/nano/templates/sleeper.tmpl b/nano/templates/sleeper.tmpl index efe73830ea9..8cd59a4e4b9 100644 --- a/nano/templates/sleeper.tmpl +++ b/nano/templates/sleeper.tmpl @@ -63,50 +63,50 @@ Used In File(s): \code\game\machinery\Sleeper.dm
Patient Temperature:
{{if data.occupant.temperatureSuitability == -3}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'cold3')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == -2}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'cold2')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == -1}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'cold1')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == 0}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'good')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == 1}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'hot1')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == 2}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'hot2')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == 3}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'hot3')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{/if}} If you can get the changing temperature bars to work right, congratulations -->
Patient Temperature:
{{if data.occupant.temperatureSuitability == -3}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'bad')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == -2}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'average')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == -1}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'average')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == 0}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'good')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == 1}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'average')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == 2}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'average')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{else data.occupant.temperatureSuitability == 3}} {{:helper.displayBar(data.occupant.bodyTemperature, 0, data.occupant.maxTemp, 'bad')}} -
{{:helper.round(data.occupant.btCelsius)}}C, {{:helper.round(data.occupant.btFaren)}}F
+
{{:helper.round(data.occupant.btCelsius)}}°C, {{:helper.round(data.occupant.btFaren)}}°F
{{/if}}