Skip to content

Commit

Permalink
Cleans up surgery and organ code. (tgstation#59068)
Browse files Browse the repository at this point in the history
About The Pull Request

Scrubs those filthy single letter variables out of surgery and organ code.
Replaces a few 0s and 1s with FALSE and TRUE where relevant
Normalises and cleans up surgery step lists and surgical implements lists.
Replaces a whole lotta for loops with for x as anything in y lops

This is my first PR (upstream anyway) so I encourage you to treat my code with as much confidence as I treat it, which is to say none, because there's a strong chance I've totally broken everything.

But it compiles!
Why It's Good For The Game

code improvement, follows contributing guidelines.
Changelog

🆑 FlamingLily
code: Cleanup of surgery and organ code
/🆑
  • Loading branch information
FlamingLily authored May 22, 2021
1 parent 15c710f commit 3958db8
Show file tree
Hide file tree
Showing 67 changed files with 1,618 additions and 1,447 deletions.
5 changes: 2 additions & 3 deletions code/modules/surgery/advanced/bioware/bioware.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

/datum/bioware/New(mob/living/carbon/human/_owner)
owner = _owner
for(var/X in owner.bioware)
var/datum/bioware/B = X
if(B.mod_type == mod_type)
for(var/datum/bioware/bioware as anything in owner.bioware)
if(bioware.mod_type == mod_type)
qdel(src)
return
owner.bioware += src
Expand Down
5 changes: 2 additions & 3 deletions code/modules/surgery/advanced/bioware/bioware_surgery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@
return FALSE
if(!istype(target))
return FALSE
for(var/X in target.bioware)
var/datum/bioware/B = X
if(B.mod_type == bioware_target)
for(var/datum/bioware/bioware as anything in target.bioware)
if(bioware.mod_type == bioware_target)
return FALSE
return TRUE
19 changes: 10 additions & 9 deletions code/modules/surgery/advanced/bioware/cortex_folding.dm
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/datum/surgery/advanced/bioware/cortex_folding
name = "Cortex Folding"
desc = "A surgical procedure which modifies the cerebral cortex into a complex fold, giving space to non-standard neural patterns."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/fold_cortex,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/fold_cortex,
/datum/surgery_step/close)
possible_locs = list(BODY_ZONE_HEAD)
target_mobtypes = list(/mob/living/carbon/human)
bioware_target = BIOWARE_CORTEX

/datum/surgery/advanced/bioware/cortex_folding/can_start(mob/user, mob/living/carbon/target)
var/obj/item/organ/brain/B = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!B)
var/obj/item/organ/brain/target_brain = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!target_brain)
return FALSE
return ..()

Expand Down
19 changes: 10 additions & 9 deletions code/modules/surgery/advanced/bioware/cortex_imprint.dm
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
/datum/surgery/advanced/bioware/cortex_imprint
name = "Cortex Imprint"
desc = "A surgical procedure which modifies the cerebral cortex into a redundant neural pattern, making the brain able to bypass impediments caused by minor brain traumas."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/imprint_cortex,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/imprint_cortex,
/datum/surgery_step/close)
possible_locs = list(BODY_ZONE_HEAD)
target_mobtypes = list(/mob/living/carbon/human)
bioware_target = BIOWARE_CORTEX

/datum/surgery/advanced/bioware/cortex_imprint/can_start(mob/user, mob/living/carbon/target)
var/obj/item/organ/brain/B = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!B)
var/obj/item/organ/brain/target_brain = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!target_brain)
return FALSE
return ..()

Expand Down
15 changes: 8 additions & 7 deletions code/modules/surgery/advanced/bioware/ligament_hook.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
name = "Ligament Hook"
desc = "A surgical procedure which reshapes the connections between torso and limbs, making it so limbs can be attached manually if severed. \
However this weakens the connection, making them easier to detach as well."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/reshape_ligaments,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/reshape_ligaments,
/datum/surgery_step/close)
possible_locs = list(BODY_ZONE_CHEST)
bioware_target = BIOWARE_LIGAMENTS

Expand Down
15 changes: 8 additions & 7 deletions code/modules/surgery/advanced/bioware/ligament_reinforcement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@
name = "Ligament Reinforcement"
desc = "A surgical procedure which adds a protective tissue and bone cage around the connections between the torso and limbs, preventing dismemberment. \
However, the nerve connections as a result are more easily interrupted, making it easier to disable limbs with damage."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/reinforce_ligaments,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/reinforce_ligaments,
/datum/surgery_step/close)
possible_locs = list(BODY_ZONE_CHEST)
bioware_target = BIOWARE_LIGAMENTS

Expand Down
15 changes: 8 additions & 7 deletions code/modules/surgery/advanced/bioware/muscled_veins.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/datum/surgery/advanced/bioware/muscled_veins
name = "Vein Muscle Membrane"
desc = "A surgical procedure which adds a muscled membrane to blood vessels, allowing them to pump blood without a heart."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/muscled_veins,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/muscled_veins,
/datum/surgery_step/close)
possible_locs = list(BODY_ZONE_CHEST)
bioware_target = BIOWARE_CIRCULATION

Expand Down
15 changes: 8 additions & 7 deletions code/modules/surgery/advanced/bioware/nerve_grounding.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/datum/surgery/advanced/bioware/nerve_grounding
name = "Nerve Grounding"
desc = "A surgical procedure which makes the patient's nerves act as grounding rods, protecting them from electrical shocks."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/ground_nerves,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/ground_nerves,
/datum/surgery_step/close)
possible_locs = list(BODY_ZONE_CHEST)
bioware_target = BIOWARE_NERVES

Expand Down
15 changes: 8 additions & 7 deletions code/modules/surgery/advanced/bioware/nerve_splicing.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/datum/surgery/advanced/bioware/nerve_splicing
name = "Nerve Splicing"
desc = "A surgical procedure which splices the patient's nerves, making them more resistant to stuns."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/splice_nerves,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/splice_nerves,
/datum/surgery_step/close)
possible_locs = list(BODY_ZONE_CHEST)
bioware_target = BIOWARE_NERVES

Expand Down
15 changes: 8 additions & 7 deletions code/modules/surgery/advanced/bioware/vein_threading.dm
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/datum/surgery/advanced/bioware/vein_threading
name = "Vein Threading"
desc = "A surgical procedure which severely reduces the amount of blood lost in case of injury."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/thread_veins,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/incise,
/datum/surgery_step/incise,
/datum/surgery_step/thread_veins,
/datum/surgery_step/close)
possible_locs = list(BODY_ZONE_CHEST)
bioware_target = BIOWARE_CIRCULATION

Expand Down
10 changes: 7 additions & 3 deletions code/modules/surgery/advanced/brainwashing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@
/datum/surgery/advanced/brainwashing/can_start(mob/user, mob/living/carbon/target)
if(!..())
return FALSE
var/obj/item/organ/brain/B = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!B)
var/obj/item/organ/brain/target_brain = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!target_brain)
return FALSE
return TRUE

/datum/surgery_step/brainwash
name = "brainwash"
implements = list(TOOL_HEMOSTAT = 85, TOOL_WIRECUTTER = 50, /obj/item/stack/package_wrap = 35, /obj/item/stack/cable_coil = 15)
implements = list(
TOOL_HEMOSTAT = 85,
TOOL_WIRECUTTER = 50,
/obj/item/stack/package_wrap = 35,
/obj/item/stack/cable_coil = 15)
time = 200
var/objective

Expand Down
18 changes: 11 additions & 7 deletions code/modules/surgery/advanced/lobotomy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@
/datum/surgery/advanced/lobotomy/can_start(mob/user, mob/living/carbon/target)
if(!..())
return FALSE
var/obj/item/organ/brain/B = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!B)
var/obj/item/organ/brain/target_brain = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!target_brain)
return FALSE
return TRUE

/datum/surgery_step/lobotomize
name = "perform lobotomy"
implements = list(TOOL_SCALPEL = 85, /obj/item/melee/transforming/energy/sword = 55, /obj/item/kitchen/knife = 35,
/obj/item/shard = 25, /obj/item = 20)
implements = list(
TOOL_SCALPEL = 85,
/obj/item/melee/transforming/energy/sword = 55,
/obj/item/kitchen/knife = 35,
/obj/item/shard = 25,
/obj/item = 20)
time = 100

/datum/surgery_step/lobotomize/tool_check(mob/user, obj/item/tool)
Expand Down Expand Up @@ -57,12 +61,12 @@
return ..()

/datum/surgery_step/lobotomize/failure(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
var/obj/item/organ/brain/B = target.getorganslot(ORGAN_SLOT_BRAIN)
if(B)
var/obj/item/organ/brain/target_brain = target.getorganslot(ORGAN_SLOT_BRAIN)
if(target_brain)
display_results(user, target, "<span class='warning'>You remove the wrong part, causing more damage!</span>",
"<span class='notice'>[user] successfully lobotomizes [target]!</span>",
"<span class='notice'>[user] completes the surgery on [target]'s brain.</span>")
B.applyOrganDamage(80)
target_brain.applyOrganDamage(80)
switch(rand(1,3))
if(1)
target.gain_trauma_type(BRAIN_TRAUMA_MILD, TRAUMA_RESILIENCE_MAGIC)
Expand Down
25 changes: 14 additions & 11 deletions code/modules/surgery/advanced/necrotic_revival.dm
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
/datum/surgery/advanced/necrotic_revival
name = "Necrotic Revival"
desc = "An experimental surgical procedure that stimulates the growth of a Romerol tumor inside the patient's brain. Requires zombie powder or rezadone."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/saw,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/bionecrosis,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/saw,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/bionecrosis,
/datum/surgery_step/close)

possible_locs = list(BODY_ZONE_HEAD)

/datum/surgery/advanced/necrotic_revival/can_start(mob/user, mob/living/carbon/target)
. = ..()
var/obj/item/organ/zombie_infection/ZI = target.getorganslot(ORGAN_SLOT_ZOMBIE)
if(ZI)
var/obj/item/organ/zombie_infection/z_infection = target.getorganslot(ORGAN_SLOT_ZOMBIE)
if(z_infection)
return FALSE

/datum/surgery_step/bionecrosis
name = "start bionecrosis"
implements = list(/obj/item/reagent_containers/syringe = 100, /obj/item/pen = 30)
implements = list(
/obj/item/reagent_containers/syringe = 100,
/obj/item/pen = 30)
time = 50
chems_needed = list(/datum/reagent/toxin/zombiepowder, /datum/reagent/medicine/rezadone)
require_all_chems = FALSE
Expand All @@ -33,6 +36,6 @@
"<span class='notice'>[user] successfully grows a romerol tumor on [target]'s brain!</span>",
"<span class='notice'>[user] completes the surgery on [target]'s brain.</span>")
if(!target.getorganslot(ORGAN_SLOT_ZOMBIE))
var/obj/item/organ/zombie_infection/ZI = new()
ZI.Insert(target)
var/obj/item/organ/zombie_infection/z_infection = new()
z_infection.Insert(target)
return ..()
22 changes: 13 additions & 9 deletions code/modules/surgery/advanced/pacification.dm
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
/datum/surgery/advanced/pacify
name = "Pacification"
desc = "A surgical procedure which permanently inhibits the aggression center of the brain, making the patient unwilling to cause direct harm."
steps = list(/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/saw,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/pacify,
/datum/surgery_step/close)
steps = list(
/datum/surgery_step/incise,
/datum/surgery_step/retract_skin,
/datum/surgery_step/saw,
/datum/surgery_step/clamp_bleeders,
/datum/surgery_step/pacify,
/datum/surgery_step/close)

target_mobtypes = list(/mob/living/carbon/human)
possible_locs = list(BODY_ZONE_HEAD)
requires_bodypart_type = 0

/datum/surgery/advanced/pacify/can_start(mob/user, mob/living/carbon/target)
. = ..()
var/obj/item/organ/brain/B = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!B)
var/obj/item/organ/brain/target_brain = target.getorganslot(ORGAN_SLOT_BRAIN)
if(!target_brain)
return FALSE

/datum/surgery_step/pacify
name = "rewire brain"
implements = list(TOOL_HEMOSTAT = 100, TOOL_SCREWDRIVER = 35, /obj/item/pen = 15)
implements = list(
TOOL_HEMOSTAT = 100,
TOOL_SCREWDRIVER = 35,
/obj/item/pen = 15)
time = 40

/datum/surgery_step/pacify/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
Expand Down
Loading

0 comments on commit 3958db8

Please sign in to comment.