From 0b92d0728ca87acf69dd00beb7163ddb8c46315a Mon Sep 17 00:00:00 2001
From: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com>
Date: Sun, 17 Sep 2023 19:26:11 +0200
Subject: [PATCH] Fixing examining logic (#22180)
* fixing examining logic
* new glob proc, god this looks much better
* this looks much better
* dont need this
* if they're missing arm, we know they're missing hand
---
code/__DEFINES/mob_defines.dm | 25 ++++
code/modules/clothing/clothing.dm | 7 +-
code/modules/mob/living/carbon/examine.dm | 2 +-
.../mob/living/carbon/human/human_examine.dm | 112 ++++++++++++------
4 files changed, 105 insertions(+), 41 deletions(-)
diff --git a/code/__DEFINES/mob_defines.dm b/code/__DEFINES/mob_defines.dm
index b7599881e39..bc34c47d799 100644
--- a/code/__DEFINES/mob_defines.dm
+++ b/code/__DEFINES/mob_defines.dm
@@ -310,3 +310,28 @@
#define MAX_EYE_BLURRY_FILTER_SIZE 2
#define EYE_BLUR_TO_FILTER_SIZE_MULTIPLIER 0.005
+
+/proc/bodypart_name_to_clothing_bitflag(bodypart_name)
+ switch(bodypart_name)
+ if("head")
+ return HEAD
+ if("chest")
+ return UPPER_TORSO
+ if("groin")
+ return LOWER_TORSO
+ if("l_arm")
+ return ARM_LEFT
+ if("l_hand")
+ return HAND_LEFT
+ if("r_arm")
+ return ARM_RIGHT
+ if("r_hand")
+ return HAND_RIGHT
+ if("r_leg")
+ return LEG_RIGHT
+ if("r_foot")
+ return FOOT_RIGHT
+ if("l_leg")
+ return LEG_LEFT
+ if("l_foot")
+ return FOOT_LEFT
diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm
index 96181c6ee57..1eea02c14ba 100644
--- a/code/modules/clothing/clothing.dm
+++ b/code/modules/clothing/clothing.dm
@@ -853,7 +853,6 @@
if(H.w_uniform.sprite_sheets[H.dna.species.name] && icon_exists(H.w_uniform.sprite_sheets[H.dna.species.name], "[basecolor]_d_s"))
item_color = item_color == "[basecolor]" ? "[basecolor]_d" : "[basecolor]"
usr.update_inv_w_uniform()
-
else
if(H.w_uniform.sprite_sheets["Human"] && icon_exists(H.w_uniform.sprite_sheets["Human"], "[basecolor]_d_s"))
item_color = item_color == "[basecolor]" ? "[basecolor]_d" : "[basecolor]"
@@ -863,6 +862,12 @@
else
to_chat(usr, "You cannot roll down the uniform!")
+ if(item_color == "[basecolor]")
+ body_parts_covered = initial(body_parts_covered)
+ else
+ body_parts_covered &= ~UPPER_TORSO
+ body_parts_covered &= ~LOWER_TORSO
+ body_parts_covered &= ~ARMS
/obj/item/clothing/under/verb/removetie()
set name = "Remove Accessory"
diff --git a/code/modules/mob/living/carbon/examine.dm b/code/modules/mob/living/carbon/examine.dm
index f1358c26e82..fe0b57c2cfb 100644
--- a/code/modules/mob/living/carbon/examine.dm
+++ b/code/modules/mob/living/carbon/examine.dm
@@ -213,7 +213,7 @@
msg += ""
// Stuff at the start of the block
- msg += examine_start_damage_block()
+ msg += examine_start_damage_block(skipgloves, skipsuitstorage, skipjumpsuit, skipshoes, skipmask, skipears, skipeyes, skipface)
// Show how badly they're damaged
msg += examine_damage_flavor()
diff --git a/code/modules/mob/living/carbon/human/human_examine.dm b/code/modules/mob/living/carbon/human/human_examine.dm
index d17ef28765b..8eebf617d92 100644
--- a/code/modules/mob/living/carbon/human/human_examine.dm
+++ b/code/modules/mob/living/carbon/human/human_examine.dm
@@ -72,6 +72,7 @@
var/msg = ""
var/list/wound_flavor_text = list()
var/list/is_destroyed = list()
+ var/skip_bodyparts = 0
for(var/organ_tag in dna.species.has_limbs)
var/list/organ_data = dna.species.has_limbs[organ_tag]
@@ -79,56 +80,89 @@
is_destroyed["[organ_data["descriptor"]]"] = 1
var/obj/item/organ/external/E = bodyparts_by_name[organ_tag]
+ var/bodypart_clothing_bitflag = bodypart_name_to_clothing_bitflag(organ_tag)
if(!E)
+ if(bodypart_clothing_bitflag & skip_bodyparts)
+ continue
wound_flavor_text["[organ_tag]"] = "[p_they(TRUE)] [p_are()] missing [p_their()] [organ_descriptor].\n"
- else
- if(!ismachineperson(src))
- if(E.is_robotic())
- wound_flavor_text["[E.limb_name]"] = "[p_they(TRUE)] [p_have()] a robotic [E.name]!\n"
+ if(bodypart_clothing_bitflag & ARM_LEFT)
+ skip_bodyparts |= HAND_LEFT
+ wound_flavor_text["l_hand"] = null
+ if(bodypart_clothing_bitflag & ARM_RIGHT)
+ skip_bodyparts |= HAND_RIGHT
+ wound_flavor_text["r_hand"] = null
+ if(bodypart_clothing_bitflag & LEG_LEFT)
+ skip_bodyparts |= FOOT_LEFT
+ wound_flavor_text["l_foot"] = null
+ if(bodypart_clothing_bitflag & LEG_RIGHT)
+ skip_bodyparts |= FOOT_RIGHT
+ wound_flavor_text["r_foot"] = null
+ continue
- else if(E.status & ORGAN_SPLINTED)
- wound_flavor_text["[E.limb_name]"] = "[p_they(TRUE)] [p_have()] a splint on [p_their()] [E.name]!\n"
+ if(bodypart_clothing_bitflag & HEAD)
+ if(skip_mask)
+ continue
+ var/obj/item/clothing/mask/current_mask = wear_mask
+ if(istype(current_mask) && (current_mask.body_parts_covered & bodypart_clothing_bitflag))
+ continue
- else if(!E.properly_attached)
- wound_flavor_text["[E.limb_name]"] = "[p_their(TRUE)] [E.name] is barely attached!\n"
+ var/chest_groin_arms_legs_bitflag = ARMS | LEGS | UPPER_TORSO | LOWER_TORSO //is what covered by jumpsuit
+ if(bodypart_clothing_bitflag & chest_groin_arms_legs_bitflag)
+ if(skip_jumpsuit)
+ continue
+ if(!isnull(w_uniform) && (w_uniform.body_parts_covered & bodypart_clothing_bitflag))
+ continue
- else if(E.status & ORGAN_BURNT)
- wound_flavor_text["[E.limb_name]"] = "[p_their(TRUE)] [E.name] is badly burnt!\n"
+ if(bodypart_clothing_bitflag & HANDS)
+ if(skip_gloves)
+ continue
+ var/obj/item/clothing/gloves/current_gloves = gloves
+ if(istype(current_gloves) && (current_gloves.body_parts_covered & bodypart_clothing_bitflag))
+ continue
- if(E.open)
- if(E.is_robotic())
- msg += "The maintenance hatch on [p_their()] [ignore_limb_branding(E.limb_name)] is open!\n"
- else
- msg += "[p_their(TRUE)] [ignore_limb_branding(E.limb_name)] has an open incision!\n"
+ if(bodypart_clothing_bitflag & FEET)
+ if(skip_shoes)
+ continue
+ var/obj/item/clothing/shoes/current_shoes = shoes
+ if(istype(current_shoes) && (current_shoes.body_parts_covered & bodypart_clothing_bitflag))
+ continue
- for(var/obj/item/I in E.embedded_objects)
- msg += "[p_they(TRUE)] [p_have()] \a [bicon(I)] [I] embedded in [p_their()] [E.name]!\n"
+ if(!ismachineperson(src))
+ if(E.is_robotic())
+ wound_flavor_text["[E.limb_name]"] = "[p_they(TRUE)] [p_have()] a robotic [E.name]!\n"
+
+ else if(E.status & ORGAN_SPLINTED)
+ wound_flavor_text["[E.limb_name]"] = "[p_they(TRUE)] [p_have()] a splint on [p_their()] [E.name]!\n"
+
+ else if(!E.properly_attached)
+ wound_flavor_text["[E.limb_name]"] = "[p_their(TRUE)] [E.name] is barely attached!\n"
+
+ else if(E.status & ORGAN_BURNT)
+ wound_flavor_text["[E.limb_name]"] = "[p_their(TRUE)] [E.name] is badly burnt!\n"
+
+ if(E.open)
+ if(E.is_robotic())
+ msg += "The maintenance hatch on [p_their()] [ignore_limb_branding(E.limb_name)] is open!\n"
+ else
+ msg += "[p_their(TRUE)] [ignore_limb_branding(E.limb_name)] has an open incision!\n"
+
+ for(var/obj/item/I in E.embedded_objects)
+ msg += "[p_they(TRUE)] [p_have()] \a [bicon(I)] [I] embedded in [p_their()] [E.name]!\n"
//Handles the text strings being added to the actual description.
//If they have something that covers the limb, and it is not missing, put flavortext. If it is covered but bleeding, add other flavortext.
- if(wound_flavor_text["head"] && (is_destroyed["head"] || (!skip_mask && !(wear_mask && istype(wear_mask, /obj/item/clothing/mask/gas)))))
- msg += wound_flavor_text["head"]
- if(wound_flavor_text["chest"] && !w_uniform && !skip_jumpsuit) //No need. A missing chest gibs you.
- msg += wound_flavor_text["chest"]
- if(wound_flavor_text["l_arm"] && (is_destroyed["left arm"] || (!w_uniform && !skip_jumpsuit)))
- msg += wound_flavor_text["l_arm"]
- if(wound_flavor_text["l_hand"] && (is_destroyed["left hand"] || (!gloves && !skip_gloves)))
- msg += wound_flavor_text["l_hand"]
- if(wound_flavor_text["r_arm"] && (is_destroyed["right arm"] || (!w_uniform && !skip_jumpsuit)))
- msg += wound_flavor_text["r_arm"]
- if(wound_flavor_text["r_hand"] && (is_destroyed["right hand"] || (!gloves && !skip_gloves)))
- msg += wound_flavor_text["r_hand"]
- if(wound_flavor_text["groin"] && (is_destroyed["groin"] || (!w_uniform && !skip_jumpsuit)))
- msg += wound_flavor_text["groin"]
- if(wound_flavor_text["l_leg"] && (is_destroyed["left leg"] || (!w_uniform && !skip_jumpsuit)))
- msg += wound_flavor_text["l_leg"]
- if(wound_flavor_text["l_foot"]&& (is_destroyed["left foot"] || (!shoes && !skip_shoes)))
- msg += wound_flavor_text["l_foot"]
- if(wound_flavor_text["r_leg"] && (is_destroyed["right leg"] || (!w_uniform && !skip_jumpsuit)))
- msg += wound_flavor_text["r_leg"]
- if(wound_flavor_text["r_foot"]&& (is_destroyed["right foot"] || (!shoes && !skip_shoes)))
- msg += wound_flavor_text["r_foot"]
+ msg += wound_flavor_text["head"]
+ msg += wound_flavor_text["chest"]
+ msg += wound_flavor_text["groin"]
+ msg += wound_flavor_text["l_arm"]
+ msg += wound_flavor_text["l_hand"]
+ msg += wound_flavor_text["r_arm"]
+ msg += wound_flavor_text["r_hand"]
+ msg += wound_flavor_text["l_leg"]
+ msg += wound_flavor_text["l_foot"]
+ msg += wound_flavor_text["r_leg"]
+ msg += wound_flavor_text["r_foot"]
return msg
/mob/living/carbon/human/examine_extra_damage_flavor()