From be6eca62ddd66c94cdfc28ccbe9a2cabbbfa522e Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Thu, 18 Feb 2021 05:45:37 +0100 Subject: [PATCH] [MIRROR] AdjustHealth proc cleanup (#3475) * AdjustHealth proc cleanup (#56966) This PR cleans up duplicate definition of the AdjustHealth proc for simplemobs, as otherwise you cannot properly locate the definition via VSCode DMcode plugins. No functionality changes, as this is exactly how it already works - duplicate definition calls the "real" proc definition via ..(). Autodoc documentation of the relevant proc included. * AdjustHealth proc cleanup Co-authored-by: Arkatos1 <43862960+Arkatos1@users.noreply.github.com> --- .../mob/living/simple_animal/damage_procs.dm | 25 +++++++++++++------ .../mob/living/simple_animal/simple_animal.dm | 7 ------ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/code/modules/mob/living/simple_animal/damage_procs.dm b/code/modules/mob/living/simple_animal/damage_procs.dm index be113d9201f..922ddc61bf1 100644 --- a/code/modules/mob/living/simple_animal/damage_procs.dm +++ b/code/modules/mob/living/simple_animal/damage_procs.dm @@ -1,11 +1,22 @@ - +/** + * Adjusts the health of a simple mob by a set amount and wakes AI if its idle to react + * + * Arguments: + * * amount The amount that will be used to adjust the mob's health + * * updating_health If the mob's health should be immediately updated to the new value + * * forced If we should force update the adjustment of the mob's health no matter the restrictions, like GODMODE + */ /mob/living/simple_animal/proc/adjustHealth(amount, updating_health = TRUE, forced = FALSE) - if(!forced && (status_flags & GODMODE)) - return FALSE - bruteloss = round(clamp(bruteloss + amount, 0, maxHealth * 2), DAMAGE_PRECISION) - if(updating_health) - updatehealth() - return amount + . = FALSE + if(forced || !(status_flags & GODMODE)) + bruteloss = round(clamp(bruteloss + amount, 0, maxHealth * 2), DAMAGE_PRECISION) + if(updating_health) + updatehealth() + . = amount + if(ckey || stat) + return + if(AIStatus == AI_IDLE) + toggle_ai(AI_ON) /mob/living/simple_animal/adjustBruteLoss(amount, updating_health = TRUE, forced = FALSE) if(forced) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index c99709fd718..beedeea489d 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -705,13 +705,6 @@ if (pulledby || shouldwakeup) toggle_ai(AI_ON) -/mob/living/simple_animal/adjustHealth(amount, updating_health = TRUE, forced = FALSE) - . = ..() - if(!ckey && !stat)//Not unconscious - if(AIStatus == AI_IDLE) - toggle_ai(AI_ON) - - /mob/living/simple_animal/onTransitZ(old_z, new_z) ..() if (AIStatus == AI_Z_OFF)