diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index a4311d37279..5b14a7be65b 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -255,6 +255,7 @@ //Brain Damage defines #define BRAIN_DAMAGE_MILD 20 +#define BRAIN_DAMAGE_ASYNC_BLINKING 60 #define BRAIN_DAMAGE_SEVERE 100 #define BRAIN_DAMAGE_DEATH 200 diff --git a/code/datums/components/manual_blinking.dm b/code/datums/components/manual_blinking.dm index 59e963b27ca..aed2c531e3d 100644 --- a/code/datums/components/manual_blinking.dm +++ b/code/datums/components/manual_blinking.dm @@ -5,7 +5,9 @@ var/warn_grace = FALSE var/warn_dying = FALSE var/last_blink - var/check_every = 20 SECONDS + /// How long can you not blink before you get a warning? + var/warning_delay = 20 SECONDS + /// Delay between getting a warning and you starting to take eye damage var/grace_period = 6 SECONDS /// Organ damage taken per tick var/damage_rate = 1 @@ -15,12 +17,12 @@ var/display_message = TRUE var/list/valid_emotes = list(/datum/emote/living/carbon/human/blink, /datum/emote/living/carbon/human/blink_r) -/datum/component/manual_blinking/Initialize(damage_rate = 1, check_every = 20 SECONDS, grace_period = 6 SECONDS, display_message = TRUE) +/datum/component/manual_blinking/Initialize(damage_rate = 1, warning_delay = 20 SECONDS, grace_period = 6 SECONDS, display_message = TRUE) if(!iscarbon(parent)) return COMPONENT_INCOMPATIBLE src.damage_rate = damage_rate - src.check_every = check_every + src.warning_delay = warning_delay src.grace_period = grace_period src.display_message = display_message @@ -70,12 +72,12 @@ STOP_PROCESSING(SSdcs, src) /datum/component/manual_blinking/process() - if(world.time > (last_blink + check_every + grace_period)) + if(world.time > (last_blink + warning_delay + grace_period)) if(!warn_dying) to_chat(parent, span_userdanger("Your eyes begin to wither, you need to blink!")) warn_dying = TRUE parent_eyes.apply_organ_damage(damage_rate) - else if(world.time > (last_blink + check_every)) + else if(world.time > (last_blink + warning_delay)) if(!warn_grace) to_chat(parent, span_danger("You feel a need to blink!")) warn_grace = TRUE diff --git a/code/datums/quirks/negative_quirks/fluoride_stare.dm b/code/datums/quirks/negative_quirks/fluoride_stare.dm index 1bd2dd91acf..97b9c75f3e9 100644 --- a/code/datums/quirks/negative_quirks/fluoride_stare.dm +++ b/code/datums/quirks/negative_quirks/fluoride_stare.dm @@ -28,7 +28,7 @@ /datum/quirk/item_quirk/fluoride_stare/add(client/client_source) ADD_TRAIT(quirk_holder, TRAIT_NO_EYELIDS, QUIRK_TRAIT) - quirk_holder.AddComponent(/datum/component/manual_blinking, 1, 30 SECONDS, 10 SECONDS, FALSE) + quirk_holder.AddComponent(/datum/component/manual_blinking, 0.5, 3 MINUTES, 30 SECONDS, FALSE) /datum/quirk/item_quirk/fluoride_stare/remove() REMOVE_TRAIT(quirk_holder, TRAIT_NO_EYELIDS, QUIRK_TRAIT) diff --git a/code/modules/mob/living/brain/brain_item.dm b/code/modules/mob/living/brain/brain_item.dm index 2aa65797fa1..17efdef1455 100644 --- a/code/modules/mob/living/brain/brain_item.dm +++ b/code/modules/mob/living/brain/brain_item.dm @@ -337,9 +337,15 @@ /obj/item/organ/brain/check_damage_thresholds(mob/M) . = ..() - //if we're not more injured than before, return without gambling for a trauma + // If we crossed blinking brain damage thresholds either way, update our blinking + if ((prev_damage > BRAIN_DAMAGE_ASYNC_BLINKING && damage < BRAIN_DAMAGE_ASYNC_BLINKING) || (prev_damage < BRAIN_DAMAGE_ASYNC_BLINKING && damage > BRAIN_DAMAGE_ASYNC_BLINKING)) + var/obj/item/organ/eyes/eyes = owner.get_organ_slot(ORGAN_SLOT_EYES) + eyes?.animate_eyelids(owner) + + // If we're not more injured than before, return without gambling for a trauma if(damage <= prev_damage) return + damage_delta = damage - prev_damage if(damage > BRAIN_DAMAGE_MILD) if(prob(damage_delta * (1 + max(0, (damage - BRAIN_DAMAGE_MILD)/100)))) //Base chance is the hit damage; for every point of damage past the threshold the chance is increased by 1% //learn how to do your bloody math properly goddamnit @@ -353,20 +359,22 @@ else gain_trauma_type(BRAIN_TRAUMA_SEVERE, natural_gain = TRUE) - if (owner) - if(owner.stat < UNCONSCIOUS) //conscious or soft-crit - var/brain_message - if(prev_damage < BRAIN_DAMAGE_MILD && damage >= BRAIN_DAMAGE_MILD) - brain_message = span_warning("You feel lightheaded.") - else if(prev_damage < BRAIN_DAMAGE_SEVERE && damage >= BRAIN_DAMAGE_SEVERE) - brain_message = span_warning("You feel less in control of your thoughts.") - else if(prev_damage < (BRAIN_DAMAGE_DEATH - 20) && damage >= (BRAIN_DAMAGE_DEATH - 20)) - brain_message = span_warning("You can feel your mind flickering on and off...") + if (!owner || owner.stat > UNCONSCIOUS) + return - if(.) - . += "\n[brain_message]" - else - return brain_message + // Conscious or soft-crit + var/brain_message + if(prev_damage < BRAIN_DAMAGE_MILD && damage >= BRAIN_DAMAGE_MILD) + brain_message = span_warning("You feel lightheaded.") + else if(prev_damage < BRAIN_DAMAGE_SEVERE && damage >= BRAIN_DAMAGE_SEVERE) + brain_message = span_warning("You feel less in control of your thoughts.") + else if(prev_damage < (BRAIN_DAMAGE_DEATH - 20) && damage >= (BRAIN_DAMAGE_DEATH - 20)) + brain_message = span_warning("You can feel your mind flickering on and off...") + + if(.) + . += "\n[brain_message]" + else + return brain_message /obj/item/organ/brain/before_organ_replacement(obj/item/organ/replacement) . = ..() diff --git a/code/modules/surgery/organs/internal/eyes/_eyes.dm b/code/modules/surgery/organs/internal/eyes/_eyes.dm index ee9a7259443..98d32916c58 100644 --- a/code/modules/surgery/organs/internal/eyes/_eyes.dm +++ b/code/modules/surgery/organs/internal/eyes/_eyes.dm @@ -91,7 +91,7 @@ eye_color_left = as_human.eye_color_left if (!eye_color_right) eye_color_right = as_human.eye_color_right - refresh(receiver, call_update = !special) + refresh(receiver, call_update = TRUE) RegisterSignal(receiver, COMSIG_ATOM_BULLET_ACT, PROC_REF(on_bullet_act)) RegisterSignal(receiver, COMSIG_COMPONENT_CLEAN_FACE_ACT, PROC_REF(on_face_wash)) if (scarring) @@ -416,7 +416,6 @@ #define RAND_BLINKING_DELAY 1 SECONDS #define BLINK_DURATION 0.15 SECONDS #define BLINK_LOOPS 5 -#define ASYNC_BLINKING_BRAIN_DAMAGE 60 /// Modifies eye overlays to also act as eyelids, both for blinking and for when you're knocked out cold /obj/item/organ/eyes/proc/setup_eyelids(mutable_appearance/eye_left, mutable_appearance/eye_right, mob/living/carbon/human/parent) @@ -461,7 +460,6 @@ if (anim_times) if (sync_blinking) wait_time = anim_times[1] - anim_times.Cut(1, 2) else wait_time = rand(max(BASE_BLINKING_DELAY - RAND_BLINKING_DELAY, anim_times[1] - RAND_BLINKING_DELAY), anim_times[1]) @@ -472,17 +470,15 @@ for (var/i in 1 to cycles) if (anim_times) if (sync_blinking) - wait_time = anim_times[1] - anim_times.Cut(1, 2) + wait_time = anim_times[i + 1] else - wait_time = rand(max(BASE_BLINKING_DELAY - RAND_BLINKING_DELAY, anim_times[1] - RAND_BLINKING_DELAY), anim_times[1]) + wait_time = rand(max(BASE_BLINKING_DELAY - RAND_BLINKING_DELAY, anim_times[i + 1] - RAND_BLINKING_DELAY), anim_times[i + 1]) else wait_time = rand(BASE_BLINKING_DELAY - RAND_BLINKING_DELAY, BASE_BLINKING_DELAY + RAND_BLINKING_DELAY) . += wait_time if (anim_times && !sync_blinking) // Make sure that we're somewhat in sync with the other eye - animate(time = anim_times[1] - wait_time) - anim_times.Cut(1, 2) + animate(time = anim_times[i + 1] - wait_time) animate(alpha = 255, time = 0) animate(time = BLINK_DURATION) if (i != cycles) @@ -490,17 +486,18 @@ animate(time = wait_time) /obj/item/organ/eyes/proc/blink(duration = BLINK_DURATION, restart_animation = TRUE) - var/left_delayed = rand(50) + var/left_delayed = prob(50) // Storing blink delay so mistimed blinks of lizards don't get cut short - var/blink_delay = synchronized_blinking ? rand(0, RAND_BLINKING_DELAY) : 0 + var/sync_blinking = synchronized_blinking && (owner.get_organ_loss(ORGAN_SLOT_BRAIN) < BRAIN_DAMAGE_ASYNC_BLINKING) + var/blink_delay = sync_blinking ? 0 : rand(0, RAND_BLINKING_DELAY) animate(eyelid_left, alpha = 0, time = 0) - if (!synchronized_blinking && left_delayed) + if (!sync_blinking && left_delayed) animate(time = blink_delay) animate(alpha = 255, time = 0) animate(time = duration) animate(alpha = 0, time = 0) animate(eyelid_right, alpha = 0, time = 0) - if (!synchronized_blinking && !left_delayed) + if (!sync_blinking && !left_delayed) animate(time = blink_delay) animate(alpha = 255, time = 0) animate(time = duration) @@ -509,7 +506,7 @@ addtimer(CALLBACK(src, PROC_REF(animate_eyelids), owner), blink_delay + duration) /obj/item/organ/eyes/proc/animate_eyelids(mob/living/carbon/human/parent) - var/sync_blinking = synchronized_blinking && (parent.get_organ_loss(ORGAN_SLOT_BRAIN) < ASYNC_BLINKING_BRAIN_DAMAGE) + var/sync_blinking = synchronized_blinking && (parent.get_organ_loss(ORGAN_SLOT_BRAIN) < BRAIN_DAMAGE_ASYNC_BLINKING) // Randomize order for unsynched animations if (sync_blinking || prob(50)) var/list/anim_times = animate_eyelid(eyelid_left, parent, sync_blinking) @@ -532,7 +529,6 @@ #undef RAND_BLINKING_DELAY #undef BLINK_DURATION #undef BLINK_LOOPS -#undef ASYNC_BLINKING_BRAIN_DAMAGE /// by default, returns the eyes' penlight_message var as a notice span. May do other things when overridden, such as eldritch insanity, or eye damage, or whatnot. Whatever you want, really. /obj/item/organ/eyes/proc/penlight_examine(mob/living/viewer)