From e9928ebbe3896b3649662e33aef951c130d7bfae Mon Sep 17 00:00:00 2001 From: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Date: Thu, 6 Jul 2023 12:49:12 -0500 Subject: [PATCH] Fixes a runtime with cybernetic hearts being EMP'd outside of mobs (#76587) ## About The Pull Request This proc made a false assumption owner always was set when emp'd, when hearts can just be emp'd out in the wild ## Why It's Good For The Game Runtimes ## Changelog :cl: Melbert fix: Fixed EMPing a cybernetic heart not implanted in a body not applying effects (stopping the heartbeat temporarily) /:cl: --- .../surgery/organs/internal/heart/_heart.dm | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/code/modules/surgery/organs/internal/heart/_heart.dm b/code/modules/surgery/organs/internal/heart/_heart.dm index 77eb9c8d7ed..c26f7d0dc83 100644 --- a/code/modules/surgery/organs/internal/heart/_heart.dm +++ b/code/modules/surgery/organs/internal/heart/_heart.dm @@ -229,23 +229,25 @@ /obj/item/organ/internal/heart/cybernetic/emp_act(severity) . = ..() - - // If the owner doesn't need a heart, we don't need to do anything with it. - if(!owner.needs_heart()) - return - if(. & EMP_PROTECT_SELF) return - if(!COOLDOWN_FINISHED(src, severe_cooldown)) //So we cant just spam emp to kill people. + // Some effects are byassed if our owner (should it exist) doesn't need a heart + var/owner_needs_us = owner?.needs_heart() + + if(owner_needs_us && !COOLDOWN_FINISHED(src, severe_cooldown)) //So we cant just spam emp to kill people. owner.set_dizzy_if_lower(20 SECONDS) owner.losebreath += 10 COOLDOWN_START(src, severe_cooldown, 20 SECONDS) + if(prob(emp_vulnerability/severity)) //Chance of permanent effects organ_flags |= ORGAN_EMP //Starts organ faliure - gonna need replacing soon. Stop() - owner.visible_message(span_danger("[owner] clutches at [owner.p_their()] chest as if [owner.p_their()] heart is stopping!"), \ - span_userdanger("You feel a terrible pain in your chest, as if your heart has stopped!")) addtimer(CALLBACK(src, PROC_REF(Restart)), 10 SECONDS) + if(owner_needs_us) + owner.visible_message( + span_danger("[owner] clutches at [owner.p_their()] chest as if [owner.p_their()] heart is stopping!"), + span_userdanger("You feel a terrible pain in your chest, as if your heart has stopped!"), + ) /obj/item/organ/internal/heart/cybernetic/on_life(seconds_per_tick, times_fired) . = ..()