mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-07 15:32:47 +00:00
* 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>
35 lines
1.1 KiB
Plaintext
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
|