Vitals Monitor (#11769)

This commit is contained in:
Geeves
2021-04-30 00:47:12 +02:00
committed by GitHub
parent f3431db680
commit 25fb847e12
8 changed files with 240 additions and 4 deletions
+1
View File
@@ -814,6 +814,7 @@
#include "code\game\objects\items\tajara.dm"
#include "code\game\objects\items\toys.dm"
#include "code\game\objects\items\trash.dm"
#include "code\game\objects\items\vitals_monitor.dm"
#include "code\game\objects\items\devices\aicard.dm"
#include "code\game\objects\items\devices\augment_implanter.dm"
#include "code\game\objects\items\devices\binoculars.dm"
+121
View File
@@ -0,0 +1,121 @@
/obj/item/vitals_monitor
name = "vitals monitor"
desc = "A vitals monitor, used to track a patient's vitality. It needs to be attached to a rollerbed to function."
icon = 'icons/obj/contained_items/tools/vitals_monitor.dmi'
icon_state = "vitals_monitor"
item_state = "vitals_monitor"
contained_sprite = TRUE
var/obj/structure/bed/roller/bed
var/reported_critical = FALSE
/obj/item/vitals_monitor/process()
if(!bed)
return
var/mob/living/carbon/human/H
if(bed?.buckled)
if(ishuman(bed.buckled))
H = bed.buckled
else if(istype(bed.buckled, /obj/structure/closet))
H = locate() in bed.buckled.contents
if(!H)
return
if(H.is_asystole())
if(!reported_critical)
bed.visible_message(SPAN_WARNING("\The [src] flashes red!"))
playsound(bed.loc, 'sound/machines/airalarm.ogg', 70)
reported_critical = TRUE
update_icon()
else if(reported_critical)
bed.visible_message(SPAN_NOTICE("\The [src] returns to a normal green."))
reported_critical = FALSE
update_icon()
/obj/item/vitals_monitor/proc/update_monitor()
if(bed)
START_PROCESSING(SSprocessing, src)
else
STOP_PROCESSING(SSprocessing, src)
reported_critical = FALSE
update_icon()
/obj/item/vitals_monitor/update_icon()
if(bed)
if(bed.density)
icon_state = "[initial(icon_state)]-bb"
layer = bed.buckled.layer + 0.1
else
icon_state = "[initial(icon_state)]-b"
layer = bed.layer + 0.1
else
icon_state = initial(icon_state)
layer = initial(layer)
if(reported_critical)
color = color_rotation(-120)
else
color = null
/obj/item/vitals_monitor/CtrlClick(var/mob/user)
if(bed)
return bed.CtrlClick(user)
return ..()
/obj/item/vitals_monitor/Click() // attack_hand doesn't work here because it's inside the rollerbed
if(bed && bed.Adjacent(usr))
interact(usr)
return
return ..()
/obj/item/vitals_monitor/interact(mob/user)
var/datum/vueui/ui = SSvueui.get_open_ui(user, src)
if(!ui)
ui = new(user, src, "devices-vitalsmonitor", 480, 250, capitalize_first_letters(name), set_state_object = bed)
ui.auto_update_content = TRUE
ui.open()
/obj/item/vitals_monitor/vueui_data_change(var/list/data, var/mob/user, var/datum/vueui/ui)
if(!data)
data = list()
var/mob/living/carbon/human/H
if(bed?.buckled)
if(ishuman(bed.buckled))
H = bed.buckled
else if(istype(bed.buckled, /obj/structure/closet))
H = locate() in bed.buckled.contents
var/has_occupant = !isnull(H)
VUEUI_SET_CHECK(data["has_occupant"], has_occupant, ., data)
if(has_occupant)
var/displayed_stat = H.stat
var/blood_oxygenation = H.get_blood_oxygenation()
if(H.status_flags & FAKEDEATH)
displayed_stat = DEAD
blood_oxygenation = min(blood_oxygenation, BLOOD_VOLUME_SURVIVE)
var/pulse_result
if(H.should_have_organ(BP_HEART))
var/obj/item/organ/internal/heart/heart = H.internal_organs_by_name[BP_HEART]
if(!heart)
pulse_result = 0
else if(BP_IS_ROBOTIC(heart))
pulse_result = -2
else if(H.status_flags & FAKEDEATH)
pulse_result = 0
else
pulse_result = H.get_pulse(GETPULSE_TOOL)
else
pulse_result = -1
if(pulse_result == ">250")
pulse_result = -3
VUEUI_SET_CHECK(data["stat"], displayed_stat, ., data)
VUEUI_SET_CHECK(data["brain_activity"], H.get_brain_result(), ., data)
VUEUI_SET_CHECK(data["blood_pressure"], H.get_blood_pressure(), ., data)
VUEUI_SET_CHECK(data["blood_pressure_level"], H.get_blood_pressure_alert(), ., data)
VUEUI_SET_CHECK(data["blood_volume"], H.get_blood_volume(), ., data)
VUEUI_SET_CHECK(data["blood_o2"], blood_oxygenation, ., data)
@@ -224,6 +224,7 @@
var/base_state = "standard"
var/item_bedpath = /obj/item/roller
var/obj/item/reagent_containers/beaker
var/obj/item/vitals_monitor/vitals
var/iv_attached = 0
var/iv_stand = TRUE
var/patient_shift = 9 //How much are mobs moved up when they are buckled_to.
@@ -234,8 +235,15 @@
..()
LAZYADD(can_buckle, /obj/structure/closet/body_bag)
/obj/structure/bed/roller/Destroy()
QDEL_NULL(beaker)
vitals.bed = null
QDEL_NULL(vitals)
return ..()
/obj/structure/bed/roller/update_icon()
overlays.Cut()
cut_overlays()
vis_contents = list()
if(density)
icon_state = "[base_state]_up"
else
@@ -245,18 +253,31 @@
var/percentage = round((beaker.reagents.total_volume / beaker.volume) * 100, 25)
var/image/filling = image(icon, "iv_filling[percentage]")
filling.color = beaker.reagents.get_color()
iv.overlays += filling
iv.add_overlay(filling)
if(percentage < 25)
iv.overlays += image(icon, "light_low")
iv.add_overlay(image(icon, "light_low"))
if(density)
iv.pixel_y = 6
overlays += iv
add_overlay(iv)
if(vitals)
vitals.update_monitor()
vis_contents += vitals
if(bag_strap && istype(buckled, /obj/structure/closet/body_bag))
LAZYADD(buckled.overlays, image(icon, bag_strap))
/obj/structure/bed/roller/attackby(obj/item/I, mob/user)
if(iswrench(I) || istype(I, /obj/item/stack) || iswirecutter(I))
return 1
if(istype(I, /obj/item/vitals_monitor))
if(vitals)
to_chat(user, SPAN_WARNING("\The [src] already has a vitals monitor attached!"))
return
to_chat(user, SPAN_NOTICE("You attach \the [I] to \the [src]."))
user.drop_from_inventory(I, src)
vitals = I
vitals.bed = src
update_icon()
return
if(iv_stand && !beaker && (istype(I, /obj/item/reagent_containers/glass/beaker) || istype(I, /obj/item/reagent_containers/blood)))
if(!user.unEquip(I, target = src))
return
@@ -295,6 +316,14 @@
beaker = null
update_icon()
/obj/structure/bed/roller/proc/remove_vitals(mob/user)
to_chat(user, SPAN_NOTICE("You detach \the [vitals] from \the [src]."))
vitals.bed = null
vitals.update_monitor()
user.put_in_hands(vitals)
vitals = null
update_icon()
/obj/structure/bed/roller/proc/attach_iv(mob/living/carbon/human/target, mob/user)
if(!beaker)
return
@@ -329,6 +358,9 @@
if(beaker)
remove_beaker(usr)
return
if(vitals)
remove_vitals(usr)
return
if(buckled)
return
collapse()
@@ -0,0 +1,6 @@
author: Geeves
delete-after: True
changes:
- rscadd: "Added vitals monitors for rollerbeds, two mapped into medical's GTR."
Binary file not shown.

After

Width:  |  Height:  |  Size: 526 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

+5
View File
@@ -39336,6 +39336,11 @@
icon_state = "0-2"
},
/obj/structure/table/standard,
/obj/item/vitals_monitor,
/obj/item/vitals_monitor{
pixel_x = 2;
pixel_y = 4
},
/turf/simulated/floor/tiled/dark,
/area/medical/gen_treatment)
"bqJ" = (
@@ -0,0 +1,71 @@
<template>
<div>
<h3>Patient Vitals:</h3>
<template v-if="has_occupant">
<vui-group>
<vui-group-item label="Status:"><span :style="{color:consciousnessLabel(stat)}">{{ consciousnessText(stat) }}</span></vui-group-item>
<vui-group-item label="Brain Activity:"><vui-progress :class="progressClass(brain_activity)" :value="brain_activity">{{brain_activity}}%</vui-progress></vui-group-item>
<vui-group-item label="BP:" :style="{color:getPressureClass(blood_pressure_level)}">{{blood_pressure}}</vui-group-item>
<vui-group-item label="Blood Oxygenation:"><vui-progress :class="progressClass(brain_activity)" :value="Math.round(blood_o2)">{{Math.round(blood_o2)}}%</vui-progress></vui-group-item>
</vui-group>
</template>
<template v-else>
<span class="bad">No patient detected.</span>
</template>
</div>
</template>
<script>
export default {
data() {
return this.$root.$data.state;
},
methods: {
consciousnessLabel(value) {
switch (value) {
case 0:
return "LimeGreen"
case 1:
return "OrangeRed"
case 2:
return "Crimson"
}
},
consciousnessText(value) {
switch (value) {
case 0:
return "Conscious"
case 1:
return "Unconscious"
case 2:
return "DEAD"
}
},
progressClass(value) {
if (value <= 50) {
return "bad"
}
else if (value <= 90) {
return "average"
}
else {
return "good"
}
},
getPressureClass(tpressure) {
switch (tpressure) {
case 1:
return "Crimson"
case 2:
return "LimeGreen"
case 3:
return "LawnGreen"
case 4:
return "Crimson"
default:
return "LightSkyBlue"
}
}
}
};
</script>