From 2359f6cb996d498cdf376dbc8a259e0aa4a070db Mon Sep 17 00:00:00 2001
From: DGamerL <108773801+DGamerL@users.noreply.github.com>
Date: Sun, 7 Apr 2024 12:16:22 +0200
Subject: [PATCH] Refactors this entire proc because fuck this thing (#25013)
---
.../clothing/under/accessories/accessory.dm | 91 ++++++++++---------
1 file changed, 48 insertions(+), 43 deletions(-)
diff --git a/code/modules/clothing/under/accessories/accessory.dm b/code/modules/clothing/under/accessories/accessory.dm
index 2d3d63cf850..276f49e03e8 100644
--- a/code/modules/clothing/under/accessories/accessory.dm
+++ b/code/modules/clothing/under/accessories/accessory.dm
@@ -152,50 +152,55 @@
item_color = "stethoscope"
/obj/item/clothing/accessory/stethoscope/attack(mob/living/carbon/human/M, mob/living/user)
- if(ishuman(M) && isliving(user))
- if(user == M)
- user.visible_message("[user] places [src] against [user.p_their()] chest and listens attentively.", "You place [src] against your chest...")
- else
- user.visible_message("[user] places \the [src] against [M]'s chest and listens attentively.", "You place \the [src] against [M]'s chest...")
- var/datum/organ/heart/heart_datum = M.get_int_organ_datum(ORGAN_DATUM_HEART)
- var/obj/item/organ/internal/H = heart_datum.linked_organ
- var/datum/organ/lungs/lung_datum = M.get_int_organ_datum(ORGAN_DATUM_LUNGS)
- var/obj/item/organ/internal/L = lung_datum.linked_organ
- if(M.pulse && (H || (L && !HAS_TRAIT(M, TRAIT_NOBREATH))))
- var/color = "notice"
- if(H)
- var/heart_sound
- switch(H.damage)
- if(0 to 1)
- heart_sound = "healthy"
- if(1 to 25)
- heart_sound = "offbeat"
- if(25 to 50)
- heart_sound = "uneven"
- color = "warning"
- if(50 to INFINITY)
- heart_sound = "weak, unhealthy"
- color = "warning"
- to_chat(user, "You hear \an [heart_sound] pulse.")
- if(L)
- var/lung_sound
- switch(L.damage)
- if(0 to 1)
- lung_sound = "healthy respiration"
- if(1 to 25)
- lung_sound = "labored respiration"
- if(25 to 50)
- lung_sound = "pained respiration"
- color = "warning"
- if(50 to INFINITY)
- lung_sound = "gurgling"
- color = "warning"
- to_chat(user, "You hear [lung_sound].")
- else
- to_chat(user, "You don't hear anything.")
- return
- return ..(M,user)
+ if(!ishuman(M) || !isliving(user))
+ return ..(M, user)
+ if(user == M)
+ user.visible_message("[user] places [src] against [user.p_their()] chest and listens attentively.", "You place [src] against your chest...")
+ else
+ user.visible_message("[user] places [src] against [M]'s chest and listens attentively.", "You place [src] against [M]'s chest...")
+ var/datum/organ/heart/heart_datum = M.get_int_organ_datum(ORGAN_DATUM_HEART)
+ var/datum/organ/lungs/lung_datum = M.get_int_organ_datum(ORGAN_DATUM_LUNGS)
+ if(!lung_datum || !heart_datum)
+ to_chat(user, "You don't hear anything.")
+ return
+
+ var/obj/item/organ/internal/H = heart_datum.linked_organ
+ var/obj/item/organ/internal/L = lung_datum.linked_organ
+ if(!M.pulse || (!H || !(L && !HAS_TRAIT(M, TRAIT_NOBREATH))))
+ to_chat(user, "You don't hear anything.")
+ return
+
+ var/color = "notice"
+ if(H)
+ var/heart_sound
+ switch(H.damage)
+ if(0 to 1)
+ heart_sound = "healthy"
+ if(1 to 25)
+ heart_sound = "offbeat"
+ if(25 to 50)
+ heart_sound = "uneven"
+ color = "warning"
+ if(50 to INFINITY)
+ heart_sound = "weak, unhealthy"
+ color = "warning"
+ to_chat(user, "You hear \an [heart_sound] pulse.")
+
+ if(L)
+ var/lung_sound
+ switch(L.damage)
+ if(0 to 1)
+ lung_sound = "healthy respiration"
+ if(1 to 25)
+ lung_sound = "labored respiration"
+ if(25 to 50)
+ lung_sound = "pained respiration"
+ color = "warning"
+ if(50 to INFINITY)
+ lung_sound = "gurgling"
+ color = "warning"
+ to_chat(user, "You hear [lung_sound].")
//Medals
/obj/item/clothing/accessory/medal