diff --git a/code/modules/mob/living/carbon/handle_corruption.dm b/code/modules/mob/living/carbon/handle_corruption.dm new file mode 100644 index 0000000000..0586d27776 --- /dev/null +++ b/code/modules/mob/living/carbon/handle_corruption.dm @@ -0,0 +1,165 @@ +////////////////////////////////////// +//SYSTEM CORRUPTION FOR ROBOT-PEOPLE// +////////////////////////////////////// + +//Moved into its own file for easier accessability & less cluttering of carbon/life.dm. Used in BiologicalLife() + + +#define CORRUPTION_CHECK_INTERVAL 10//Life() is called once every second.. I think?. +#define CORRUPTION_THRESHHOLD_MINOR 10 //Above: Annoyances, to remind you you should get your corruption fixed. +#define CORRUPTION_THRESHHOLD_MAJOR 40 //Above: Very annoying stuff, go get fixed. +#define CORRUPTION_THRESHHOLD_CRITICAL 70 //Above: Extremely annoying stuff, possibly life-threatening + +/mob/living/carbon/proc/handle_corruption() + if(!HAS_TRAIT(src, TRAIT_ROBOTIC_ORGANISM)) //Only robot-people need to care about this + return + corruption_timer++ + var/corruption = getToxLoss(toxins_type = TOX_SYSCORRUPT) + var/corruption_state + var/timer_req = CORRUPTION_CHECK_INTERVAL + switch(corruption) + if(0 to CORRUPTION_THRESHHOLD_MINOR) + timer_req = INFINITY //Below minor corruption you are fiiine + corruption_state = "None" + if(CORRUPTION_THRESHHOLD_MINOR to CORRUPTION_THRESHHOLD_MAJOR) + corruption_state = "Minor" + if(CORRUPTION_THRESHHOLD_MAJOR to CORRUPTION_THRESHHOLD_CRITICAL) + timer_req -= 1 + corruption_state = "Major" + if(CORRUPTION_THRESHHOLD_CRITICAL to INFINITY) + timer_req -= 2 + corruption_state = "Critical" + if(corruption_timer < timer_req) + return + corruption_timer = 0 + if(!prob(corruption)) //Lucky you beat the rng roll! + return + var/list/whatmighthappen = list() + whatmighthappen += list("avoided" = 4, "dropthing" = 1, "movetile" = 1, "shortdeaf" = 1, "flopover" = 2, "nutriloss" = 1, "selfflash" = 1, "harmies" = 1) + if(corruption >= CORRUPTION_THRESHHOLD_MAJOR) + whatmighthappen += list("longdeaf" = 1, "longknockdown" = 1, "shortlimbdisable" = 1, "shortblind" = 1, "shortstun" = 1, "shortmute" = 1, "vomit" = 1, "halluscinate" = 2) + if(corruption >= CORRUPTION_THRESHHOLD_CRITICAL) + whatmighthappen += list("receporgandamage" = 1, "longlimbdisable" = 1, "blindmutedeaf" = 1, "longstun" = 1, "sleep" = 1, "inducetrauma" = 1, "amplifycorrupt" = 2, "changetemp" = 2) + var/event = pickweight(whatmighthappen) + log_message("has been affected by [event] due to system corruption of [corruption], with a corruption state of [corruption_state]", LOG_ATTACK) + switch(event) + if("avoided") + to_chat(src, "System malfunction avoided by hardware safeguards - intervention recommended.") + adjustToxLoss(-0.2, toxins_type = TOX_SYSCORRUPT) //If you roll this, your system safeguards caught onto the system corruption and neutralised a bit of it. + if("dropthing") + drop_all_held_items() + to_chat(src, "Error - Malfunction in arm circuitry.") + if("movetile") + if(CHECK_MOBILITY(src, MOBILITY_MOVE) && !ismovable(loc)) + step(src, pick(GLOB.cardinals)) + to_chat(src, "Error - Malfuction in movement control subsystem.") + if("shortdeaf") + ADD_TRAIT(src, TRAIT_DEAF, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_hearing), 5 SECONDS) + to_chat(src, "ZZZZT") + if("flopover") + DefaultCombatKnockdown(1) + to_chat(src, "Error - Malfunction in actuator circuitry.") + if("nutriloss") + nutrition = max(0, nutrition - 50) + to_chat(src, "Power surge detected in internal battery cell.") + if("selfflash") + if(flash_act(override_protection = 1)) + confused += 2 + to_chat(src, "Error - Sensory system overload detected!") + if("harmies") + a_intent_change(INTENT_HARM) + to_chat(src, "Intent subsystem successfully recalibrated.") + if("longdeaf") + ADD_TRAIT(src, TRAIT_DEAF, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_hearing), 20 SECONDS) + to_chat(src, "Hearing subsystem successfully shutdown.") + if("longknockdown") + DefaultCombatKnockdown(50) + to_chat(src, "Significant error in actuator subsystem - Rebooting.") + if("shortlimbdisable") + var/disabled_type = pick(list(TRAIT_PARALYSIS_L_ARM, TRAIT_PARALYSIS_R_ARM, TRAIT_PARALYSIS_L_LEG, TRAIT_PARALYSIS_R_LEG)) + ADD_TRAIT(src, disabled_type, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_limb, disabled_type), 5 SECONDS) + to_chat(src, "Error - Limb control subsystem partially shutdown, rebooting.") + if("shortblind") + ADD_TRAIT(src, TRAIT_BLIND, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_vision), 5 SECONDS) + to_chat(src, "Visual receptor shutdown detected - Initiating reboot.") + if("shortstun") + Stun(30) + to_chat(src, "Deadlock detected in primary systems, error code [rand(101, 999)].") + if("shortmute") + ADD_TRAIT(src, TRAIT_MUTE, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_speech), 5 SECONDS) + to_chat(src, "Communications matrix successfully shutdown for maintenance.") + if("vomit") + to_chat(src, "Ejecting contaminant.") + vomit() + if("halluscinate") + hallucination += 20 //Doesn't give a cue + if("receporgandamage") + adjustOrganLoss(ORGAN_SLOT_EARS, rand(10, 20)) + adjustOrganLoss(ORGAN_SLOT_EYES, rand(10, 20)) + to_chat(src, "Power spike detected in auditory and visual systems!") + if("longlimbdisable") + var/disabled_type = pick(list(TRAIT_PARALYSIS_L_ARM, TRAIT_PARALYSIS_R_ARM, TRAIT_PARALYSIS_L_LEG, TRAIT_PARALYSIS_R_LEG)) + ADD_TRAIT(src, disabled_type, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_limb, disabled_type), 25 SECONDS) + to_chat(src, "Fatal error in limb control subsystem - rebooting.") + if("blindmutedeaf") + ADD_TRAIT(src, TRAIT_BLIND, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_vision), (rand(10, 25)) SECONDS) + ADD_TRAIT(src, TRAIT_DEAF, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_hearing), (rand(15, 35)) SECONDS) + ADD_TRAIT(src, TRAIT_MUTE, CORRUPTED_SYSTEM) + addtimer(CALLBACK(src, .proc/reenable_speech), (rand(20, 45)) SECONDS) + to_chat(src, "Fatal error in multiple systems - Performing recovery.") + if("longstun") + Stun(80) + to_chat(src, "") + if("sleep") + addtimer(CALLBACK(src, .proc/forcesleep), (rand(6, 10)) SECONDS) + to_chat(src, "Priority 1 shutdown order received in operating system - Preparing powerdown.") + if("inducetrauma") + to_chat(src, "Major interference detected in main operating matrix - Complications possible.") + var/resistance = pick( + 65;TRAUMA_RESILIENCE_BASIC, + 35;TRAUMA_RESILIENCE_SURGERY) + + var/trauma_type = pickweight(list( + BRAIN_TRAUMA_MILD = 80, + BRAIN_TRAUMA_SEVERE = 10)) + gain_trauma_type(trauma_type, resistance) //Gaining the trauma will inform them, but we'll tell them too so they know what the reason was. + if("amplifycorrupt") + adjustToxLoss(5, toxins_type = TOX_SYSCORRUPT) + to_chat(src, "System safeguards failing - Action urgently required.") + if("changetemp") + adjust_bodytemperature(rand(150, 250)) + to_chat(src, "Warning - Fatal coolant flow error at node [rand(6, 99)]!") //This is totally not a reference to anything. + +/mob/living/carbon/proc/reenable_limb(disabled_limb) + REMOVE_TRAIT(src, disabled_limb, CORRUPTED_SYSTEM) + to_chat(src, "Limb control subsystem successfully rebooted.") + +/mob/living/carbon/proc/reenable_hearing() + REMOVE_TRAIT(src, TRAIT_DEAF, CORRUPTED_SYSTEM) + to_chat(src, "Hearing restored.") + +/mob/living/carbon/proc/reenable_vision() + REMOVE_TRAIT(src, TRAIT_BLIND, CORRUPTED_SYSTEM) + to_chat(src, "Visual receptors back online.") + +/mob/living/carbon/proc/reenable_speech() + REMOVE_TRAIT(src, TRAIT_MUTE, CORRUPTED_SYSTEM) + to_chat(src, "Communications subsystem operational.") + +/mob/living/carbon/proc/forcesleep(time = 100) + to_chat(src, "Preparations complete, powering down.") + Sleeping(time, 0) + + +#undef CORRUPTION_CHECK_INTERVAL +#undef CORRUPTION_THRESHHOLD_MINOR +#undef CORRUPTION_THRESHHOLD_MAJOR +#undef CORRUPTION_THRESHHOLD_CRITICAL diff --git a/code/modules/mob/living/carbon/life.dm b/code/modules/mob/living/carbon/life.dm index da453dc164..6243b6cb36 100644 --- a/code/modules/mob/living/carbon/life.dm +++ b/code/modules/mob/living/carbon/life.dm @@ -738,166 +738,3 @@ GLOBAL_LIST_INIT(ballmer_windows_me_msg, list("Yo man, what if, we like, uh, put return heart.beating = !status - -////////////////////////////////////// -//SYSTEM CORRUPTION FOR ROBOT-PEOPLE// -////////////////////////////////////// - -#define CORRUPTION_CHECK_INTERVAL 10//Life() is called once every second.. I think?. -#define CORRUPTION_THRESHHOLD_MINOR 10 //Above: Annoyances, to remind you you should get your corruption fixed. -#define CORRUPTION_THRESHHOLD_MAJOR 40 //Above: Very annoying stuff, go get fixed. -#define CORRUPTION_THRESHHOLD_CRITICAL 70 //Above: Extremely annoying stuff, possibly life-threatening - -/mob/living/carbon/proc/handle_corruption() - if(!HAS_TRAIT(src, TRAIT_ROBOTIC_ORGANISM)) //Only robot-people need to care about this - return - corruption_timer++ - var/corruption = getToxLoss(toxins_type = TOX_SYSCORRUPT) - var/corruption_state - var/timer_req = CORRUPTION_CHECK_INTERVAL - switch(corruption) - if(0 to CORRUPTION_THRESHHOLD_MINOR) - timer_req = INFINITY //Below minor corruption you are fiiine - corruption_state = "None" - if(CORRUPTION_THRESHHOLD_MINOR to CORRUPTION_THRESHHOLD_MAJOR) - corruption_state = "Minor" - if(CORRUPTION_THRESHHOLD_MAJOR to CORRUPTION_THRESHHOLD_CRITICAL) - timer_req -= 1 - corruption_state = "Major" - if(CORRUPTION_THRESHHOLD_CRITICAL to INFINITY) - timer_req -= 2 - corruption_state = "Critical" - if(corruption_timer < timer_req) - return - corruption_timer = 0 - if(!prob(corruption)) //Lucky you beat the rng roll! - return - var/list/whatmighthappen = list() - whatmighthappen += list("avoided" = 4, "dropthing" = 1, "movetile" = 1, "shortdeaf" = 1, "flopover" = 2, "nutriloss" = 1, "selfflash" = 1, "harmies" = 1) - if(corruption >= CORRUPTION_THRESHHOLD_MAJOR) - whatmighthappen += list("longdeaf" = 1, "longknockdown" = 1, "shortlimbdisable" = 1, "shortblind" = 1, "shortstun" = 1, "shortmute" = 1, "vomit" = 1, "halluscinate" = 2) - if(corruption >= CORRUPTION_THRESHHOLD_CRITICAL) - whatmighthappen += list("receporgandamage" = 1, "longlimbdisable" = 1, "blindmutedeaf" = 1, "longstun" = 1, "sleep" = 1, "inducetrauma" = 1, "amplifycorrupt" = 2, "changetemp" = 2) - var/event = pickweight(whatmighthappen) - log_message("has been affected by [event] due to system corruption of [corruption], with a corruption state of [corruption_state]", LOG_ATTACK) - switch(event) - if("avoided") - to_chat(src, "System malfunction avoided by hardware safeguards - intervention recommended.") - adjustToxLoss(-0.2, toxins_type = TOX_SYSCORRUPT) //If you roll this, your system safeguards caught onto the system corruption and neutralised a bit of it. - if("dropthing") - drop_all_held_items() - to_chat(src, "Error - Malfunction in arm circuitry.") - if("movetile") - if(CHECK_MOBILITY(src, MOBILITY_MOVE) && !ismovable(loc)) - step(src, pick(GLOB.cardinals)) - to_chat(src, "Error - Malfuction in movement control subsystem.") - if("shortdeaf") - ADD_TRAIT(src, TRAIT_DEAF, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_hearing), 5 SECONDS) - to_chat(src, "ZZZZT") - if("flopover") - DefaultCombatKnockdown(1) - to_chat(src, "Error - Malfunction in actuator circuitry.") - if("nutriloss") - nutrition = max(0, nutrition - 50) - to_chat(src, "Power surge detected in internal battery cell.") - if("selfflash") - if(flash_act(override_protection = 1)) - confused += 2 - to_chat(src, "Error - Sensory system overload detected!") - if("harmies") - a_intent_change(INTENT_HARM) - to_chat(src, "Intent subsystem successfully recalibrated.") - if("longdeaf") - ADD_TRAIT(src, TRAIT_DEAF, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_hearing), 20 SECONDS) - to_chat(src, "Hearing subsystem successfully shutdown.") - if("longknockdown") - DefaultCombatKnockdown(50) - to_chat(src, "Significant error in actuator subsystem - Rebooting.") - if("shortlimbdisable") - var/disabled_type = pick(list(TRAIT_PARALYSIS_L_ARM, TRAIT_PARALYSIS_R_ARM, TRAIT_PARALYSIS_L_LEG, TRAIT_PARALYSIS_R_LEG)) - ADD_TRAIT(src, disabled_type, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_limb, disabled_type), 5 SECONDS) - to_chat(src, "Error - Limb control subsystem partially shutdown, rebooting.") - if("shortblind") - ADD_TRAIT(src, TRAIT_BLIND, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_vision), 5 SECONDS) - to_chat(src, "Visual receptor shutdown detected - Initiating reboot.") - if("shortstun") - Stun(30) - to_chat(src, "Deadlock detected in primary systems, error code [rand(101, 999)].") - if("shortmute") - ADD_TRAIT(src, TRAIT_MUTE, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_speech), 5 SECONDS) - to_chat(src, "Communications matrix successfully shutdown for maintenance.") - if("vomit") - to_chat(src, "Ejecting contaminant.") - vomit() - if("halluscinate") - hallucination += 20 //Doesn't give a cue - if("receporgandamage") - adjustOrganLoss(ORGAN_SLOT_EARS, rand(10, 20)) - adjustOrganLoss(ORGAN_SLOT_EYES, rand(10, 20)) - to_chat(src, "Power spike detected in auditory and visual systems!") - if("longlimbdisable") - var/disabled_type = pick(list(TRAIT_PARALYSIS_L_ARM, TRAIT_PARALYSIS_R_ARM, TRAIT_PARALYSIS_L_LEG, TRAIT_PARALYSIS_R_LEG)) - ADD_TRAIT(src, disabled_type, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_limb, disabled_type), 25 SECONDS) - to_chat(src, "Fatal error in limb control subsystem - rebooting.") - if("blindmutedeaf") - ADD_TRAIT(src, TRAIT_BLIND, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_vision), (rand(10, 25)) SECONDS) - ADD_TRAIT(src, TRAIT_DEAF, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_hearing), (rand(15, 35)) SECONDS) - ADD_TRAIT(src, TRAIT_MUTE, CORRUPTED_SYSTEM) - addtimer(CALLBACK(src, .proc/reenable_speech), (rand(20, 45)) SECONDS) - to_chat(src, "Fatal error in multiple systems - Performing recovery.") - if("longstun") - Stun(80) - to_chat(src, "") - if("sleep") - addtimer(CALLBACK(src, .proc/forcesleep), (rand(6, 10)) SECONDS) - to_chat(src, "Priority 1 shutdown order received in operating system - Preparing powerdown.") - if("inducetrauma") - to_chat(src, "Major interference detected in main operating matrix - Complications possible.") - var/resistance = pick( - 65;TRAUMA_RESILIENCE_BASIC, - 35;TRAUMA_RESILIENCE_SURGERY) - - var/trauma_type = pickweight(list( - BRAIN_TRAUMA_MILD = 80, - BRAIN_TRAUMA_SEVERE = 10)) - gain_trauma_type(trauma_type, resistance) //Gaining the trauma will inform them, but we'll tell them too so they know what the reason was. - if("amplifycorrupt") - adjustToxLoss(5, toxins_type = TOX_SYSCORRUPT) - to_chat(src, "System safeguards failing - Action urgently required.") - if("changetemp") - adjust_bodytemperature(rand(150, 250)) - to_chat(src, "Warning - Fatal coolant flow error at node [rand(6, 99)]!") //This is totally not a reference to anything. - -/mob/living/carbon/proc/reenable_limb(disabled_limb) - REMOVE_TRAIT(src, disabled_limb, CORRUPTED_SYSTEM) - to_chat(src, "Limb control subsystem successfully rebooted.") - -/mob/living/carbon/proc/reenable_hearing() - REMOVE_TRAIT(src, TRAIT_DEAF, CORRUPTED_SYSTEM) - to_chat(src, "Hearing restored.") - -/mob/living/carbon/proc/reenable_vision() - REMOVE_TRAIT(src, TRAIT_BLIND, CORRUPTED_SYSTEM) - to_chat(src, "Visual receptors back online.") - -/mob/living/carbon/proc/reenable_speech() - REMOVE_TRAIT(src, TRAIT_MUTE, CORRUPTED_SYSTEM) - to_chat(src, "Communications subsystem operational.") - -/mob/living/carbon/proc/forcesleep(time = 100) - to_chat(src, "Preparations complete, powering down.") - Sleeping(time, 0) - - -#undef CORRUPTION_CHECK_INTERVAL -#undef CORRUPTION_THRESHHOLD_MINOR -#undef CORRUPTION_THRESHHOLD_MAJOR -#undef CORRUPTION_THRESHHOLD_CRITICAL