mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 00:27:31 +01:00
ca2cc70322
## 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). /🆑
36 lines
1.1 KiB
Plaintext
36 lines
1.1 KiB
Plaintext
/datum/element/earhealing
|
|
element_flags = ELEMENT_DETACH_ON_HOST_DESTROY
|
|
var/list/user_by_item = list()
|
|
|
|
/datum/element/earhealing/Attach(datum/target)
|
|
. = ..()
|
|
if(!isitem(target))
|
|
return ELEMENT_INCOMPATIBLE
|
|
|
|
RegisterSignals(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED), PROC_REF(on_equip))
|
|
|
|
/datum/element/earhealing/Detach(datum/target)
|
|
. = ..()
|
|
UnregisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED))
|
|
user_by_item -= target
|
|
|
|
/datum/element/earhealing/proc/on_equip(datum/source, mob/living/carbon/user, slot)
|
|
SIGNAL_HANDLER
|
|
|
|
if((slot & ITEM_SLOT_EARS) && istype(user))
|
|
START_PROCESSING(SSdcs, src)
|
|
user_by_item[source] = user
|
|
else
|
|
user_by_item -= source
|
|
|
|
/datum/element/earhealing/process(seconds_per_tick)
|
|
for(var/i in user_by_item)
|
|
var/mob/living/carbon/user = user_by_item[i]
|
|
var/obj/item/organ/ears/ears = user.get_organ_slot(ORGAN_SLOT_EARS)
|
|
if(!ears || (ears.organ_flags & ORGAN_FAILING) || IS_ROBOTIC_ORGAN(ears))
|
|
continue
|
|
|
|
ears.adjust_temporary_deafness(-0.5 SECONDS * seconds_per_tick)
|
|
ears.apply_organ_damage(-0.025 * seconds_per_tick)
|
|
CHECK_TICK
|