From 47f71ccde19f0b43b93ae66bf3f7f9a2b9680b2d Mon Sep 17 00:00:00 2001 From: JimKil3 <47290811+JimKil3@users.noreply.github.com> Date: Sun, 29 Jan 2023 03:00:28 -0500 Subject: [PATCH] Fixes an issue with flashing (#20265) * fixes it Adds a check for the mob's eye status & moves checks above parent call * i hate github * coding chat advice * unbuffs slimes I had to rewrite the whole PR for this :( * tweak + comments * rewrites the PR again * oops * farie request * aaa * Apply suggestions from code review Mostly whitespace & an implied thing Co-authored-by: Farie82 * another code review commit Moves checks that stop eye damage but not flashing back --------- Co-authored-by: Farie82 --- code/modules/mob/living/carbon/carbon.dm | 15 +++++++++++++-- code/modules/mob/living/carbon/human/human.dm | 9 +++++++++ code/modules/mob/living/living.dm | 9 ++++++++- 3 files changed, 30 insertions(+), 3 deletions(-) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 7dfdf6c08ad..e9aea382af2 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -357,8 +357,17 @@ if(HAS_TRAIT(H, TRAIT_SKELETONIZED) && (!H.w_uniform) && (!H.wear_suit)) H.play_xylophone() -/mob/living/carbon/flash_eyes(intensity = 1, override_blindness_check = 0, affect_silicon = 0, visual = 0, laser_pointer = FALSE, type = /obj/screen/fullscreen/flash) +/mob/living/carbon/can_be_flashed(intensity = 1, override_blindness_check = 0) + var/obj/item/organ/internal/eyes/E = get_int_organ(/obj/item/organ/internal/eyes) . = ..() + + if((E && (E.status & ORGAN_DEAD)) || !.) + return FALSE + +/mob/living/carbon/flash_eyes(intensity = 1, override_blindness_check = 0, affect_silicon = 0, visual = 0, laser_pointer = FALSE, type = /obj/screen/fullscreen/flash) + //Parent proc checks if a mob can_be_flashed() + . = ..() + SIGNAL_HANDLER SEND_SIGNAL(src, COMSIG_CARBON_FLASH_EYES, laser_pointer) var/damage = intensity - check_eye_prot() @@ -366,8 +375,10 @@ if(.) if(visual) return + + //Checks that shouldn't stop flashing, but should stop eye damage, so they go here instead of in can_be_flashed() var/obj/item/organ/internal/eyes/E = get_int_organ(/obj/item/organ/internal/eyes) - if(!E || (E && E.weld_proof)) + if(!E || E.weld_proof) return var/extra_darkview = 0 diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index a59f1ef1b45..74c0864567d 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -930,6 +930,15 @@ rank = "AI" set_criminal_status(user, found_record, new_status, reason, rank) +/mob/living/carbon/human/can_be_flashed(intensity = 1, override_blindness_check = 0) + + var/obj/item/organ/internal/eyes/E = get_int_organ(/obj/item/organ/internal/eyes) + . = ..() + + if((!. || (!E && !(dna.species.bodyflags & NO_EYES)))) + return FALSE + + return TRUE ///check_eye_prot() ///Returns a number between -1 to 2 diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 5e93beeb6dd..04ba1d8b13f 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -830,9 +830,16 @@ /mob/living/proc/can_use_vents() return "You can't fit into that vent." +//Checks for anything other than eye protection that would stop flashing. Overridden in carbon.dm and human.dm +/mob/living/proc/can_be_flashed(intensity = 1, override_blindness_check = 0) + if(check_eye_prot() >= intensity || (!override_blindness_check && (HAS_TRAIT(src, TRAIT_BLIND) || HAS_TRAIT(src, TRAIT_FLASH_PROTECTION)))) + return FALSE + + return TRUE + //called when the mob receives a bright flash /mob/living/proc/flash_eyes(intensity = 1, override_blindness_check = 0, affect_silicon = 0, visual = 0, laser_pointer = FALSE, type = /obj/screen/fullscreen/flash) - if(check_eye_prot() < intensity && (override_blindness_check || !HAS_TRAIT(src, TRAIT_BLIND)) && !HAS_TRAIT(src, TRAIT_FLASH_PROTECTION)) + if(can_be_flashed(intensity, override_blindness_check)) overlay_fullscreen("flash", type) addtimer(CALLBACK(src, PROC_REF(clear_fullscreen), "flash", 25), 25) return 1