From fbe49dabbc883817ce90242674be160e510574be Mon Sep 17 00:00:00 2001 From: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com> Date: Fri, 16 Aug 2024 01:51:48 +0200 Subject: [PATCH] Fixing blood spreading too much during surgery (#26266) * bloody blood * ehhhh * here too * bloodwrite fix * a * review changes * max blood amount to argument * Update code/game/atoms.dm Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com> * Update code/modules/mob/living/carbon/human/human_defense.dm Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Signed-off-by: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com> * tab --------- Signed-off-by: HMBGERDO <61080616+HMBGERDO@users.noreply.github.com> Co-authored-by: DGamerL <108773801+DGamerL@users.noreply.github.com> Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> --- code/game/atoms.dm | 21 +++++++++++++++---- .../effects/decals/Cleanable/humans.dm | 5 ++++- code/game/objects/items/weapons/soap.dm | 2 +- code/modules/detective_work/detective_work.dm | 9 ++------ .../mob/living/carbon/human/human_defense.dm | 19 ++++++++++++++--- .../mob/living/carbon/human/human_mob.dm | 6 +++--- code/modules/surgery/organs/blood.dm | 10 +++++++-- code/modules/surgery/other.dm | 2 +- code/modules/surgery/surgery.dm | 2 +- 9 files changed, 53 insertions(+), 23 deletions(-) diff --git a/code/game/atoms.dm b/code/game/atoms.dm index fbf492896f70..401a22ead042 100644 --- a/code/game/atoms.dm +++ b/code/game/atoms.dm @@ -869,7 +869,7 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons) /obj/effect/decal/cleanable/blood/splatter/transfer_mob_blood_dna(mob/living/L) ..(L) var/list/b_data = L.get_blood_data(L.get_blood_id()) - if(b_data) + if(b_data && !isnull(b_data["blood_color"])) basecolor = b_data["blood_color"] else basecolor = "#A10808" @@ -878,7 +878,7 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons) /obj/effect/decal/cleanable/blood/footprints/transfer_mob_blood_dna(mob/living/L) ..(L) var/list/b_data = L.get_blood_data(L.get_blood_id()) - if(b_data) + if(b_data && !isnull(b_data["blood_color"])) basecolor = b_data["blood_color"] else basecolor = "#A10808" @@ -920,9 +920,22 @@ GLOBAL_LIST_EMPTY(blood_splatter_icons) add_blood_overlay() return TRUE //we applied blood to the item -/obj/item/clothing/gloves/add_blood(list/blood_dna, b_color) +/* + * This proc makes src gloves bloody, if you touch something with them you will leave a blood trace + + * blood_dna: list of blood DNAs stored in each atom in blood_DNA variable or in get_blood_dna_list() on carbons + * b_color: blood color, simple. If there will be null, the blood will be red, otherwise the color you pass + * amount: amount of "blood charges" you want to give to the gloves, that will be used to make items/walls bloody. + You can make something bloody this amount - 1 times. + If this variable will be null, amount will be set randomly from 2 to max_amount + * max_amount: if amount is not set, amount will be random from 2 to this value, default 4 +*/ +/obj/item/clothing/gloves/add_blood(list/blood_dna, b_color, amount, max_amount = 4) . = ..() - transfer_blood = rand(2, 4) + if(isnull(amount)) + transfer_blood = rand(2, max_amount) + else + transfer_blood = max(1, amount) /turf/add_blood(list/blood_dna, b_color) if(isnull(b_color)) diff --git a/code/game/objects/effects/decals/Cleanable/humans.dm b/code/game/objects/effects/decals/Cleanable/humans.dm index e822521c5bce..52150a68b92b 100644 --- a/code/game/objects/effects/decals/Cleanable/humans.dm +++ b/code/game/objects/effects/decals/Cleanable/humans.dm @@ -185,7 +185,10 @@ user.blood_DNA = list() user.blood_DNA |= blood_DNA.Copy() user.bloody_hands += taken - user.hand_blood_color = basecolor + if(isnull(basecolor)) + user.hand_blood_color = "#A10808" + else + user.hand_blood_color = basecolor user.update_inv_gloves() add_verb(user, /mob/living/carbon/human/proc/bloody_doodle) diff --git a/code/game/objects/items/weapons/soap.dm b/code/game/objects/items/weapons/soap.dm index d474d5a264b2..7b7cf35ccc35 100644 --- a/code/game/objects/items/weapons/soap.dm +++ b/code/game/objects/items/weapons/soap.dm @@ -99,7 +99,7 @@ if(!istype(carried_item, /obj/item/bio_chip))//If it's not an implant. carried_item.add_mob_blood(target)//Oh yes, there will be blood... var/mob/living/carbon/human/H = target - H.make_bloody_hands(H.get_blood_dna_list(), H.get_blood_color()) + H.make_bloody_hands(H.get_blood_dna_list(), H.get_blood_color(), 0) H.bloody_body(target) return diff --git a/code/modules/detective_work/detective_work.dm b/code/modules/detective_work/detective_work.dm index 4d67d40fb05f..410adfcc5594 100644 --- a/code/modules/detective_work/detective_work.dm +++ b/code/modules/detective_work/detective_work.dm @@ -7,19 +7,14 @@ G.transfer_blood-- if(blood_DNA && should_spread_blood) - var/old_transfer_blood = G.transfer_blood - G.add_blood(blood_DNA, blood_color) - G.transfer_blood = max(1, old_transfer_blood) - M.update_inv_gloves() + M.make_bloody_hands(G.blood_DNA, G.blood_color, G.transfer_blood) else if(M.bloody_hands > 1 && add_blood(M.blood_DNA, M.hand_blood_color)) M.bloody_hands-- if(blood_DNA && should_spread_blood) - var/old_bloody_hands = M.bloody_hands - M.make_bloody_hands(blood_DNA, blood_color) - M.bloody_hands = max(1, old_bloody_hands) + M.make_bloody_hands(blood_DNA, blood_color, M.bloody_hands) if(!suit_fibers) suit_fibers = list() var/fibertext diff --git a/code/modules/mob/living/carbon/human/human_defense.dm b/code/modules/mob/living/carbon/human/human_defense.dm index a2db48cfdcf7..009b43763c8c 100644 --- a/code/modules/mob/living/carbon/human/human_defense.dm +++ b/code/modules/mob/living/carbon/human/human_defense.dm @@ -616,14 +616,27 @@ emp_act visible_message("[I] embeds itself in [src]'s [L.name]!","[I] embeds itself in your [L.name]!") return TRUE -/mob/living/carbon/human/proc/make_bloody_hands(list/blood_dna, b_color) +/* + * This proc makes human hands bloody, if you touch something, you will leave a blood trace + + * blood_dna: list of blood DNAs stored in each atom in blood_DNA variable or in get_blood_dna_list() on carbons + * b_color: blood color, simple. If there will be null, the blood will be red, otherwise the color you pass + * amount: amount of "blood charges" you want to give, that will be used to make items/walls bloody. + You can make something bloody this amount - 1 times. + If this variable will be null, amount will be set randomly from 2 to max_amount + * max_amount: if amount is not set, amount will be random from 2 to this value, default 4 +*/ +/mob/living/carbon/human/proc/make_bloody_hands(list/blood_dna, b_color, amount, max_amount = 4) if(isnull(b_color)) b_color = "#A10808" if(gloves) - gloves.add_blood(blood_dna, blood_color) + gloves.add_blood(blood_dna, blood_color, amount, max_amount) else hand_blood_color = b_color - bloody_hands = rand(2, 4) + if(isnull(amount)) + bloody_hands = rand(2, max_amount) + else + bloody_hands = max(1, amount) transfer_blood_dna(blood_dna) add_verb(src, /mob/living/carbon/human/proc/bloody_doodle) update_inv_gloves() //updates on-mob overlays for bloody hands and/or bloody gloves diff --git a/code/modules/mob/living/carbon/human/human_mob.dm b/code/modules/mob/living/carbon/human/human_mob.dm index 4e587c7e3e91..7c1d9dc48f18 100644 --- a/code/modules/mob/living/carbon/human/human_mob.dm +++ b/code/modules/mob/living/carbon/human/human_mob.dm @@ -1281,7 +1281,7 @@ if(incapacitated()) to_chat(src, "You can't write on the floor in your current state!") return - if(!bloody_hands) + if(bloody_hands <= 1) remove_verb(src, /mob/living/carbon/human/proc/bloody_doodle) if(gloves) @@ -1310,7 +1310,7 @@ to_chat(src, "There is no space to write on!") return - var/max_length = bloody_hands * 30 //tweeter style + var/max_length = (bloody_hands - 1) * 30 //tweeter style var/message = tgui_input_text(src, "Write a message. It cannot be longer than [max_length] characters.", "Blood writing", max_length = max_length) if(origin != loc) @@ -1318,7 +1318,7 @@ return if(message) var/used_blood_amount = round(length(message) / 30, 1) - bloody_hands = max(0, bloody_hands - used_blood_amount) //use up some blood + bloody_hands = max(1, bloody_hands - used_blood_amount) //use up some blood if(length(message) > max_length) message += "-" diff --git a/code/modules/surgery/organs/blood.dm b/code/modules/surgery/organs/blood.dm index a74fbc7ea4e7..e8983586475d 100644 --- a/code/modules/surgery/organs/blood.dm +++ b/code/modules/surgery/organs/blood.dm @@ -278,7 +278,10 @@ drop.overlays |= I drop.transfer_mob_blood_dna(src) - drop.basecolor = b_data["blood_color"] + if(b_data && !isnull(b_data["blood_color"])) + drop.basecolor = b_data["blood_color"] + else + drop.basecolor = "#A10808" drop.update_icon() else temp_blood_DNA = list() @@ -287,7 +290,10 @@ else drop = new(T) drop.transfer_mob_blood_dna(src) - drop.basecolor = b_data["blood_color"] + if(b_data && !isnull(b_data["blood_color"])) + drop.basecolor = b_data["blood_color"] + else + drop.basecolor = "#A10808" drop.update_icon() if(emittor_intertia) drop.newtonian_move(emittor_intertia) diff --git a/code/modules/surgery/other.dm b/code/modules/surgery/other.dm index 9591072d1ac6..26a174caa348 100644 --- a/code/modules/surgery/other.dm +++ b/code/modules/surgery/other.dm @@ -109,7 +109,7 @@ affected.fix_internal_bleeding() if(ishuman(user) && prob(40)) var/mob/living/carbon/human/U = user - U.make_bloody_hands(target.get_blood_dna_list(), target.get_blood_color()) + U.make_bloody_hands(target.get_blood_dna_list(), target.get_blood_color(), 0) return SURGERY_STEP_CONTINUE diff --git a/code/modules/surgery/surgery.dm b/code/modules/surgery/surgery.dm index 3184d963abb3..3e5bfdf98eac 100644 --- a/code/modules/surgery/surgery.dm +++ b/code/modules/surgery/surgery.dm @@ -452,7 +452,7 @@ switch(blood_level) if(SURGERY_BLOODSPREAD_HANDS) target.visible_message("Blood splashes onto [user]'s hands.") - H.make_bloody_hands(target.get_blood_dna_list(), target.get_blood_color()) + H.make_bloody_hands(target.get_blood_dna_list(), target.get_blood_color(), 0) if(SURGERY_BLOODSPREAD_FULLBODY) target.visible_message("A spray of blood coats [user].") H.bloody_body(target)