From e2bdc3bfb9adcbf8b54533f06f454ba699b7ca7f Mon Sep 17 00:00:00 2001 From: Qwertytoforty <52090703+Qwertytoforty@users.noreply.github.com> Date: Sun, 4 Feb 2024 16:45:10 -0500 Subject: [PATCH] Reboots the CNS implant (#23813) * Reboots the CNS implant * Update code/modules/surgery/organs/augments_internal.dm Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com> * contra you nerd you forgot a bracket * Apply suggestions from code review Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com> * requested changes --------- Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com> --- code/__DEFINES/dcs/signals.dm | 7 ++- code/modules/mob/living/carbon/carbon_life.dm | 1 + .../mob/living/carbon/carbon_status_procs.dm | 2 + .../mob/living/carbon/carbon_update_status.dm | 1 + code/modules/mob/living/damage_procs.dm | 4 +- code/modules/mob/living/living_defines.dm | 2 + .../surgery/organs/augments_internal.dm | 47 +++++++++++++------ 7 files changed, 46 insertions(+), 18 deletions(-) diff --git a/code/__DEFINES/dcs/signals.dm b/code/__DEFINES/dcs/signals.dm index ed7d9d1aa0a..c43d9005767 100644 --- a/code/__DEFINES/dcs/signals.dm +++ b/code/__DEFINES/dcs/signals.dm @@ -525,7 +525,12 @@ #define COMSIG_CARBON_UPDATE_HANDCUFFED "carbon_update_handcuff" /// From /mob/living/carbon/regenerate_icons() #define COMSIG_CARBON_REGENERATE_ICONS "carbon_regen_icons" - +/// From /mob/living/carbon/enter_stamcrit() +#define COMSIG_CARBON_ENTER_STAMINACRIT "carbon_enter_staminacrit" +/// From /mob/living/carbon/update_stamina() +#define COMSIG_CARBON_EXIT_STAMINACRIT "carbon_exit_staminacrit" +/// From /mob/living/carbon/handle_status_effects() +#define COMSIG_CARBON_STAMINA_REGENERATED "carbon_stamina_regenerated" // /mob/living/simple_animal/hostile signals #define COMSIG_HOSTILE_ATTACKINGTARGET "hostile_attackingtarget" diff --git a/code/modules/mob/living/carbon/carbon_life.dm b/code/modules/mob/living/carbon/carbon_life.dm index f533b975c09..6ece22e7cd0 100644 --- a/code/modules/mob/living/carbon/carbon_life.dm +++ b/code/modules/mob/living/carbon/carbon_life.dm @@ -254,6 +254,7 @@ update_stamina() if(staminaloss) setStaminaLoss(0, FALSE) + SEND_SIGNAL(src, COMSIG_CARBON_STAMINA_REGENERATED) update_health_hud() // Keep SSD people asleep diff --git a/code/modules/mob/living/carbon/carbon_status_procs.dm b/code/modules/mob/living/carbon/carbon_status_procs.dm index d39c9f40eae..b96a55084a3 100644 --- a/code/modules/mob/living/carbon/carbon_status_procs.dm +++ b/code/modules/mob/living/carbon/carbon_status_procs.dm @@ -8,6 +8,8 @@ return if(!IsWeakened()) to_chat(src, "You're too exhausted to keep going...") + SEND_SIGNAL(src, COMSIG_CARBON_ENTER_STAMINACRIT) + stam_regen_start_time = world.time + (STAMINA_REGEN_BLOCK_TIME * stamina_regen_block_modifier) var/prev = stam_paralyzed stam_paralyzed = TRUE ADD_TRAIT(src, TRAIT_IMMOBILIZED, "stam_crit") // make defines later diff --git a/code/modules/mob/living/carbon/carbon_update_status.dm b/code/modules/mob/living/carbon/carbon_update_status.dm index 541bce6eaf1..9fcb471bed5 100644 --- a/code/modules/mob/living/carbon/carbon_update_status.dm +++ b/code/modules/mob/living/carbon/carbon_update_status.dm @@ -24,6 +24,7 @@ if(stam > DAMAGE_PRECISION && (maxHealth - stam) <= HEALTH_THRESHOLD_CRIT && !stat) enter_stamcrit() else if(stam_paralyzed) + SEND_SIGNAL(src, COMSIG_CARBON_EXIT_STAMINACRIT) stam_paralyzed = FALSE REMOVE_TRAIT(src, TRAIT_IMMOBILIZED, "stam_crit") // make defines later REMOVE_TRAIT(src, TRAIT_FLOORED, "stam_crit") diff --git a/code/modules/mob/living/damage_procs.dm b/code/modules/mob/living/damage_procs.dm index ed47d4a0bed..9da5da6e35d 100644 --- a/code/modules/mob/living/damage_procs.dm +++ b/code/modules/mob/living/damage_procs.dm @@ -284,7 +284,7 @@ else . = STATUS_UPDATE_STAMINA if(amount > 0) - stam_regen_start_time = world.time + STAMINA_REGEN_BLOCK_TIME + stam_regen_start_time = world.time + (STAMINA_REGEN_BLOCK_TIME * stamina_regen_block_modifier) if(updating) update_health_hud() update_stamina() @@ -300,7 +300,7 @@ else . = STATUS_UPDATE_STAMINA if(amount > 0) - stam_regen_start_time = world.time + STAMINA_REGEN_BLOCK_TIME + stam_regen_start_time = world.time + (STAMINA_REGEN_BLOCK_TIME * stamina_regen_block_modifier) if(updating) update_health_hud() update_stamina() diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index ced34a42995..305e1142491 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -71,6 +71,8 @@ var/stun_absorption = null //converted to a list of stun absorption sources this mob has when one is added var/stam_regen_start_time = 0 //used to halt stamina regen temporarily + /// A multiplier for the ammount of time it takes for someone to regenerate stamina damage. + var/stamina_regen_block_modifier = 1 var/stam_paralyzed = FALSE //knocks you down /// Number of degrees of rotation of a mob. 0 means no rotation, up-side facing NORTH. 90 means up-side rotated to face EAST, and so on. diff --git a/code/modules/surgery/organs/augments_internal.dm b/code/modules/surgery/organs/augments_internal.dm index ae39f0a8461..b11d56ed24f 100644 --- a/code/modules/surgery/organs/augments_internal.dm +++ b/code/modules/surgery/organs/augments_internal.dm @@ -132,27 +132,44 @@ implant_color = "#FFFF00" slot = "brain_antistun" origin_tech = "materials=5;programming=4;biotech=5" - var/last_stamina_damage = 0 - var/max_stamina_increment = 40 + /// How much we multiply the owners stamina regen block modifier by. + var/stamina_crit_time_multiplier = 0.4 + /// Are we currently modifying somoeones stamina regen block modifier? If so, we will want to undo it on removal. + var/currently_modifying_stamina = FALSE + COOLDOWN_DECLARE(implant_cooldown) -/obj/item/organ/internal/cyberimp/brain/anti_stam/on_life() +/obj/item/organ/internal/cyberimp/brain/anti_stam/insert(mob/living/carbon/M, special = FALSE) ..() - if(crit_fail) - return - if(last_stamina_damage + max_stamina_increment < owner.getStaminaLoss()) - owner.setStaminaLoss(last_stamina_damage + max_stamina_increment) - last_stamina_damage = owner.getStaminaLoss() + RegisterSignal(M, COMSIG_CARBON_ENTER_STAMINACRIT, PROC_REF(on_enter)) + RegisterSignal(M, COMSIG_CARBON_EXIT_STAMINACRIT, PROC_REF(on_exit)) + RegisterSignal(M, COMSIG_CARBON_STAMINA_REGENERATED, PROC_REF(on_regen)) +/obj/item/organ/internal/cyberimp/brain/anti_stam/remove(mob/living/carbon/M, special = FALSE) + UnregisterSignal(M, list(COMSIG_CARBON_ENTER_STAMINACRIT, COMSIG_CARBON_EXIT_STAMINACRIT, COMSIG_CARBON_STAMINA_REGENERATED)) + on_exit() + return ..() + +/obj/item/organ/internal/cyberimp/brain/anti_stam/proc/on_enter() + SIGNAL_HANDLER // COMSIG_CARBON_ENTER_STAMINACRIT + if(currently_modifying_stamina || !COOLDOWN_FINISHED(src, implant_cooldown)) + return + owner.stamina_regen_block_modifier *= stamina_crit_time_multiplier + currently_modifying_stamina = TRUE + +/obj/item/organ/internal/cyberimp/brain/anti_stam/proc/on_exit() + SIGNAL_HANDLER // COMSIG_CARBON_EXIT_STAMINACRIT + if(!currently_modifying_stamina) + return + owner.stamina_regen_block_modifier /= stamina_crit_time_multiplier + currently_modifying_stamina = FALSE + +/obj/item/organ/internal/cyberimp/brain/anti_stam/proc/on_regen() + SIGNAL_HANDLER // COMSIG_CARBON_STAMINA_REGENERATED + owner.update_stamina() //This is here so they actually get unstaminacrit when it triggers, vs 2-4 seconds later /obj/item/organ/internal/cyberimp/brain/anti_stam/emp_act(severity) ..() - if(crit_fail || emp_proof) - return - crit_fail = TRUE - addtimer(CALLBACK(src, PROC_REF(reboot)), 90 / severity) - -/obj/item/organ/internal/cyberimp/brain/anti_stam/proc/reboot() - crit_fail = FALSE + COOLDOWN_START(src, implant_cooldown, 1 MINUTES / severity) /obj/item/organ/internal/cyberimp/brain/anti_stam/hardened name = "Hardened CNS Rebooter implant"