Files
Bubberstation/code/datums/elements/earhealing.dm
SkyratBot 82f99baabe [MIRROR] Fixes some issues with deafness & earhealing [MDB IGNORE] (#15586)
* Fixes some issues with deafness & earhealing (#69136)

1- Replaces checks for deafness as a clothing trait, since clothing traits' have a ref to themselves in the source
2- Makes ear healing not NOT heal if you're above 0 ear damage, because that's the point of fixing your ears?

* Fixes some issues with deafness & earhealing

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
2022-08-13 13:35:29 +01:00

35 lines
1.1 KiB
Plaintext

/datum/element/earhealing
element_flags = ELEMENT_DETACH
var/list/user_by_item = list()
/datum/element/earhealing/Attach(datum/target)
. = ..()
if(!isitem(target))
return ELEMENT_INCOMPATIBLE
RegisterSignal(target, list(COMSIG_ITEM_EQUIPPED, COMSIG_ITEM_DROPPED), .proc/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(delta_time)
for(var/i in user_by_item)
var/mob/living/carbon/user = user_by_item[i]
var/obj/item/organ/internal/ears/ears = user.getorganslot(ORGAN_SLOT_EARS)
if(!ears || !ears.damage || ears.organ_flags & ORGAN_FAILING)
continue
ears.deaf = max(ears.deaf - 0.25 * delta_time, (ears.damage < ears.maxHealth ? 0 : 1)) // Do not clear deafness if our ears are too damaged
ears.applyOrganDamage(-0.025 * delta_time)
CHECK_TICK