/obj/item/organ/ears
name = "ears"
icon_state = "ears"
desc = "There are three parts to the ear. Inner, middle and outer. Only one of these parts should be normally visible."
zone = BODY_ZONE_HEAD
slot = ORGAN_ITEM_SLOT_EARS
gender = PLURAL
healing_factor = STANDARD_ORGAN_HEALING
decay_factor = STANDARD_ORGAN_DECAY
low_threshold_passed = "Your ears begin to resonate with an internal ring sometimes."
now_failing = "You are unable to hear at all!"
now_fixed = "Noise slowly begins filling your ears once more."
low_threshold_cleared = "The ringing in your ears has died down."
// `deaf` measures "ticks" of deafness. While > 0, the person is unable
// to hear anything.
var/deaf = 0
// `ear_damage` measures long term damage to the ears, if too high,
// the person will not have either `deaf` or `ear_damage` decrease
// without external aid (earmuffs, drugs)
var/ear_damage = 0
//Resistance against loud noises
var/bang_protect = 0
// Multiplier for both long term and short term ear damage
var/damage_multiplier = 1
/obj/item/organ/ears/on_life()
. = ..()
// genetic deafness prevents the body from using the ears, even if healthy
if(owner && HAS_TRAIT(owner, TRAIT_DEAF))
deaf = max(deaf, 1)
else if(.) // if this organ is failing, do not clear deaf stacks.
deaf = max(deaf - 1, 0)
if(prob(damage / 20) && (damage > low_threshold))
adjustEarDamage(0, 4)
SEND_SOUND(owner, sound('sound/weapons/flash_ring.ogg'))
to_chat(owner, "The ringing in your ears grows louder, blocking out any external noises for a moment.")
else if(!. && !deaf)
deaf = 1 //stop being not deaf you deaf idiot
/obj/item/organ/ears/proc/restoreEars()
deaf = 0
ear_damage = 0
organ_flags &= ~ORGAN_FAILING
var/mob/living/carbon/C = owner
if(iscarbon(owner) && HAS_TRAIT(C, TRAIT_DEAF))
deaf = 1
/obj/item/organ/ears/proc/adjustEarDamage(ddmg, ddeaf)
ear_damage = max(ear_damage + (ddmg*damage_multiplier), 0)
deaf = max(deaf + (ddeaf*damage_multiplier), 0)
/obj/item/organ/ears/proc/minimumDeafTicks(value)
deaf = max(deaf, value)
/obj/item/organ/ears/invincible
damage_multiplier = 0
/mob/proc/restoreEars()
/mob/living/carbon/restoreEars()
var/obj/item/organ/ears/ears = getorgan(/obj/item/organ/ears)
if(ears)
ears.restoreEars()
/mob/proc/adjustEarDamage()
/mob/living/carbon/adjustEarDamage(ddmg, ddeaf)
var/obj/item/organ/ears/ears = getorgan(/obj/item/organ/ears)
if(ears)
ears.adjustEarDamage(ddmg, ddeaf)
/mob/proc/minimumDeafTicks()
/mob/living/carbon/minimumDeafTicks(value)
var/obj/item/organ/ears/ears = getorgan(/obj/item/organ/ears)
if(ears)
ears.minimumDeafTicks(value)
/obj/item/organ/ears/cat
name = "cat ears"
icon = 'icons/obj/clothing/hats.dmi'
icon_state = "kitty"
damage_multiplier = 2
/obj/item/organ/ears/cat/Insert(mob/living/carbon/human/H, special = 0, drop_if_replaced = TRUE)
..()
if(istype(H))
color = H.hair_color
H.dna.species.mutant_bodyparts["mam_ears"] = "Cat"
H.dna.features["mam_ears"] = "Cat"
H.update_body()
/obj/item/organ/ears/cat/Remove(special = FALSE)
if(!QDELETED(owner) && ishuman(owner))
var/mob/living/carbon/human/H = owner
color = H.hair_color
H.dna.features["mam_ears"] = "None"
H.dna.species.mutant_bodyparts -= "mam_ears"
H.update_body()
return ..()
/obj/item/organ/ears/bronze
name = "tin ears"
desc = "The robust ears of a bronze golem. "
damage_multiplier = 0.1 //STRONK
bang_protect = 1 //Fear me weaklings.
/obj/item/organ/ears/cybernetic
name = "cybernetic ears"
icon_state = "ears-c"
desc = "a basic cybernetic designed to mimic the operation of ears."
damage_multiplier = 0.9
organ_flags = ORGAN_SYNTHETIC
/obj/item/organ/ears/cybernetic/upgraded
name = "upgraded cybernetic ears"
icon_state = "ears-c-u"
desc = "an advanced cybernetic ear, surpassing the performance of organic ears"
damage_multiplier = 0.5
/obj/item/organ/ears/cybernetic/emp_act(severity)
. = ..()
if(. & EMP_PROTECT_SELF)
return
damage += 0.15 * severity
/obj/item/organ/ears/ipc
name = "auditory sensors"
icon_state = "ears-c"
desc = "A pair of microphones intended to be installed in an IPC head, that grant the ability to hear."
zone = BODY_ZONE_HEAD
slot = ORGAN_ITEM_SLOT_EARS
gender = PLURAL
organ_flags = ORGAN_SYNTHETIC
/obj/item/organ/ears/ipc/emp_act(severity)
. = ..()
if(!owner || . & EMP_PROTECT_SELF)
return
to_chat(owner, "Alert: Auditory systems corrupted!.")
switch(severity)
if(1 to 50)
owner.Jitter(15)
owner.Dizzy(15)
owner.DefaultCombatKnockdown(40)
if(50 to INFINITY)
owner.Jitter(30)
owner.Dizzy(30)
owner.DefaultCombatKnockdown(80)
deaf = max(deaf, 30)
damage += 0.15 * severity