Skip to content

Commit

Permalink
Gives Surgical Drapes a Use (ParadiseSS13#25686)
Browse files Browse the repository at this point in the history
* Gives drapes some utility for starting surgeries

* Adds a nice helping of drapes throughout the codebase

* add icon, realize I didn't think that through

* Handles blood with signals

* whoopsie daisy

* range

* how about borgs

* Apply suggestions from code review

Co-authored-by: Matt <[email protected]>
Signed-off-by: Luc <[email protected]>

* burza suggestion

* more dgamer reviews

* Oops

* Update code/modules/surgery/surgery.dm

Co-authored-by: DGamerL <[email protected]>
Signed-off-by: Luc <[email protected]>

---------

Signed-off-by: Luc <[email protected]>
Co-authored-by: Matt <[email protected]>
Co-authored-by: DGamerL <[email protected]>
  • Loading branch information
3 people committed Jul 1, 2024
1 parent 87e6460 commit 77253c5
Show file tree
Hide file tree
Showing 13 changed files with 157 additions and 23 deletions.
14 changes: 13 additions & 1 deletion code/__DEFINES/dcs/signals.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@
#define COMSIG_ATOM_HULK_ATTACK "hulk_attack"
///from base of atom/animal_attack(): (/mob/user)
#define COMSIG_ATOM_ATTACK_ANIMAL "attack_animal"
///from base of atom/examine(): (/mob)
///from base of atom/examine(): (examining_user, examine_list)
#define COMSIG_PARENT_EXAMINE "atom_examine"
///from base of atom/examine_more(): (examining_user, examine_list)
#define COMSIG_PARENT_EXAMINE_MORE "atom_examine_more"
///from base of atom/get_examine_name(): (/mob, list/overrides)
#define COMSIG_ATOM_GET_EXAMINE_NAME "atom_examine_name"
//Positions for overrides list
Expand Down Expand Up @@ -508,6 +510,16 @@
//sent from a mob when they set themselves to DNR
#define COMSIG_LIVING_SET_DNR "set_dnr"

// Sent from a surgery step when blood is being splashed. (datum/surgery, mob/user, mob/target, zone, obj/item/tool)
#define COMSIG_SURGERY_BLOOD_SPLASH "surgery_blood_splash"
/// If returned from this signal, will prevent any surgery splashing.
#define COMPONENT_BLOOD_SPLASH_HANDLED (1<<0)

// Sent from a surgery step when organs are being spread from an incision
#define COMSIG_SURGERY_GERM_SPREAD "surgery_germ_spread"
/// If returned from this signal, germ spread will be blocked.
#define COMPONENT_GERM_SPREAD_BLOCK (1<<0)


//ALL OF THESE DO NOT TAKE INTO ACCOUNT WHETHER AMOUNT IS 0 OR LOWER AND ARE SENT REGARDLESS!
// none of these are called as of right now, as there is nothing listening for them.
Expand Down
92 changes: 88 additions & 4 deletions code/datums/components/surgery_initiator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@
/// Also, note that for anything sharp, SURGERY_INITIATOR_ORGANIC should be set as well.
var/valid_starting_types = SURGERY_INITIATOR_ORGANIC

/// How effective this is at preventing infections.
/// 0 = preventing nothing, 1 = preventing any infection
var/germ_prevention_quality = 0

/// The sound to play when starting surgeries
var/surgery_start_sound = null

// Replace any other surgery initiator
dupe_type = /datum/component/surgery_initiator

Expand All @@ -43,10 +50,16 @@
/datum/component/surgery_initiator/RegisterWithParent()
RegisterSignal(parent, COMSIG_ITEM_ATTACK, PROC_REF(initiate_surgery_moment))
RegisterSignal(parent, COMSIG_ATOM_UPDATE_SHARPNESS, PROC_REF(on_parent_sharpness_change))
RegisterSignal(parent, COMSIG_PARENT_EXAMINE_MORE, PROC_REF(on_parent_examine_more))

/datum/component/surgery_initiator/UnregisterFromParent()
UnregisterSignal(parent, COMSIG_ITEM_ATTACK)
UnregisterSignal(parent, COMSIG_ATOM_UPDATE_SHARPNESS)
UnregisterSignal(parent, COMSIG_PARENT_EXAMINE_MORE)

/datum/component/surgery_initiator/proc/on_parent_examine_more(datum/source, mob/user, list/examine_list)
SIGNAL_HANDLER // COMSIG_PARENT_EXAMINE_MORE
examine_list += "<span class='notice'>You can use this on someone who is laying down to begin surgery on them.</span>"

/// Keep tabs on the attached item's sharpness.
/// This component gets added in atoms when they're made sharp as well.
Expand Down Expand Up @@ -134,8 +147,14 @@
if(!procedure)
return

if(!on_surgery_selection(user, target, procedure))
return

return try_choose_surgery(user, target, procedure)

/datum/component/surgery_initiator/proc/on_surgery_selection(mob/user, mob/living/target, datum/surgery/target_surgery)
return TRUE

/datum/component/surgery_initiator/proc/get_available_surgeries(mob/user, mob/living/target)
var/list/available_surgeries = list()
for(var/datum/surgery/surgery in GLOB.surgeries_list)
Expand All @@ -150,16 +169,19 @@

return available_surgeries

/datum/component/surgery_initiator/proc/cancel_unstarted_surgery_fluff(datum/surgery/the_surgery, mob/living/patient, mob/user, selected_zone)
user.visible_message(
"<span class='notice'>[user] stops the surgery on [patient]'s [parse_zone(selected_zone)] with [parent].</span>",
"<span class='notice'>You stop the surgery on [patient]'s [parse_zone(selected_zone)] with [parent].</span>",
)

/// Does the surgery de-initiation.
/datum/component/surgery_initiator/proc/attempt_cancel_surgery(datum/surgery/the_surgery, mob/living/patient, mob/user)
var/selected_zone = user.zone_selected
/// We haven't even started yet. Any surgery can be cancelled at this point.
if(the_surgery.step_number == 1)
patient.surgeries -= the_surgery
user.visible_message(
"<span class='notice'>[user] stops the surgery on [patient]'s [parse_zone(selected_zone)] with [parent].</span>",
"<span class='notice'>You stop the surgery on [patient]'s [parse_zone(selected_zone)] with [parent].</span>",
)
cancel_unstarted_surgery_fluff(the_surgery, patient, user, selected_zone)

qdel(the_surgery)
return TRUE
Expand Down Expand Up @@ -288,10 +310,17 @@

var/datum/surgery/procedure = new surgery.type(target, selected_zone, affecting_limb)


RegisterSignal(procedure, COMSIG_SURGERY_BLOOD_SPLASH, PROC_REF(on_blood_splash))

procedure.germ_prevention_quality = germ_prevention_quality

show_starting_message(user, target, procedure)

log_attack(user, target, "operated on (OPERATION TYPE: [procedure.name]) (TARGET AREA: [selected_zone])")

return procedure

/datum/component/surgery_initiator/proc/surgery_needs_exposure(datum/surgery/surgery, mob/living/target)
return !surgery.ignore_clothes && !get_location_accessible(target, target.zone_selected)

Expand All @@ -302,6 +331,14 @@
"<span class='notice'>You hold [parent] over [target]'s [parse_zone(user.zone_selected)] to prepare for \an [procedure.name].</span>",
)

/datum/component/surgery_initiator/proc/on_prevent_germs()
SIGNAL_HANDLER //
return

/datum/component/surgery_initiator/proc/on_blood_splash()
SIGNAL_HANDLER // COMSIG_SURGERY_BLOOD_SPLASH
return

/datum/component/surgery_initiator/limb
can_cancel = FALSE // don't let a leg cancel a surgery

Expand All @@ -310,3 +347,50 @@

/datum/component/surgery_initiator/robo/sharp
valid_starting_types = SURGERY_INITIATOR_ORGANIC | SURGERY_INITIATOR_ROBOTIC

/datum/component/surgery_initiator/cloth
can_cancel = FALSE
surgery_start_sound = "rustle"

/datum/component/surgery_initiator/cloth/show_starting_message(mob/user, mob/living/target, datum/surgery/procedure)
user.visible_message(
"<span class='notice'>[user] drapes [parent] over [target]'s [parse_zone(user.zone_selected)] to prepare for surgery.</span>",
"<span class='notice'>You drape [parent] over [target]'s [parse_zone(user.zone_selected)] to prepare for \an [procedure.name].</span>",
)

/datum/component/surgery_initiator/cloth/try_choose_surgery(mob/user, mob/living/target, datum/surgery/surgery)
var/datum/surgery/new_procedure = ..()
if(!istype(new_procedure))
return

new_procedure.started_with_drapes = TRUE

/datum/component/surgery_initiator/cloth/on_surgery_selection(mob/user, mob/living/target, datum/surgery/target_surgery)
user.visible_message(
"<span class='notice'>[user] starts to apply [parent] onto [target].</span>",
"<span class='notice'>You start to apply [parent] onto [target].</span>",
)

if(!isnull(surgery_start_sound))
playsound(src, surgery_start_sound, 50, TRUE)

playsound(src, surgery_start_sound)
if(!do_after_once(user, 3 SECONDS, TRUE, target))
user.visible_message(
"<span class='warning'>[user] stops applying [parent] onto [target].</span>",
"<span class='warning'>You stop applying [parent] onto [target].</span>"
)
return


if(!isnull(surgery_start_sound))
playsound(src, surgery_start_sound, 50, TRUE)

return TRUE

/datum/component/surgery_initiator/cloth/on_blood_splash(datum/surgery, mob/user, mob/target, zone, obj/item/tool)
if(prob(90 * germ_prevention_quality))
target.visible_message("<span class='notice'>Blood splashes onto the dressing.</span>")
var/obj/item/I = parent // safety: this component can only go onto an item
I.add_mob_blood(target)
return COMPONENT_BLOOD_SPLASH_HANDLED
4 changes: 2 additions & 2 deletions code/game/atoms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@
/atom/proc/examine_more(mob/user)
SHOULD_CALL_PARENT(TRUE)
RETURN_TYPE(/list)

return list()
. = list()
SEND_SIGNAL(src, COMSIG_PARENT_EXAMINE_MORE, user, .)

/**
* Updates the appearence of the icon
Expand Down
2 changes: 2 additions & 0 deletions code/game/objects/items/stacks/sheets/sheet_types.dm
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ GLOBAL_LIST_INIT(cloth_recipes, list (
)),
null,
new /datum/stack_recipe("improvised gauze", /obj/item/stack/medical/bruise_pack/improvised, 1, 2, 6),
new /datum/stack_recipe("imrovised drapes", /obj/item/surgical_drapes/improvised, 1),
new /datum/stack_recipe("rag", /obj/item/reagent_containers/glass/rag, 1),
new /datum/stack_recipe("bedsheet", /obj/item/bedsheet, 3),
new /datum/stack_recipe("empty sandbag", /obj/item/emptysandbag, 4),
Expand Down Expand Up @@ -407,6 +408,7 @@ GLOBAL_LIST_INIT(durathread_recipes, list (
new /datum/stack_recipe("durathread beret", /obj/item/clothing/head/beret/durathread, 2, time = 4 SECONDS),
new /datum/stack_recipe("durathread beanie", /obj/item/clothing/head/beanie/durathread, 2, time = 4 SECONDS),
new /datum/stack_recipe("durathread bandana", /obj/item/clothing/mask/bandana/durathread, 1, time = 2.5 SECONDS),
new /datum/stack_recipe("surgical drapes", /obj/item/surgical_drapes, 1, time = 3 SECONDS)
))

/obj/item/stack/sheet/durathread
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/items/weapons/storage/backpack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@
new /obj/item/bonegel(src)
new /obj/item/bonesetter(src)
new /obj/item/FixOVein(src)
new /obj/item/surgical_drapes(src)
new /obj/item/clothing/suit/straight_jacket(src)
new /obj/item/clothing/mask/muzzle(src)
new /obj/item/reagent_containers/glass/bottle/reagent/hydrocodone(src)
Expand Down
1 change: 1 addition & 0 deletions code/game/objects/mail.dm
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
/obj/item/clothing/glasses/sunglasses,
/obj/item/food/snacks/fortunecookie,
/obj/item/scalpel/laser/laser1,
/obj/item/surgical_drapes,
/obj/item/toy/figure/crew/cmo,
/obj/item/toy/figure/crew/chemist,
/obj/item/toy/figure/crew/geneticist,
Expand Down
4 changes: 4 additions & 0 deletions code/game/objects/structures/bedsheet_bin.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ LINEN BINS
var/list/nightmare_messages = list("black")
var/comfort = 0.5

/obj/item/bedsheet/Initialize(mapload)
. = ..()
AddComponent(/datum/component/surgery_initiator/cloth, null, 0.45) // honestly, not bad.

/obj/item/bedsheet/attack_hand(mob/user)
if(isturf(loc) && user.Move_Pulled(src)) // make sure its on the ground first, prevents a speed exploit
return
Expand Down
5 changes: 5 additions & 0 deletions code/modules/clothing/under/suit.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"Kidan" = 'icons/mob/clothing/species/kidan/under/suit.dmi'
)

/obj/item/clothing/under/suit/Initialize(mapload)
. = ..()
// better than nothing! ghetto surgery time
AddComponent(/datum/component/surgery_initiator/cloth, null, 0.1)

/obj/item/clothing/under/suit/black
name = "black suit"
desc = "A black suit and red tie. Very formal."
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/silicon/robot/robot_modules.dm
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@
/obj/item/stack/medical/ointment/advanced/cyborg,
/obj/item/stack/medical/splint/cyborg,
/obj/item/stack/nanopaste/cyborg,
/obj/item/gripper/medical
/obj/item/gripper/medical,
/obj/item/surgical_drapes,
)
malf_modules = list(/obj/item/gun/syringemalf)
special_rechargables = list(
Expand Down
3 changes: 2 additions & 1 deletion code/modules/supply/supply_packs/pack_medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,8 @@
/obj/item/bonegel,
/obj/item/retractor,
/obj/item/bonesetter,
/obj/item/circular_saw)
/obj/item/circular_saw,
/obj/item/surgical_drapes)
cost = 400
containertype = /obj/structure/closet/crate/secure
containername = "surgery crate"
Expand Down
16 changes: 8 additions & 8 deletions code/modules/surgery/generic.dm
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
/datum/surgery_step/generic/cut_open/begin_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool, datum/surgery/surgery)
var/obj/item/organ/external/affected = target.get_organ(target_zone)
user.visible_message(
"[user] starts the incision on [target]'s [affected.name] with \the [tool].",
"You start the incision on [target]'s [affected.name] with \the [tool].",
"[user] starts the incision on [target]'s [affected.name] with [tool].",
"You start the incision on [target]'s [affected.name] with [tool].",
chat_message_type = MESSAGE_TYPE_COMBAT
)
affected.custom_pain("You feel a horrible pain as if from a sharp knife in your [affected.name]!")
Expand All @@ -38,8 +38,8 @@
/datum/surgery_step/generic/cut_open/end_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool, datum/surgery/surgery)
var/obj/item/organ/external/affected = target.get_organ(target_zone)
user.visible_message(
"<span class='notice'> [user] has made an incision on [target]'s [affected.name] with \the [tool].</span>",
"<span class='notice'> You have made an incision on [target]'s [affected.name] with \the [tool].</span>",
"<span class='notice'>[user] has made an incision on [target]'s [affected.name] with [tool].</span>",
"<span class='notice'>You have made an incision on [target]'s [affected.name] with [tool].</span>",
chat_message_type = MESSAGE_TYPE_COMBAT
)
affected.open = ORGAN_ORGANIC_OPEN
Expand All @@ -49,8 +49,8 @@
/datum/surgery_step/generic/cut_open/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool, datum/surgery/surgery)
var/obj/item/organ/external/affected = target.get_organ(target_zone)
user.visible_message(
"<span class='warning'> [user]'s hand slips, slicing open [target]'s [affected.name] in a wrong spot with \the [tool]!</span>",
"<span class='warning'> Your hand slips, slicing open [target]'s [affected.name] in a wrong spot with \the [tool]!</span>",
"<span class='warning'>[user]'s hand slips, slicing open [target]'s [affected.name] in a wrong spot with [tool]!</span>",
"<span class='warning'>Your hand slips, slicing open [target]'s [affected.name] in a wrong spot with [tool]!</span>",
chat_message_type = MESSAGE_TYPE_COMBAT
)
affected.receive_damage(10)
Expand Down Expand Up @@ -93,8 +93,8 @@
/datum/surgery_step/generic/clamp_bleeders/fail_step(mob/living/user, mob/living/carbon/human/target, target_zone, obj/item/tool, datum/surgery/surgery)
var/obj/item/organ/external/affected = target.get_organ(target_zone)
user.visible_message(
"<span class='warning'> [user]'s hand slips, tearing blood vessels and causing massive bleeding in [target]'s [affected.name] with \the [tool]!</span>",
"<span class='warning'> Your hand slips, tearing blood vessels and causing massive bleeding in [target]'s [affected.name] with \the [tool]!</span>",
"<span class='warning'>[user]'s hand slips, tearing blood vessels and causing massive bleeding in [target]'s [affected.name] with \the [tool]!</span>",
"<span class='warning'>Your hand slips, tearing blood vessels and causing massive bleeding in [target]'s [affected.name] with \the [tool]!</span>",
chat_message_type = MESSAGE_TYPE_COMBAT
)
affected.receive_damage(10)
Expand Down
18 changes: 13 additions & 5 deletions code/modules/surgery/surgery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@
var/abstract = FALSE
/// Whether this surgery should be cancelled when an organ change happens. (removed if requires bodypart, or added if doesn't require bodypart)
var/cancel_on_organ_change = TRUE

/// Whether the surgery was started with drapes.
var/started_with_drapes = FALSE
/// How likely it should be for the surgery to cause infection: 0-1
var/germ_prevention_quality = 0

/datum/surgery/New(atom/surgery_target, surgery_location, surgery_bodypart)
..()
Expand Down Expand Up @@ -440,16 +443,21 @@
SHOULD_CALL_PARENT(TRUE)
if(ishuman(target))
var/obj/item/organ/external/affected = target.get_organ(target_zone)
if(can_infect && affected)
if(can_infect && affected && !prob(surgery.germ_prevention_quality))
spread_germs_to_organ(affected, user, tool)
if(ishuman(user) && !isalien(target) && prob(60))
var/mob/living/carbon/human/H = user

var/blood_spread = SEND_SIGNAL(surgery, COMSIG_SURGERY_BLOOD_SPLASH, user, target, target_zone, tool)
if(blood_spread == COMPONENT_BLOOD_SPLASH_HANDLED)
return
switch(blood_level)
if(SURGERY_BLOODSPREAD_HANDS)
target.visible_message("<span class='notice'>Blood splashes onto [user]'s hands.</span>")
H.make_bloody_hands(target.get_blood_dna_list(), target.get_blood_color())
if(SURGERY_BLOODSPREAD_FULLBODY)
target.visible_message("<span class='notice'>A spray of blood coats [user].</span>")
H.bloody_body(target)
return

/**
* Finish a surgery step, performing anything that runs on the tail-end of a successful surgery.
Expand Down Expand Up @@ -484,7 +492,7 @@
* * user - The user who's manipulating the organ.
* * tool - The tool the user is using to mess with the organ.
*/
/proc/spread_germs_to_organ(obj/item/organ/target_organ, mob/living/carbon/human/user, obj/item/tool)
/datum/surgery_step/proc/spread_germs_to_organ(obj/item/organ/target_organ, mob/living/carbon/human/user, obj/item/tool, datum/surgery/surgery)
if(!istype(user) || !istype(target_organ) || target_organ.is_robotic() || target_organ.sterile)
return

Expand All @@ -502,7 +510,7 @@
* * E - An external organ being operated on.
* * tool - The tool performing the operation.
*/
/proc/spread_germs_by_incision(obj/item/organ/external/E, obj/item/tool)
/datum/surgery_step/proc/spread_germs_by_incision(obj/item/organ/external/E, obj/item/tool, datum/surgery/surgery)
if(!is_external_organ(E))
return
if(!E.owner)
Expand Down
17 changes: 16 additions & 1 deletion code/modules/surgery/tools.dm
Original file line number Diff line number Diff line change
Expand Up @@ -274,9 +274,24 @@

/obj/item/surgical_drapes
name = "surgical drapes"
desc = "Apearature brand surgical drapes providing privacy and infection control."
desc = "Apearature brand surgical drapes providing privacy and infection control. Built from durathread."
icon = 'icons/obj/surgery.dmi'
icon_state = "surgical_drapes"
w_class = WEIGHT_CLASS_SMALL
origin_tech = "biotech=1"
attack_verb = list("slapped")
/// How effective this is at preventing infections during surgeries.
var/surgery_effectiveness = 0.9

/obj/item/surgical_drapes/Initialize(mapload)
. = ..()
ADD_TRAIT(src, TRAIT_SURGICAL, ROUNDSTART_TRAIT)
AddComponent(/datum/component/surgery_initiator/cloth, null, surgery_effectiveness)

/obj/item/surgical_drapes/improvised
name = "improvised drapes"
desc = "Hastily-sliced fabric that seems like it'd be useful for surgery. Probably better than the shirt off your back."
icon = 'icons/obj/stacks/miscellaneous.dmi'
icon_state = "empty-sandbags"
origin_tech = null
surgery_effectiveness = 0.67

0 comments on commit 77253c5

Please sign in to comment.