Skip to content

Commit

Permalink
[MIRROR] Health analyzer displays blood alcohol content (#1899)
Browse files Browse the repository at this point in the history
* Health analyzer displays blood alcohol content (#81306)

---------

Co-authored-by: NovaBot <[email protected]>
Co-authored-by: lessthanthree <[email protected]>
Co-authored-by: san7890 <[email protected]>
  • Loading branch information
4 people authored Feb 9, 2024
1 parent 08d383e commit ffd4672
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 3 deletions.
2 changes: 2 additions & 0 deletions code/game/machinery/medical_kiosk.dm
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
var/blood_percent = round((patient.blood_volume / BLOOD_VOLUME_NORMAL)*100)
var/blood_type = patient.dna.blood_type
var/blood_warning = " "
var/blood_alcohol = patient.get_blood_alcohol_content()

for(var/thing in patient.diseases) //Disease Information
var/datum/disease/D = thing
Expand Down Expand Up @@ -358,6 +359,7 @@
data["bleed_status"] = bleed_status
data["blood_levels"] = blood_percent - (chaos_modifier * (rand(1,35)))
data["blood_status"] = blood_status
data["blood_alcohol"] = blood_alcohol
data["chemical_list"] = chemical_list
data["overdose_list"] = overdose_list
data["addict_list"] = addict_list
Expand Down
14 changes: 11 additions & 3 deletions code/game/objects/items/devices/scanners/health_analyzer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -382,11 +382,19 @@
var/datum/reagent/R = GLOB.chemical_reagents_list[blood_id]
blood_type = R ? R.name : blood_id
if(carbontarget.blood_volume <= BLOOD_VOLUME_SAFE && carbontarget.blood_volume > BLOOD_VOLUME_OKAY)
render_list += "<span class='alert ml-1'>Blood level: LOW [blood_percent] %, [carbontarget.blood_volume] cl,</span> [span_info("type: [blood_type]")]\n"
render_list += "<span class='alert ml-1'>Blood level: LOW [blood_percent]%, [carbontarget.blood_volume] cl,</span> [span_info("type: [blood_type]")]\n"
else if(carbontarget.blood_volume <= BLOOD_VOLUME_OKAY)
render_list += "<span class='alert ml-1'>Blood level: <b>CRITICAL [blood_percent] %</b>, [carbontarget.blood_volume] cl,</span> [span_info("type: [blood_type]")]\n"
render_list += "<span class='alert ml-1'>Blood level: <b>CRITICAL [blood_percent]%</b>, [carbontarget.blood_volume] cl,</span> [span_info("type: [blood_type]")]\n"
else
render_list += "<span class='info ml-1'>Blood level: [blood_percent] %, [carbontarget.blood_volume] cl, type: [blood_type]</span>\n"
render_list += "<span class='info ml-1'>Blood level: [blood_percent]%, [carbontarget.blood_volume] cl, type: [blood_type]</span>\n"

// Blood Alcohol Content
var/blood_alcohol_content = target.get_blood_alcohol_content()
if(blood_alcohol_content > 0)
if(blood_alcohol_content >= 0.24)
render_list += "<span class='alert ml-1'>Blood alcohol content: <b>CRITICAL [blood_alcohol_content]%</b></span>\n"
else
render_list += "<span class='info ml-1'>Blood alcohol content: [blood_alcohol_content]%</span>\n"

// Cybernetics
if(iscarbon(target))
Expand Down
11 changes: 11 additions & 0 deletions code/modules/mob/living/blood.dm
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#define BLOOD_DRIP_RATE_MOD 90 //Greater number means creating blood drips more often while bleeding
// Conversion between internal drunk power and common blood alcohol content
#define DRUNK_POWER_TO_BLOOD_ALCOHOL 0.003

/****************************************************
BLOOD SYSTEM
Expand Down Expand Up @@ -376,4 +378,13 @@
if(!B)
B = new(T)

/mob/living/proc/get_blood_alcohol_content()
var/blood_alcohol_content = 0
var/datum/status_effect/inebriated/inebriation = has_status_effect(/datum/status_effect/inebriated)
if(!isnull(inebriation))
blood_alcohol_content = round(inebriation.drunk_value * DRUNK_POWER_TO_BLOOD_ALCOHOL, 0.01)

return blood_alcohol_content

#undef BLOOD_DRIP_RATE_MOD
#undef DRUNK_POWER_TO_BLOOD_ALCOHOL
14 changes: 14 additions & 0 deletions tgui/packages/tgui/interfaces/MedicalKiosk.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ const MedicalKioskScanResults4 = (props) => {
overdose_list = [],
addict_list = [],
hallucinating_status,
blood_alcohol,
} = data;
return (
<Section title="Chemical and Psychoactive Analysis">
Expand Down Expand Up @@ -281,6 +282,19 @@ const MedicalKioskScanResults4 = (props) => {
<LabeledList.Item label="Psychoactive Status">
{hallucinating_status}
</LabeledList.Item>
<LabeledList.Item label="Blood Alcohol Content">
<ProgressBar
value={blood_alcohol}
minValue={0}
maxValue={0.3}
ranges={{
blue: [-Infinity, 0.23],
bad: [0.23, Infinity],
}}
>
<AnimatedNumber value={blood_alcohol} />
</ProgressBar>
</LabeledList.Item>
</LabeledList>
</Section>
);
Expand Down

0 comments on commit ffd4672

Please sign in to comment.