Organ damage refactor/cleanup (#93436)

## About The Pull Request
So, my original goal was just a refactor for the emissive overlays of
eyes, as a way to implement the specular emissive introduced by smartkar
some time ago, but somehow I found myself dragged into a bigger refactor
or cleanup of organ damage, thresholds, failures. One of the main
problem was that there were no procs called when a organ suffered enough
damage to fail or when recovering from failure. It'd just enable or
disable a bitflag, leaving it up to subtypes to decide how to tackle
organ failure their own ways: diverse, funky and sometimes incompatible.
More often than not relying on their very own "update_thingamajig" kinda
procs that run whenever the organ takes damage, rather than just when
the threshold is reached (low, high, failure. There are however a couple
organs with their own quirky thresholds, I let those slide).

There's also a bit of old code, especially for ears, with the
`AdjustEarDamage` and temporary deafness both predating the framework
for organ damage as far as I know. It really needed a coat of fresh
paint.

Oh, there were also more than a handful of organs that still heavily
relied on some ORGAN_TRAIT source instead of the `organ_traits` list and
the two add/remove procs `add_organ_trait` or `remove_organ_trait`. This
include organs that lose or gain specific traits when failing et
viceversa.

~~Lastly, felinids (and the halloween ghost species) having reflective
eyes. It's just a nod to the tapetum lucidum that animals with night
vision often have (including cats), which is why their eyes are a bit
brighter in the dark. Felinids however, do not have night vision (nor do
ghosts). This is merely cosmetic.~~ Cut out for the time being due to
issues with the specular emissive...

## Why It's Good For The Game
Refactoring / cleaning up old organ code.

## Changelog

🆑
refactor: Refactored organ damage code a little. Hopefully there won't
be issues (otherwise report them).
/🆑
This commit is contained in:
Ghom
2025-10-21 16:52:28 -05:00
committed by GitHub
parent 593fe47c1c
commit ca2cc70322
34 changed files with 422 additions and 388 deletions
@@ -18,9 +18,7 @@
if(iscarbon(M))
var/mob/living/carbon/C = M
if(!IS_CHANGELING(C))
var/obj/item/organ/ears/ears = C.get_organ_slot(ORGAN_SLOT_EARS)
if(ears)
ears.adjustEarDamage(0, 30)
C.sound_damage(deafen = 30 SECONDS)
C.adjust_confusion(25 SECONDS)
C.set_jitter_if_lower(100 SECONDS)
else
@@ -264,8 +264,7 @@
hearer.adjust_timed_status_effect(15 SECONDS, /datum/status_effect/speech/slurring/heretic)
hearer.emote("scream")
hearer.add_mood_event("gates_of_mansus", /datum/mood_event/gates_of_mansus)
var/obj/item/organ/ears/regret = hearer.get_organ_slot(ORGAN_SLOT_EARS)
regret?.adjustEarDamage(10,20)
hearer.sound_damage(10, 40 SECONDS)
return "[owner.p_Their()] lungs emit [span_hypnophrase(breath_noise)]"
/// It's full of worms
@@ -44,16 +44,14 @@
/// The duration of these effects are based on sanity, mainly for flavor but also to make it a weaker alpha strike
var/maximum_duration = 15 SECONDS
var/mind_gate_duration = ((SANITY_MAXIMUM - cast_on.mob_mood.sanity) / (SANITY_MAXIMUM - SANITY_INSANE)) * maximum_duration
var/mind_gate_duration = ((SANITY_MAXIMUM - cast_on.mob_mood.sanity) / (SANITY_MAXIMUM - SANITY_INSANE)) * maximum_duration + 1 SECONDS
to_chat(cast_on, span_warning("Your eyes cry out in pain, your ears bleed and your lips seal! THE MOON SMILES UPON YOU!"))
cast_on.adjust_temp_blindness(mind_gate_duration + 1 SECONDS)
cast_on.set_eye_blur_if_lower(mind_gate_duration + 2 SECONDS)
cast_on.adjust_temp_blindness(mind_gate_duration)
cast_on.set_eye_blur_if_lower(mind_gate_duration + 1 SECONDS)
var/obj/item/organ/ears/ears = cast_on.get_organ_slot(ORGAN_SLOT_EARS)
//adjustEarDamage takes deafness duration parameter in one unit per two seconds, instead of the normal time, so we divide by two seconds
ears?.adjustEarDamage(0, (mind_gate_duration + 1 SECONDS) / (2 SECONDS))
cast_on.sound_damage(0, mind_gate_duration)
cast_on.adjust_silence(mind_gate_duration + 1 SECONDS)
cast_on.adjust_silence(mind_gate_duration)
cast_on.add_mood_event("moon_smile", /datum/mood_event/moon_smile)
// Only knocksdown if the target has a low enough sanity