[MIRROR] Converts blindness and nearsightedness to status effects, scratches some VERY dumb blindness handling that resulted in mobs becoming "incurably" blind [MDB IGNORE] (#18760)

* Converts blindness and nearsightedness to status effects, scratches some VERY dumb blindness handling that resulted in mobs becoming "incurably" blind

* Fixes the conflicts and makes shit compile!

* Fixes other things that didn't show up because I hadn't updated

* Fixes the lints.

* Okay NOW it's ready (please don't add anything else that touches blindness I beg you)

---------

Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com>
Co-authored-by: GoldenAlpharex <jerego1234@hotmail.com>
This commit is contained in:
SkyratBot
2023-02-03 16:08:32 -05:00
committed by GitHub
co-authored by MrMelbert GoldenAlpharex
parent bc6b643082
commit 1fe0d145a3
88 changed files with 850 additions and 654 deletions
+2 -4
View File
@@ -48,11 +48,9 @@
span_notice("[user] completes the surgery on [target]'s eyes."),
)
display_pain(target, "Your vision blurs, but it seems like you can see a little better now!")
target.cure_blind(list(EYE_DAMAGE))
target.set_blindness(0)
target.cure_nearsighted(list(EYE_DAMAGE))
target.remove_status_effect(/datum/status_effect/temporary_blindness)
target.set_eye_blur_if_lower(70 SECONDS) //this will fix itself slowly.
target_eyes.setOrganDamage(0)
target_eyes.setOrganDamage(0) // heals nearsightedness and blindness from eye damage
return ..()
/datum/surgery_step/fix_eyes/failure(mob/user, mob/living/carbon/target, target_zone, obj/item/tool, datum/surgery/surgery)
+6 -8
View File
@@ -179,8 +179,13 @@ INITIALIZE_IMMEDIATE(/obj/item/organ)
return
damage = clamp(damage + damage_amount, 0, maximum)
var/mess = check_damage_thresholds(owner)
check_failing_thresholds()
prev_damage = damage
if(damage >= maxHealth)
organ_flags |= ORGAN_FAILING
else
organ_flags &= ~ORGAN_FAILING
if(mess && owner && owner.stat <= SOFT_CRIT)
to_chat(owner, mess)
@@ -213,13 +218,6 @@ INITIALIZE_IMMEDIATE(/obj/item/organ)
if(prev_damage == maxHealth)
return now_fixed
///Checks if an organ should/shouldn't be failing and gives the appropriate organ flag
/obj/item/organ/proc/check_failing_thresholds()
if(damage >= maxHealth)
organ_flags |= ORGAN_FAILING
if(damage < maxHealth)
organ_flags &= ~ORGAN_FAILING
//Looking for brains?
//Try code/modules/mob/living/carbon/brain/brain_item.dm
+92 -77
View File
@@ -20,79 +20,74 @@
high_threshold_cleared = "<span class='info'>Your vision functions passably once more.</span>"
low_threshold_cleared = "<span class='info'>Your vision is cleared of any ailment.</span>"
var/sight_flags = 0
/// Sight flags this eye pair imparts on its user.
var/sight_flags = NONE
/// changes how the eyes overlay is applied, makes it apply over the lighting layer
var/overlay_ignore_lighting = FALSE
/// How much a mob can see in the dark with these eyes
var/see_in_dark = 2
/// How much innate tint these eyes have
var/tint = 0
/// How much innare flash protection these eyes have, usually paired with tint
var/flash_protect = FLASH_PROTECTION_NONE
/// What level of invisibility these eyes can see
var/see_invisible = SEE_INVISIBLE_LIVING
/// How much alpha lighting has (basically, night vision)
var/lighting_alpha
var/eye_color_left = "" //set to a hex code to override a mob's left eye color
var/eye_color_right = "" //set to a hex code to override a mob's right eye color
var/eye_icon_state = "eyes"
var/old_eye_color_left = "fff"
var/old_eye_color_right = "fff"
var/flash_protect = FLASH_PROTECTION_NONE
var/see_invisible = SEE_INVISIBLE_LIVING
var/lighting_alpha
var/no_glasses
/// Glasses cannot be worn over these eyes. Currently unused
var/no_glasses = FALSE
/// indication that the eyes are undergoing some negative effect
var/damaged = FALSE
/// Native FOV that will be applied if a config is enabled
var/native_fov = FOV_180_DEGREES //SKYRAT EDIT CHANGE
/obj/item/organ/internal/eyes/Insert(mob/living/carbon/eye_owner, special = FALSE, drop_if_replaced = FALSE, initialising)
/obj/item/organ/internal/eyes/Insert(mob/living/carbon/eye_owner, special = FALSE, drop_if_replaced = FALSE)
. = ..()
if(ishuman(eye_owner))
var/mob/living/carbon/human/human_owner = eye_owner
// SKYRAT EDIT ADDITION
if(human_owner.emissive_eyes)
is_emissive = TRUE
// SKYRAT EDIT END
old_eye_color_left = human_owner.eye_color_left
old_eye_color_right = human_owner.eye_color_right
if(initial(eye_color_left))
human_owner.eye_color_left = eye_color_left
else
eye_color_left = human_owner.eye_color_left
if(initial(eye_color_right))
human_owner.eye_color_right = eye_color_right
else
eye_color_right = human_owner.eye_color_right
if(HAS_TRAIT(human_owner, TRAIT_NIGHT_VISION) && !lighting_alpha)
lighting_alpha = LIGHTING_PLANE_ALPHA_NV_TRAIT
if(CONFIG_GET(flag/native_fov) && native_fov)
human_owner.add_fov_trait(type, native_fov)
eye_owner.update_tint()
owner.update_sight()
if(eye_owner.has_dna() && ishuman(eye_owner))
eye_owner.dna.species.handle_body(eye_owner) //updates eye icon
owner.cure_blind(NO_EYES)
apply_damaged_eye_effects()
refresh()
/// Refreshes the visuals of the eyes
/// If call_update is TRUE, we also will call udpate_body
/obj/item/organ/internal/eyes/proc/refresh(call_update = TRUE)
if(ishuman(owner))
var/mob/living/carbon/human/affected_human = owner
// SKYRAT EDIT ADDITION
if (affected_human.emissive_eyes)
is_emissive = TRUE
// SKYRAT EDIT END
old_eye_color_left = affected_human.eye_color_left
old_eye_color_right = affected_human.eye_color_right
if(initial(eye_color_left))
affected_human.eye_color_left = eye_color_left
else
eye_color_left = affected_human.eye_color_left
if(initial(eye_color_right))
affected_human.eye_color_right = eye_color_right
else
eye_color_right = affected_human.eye_color_right
if(HAS_TRAIT(affected_human, TRAIT_NIGHT_VISION) && !lighting_alpha)
lighting_alpha = LIGHTING_PLANE_ALPHA_NV_TRAIT
owner.update_tint()
owner.update_sight()
if(call_update && owner.has_dna() && ishuman(owner))
var/mob/living/carbon/human/affected_human = owner
affected_human.dna.species.handle_body(affected_human) //updates eye icon
owner.update_tint()
if(!ishuman(owner))
return
/obj/item/organ/internal/eyes/Remove(mob/living/carbon/eye_owner, special = 0)
var/mob/living/carbon/human/affected_human = owner
old_eye_color_left = affected_human.eye_color_left
old_eye_color_right = affected_human.eye_color_right
if(initial(eye_color_left))
affected_human.eye_color_left = eye_color_left
else
eye_color_left = affected_human.eye_color_left
if(initial(eye_color_right))
affected_human.eye_color_right = eye_color_right
else
eye_color_right = affected_human.eye_color_right
if(HAS_TRAIT(affected_human, TRAIT_NIGHT_VISION) && !lighting_alpha)
lighting_alpha = LIGHTING_PLANE_ALPHA_NV_TRAIT
if(CONFIG_GET(flag/native_fov) && native_fov)
owner.add_fov_trait(type, native_fov)
// SKYRAT EDIT ADDITION - EMISSIVES
if (affected_human.emissive_eyes)
is_emissive = TRUE
// SKYRAT EDIT END
if(call_update)
owner.dna?.species?.handle_body(affected_human) //updates eye icon
/obj/item/organ/internal/eyes/Remove(mob/living/carbon/eye_owner, special = FALSE)
..()
if(ishuman(eye_owner))
var/mob/living/carbon/human/human_owner = eye_owner
@@ -103,11 +98,18 @@
human_owner.update_body()
if(native_fov)
eye_owner.remove_fov_trait(type)
// Cure blindness from eye damage
eye_owner.cure_blind(EYE_DAMAGE)
eye_owner.cure_nearsighted(EYE_DAMAGE)
eye_owner.set_blindness(0)
// Eye blind and temp blind go to, even if this is a bit of cheesy way to clear blindness
eye_owner.remove_status_effect(/datum/status_effect/eye_blur)
eye_owner.clear_fullscreen("eye_damage", 0)
eye_owner.remove_status_effect(/datum/status_effect/temporary_blindness)
// Then become blind anyways (if not special)
if(!special)
eye_owner.become_blind(NO_EYES)
eye_owner.update_tint()
eye_owner.update_sight()
is_emissive = FALSE // SKYRAT EDIT ADDITION
@@ -157,31 +159,44 @@
eye_color_left = initial(eye_color_left)
eye_color_right = initial(eye_color_right)
/obj/item/organ/internal/eyes/on_life(delta_time, times_fired)
/obj/item/organ/internal/eyes/applyOrganDamage(damage_amount, maximum, required_organtype)
. = ..()
var/mob/living/carbon/eye_owner = owner
//various degrees of "oh fuck my eyes", from "point a laser at your eye" to "staring at the Sun" intensities
if(damage > 20)
damaged = TRUE
if((organ_flags & ORGAN_FAILING))
eye_owner.become_blind(EYE_DAMAGE)
return
if(!owner)
return
apply_damaged_eye_effects()
var/obj/item/clothing/glasses/eyewear = eye_owner.glasses
var/has_prescription_glasses = istype(eyewear) && eyewear.vision_correction
if(has_prescription_glasses)
return
var/severity = damage > 30 ? 2 : 1
eye_owner.overlay_fullscreen("eye_damage", /atom/movable/screen/fullscreen/impaired, severity)
/// Applies effects to our owner based on how damaged our eyes are
/obj/item/organ/internal/eyes/proc/apply_damaged_eye_effects()
// we're in healthy threshold, either try to heal (if damaged) or do nothing
if(damage <= low_threshold)
if(damaged)
damaged = FALSE
// clear nearsightedness from damage
owner.cure_nearsighted(EYE_DAMAGE)
// if we're still nearsighted, reset its severity
// this is kinda icky, ideally we'd track severity to source but that's way more complex
var/datum/status_effect/grouped/nearsighted/nearsightedness = owner.is_nearsighted()
nearsightedness?.set_nearsighted_severity(1)
// and cure blindness from damage
owner.cure_blind(EYE_DAMAGE)
return
//called once since we don't want to keep clearing the screen of eye damage for people who are below 20 damage
if(damaged)
damaged = FALSE
eye_owner.clear_fullscreen("eye_damage")
eye_owner.cure_blind(EYE_DAMAGE)
//various degrees of "oh fuck my eyes", from "point a laser at your eye" to "staring at the Sun" intensities
// 50 - blind
// 49-31 - nearsighted (2 severity)
// 30-20 - nearsighted (1 severity)
if(organ_flags & ORGAN_FAILING)
// become blind from damage
owner.become_blind(EYE_DAMAGE)
else
// become nearsighted from damage
owner.become_nearsighted(EYE_DAMAGE)
// update the severity of our nearsightedness based on our eye damage
var/datum/status_effect/grouped/nearsighted/nearsightedness = owner.is_nearsighted()
nearsightedness.set_nearsighted_severity(damage > high_threshold ? 2 : 1)
damaged = TRUE
/obj/item/organ/internal/eyes/night_vision
see_in_dark = NIGHTVISION_FOV_RANGE
@@ -564,7 +579,7 @@
ADD_TRAIT(adapted, TRAIT_UNNATURAL_RED_GLOWY_EYES, ORGAN_TRAIT)
/obj/item/organ/internal/eyes/night_vision/maintenance_adapted/on_life(delta_time, times_fired)
if(!HAS_TRAIT(owner, TRAIT_BLIND) && isturf(owner.loc) && owner.has_light_nearby(light_amount=0.5)) //we allow a little more than usual so we can produce light from the adapted eyes
if(!owner.is_blind() && isturf(owner.loc) && owner.has_light_nearby(light_amount=0.5)) //we allow a little more than usual so we can produce light from the adapted eyes
to_chat(owner, span_danger("Your eyes! They burn in the light!"))
applyOrganDamage(10) //blind quickly
playsound(owner, 'sound/machines/grill/grillsizzle.ogg', 50)