From 1c231a9f9bd3d5ad3b9adc6bda0e84e2f37cd0e1 Mon Sep 17 00:00:00 2001 From: NovaBot <154629622+NovaBot13@users.noreply.github.com> Date: Wed, 12 Jun 2024 01:35:09 -0400 Subject: [PATCH] [MIRROR] Changes up carbon EMP handling [MDB IGNORE] (#2990) * Changes up carbon EMP handling (#83857) ## About The Pull Request The organ refactor 6 months ago changed up organs, making them be actually inside bodyparts and the mob. This introduced the bug of all emp effects being called twice on everything thanks to how /mob/living handles it (Fixed in this PR), but also some new stuff: Made bodyparts handle organ EMPs. This also means we can now have support for bodyparts with EMP_PROTECT_CONTENTS protecting the organs inside. Made a new proc for bodyparts once they are successfully hit by an emp. Makes it much easier to add overrides for the behaviour. Fixed emps hitting bodyparts twice ## Why It's Good For The Game It lays a groundwork for some interesting limb concepts, and makes organ emps make a bit more sense. Fixes a bug that laid unnoticed for 6 months. ## Changelog :cl: fix: EMPs on carbons no longer happen twice code: Moves organ emps under bodyparts, changes how bodyparts handle emp effects /:cl: --------- Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> * Changes up carbon EMP handling --------- Co-authored-by: Waterpig <49160555+Majkl-J@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: NovaBot13 --- .../mob/living/carbon/carbon_defense.dm | 9 --------- code/modules/surgery/bodyparts/_bodyparts.dm | 18 +++++++++++++++--- .../surgery/bodyparts/robot_bodyparts.dm | 16 ++++++++++------ 3 files changed, 25 insertions(+), 18 deletions(-) diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index 4406a1cdec7..78e08706ed3 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -240,15 +240,6 @@ show_message(span_userdanger("The blob attacks!")) adjustBruteLoss(10) -/mob/living/carbon/emp_act(severity) - . = ..() - if(. & EMP_PROTECT_CONTENTS) - return - for(var/obj/item/organ/organ as anything in organs) - organ.emp_act(severity) - for(var/obj/item/bodypart/bodypart as anything in src.bodyparts) - bodypart.emp_act(severity) - ///Adds to the parent by also adding functionality to propagate shocks through pulling and doing some fluff effects. /mob/living/carbon/electrocute_act(shock_damage, source, siemens_coeff = 1, flags = NONE, jitter_time = 20 SECONDS, stutter_time = 4 SECONDS, stun_duration = 4 SECONDS) . = ..() diff --git a/code/modules/surgery/bodyparts/_bodyparts.dm b/code/modules/surgery/bodyparts/_bodyparts.dm index 20b685fdcae..fe5f4facc45 100644 --- a/code/modules/surgery/bodyparts/_bodyparts.dm +++ b/code/modules/surgery/bodyparts/_bodyparts.dm @@ -1407,12 +1407,24 @@ else update_icon_dropped() -// Note: Does NOT return EMP protection value from parent call or pass it on to subtypes +// Note: For effects on subtypes, use the emp_effect() proc instead /obj/item/bodypart/emp_act(severity) var/protection = ..() - if((protection & EMP_PROTECT_WIRES) || !IS_ROBOTIC_LIMB(src)) - return FALSE + // If the limb doesn't protect contents, strike them first + if(!(protection & EMP_PROTECT_CONTENTS)) + for(var/atom/content as anything in contents) + content.emp_act(severity) + + if((protection & (EMP_PROTECT_WIRES | EMP_PROTECT_SELF))) + return protection + emp_effect(severity, protection) + return protection + +/// The actual effect of EMPs on the limb. Allows children to override it however they want +/obj/item/bodypart/proc/emp_effect(severity, protection) + if(!IS_ROBOTIC_LIMB(src)) + return FALSE // with defines at the time of writing, this is 2 brute and 1.5 burn // 2 + 1.5 = 3,5, with 6 limbs thats 21, on a heavy 42 // 42 * 0.8 = 33.6 diff --git a/code/modules/surgery/bodyparts/robot_bodyparts.dm b/code/modules/surgery/bodyparts/robot_bodyparts.dm index cdd92df7b88..0891e32cb16 100644 --- a/code/modules/surgery/bodyparts/robot_bodyparts.dm +++ b/code/modules/surgery/bodyparts/robot_bodyparts.dm @@ -115,7 +115,7 @@ damage_examines = list(BRUTE = ROBOTIC_BRUTE_EXAMINE_TEXT, BURN = ROBOTIC_BURN_EXAMINE_TEXT) bodypart_flags = BODYPART_UNHUSKABLE -/obj/item/bodypart/leg/left/robot/emp_act(severity) +/obj/item/bodypart/leg/left/robot/emp_effect(severity, protection) . = ..() if(!. || isnull(owner)) return @@ -125,8 +125,9 @@ knockdown_time *= 2 owner.Knockdown(knockdown_time) if(owner.incapacitated(IGNORE_RESTRAINTS|IGNORE_GRAB)) // So the message isn't duplicated. If they were stunned beforehand by something else, then the message not showing makes more sense anyways. - return + return FALSE to_chat(owner, span_danger("As your [plaintext_zone] unexpectedly malfunctions, it causes you to fall to the ground!")) + return /obj/item/bodypart/leg/right/robot name = "cyborg right leg" @@ -163,7 +164,7 @@ damage_examines = list(BRUTE = ROBOTIC_BRUTE_EXAMINE_TEXT, BURN = ROBOTIC_BURN_EXAMINE_TEXT) bodypart_flags = BODYPART_UNHUSKABLE -/obj/item/bodypart/leg/right/robot/emp_act(severity) +/obj/item/bodypart/leg/right/robot/emp_effect(severity, protection) . = ..() if(!. || isnull(owner)) return @@ -173,8 +174,9 @@ knockdown_time *= 2 owner.Knockdown(knockdown_time) if(owner.incapacitated(IGNORE_RESTRAINTS|IGNORE_GRAB)) // So the message isn't duplicated. If they were stunned beforehand by something else, then the message not showing makes more sense anyways. - return + return FALSE to_chat(owner, span_danger("As your [plaintext_zone] unexpectedly malfunctions, it causes you to fall to the ground!")) + return /obj/item/bodypart/chest/robot name = "cyborg torso" @@ -215,7 +217,7 @@ var/wired = FALSE var/obj/item/stock_parts/cell/cell = null -/obj/item/bodypart/chest/robot/emp_act(severity) +/obj/item/bodypart/chest/robot/emp_effect(severity, protection) . = ..() if(!. || isnull(owner)) return @@ -236,6 +238,7 @@ to_chat(owner, span_danger("Your [plaintext_zone]'s logic boards temporarily become unresponsive!")) owner.Stun(stun_time) owner.Shake(pixelshiftx = shift_x, pixelshifty = shift_y, duration = shake_duration) + return /obj/item/bodypart/chest/robot/get_cell() return cell @@ -394,7 +397,7 @@ #define EMP_GLITCH "EMP_GLITCH" -/obj/item/bodypart/head/robot/emp_act(severity) +/obj/item/bodypart/head/robot/emp_effect(severity, protection) . = ..() if(!. || isnull(owner)) return @@ -408,6 +411,7 @@ owner.add_client_colour(/datum/client_colour/malfunction) addtimer(CALLBACK(owner, TYPE_PROC_REF(/mob/living/carbon/human, remove_client_colour), /datum/client_colour/malfunction), glitch_duration) + return #undef EMP_GLITCH