Skip to content

Commit

Permalink
[MIRROR] Changes up carbon EMP handling [MDB IGNORE] (#2990)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>

* Changes up carbon EMP handling

---------

Co-authored-by: Waterpig <[email protected]>
Co-authored-by: Time-Green <[email protected]>
Co-authored-by: NovaBot13 <[email protected]>
  • Loading branch information
4 people authored and StealsThePRs committed Jun 12, 2024
1 parent 57df0ee commit 1c231a9
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 18 deletions.
9 changes: 0 additions & 9 deletions code/modules/mob/living/carbon/carbon_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
. = ..()
Expand Down
18 changes: 15 additions & 3 deletions code/modules/surgery/bodyparts/_bodyparts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions code/modules/surgery/bodyparts/robot_bodyparts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 1c231a9

Please sign in to comment.