From 2bdadebbadab0de472efd9993d4b1595daee16e9 Mon Sep 17 00:00:00 2001 From: nikothedude <59709059+nikothedude@users.noreply.github.com> Date: Fri, 29 Sep 2023 16:45:43 -0400 Subject: [PATCH] Moves gauze removal signals to gauze destroy, removing weird seep_gauze usages + misc improvements (#78570) ## About The Pull Request Title. ## Why It's Good For The Game Gauze removal was handled by using seep_gauze(9999) instead of just deleting it, which was really fucking weird?? This makes behavior more sensical and modular (you can remove gauze without using seep_gauze now). ## Changelog :cl: code: Gauze removal is now handled by the gauze's destroy instead of seep_gauze /:cl: --- .../signals/signals_mob/signals_mob_carbon.dm | 6 ++++-- code/datums/wounds/_wounds.dm | 6 +++--- code/game/objects/items/stacks/medical.dm | 9 +++++++++ code/modules/surgery/bodyparts/_bodyparts.dm | 20 +++++++++---------- 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_carbon.dm b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_carbon.dm index 677a65a7be1..c96d21b7163 100644 --- a/code/__DEFINES/dcs/signals/signals_mob/signals_mob_carbon.dm +++ b/code/__DEFINES/dcs/signals/signals_mob/signals_mob_carbon.dm @@ -36,8 +36,10 @@ #define COMSIG_BODYPART_ATTACHED "bodypart_removed" ///from base of /obj/item/bodypart/proc/try_attach_limb(): (new_limb, special) #define COMSIG_CARBON_POST_ATTACH_LIMB "carbon_post_attach_limb" -#define COMSIG_BODYPART_GAUZED "bodypart_gauzed" // from /obj/item/bodypart/proc/apply_gauze(/obj/item/stack/gauze) -#define COMSIG_BODYPART_GAUZE_DESTROYED "bodypart_degauzed" // from [/obj/item/bodypart/proc/seep_gauze] when it runs out of absorption +/// from /obj/item/bodypart/proc/apply_gauze(/obj/item/stack/gauze): (/obj/item/stack/medical/gauze/applied_gauze, /obj/item/stack/medical/gauze/stack_used) +#define COMSIG_BODYPART_GAUZED "bodypart_gauzed" +/// from /obj/item/stack/medical/gauze/Destroy(): (/obj/item/stack/medical/gauze/removed_gauze) +#define COMSIG_BODYPART_UNGAUZED "bodypart_ungauzed" /// Called from bodypart changing owner, which could be on attach or detachment. Either argument can be null. (mob/living/carbon/new_owner, mob/living/carbon/old_owner) #define COMSIG_BODYPART_CHANGED_OWNER "bodypart_changed_owner" diff --git a/code/datums/wounds/_wounds.dm b/code/datums/wounds/_wounds.dm index 434a2cd70d5..bc873095b17 100644 --- a/code/datums/wounds/_wounds.dm +++ b/code/datums/wounds/_wounds.dm @@ -290,7 +290,7 @@ . = limb if(limb) // if we're nulling limb, we're basically detaching from it, so we should remove ourselves in that case UnregisterSignal(limb, COMSIG_QDELETING) - UnregisterSignal(limb, list(COMSIG_BODYPART_GAUZED, COMSIG_BODYPART_GAUZE_DESTROYED)) + UnregisterSignal(limb, list(COMSIG_BODYPART_GAUZED, COMSIG_BODYPART_UNGAUZED)) LAZYREMOVE(limb.wounds, src) limb.update_wounds(replaced) if (disabling) @@ -302,7 +302,7 @@ if (limb) RegisterSignal(limb, COMSIG_QDELETING, PROC_REF(source_died)) - RegisterSignals(limb, list(COMSIG_BODYPART_GAUZED, COMSIG_BODYPART_GAUZE_DESTROYED), PROC_REF(gauze_state_changed)) + RegisterSignals(limb, list(COMSIG_BODYPART_GAUZED, COMSIG_BODYPART_UNGAUZED), PROC_REF(gauze_state_changed)) if (disabling) limb.add_traits(list(TRAIT_PARALYSIS, TRAIT_DISABLED_BY_WOUND), REF(src)) @@ -442,7 +442,7 @@ set_interaction_efficiency_penalty(initial(interaction_efficiency_penalty)) if(initial(disabling)) - set_disabling(!limb.current_gauze) + set_disabling(isnull(limb.current_gauze)) limb.update_wounds(replaced_or_replacing) diff --git a/code/game/objects/items/stacks/medical.dm b/code/game/objects/items/stacks/medical.dm index 081ab5d78e0..4b94046e1fe 100644 --- a/code/game/objects/items/stacks/medical.dm +++ b/code/game/objects/items/stacks/medical.dm @@ -159,6 +159,15 @@ splint_factor = 0.7 burn_cleanliness_bonus = 0.35 merge_type = /obj/item/stack/medical/gauze + var/obj/item/bodypart/gauzed_bodypart + +/obj/item/stack/medical/gauze/Destroy(force) + . = ..() + + if (gauzed_bodypart) + gauzed_bodypart.current_gauze = null + SEND_SIGNAL(gauzed_bodypart, COMSIG_BODYPART_UNGAUZED, src) + gauzed_bodypart = null // gauze is only relevant for wounds, which are handled in the wounds themselves /obj/item/stack/medical/gauze/try_heal(mob/living/patient, mob/user, silent) diff --git a/code/modules/surgery/bodyparts/_bodyparts.dm b/code/modules/surgery/bodyparts/_bodyparts.dm index 92d4747e2e3..de841fdf1b8 100644 --- a/code/modules/surgery/bodyparts/_bodyparts.dm +++ b/code/modules/surgery/bodyparts/_bodyparts.dm @@ -152,7 +152,7 @@ /// How much generic bleedstacks we have on this bodypart var/generic_bleedstacks /// If we have a gauze wrapping currently applied (not including splints) - var/obj/item/stack/current_gauze + var/obj/item/stack/medical/gauze/current_gauze /// If something is currently grasping this bodypart and trying to staunch bleeding (see [/obj/item/hand_item/self_grasp]) var/obj/item/hand_item/self_grasp/grasped_by @@ -404,10 +404,10 @@ var/atom/drop_loc = drop_location() if(IS_ORGANIC_LIMB(src)) playsound(drop_loc, 'sound/misc/splort.ogg', 50, TRUE, -1) - seep_gauze(9999) // destroy any existing gauze if any exists - for(var/obj/item/organ/bodypart_organ in get_organs()) + QDEL_NULL(current_gauze) + for(var/obj/item/organ/bodypart_organ as anything in get_organs()) bodypart_organ.transfer_to_limb(src, owner) - for(var/obj/item/organ/external/external in external_organs) + for(var/obj/item/organ/external/external as anything in external_organs) external.remove_from_limb() external.forceMove(drop_loc) for(var/obj/item/item_in_bodypart in src) @@ -1212,17 +1212,18 @@ * Arguments: * * gauze- Just the gauze stack we're taking a sheet from to apply here */ -/obj/item/bodypart/proc/apply_gauze(obj/item/stack/gauze) - if(!istype(gauze) || !gauze.absorption_capacity) +/obj/item/bodypart/proc/apply_gauze(obj/item/stack/medical/gauze/new_gauze) + if(!istype(new_gauze) || !new_gauze.absorption_capacity) return var/newly_gauzed = FALSE if(!current_gauze) newly_gauzed = TRUE QDEL_NULL(current_gauze) - current_gauze = new gauze.type(src, 1) - gauze.use(1) + current_gauze = new new_gauze.type(src, 1) + new_gauze.use(1) + current_gauze.gauzed_bodypart = src if(newly_gauzed) - SEND_SIGNAL(src, COMSIG_BODYPART_GAUZED, gauze) + SEND_SIGNAL(src, COMSIG_BODYPART_GAUZED, current_gauze, new_gauze) /** * seep_gauze() is for when a gauze wrapping absorbs blood or pus from wounds, lowering its absorption capacity. @@ -1239,7 +1240,6 @@ if(current_gauze.absorption_capacity <= 0) owner.visible_message(span_danger("\The [current_gauze.name] on [owner]'s [name] falls away in rags."), span_warning("\The [current_gauze.name] on your [name] falls away in rags."), vision_distance=COMBAT_MESSAGE_RANGE) QDEL_NULL(current_gauze) - SEND_SIGNAL(src, COMSIG_BODYPART_GAUZE_DESTROYED) ///Loops through all of the bodypart's external organs and update's their color. /obj/item/bodypart/proc/recolor_external_organs()