diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm
index 426e83cf015..56aaef0df5d 100644
--- a/code/__DEFINES/mobs.dm
+++ b/code/__DEFINES/mobs.dm
@@ -129,6 +129,7 @@
#define BIOWARE_NERVES "nerves"
#define BIOWARE_CIRCULATION "circulation"
#define BIOWARE_LIGAMENTS "ligaments"
+#define BIOWARE_CORTEX "cortex"
//Health hud screws for carbon mobs
#define SCREWYHUD_NONE 0
diff --git a/code/__DEFINES/traits.dm b/code/__DEFINES/traits.dm
index 4f14e08864a..f23d8e15357 100644
--- a/code/__DEFINES/traits.dm
+++ b/code/__DEFINES/traits.dm
@@ -176,6 +176,7 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai
#define TRAIT_NAIVE "naive"
#define TRAIT_PRIMITIVE "primitive"
#define TRAIT_GUNFLIP "gunflip"
+#define TRAIT_SPECIAL_TRAUMA_BOOST "special_trauma_boost" ///Increases chance of getting special traumas, makes them harder to cure
#define TRAIT_BLOODCRAWL_EAT "bloodcrawl_eat"
#define TRAIT_SPACEWALK "spacewalk"
#define TRAIT_GAMERGOD "gamer-god" //double arcade prizes
diff --git a/code/modules/mob/living/brain/brain_item.dm b/code/modules/mob/living/brain/brain_item.dm
index 5afb5676d38..7ac10912e7e 100644
--- a/code/modules/mob/living/brain/brain_item.dm
+++ b/code/modules/mob/living/brain/brain_item.dm
@@ -197,10 +197,12 @@
if(damage > BRAIN_DAMAGE_MILD)
if(prob(damage_delta * (1 + max(0, (damage - BRAIN_DAMAGE_MILD)/100)))) //Base chance is the hit damage; for every point of damage past the threshold the chance is increased by 1% //learn how to do your bloody math properly goddamnit
gain_trauma_type(BRAIN_TRAUMA_MILD, natural_gain = TRUE)
+
+ var/is_boosted = (owner && HAS_TRAIT(owner, TRAIT_SPECIAL_TRAUMA_BOOST))
if(damage > BRAIN_DAMAGE_SEVERE)
if(prob(damage_delta * (1 + max(0, (damage - BRAIN_DAMAGE_SEVERE)/100)))) //Base chance is the hit damage; for every point of damage past the threshold the chance is increased by 1%
- if(prob(20))
- gain_trauma_type(BRAIN_TRAUMA_SPECIAL, natural_gain = TRUE)
+ if(prob(20 + (is_boosted * 30)))
+ gain_trauma_type(BRAIN_TRAUMA_SPECIAL, is_boosted ? TRAUMA_RESILIENCE_SURGERY : null, natural_gain = TRUE)
else
gain_trauma_type(BRAIN_TRAUMA_SEVERE, natural_gain = TRUE)
diff --git a/code/modules/research/designs/medical_designs.dm b/code/modules/research/designs/medical_designs.dm
index 17e907becf8..37c44dc461b 100644
--- a/code/modules/research/designs/medical_designs.dm
+++ b/code/modules/research/designs/medical_designs.dm
@@ -771,6 +771,20 @@
surgery = /datum/surgery/advanced/bioware/ligament_reinforcement
research_icon_state = "surgery_chest"
+/datum/design/surgery/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 damage caused by minor brain traumas."
+ id = "surgery_cortex_imprint"
+ surgery = /datum/surgery/advanced/bioware/cortex_imprint
+ research_icon_state = "surgery_head"
+
+/datum/design/surgery/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."
+ id = "surgery_cortex_folding"
+ surgery = /datum/surgery/advanced/bioware/cortex_folding
+ research_icon_state = "surgery_head"
+
/datum/design/surgery/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."
diff --git a/code/modules/research/techweb/all_nodes.dm b/code/modules/research/techweb/all_nodes.dm
index 5b2e4d0a4df..e3c7eb35dbf 100644
--- a/code/modules/research/techweb/all_nodes.dm
+++ b/code/modules/research/techweb/all_nodes.dm
@@ -112,7 +112,7 @@
display_name = "Experimental Surgery"
description = "When evolution isn't fast enough."
prereq_ids = list("adv_surgery")
- design_ids = list("surgery_pacify","surgery_vein_thread","surgery_muscled_veins","surgery_nerve_splice","surgery_nerve_ground","surgery_ligament_hook","surgery_ligament_reinforcement","surgery_viral_bond", "surgery_heal_combo_upgrade", "surgery_exp_dissection")
+ design_ids = list("surgery_pacify","surgery_vein_thread","surgery_muscled_veins","surgery_nerve_splice","surgery_nerve_ground","surgery_ligament_hook","surgery_ligament_reinforcement","surgery_cortex_imprint","surgery_cortex_folding","surgery_viral_bond", "surgery_heal_combo_upgrade", "surgery_exp_dissection")
research_costs = list(TECHWEB_POINT_TYPE_GENERIC = 5000)
export_price = 5000
diff --git a/code/modules/surgery/advanced/bioware/bioware.dm b/code/modules/surgery/advanced/bioware/bioware.dm
index ab2f76f28ba..badf7e91d34 100644
--- a/code/modules/surgery/advanced/bioware/bioware.dm
+++ b/code/modules/surgery/advanced/bioware/bioware.dm
@@ -6,6 +6,7 @@
var/mob/living/carbon/human/owner
var/desc = "If you see this something's wrong, warn a coder."
var/active = FALSE
+ var/can_process = FALSE
var/mod_type = BIOWARE_GENERIC
/datum/bioware/New(mob/living/carbon/human/_owner)
@@ -17,7 +18,7 @@
return
owner.bioware += src
on_gain()
-
+
/datum/bioware/Destroy()
owner = null
if(active)
@@ -26,6 +27,9 @@
/datum/bioware/proc/on_gain()
active = TRUE
+ if(can_process)
+ START_PROCESSING(SSobj, src)
/datum/bioware/proc/on_lose()
+ STOP_PROCESSING(SSobj, src)
return
diff --git a/code/modules/surgery/advanced/bioware/cortex_folding.dm b/code/modules/surgery/advanced/bioware/cortex_folding.dm
new file mode 100644
index 00000000000..c4b572a7022
--- /dev/null
+++ b/code/modules/surgery/advanced/bioware/cortex_folding.dm
@@ -0,0 +1,61 @@
+/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/imprint_cortex,
+ /datum/surgery_step/close)
+ possible_locs = list(BODY_ZONE_HEAD)
+ target_mobtypes = list(/mob/living/carbon/human, /mob/living/carbon/monkey)
+ bioware_target = BIOWARE_LIGAMENTS
+
+/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)
+ return FALSE
+ return ..()
+
+/datum/surgery_step/fold_cortex
+ name = "fold cortex"
+ accept_hand = TRUE
+ time = 125
+ experience_given = MEDICAL_SKILL_ADVANCED
+
+/datum/surgery_step/fold_cortex/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
+ display_results(user, target, "You start folding [target]'s outer cerebral cortex into a fractal pattern.",
+ "[user] starts folding [target]'s outer cerebral cortex into a fractal pattern.",
+ "[user] begins to perform surgery on [target]'s brain.")
+
+/datum/surgery_step/fold_cortex/success(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery, default_display_results = FALSE)
+ display_results(user, target, "You fold [target]'s outer cerebral cortex into a fractal pattern!",
+ "[user] folds [target]'s outer cerebral cortex into a fractal pattern!",
+ "[user] completes the surgery on [target]'s brain.")
+ new /datum/bioware/cortex_fold(target)
+ return ..()
+
+/datum/surgery_step/fold_cortex/failure(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
+ if(target.getorganslot(ORGAN_SLOT_BRAIN))
+ display_results(user, target, "You screw up, damaging the brain!",
+ "[user] screws up, damaging the brain!",
+ "[user] completes the surgery on [target]'s brain.")
+ target.adjustOrganLoss(ORGAN_SLOT_BRAIN, 60)
+ target.gain_trauma_type(BRAIN_TRAUMA_SEVERE, TRAUMA_RESILIENCE_LOBOTOMY)
+ else
+ user.visible_message("[user] suddenly notices that the brain [user.p_they()] [user.p_were()] working on is not there anymore.", "You suddenly notice that the brain you were working on is not there anymore.")
+ return FALSE
+
+/datum/bioware/cortex_fold
+ name = "Cortex Fold"
+ desc = "The cerebral cortex has been folded into a complex fractal pattern, and can support non-standard neural patterns."
+ mod_type = BIOWARE_CORTEX
+
+/datum/bioware/cortex_fold/on_gain()
+ . = ..()
+ ADD_TRAIT(owner, TRAIT_SPECIAL_TRAUMA_BOOST, "cortex_fold")
+
+/datum/bioware/cortex_fold/on_lose()
+ REMOVE_TRAIT(owner, TRAIT_SPECIAL_TRAUMA_BOOST, "cortex_fold")
+ return ..()
diff --git a/code/modules/surgery/advanced/bioware/cortex_imprint.dm b/code/modules/surgery/advanced/bioware/cortex_imprint.dm
new file mode 100644
index 00000000000..951fd800ac5
--- /dev/null
+++ b/code/modules/surgery/advanced/bioware/cortex_imprint.dm
@@ -0,0 +1,58 @@
+/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 damage 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)
+ possible_locs = list(BODY_ZONE_HEAD)
+ target_mobtypes = list(/mob/living/carbon/human, /mob/living/carbon/monkey)
+ bioware_target = BIOWARE_LIGAMENTS
+
+/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)
+ return FALSE
+ return ..()
+
+/datum/surgery_step/imprint_cortex
+ name = "imprint cortex"
+ accept_hand = TRUE
+ time = 125
+ experience_given = MEDICAL_SKILL_ADVANCED
+
+/datum/surgery_step/imprint_cortex/preop(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
+ display_results(user, target, "You start carving [target]'s outer cerebral cortex into a self-imprinting pattern.",
+ "[user] starts carving [target]'s outer cerebral cortex into a self-imprinting pattern.",
+ "[user] begins to perform surgery on [target]'s brain.")
+
+/datum/surgery_step/imprint_cortex/success(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery, default_display_results = FALSE)
+ display_results(user, target, "You reshape [target]'s outer cerebral cortex into a self-imprinting pattern!",
+ "[user] reshapes [target]'s outer cerebral cortex into a self-imprinting pattern!",
+ "[user] completes the surgery on [target]'s brain.")
+ new /datum/bioware/cortex_imprint(target)
+ return ..()
+
+/datum/surgery_step/imprint_cortex/failure(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
+ if(target.getorganslot(ORGAN_SLOT_BRAIN))
+ display_results(user, target, "You screw up, damaging the brain!",
+ "[user] screws up, damaging the brain!",
+ "[user] completes the surgery on [target]'s brain.")
+ target.adjustOrganLoss(ORGAN_SLOT_BRAIN, 60)
+ target.gain_trauma_type(BRAIN_TRAUMA_SEVERE, TRAUMA_RESILIENCE_LOBOTOMY)
+ else
+ user.visible_message("[user] suddenly notices that the brain [user.p_they()] [user.p_were()] working on is not there anymore.", "You suddenly notice that the brain you were working on is not there anymore.")
+ return FALSE
+
+/datum/bioware/cortex_imprint
+ name = "Cortex Imprint"
+ desc = "The cerebral cortex has been reshaped into a redundant neural pattern, making the brain able to bypass damage caused by minor brain traumas."
+ mod_type = BIOWARE_CORTEX
+ can_process = TRUE
+
+/datum/bioware/cortex_imprint/process()
+ owner.cure_trauma_type(resilience = TRAUMA_RESILIENCE_BASIC)
+
diff --git a/code/modules/surgery/advanced/lobotomy.dm b/code/modules/surgery/advanced/lobotomy.dm
index fd02138a0cc..cc17a713537 100644
--- a/code/modules/surgery/advanced/lobotomy.dm
+++ b/code/modules/surgery/advanced/lobotomy.dm
@@ -50,7 +50,10 @@
target.gain_trauma_type(BRAIN_TRAUMA_MILD, TRAUMA_RESILIENCE_MAGIC)
experience_given = MEDICAL_SKILL_ADVANCED*0.9
if(2)
- target.gain_trauma_type(BRAIN_TRAUMA_SEVERE, TRAUMA_RESILIENCE_MAGIC)
+ if(HAS_TRAIT(target, TRAIT_SPECIAL_TRAUMA_BOOST) && prob(50))
+ target.gain_trauma_type(BRAIN_TRAUMA_SPECIAL, TRAUMA_RESILIENCE_MAGIC)
+ else
+ target.gain_trauma_type(BRAIN_TRAUMA_SEVERE, TRAUMA_RESILIENCE_MAGIC)
experience_given = MEDICAL_SKILL_ADVANCED*0.8
if(3)
target.gain_trauma_type(BRAIN_TRAUMA_SPECIAL, TRAUMA_RESILIENCE_MAGIC)
@@ -68,7 +71,10 @@
if(1)
target.gain_trauma_type(BRAIN_TRAUMA_MILD, TRAUMA_RESILIENCE_MAGIC)
if(2)
- target.gain_trauma_type(BRAIN_TRAUMA_SEVERE, TRAUMA_RESILIENCE_MAGIC)
+ if(HAS_TRAIT(target, TRAIT_SPECIAL_TRAUMA_BOOST) && prob(50))
+ target.gain_trauma_type(BRAIN_TRAUMA_SPECIAL, TRAUMA_RESILIENCE_MAGIC)
+ else
+ target.gain_trauma_type(BRAIN_TRAUMA_SEVERE, TRAUMA_RESILIENCE_MAGIC)
if(3)
target.gain_trauma_type(BRAIN_TRAUMA_SPECIAL, TRAUMA_RESILIENCE_MAGIC)
else
diff --git a/tgstation.dme b/tgstation.dme
index 929c9224358..cfc3a7f441b 100644
--- a/tgstation.dme
+++ b/tgstation.dme
@@ -2940,6 +2940,8 @@
#include "code\modules\surgery\advanced\viral_bonding.dm"
#include "code\modules\surgery\advanced\bioware\bioware.dm"
#include "code\modules\surgery\advanced\bioware\bioware_surgery.dm"
+#include "code\modules\surgery\advanced\bioware\cortex_folding.dm"
+#include "code\modules\surgery\advanced\bioware\cortex_imprint.dm"
#include "code\modules\surgery\advanced\bioware\ligament_hook.dm"
#include "code\modules\surgery\advanced\bioware\ligament_reinforcement.dm"
#include "code\modules\surgery\advanced\bioware\muscled_veins.dm"