Refactors reagent shock reduction (#28385)

* makes reagent shock reduction only apply to mobs that can process them

* Update code/modules/mob/living/carbon/human/human_life.dm

Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
Signed-off-by: chuga-git <98280110+chuga-git@users.noreply.github.com>

---------

Signed-off-by: chuga-git <98280110+chuga-git@users.noreply.github.com>
Co-authored-by: Contrabang <91113370+Contrabang@users.noreply.github.com>
This commit is contained in:
chuga-git
2025-03-02 23:39:25 +00:00
committed by GitHub
co-authored by Contrabang
parent ebf7fdbfd2
commit 6605985ef8
5 changed files with 90 additions and 80 deletions
@@ -1113,12 +1113,7 @@ GLOBAL_LIST_INIT(ventcrawl_machinery, list(/obj/machinery/atmospherics/unary/ven
return TRUE
/mob/living/carbon/proc/shock_reduction()
var/shock_reduction = 0
if(reagents)
for(var/datum/reagent/R in reagents.reagent_list)
if(R.shock_reduction)
shock_reduction += R.shock_reduction
return shock_reduction
return 0
/mob/living/carbon/proc/can_eat(flags = 255)
return TRUE
@@ -689,60 +689,83 @@
to_chat(src, "<span class='userdanger'>You feel [pick("terrible", "awful", "like shit", "sick", "numb", "cold", "sweaty", "tingly", "horrible")]!</span>")
Weaken(6 SECONDS)
/mob/living/carbon/human/proc/can_metabolize(datum/reagent/reagent)
var/datum/species/species = dna.species
if(!species || !species.reagent_tag)
return FALSE
// SYNTHETIC-oriented reagents require PROCESS_SYN
if((reagent.process_flags & SYNTHETIC) && (species.reagent_tag & PROCESS_SYN))
return TRUE
// ORGANIC-oriented reagents require PROCESS_ORG
if((reagent.process_flags & ORGANIC) && (species.reagent_tag & PROCESS_ORG))
return TRUE
// Species with PROCESS_DUO are only affected by reagents that affect both organics and synthetics, like acid and hellwater
if((reagent.process_flags & ORGANIC) && (reagent.process_flags & SYNTHETIC) && (species.reagent_tag & PROCESS_DUO))
return TRUE
return FALSE
/mob/living/carbon/human/shock_reduction()
var/shock_reduction = 0
if(reagents)
for(var/datum/reagent/R in reagents.reagent_list)
if(R.shock_reduction && can_metabolize(R))
shock_reduction += R.shock_reduction
return shock_reduction
#define BODYPART_PAIN_REDUCTION 5
/mob/living/carbon/human/update_health_hud()
if(!client)
return
if(dna.species.update_health_hud())
return
else
var/shock_reduction = shock_reduction()
if(healths)
var/health_amount = get_perceived_trauma(shock_reduction)
if(..(health_amount)) //not dead
switch(health_hud_override)
if(HEALTH_HUD_OVERRIDE_CRIT)
healths.icon_state = "health6"
if(HEALTH_HUD_OVERRIDE_DEAD)
healths.icon_state = "health7"
if(HEALTH_HUD_OVERRIDE_HEALTHY)
healths.icon_state = "health0"
var/shock_reduction = shock_reduction()
if(healths)
var/health_amount = get_perceived_trauma(shock_reduction)
if(..(health_amount)) //not dead
switch(health_hud_override)
if(HEALTH_HUD_OVERRIDE_CRIT)
healths.icon_state = "health6"
if(HEALTH_HUD_OVERRIDE_DEAD)
healths.icon_state = "health7"
if(HEALTH_HUD_OVERRIDE_HEALTHY)
healths.icon_state = "health0"
if(healthdoll)
if(stat == DEAD)
healthdoll.icon_state = "healthdoll_DEAD"
if(length(healthdoll.overlays))
healthdoll.overlays.Cut()
else
var/list/new_overlays = list()
var/list/cached_overlays = healthdoll.cached_healthdoll_overlays
// Use the dead health doll as the base, since we have proper "healthy" overlays now
healthdoll.icon_state = "healthdoll_DEAD"
for(var/obj/item/organ/external/O in bodyparts)
var/damage = O.get_damage()
damage -= shock_reduction / BODYPART_PAIN_REDUCTION
var/comparison = (O.max_damage/5)
var/icon_num = 0
if(damage > 0)
icon_num = 1
if(damage > (comparison))
icon_num = 2
if(damage > (comparison*2))
icon_num = 3
if(damage > (comparison*3))
icon_num = 4
if(damage > (comparison*4))
icon_num = 5
new_overlays += "[O.limb_name][icon_num]"
healthdoll.overlays += (new_overlays - cached_overlays)
healthdoll.overlays -= (cached_overlays - new_overlays)
healthdoll.cached_healthdoll_overlays = new_overlays
if(health <= HEALTH_THRESHOLD_SUCCUMB)
throw_alert("succumb", /atom/movable/screen/alert/succumb)
if(healthdoll)
if(stat == DEAD)
healthdoll.icon_state = "healthdoll_DEAD"
if(length(healthdoll.overlays))
healthdoll.overlays.Cut()
else
clear_alert("succumb")
var/list/new_overlays = list()
var/list/cached_overlays = healthdoll.cached_healthdoll_overlays
// Use the dead health doll as the base, since we have proper "healthy" overlays now
healthdoll.icon_state = "healthdoll_DEAD"
for(var/obj/item/organ/external/O in bodyparts)
var/damage = O.get_damage()
damage -= shock_reduction / BODYPART_PAIN_REDUCTION
var/comparison = (O.max_damage/5)
var/icon_num = 0
if(damage > 0)
icon_num = 1
if(damage > (comparison))
icon_num = 2
if(damage > (comparison*2))
icon_num = 3
if(damage > (comparison*3))
icon_num = 4
if(damage > (comparison*4))
icon_num = 5
new_overlays += "[O.limb_name][icon_num]"
healthdoll.overlays += (new_overlays - cached_overlays)
healthdoll.overlays -= (cached_overlays - new_overlays)
healthdoll.cached_healthdoll_overlays = new_overlays
if(health <= HEALTH_THRESHOLD_SUCCUMB)
throw_alert("succumb", /atom/movable/screen/alert/succumb)
else
clear_alert("succumb")
#undef BODYPART_PAIN_REDUCTION
@@ -349,10 +349,8 @@
leftover -= .
var/health_deficiency = max(H.maxHealth - H.health, H.getStaminaLoss())
if(H.reagents)
for(var/datum/reagent/R in H.reagents.reagent_list)
if(R.shock_reduction)
health_deficiency -= R.shock_reduction
health_deficiency -= H.shock_reduction()
if(HAS_TRAIT(H, TRAIT_IGNOREDAMAGESLOWDOWN))
return
if(health_deficiency >= 40 - (40 * leftover * SLOWDOWN_MULTIPLIER)) //If we have 0.25 slowdown, or halfway to the threshold of 0.5, we reduce the health threshold by that 50%
@@ -918,9 +916,6 @@
return FALSE //Unsupported slot
/datum/species/proc/update_health_hud(mob/living/carbon/human/H)
return FALSE
/datum/species/proc/handle_mutations_and_radiation(mob/living/carbon/human/H)
if(HAS_TRAIT(H, TRAIT_RADIMMUNE))
H.radiation = 0