From 6f74ae32d3ea2fb96a927f9d5b38121089c390d3 Mon Sep 17 00:00:00 2001 From: CRUNCH <143041327+Fordoxia@users.noreply.github.com> Date: Tue, 2 Jul 2024 00:20:19 +0100 Subject: [PATCH] Cleans up and Slightly Tweaks Health Analyser Code, Makes T-Ray \improper (#25788) * Update scanners.dm * Update scanners.dm * Update scanners.dm * Update scanners.dm * Update code/game/objects/items/devices/scanners.dm Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> Signed-off-by: CRUNCH <143041327+Fordoxia@users.noreply.github.com> * Update code/game/objects/items/devices/scanners.dm Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> Signed-off-by: CRUNCH <143041327+Fordoxia@users.noreply.github.com> * Update scanners.dm * Update scanners.dm * Apply suggestions from code review Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com> Signed-off-by: CRUNCH <143041327+Fordoxia@users.noreply.github.com> --------- Signed-off-by: CRUNCH <143041327+Fordoxia@users.noreply.github.com> Co-authored-by: Ryan <80364400+Sirryan2002@users.noreply.github.com> Co-authored-by: Luc <89928798+lewcc@users.noreply.github.com> --- code/game/objects/items/devices/scanners.dm | 167 +++++++++++--------- 1 file changed, 94 insertions(+), 73 deletions(-) diff --git a/code/game/objects/items/devices/scanners.dm b/code/game/objects/items/devices/scanners.dm index 13cd0522d61..906ac9501ac 100644 --- a/code/game/objects/items/devices/scanners.dm +++ b/code/game/objects/items/devices/scanners.dm @@ -9,12 +9,11 @@ BODY SCANNERS SLIME SCANNER */ -/******************************/ -/*** T-RAY SCANNER ***/ -/******************************/ - +//////////////////////////////////////// +// MARK: T-ray scanner +//////////////////////////////////////// /obj/item/t_scanner - name = "T-ray scanner" + name = "\improper T-ray scanner" desc = "A terahertz-ray emitter and scanner used to detect underfloor objects such as cables and pipes." icon = 'icons/obj/device.dmi' icon_state = "t-ray0" @@ -71,25 +70,29 @@ SLIME SCANNER if(length(t_ray_images)) flick_overlay(t_ray_images, list(viewer.client), flick_time) -/******************************/ -/*** HEALTH ANALYZER ***/ -/******************************/ +//////////////////////////////////////// +// MARK: Health analyser +//////////////////////////////////////// +#define SIMPLE_HEALTH_SCAN 0 +#define DETAILED_HEALTH_SCAN 1 /proc/get_chemscan_results(mob/living/user, mob/living/M) var/msgs = list() - if(ishuman(M)) - var/mob/living/carbon/human/H = M - if(H.reagents) - if(length(H.reagents.reagent_list)) - msgs += "Subject contains the following reagents:" - for(var/datum/reagent/R in H.reagents.reagent_list) - msgs += "[R.volume]u of [R.name][R.overdosed ? " - OVERDOSING" : "."]" - else - msgs += "Subject contains no reagents." - if(length(H.reagents.addiction_list)) - msgs += "Subject is addicted to the following reagents:" - for(var/datum/reagent/R in H.reagents.addiction_list) - msgs += "[R.name] Stage: [R.addiction_stage]/5" + if(!ishuman(M)) + return + + var/mob/living/carbon/human/H = M + if(length(H.reagents.reagent_list)) + msgs += "Subject contains the following reagents:" + for(var/datum/reagent/R in H.reagents.reagent_list) + msgs += "[R.volume]u of [R.name][R.overdosed ? " - OVERDOSING" : "."]" + else + msgs += "Subject contains no reagents." + + if(length(H.reagents.addiction_list)) + msgs += "Subject is addicted to the following reagents:" + for(var/datum/reagent/R in H.reagents.addiction_list) + msgs += "[R.name] Stage: [R.addiction_stage]/5" return msgs @@ -113,12 +116,22 @@ SLIME SCANNER throw_range = 7 materials = list(MAT_METAL=200) origin_tech = "magnets=1;biotech=1" - var/mode = 1 + /// Can be SIMPLE_HEALTH_SCAN (damage is only shown as a single % value), or DETAILED_HEALTH_SCAN (shows the % value and also damage for every specific limb). + var/mode = DETAILED_HEALTH_SCAN + /// Is the health analyzer upgraded? Allows reagents in the body to be seen. var/advanced = FALSE /obj/item/healthanalyzer/examine(mob/user) . = ..() - . += "Use [src] in hand to swap between showing specific limb damage." + . += "Use [src] in hand to toggle showing localised damage." + +/obj/item/healthanalyzer/attack_self(mob/user) + mode = !mode + switch(mode) + if(DETAILED_HEALTH_SCAN) + to_chat(user, "The scanner is now showing localised limb damage.") + if(SIMPLE_HEALTH_SCAN) + to_chat(user, "The scanner is no longer showing localised limb damage.") /obj/item/healthanalyzer/attack(mob/living/M, mob/living/user) if((HAS_TRAIT(user, TRAIT_CLUMSY) || user.getBrainLoss() >= 60) && prob(50)) @@ -131,26 +144,28 @@ SLIME SCANNER to_chat(user, chat_box_healthscan(msgs.Join("
"))) return - user.visible_message("[user] analyzes [M]'s vitals.", "You analyze [M]'s vitals.") - + user.visible_message( + "[user] analyzes [M]'s vitals.", + "You analyze [M]'s vitals." + ) healthscan(user, M, mode, advanced) - add_fingerprint(user) -// Used by the PDA medical scanner too -/proc/healthscan(mob/user, mob/living/M, mode = 1, advanced = FALSE) +// Used by the PDA medical scanner too. +/proc/healthscan(mob/user, mob/living/M, mode = DETAILED_HEALTH_SCAN, advanced = FALSE) var/list/msgs = list() if(issimple_animal(M)) - // no box here, keep it simple. + // No box here, keep it simple. if(M.stat == DEAD) to_chat(user, "Analyzing Results for [M]:\nOverall Status: Dead") - else - to_chat(user, "Analyzing Results for [M]:\nOverall Status: [round(M.health / M.maxHealth * 100, 0.1)]% Healthy") + return + + to_chat(user, "Analyzing Results for [M]:\nOverall Status: [round(M.health / M.maxHealth * 100, 0.1)]% Healthy") to_chat(user, "\t Damage Specifics: [M.maxHealth - M.health]") return - if(!ishuman(M) || ismachineperson(M)) - //these sensors are designed for organic life + // These sensors are designed for organic life. + if(!ishuman(M) || ismachineperson(M)) msgs += "Analyzing Results for ERROR:\nOverall Status: ERROR" msgs += "Key: Suffocation/Toxin/Burns/Brute" msgs += "Damage Specifics: ? - ? - ? - ?" @@ -171,7 +186,7 @@ SLIME SCANNER var/DNR = !H.ghost_can_reenter() // If the ghost can't reenter if(H.stat == DEAD) if(DNR) - status = "Dead \[DNR]" + status = "Dead (DNR)" else // Alive or unconscious if(HAS_TRAIT(H, TRAIT_FAKEDEATH)) // status still shows as "Dead" OX = fake_oxy > 50 ? "[fake_oxy]" : fake_oxy @@ -181,15 +196,16 @@ SLIME SCANNER msgs += "Analyzing Results for [H]:\nOverall Status: [status]" msgs += "Key: Suffocation/Toxin/Burns/Brute" msgs += "Damage Specifics: [OX] - [TX] - [BU] - [BR]" + if(H.timeofdeath && (H.stat == DEAD || (HAS_TRAIT(H, TRAIT_FAKEDEATH)))) msgs += "Time of Death: [station_time_timestamp("hh:mm:ss", H.timeofdeath)]" var/tdelta = round(world.time - H.timeofdeath) if(H.is_revivable() && !DNR) msgs += "Subject died [DisplayTimeText(tdelta)] ago, defibrillation may be possible!" else - msgs += "Subject died [DisplayTimeText(tdelta)] ago." + msgs += "Subject died [DisplayTimeText(tdelta)] ago. Defibrillation is not possible!" - if(mode == 1) + if(mode == DETAILED_HEALTH_SCAN) var/list/damaged = H.get_damaged_organs(1,1) if(length(damaged)) msgs += "Localized Damage, Brute/Burn:" @@ -198,6 +214,7 @@ SLIME SCANNER if(advanced) msgs.Add(get_chemscan_results(user, H)) + for(var/thing in H.viruses) var/datum/disease/D = thing if(D.visibility_flags & HIDDEN_SCANNER) @@ -207,6 +224,7 @@ SLIME SCANNER msgs += "Warning: Subject is undergoing [D.name].\nStage: [D.stage]/[D.max_stages].\nPossible Cure: [D.cure_text]" continue msgs += "Warning: [D.form] detected\nName: [D.name].\nType: [D.spread_text].\nStage: [D.stage]/[D.max_stages].\nPossible Cure: [D.cure_text]" + if(H.undergoing_cardiac_arrest()) var/datum/organ/heart/heart = H.get_int_organ_datum(ORGAN_DATUM_HEART) if(heart && !(heart.linked_organ.status & ORGAN_DEAD)) @@ -218,9 +236,11 @@ SLIME SCANNER if(H.getStaminaLoss()) msgs += "Subject appears to be suffering from fatigue." + if(H.getCloneLoss()) msgs += "Subject appears to have [H.getCloneLoss() > 30 ? "severe" : "minor"] cellular damage." + // Brain. if(H.get_int_organ(/obj/item/organ/internal/brain)) if(H.getBrainLoss() >= 100) msgs += "Subject is brain dead." @@ -230,6 +250,8 @@ SLIME SCANNER msgs += "Significant brain damage detected. Subject may have had a concussion." else msgs += "Subject has no brain." + + // Broken bones, internal bleeding, infection, and critical burns. var/broken_bone = FALSE var/internal_bleed = FALSE var/burn_wound = FALSE @@ -253,6 +275,7 @@ SLIME SCANNER if(burn_wound) msgs += "Critical burn detected. Examine patient's body for location." + // Blood. var/blood_id = H.get_blood_id() if(blood_id) if(H.bleed_rate) @@ -279,10 +302,12 @@ SLIME SCANNER var/implant_detect for(var/obj/item/organ/internal/O in H.internal_organs) if(O.is_robotic() && !O.stealth_level) - implant_detect += "[H.name] is modified with a [O.name].
" + implant_detect += "[O.name].
" if(implant_detect) msgs += "Detected cybernetic modifications:" msgs += "[implant_detect]" + + // Do you have too many genetics superpowers? if(H.gene_stability < 40) msgs += "Subject's genes are quickly breaking down!" else if(H.gene_stability < 70) @@ -298,27 +323,23 @@ SLIME SCANNER to_chat(user, chat_box_healthscan(msgs.Join("
"))) -/obj/item/healthanalyzer/attack_self(mob/user) - mode = !mode - switch(mode) - if(1) - to_chat(user, "The scanner now shows specific limb damage.") - if(0) - to_chat(user, "The scanner no longer shows limb damage.") - /obj/item/healthanalyzer/attackby(obj/item/I, mob/user, params) - if(istype(I, /obj/item/healthupgrade)) - if(advanced) - to_chat(user, "An upgrade is already installed on [src].") - else - if(user.unEquip(I)) - to_chat(user, "You install the upgrade on [src].") - add_overlay("advanced") - playsound(loc, I.usesound, 50, 1) - advanced = TRUE - qdel(I) + if(!istype(I, /obj/item/healthupgrade)) + return ..() + + if(advanced) + to_chat(user, "An upgrade is already installed on [src].") return - return ..() + + if(!user.unEquip(I)) + to_chat(user, "[src] is stuck to your hand!") + return + + to_chat(user, "You install the upgrade on [src].") + add_overlay("advanced") + playsound(loc, I.usesound, 50, TRUE) + advanced = TRUE + qdel(I) /obj/item/healthanalyzer/advanced name = "advanced health analyzer" @@ -338,10 +359,12 @@ SLIME SCANNER origin_tech = "magnets=2;biotech=2" usesound = 'sound/items/deconstruct.ogg' -/******************************/ -/*** MACHINE ANALYZER ***/ -/******************************/ +#undef SIMPLE_HEALTH_SCAN +#undef DETAILED_HEALTH_SCAN +//////////////////////////////////////// +// MARK: Machine analyzer +//////////////////////////////////////// /obj/item/robotanalyzer name = "machine analyzer" desc = "A hand-held scanner able to diagnose robotic injuries and the condition of machinery." @@ -485,10 +508,9 @@ SLIME SCANNER to_chat(user, chat_box_healthscan(msgs.Join("
"))) -/******************************/ -/*** GAS ANALYZER ***/ -/******************************/ - +//////////////////////////////////////// +// MARK: Gas analyzer +//////////////////////////////////////// /obj/item/analyzer name = "analyzer" desc = "A hand-held environmental scanner which reports current gas levels." @@ -683,10 +705,9 @@ SLIME SCANNER to_chat(user, chat_box_examine(message.Join("\n"))) return TRUE -/******************************/ -/*** REAGENT SCANNERS ***/ -/******************************/ - +//////////////////////////////////////// +// MARK: Reagent scanners +//////////////////////////////////////// /obj/item/reagent_scanner name = "reagent scanner" desc = "A hand-held reagent scanner which identifies chemical agents and blood types." @@ -764,9 +785,9 @@ SLIME SCANNER /obj/item/reagent_scanner/ui_action_click() print_report() -/******************************/ -/*** SLIME SCANNER ***/ -/******************************/ +//////////////////////////////////////// +// MARK: Slime scanner +//////////////////////////////////////// /obj/item/slime_scanner name = "slime scanner" icon = 'icons/obj/device.dmi' @@ -821,9 +842,9 @@ SLIME SCANNER to_chat(user, "Progress in core mutation: [T.applied] / [SLIME_EXTRACT_CROSSING_REQUIRED]") to_chat(user, "========================") -/******************************/ -/*** BODY ANALYZERS ***/ -/******************************/ +//////////////////////////////////////// +// MARK: Body analyzers +//////////////////////////////////////// /obj/item/bodyanalyzer name = "handheld body analyzer" desc = "A handheld scanner capable of deep-scanning an entire body."