From b8dbe4c1ab5b1934dac371cf83dc7a3372f90ff3 Mon Sep 17 00:00:00 2001 From: coiax Date: Tue, 29 Dec 2020 13:25:45 +0000 Subject: [PATCH] Make eye(s) of god NODROP only when equipped (#55651) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 👀 Make eye(s) of god NODROP only when equipped :cl: coiax tweak: The "eye of god" only becomes unremovable when put in your eye. /:cl: - The lavaland chest reward "eye of god", will only become NODROP (ie. unremovable) when actually placed in someone's glasses slot, rather than becoming immediately stuck in your hand. - Eyes of god now hurt when implanted, causing temporary blindness and screaming. - A pre-doubled eye of god is now a typepath. - Eyes of god are no longer made out of glass. - Glasses colouring procs have been moved to the top of the glasses file, but unchanged. * Apply suggestions from code review - Refactor out explicit `src` with implicit instance access. - Use ternary string expression for burrow grammar Co-authored-by: Fikou * Fix NODROP staying on beheading Even though the item is NODROP, it can still be removed from someone, such as when they're beheaded. We don't want it to remain sticky, so remove the NODROP trait. Co-authored-by: Fikou --- code/modules/clothing/glasses/_glasses.dm | 114 ++++++++++++------ .../surgery/bodyparts/dismemberment.dm | 2 +- 2 files changed, 77 insertions(+), 39 deletions(-) diff --git a/code/modules/clothing/glasses/_glasses.dm b/code/modules/clothing/glasses/_glasses.dm index 4bde967c847..155b5bfe318 100644 --- a/code/modules/clothing/glasses/_glasses.dm +++ b/code/modules/clothing/glasses/_glasses.dm @@ -54,6 +54,39 @@ H.blur_eyes(5) eyes.applyOrganDamage(5) +/obj/item/clothing/glasses/AltClick(mob/user) + if(glass_colour_type && ishuman(user)) + var/mob/living/carbon/human/H = user + if(H.client) + if(H.client.prefs) + if(src == H.glasses) + H.client.prefs.uses_glasses_colour = !H.client.prefs.uses_glasses_colour + if(H.client.prefs.uses_glasses_colour) + to_chat(H, "You will now see glasses colors.") + else + to_chat(H, "You will no longer see glasses colors.") + H.update_glasses_color(src, 1) + else + return ..() + +/obj/item/clothing/glasses/proc/change_glass_color(mob/living/carbon/human/H, datum/client_colour/glass_colour/new_color_type) + var/old_colour_type = glass_colour_type + if(!new_color_type || ispath(new_color_type)) //the new glass colour type must be null or a path. + glass_colour_type = new_color_type + if(H && H.glasses == src) + if(old_colour_type) + H.remove_client_colour(old_colour_type) + if(glass_colour_type) + H.update_glasses_color(src, 1) + + +/mob/living/carbon/human/proc/update_glasses_color(obj/item/clothing/glasses/G, glasses_equipped) + if(client?.prefs.uses_glasses_colour && glasses_equipped) + add_client_colour(G.glass_colour_type) + else + remove_client_colour(G.glass_colour_type) + + /obj/item/clothing/glasses/meson name = "optical meson scanner" desc = "Used by engineering and mining staff to see basic structural and terrain layouts through walls, regardless of lighting conditions." @@ -443,57 +476,62 @@ darkness_view = 8 lighting_alpha = LIGHTING_PLANE_ALPHA_MOSTLY_INVISIBLE resistance_flags = LAVA_PROOF | FIRE_PROOF + custom_materials = null clothing_flags = SCAN_REAGENTS + var/double = FALSE -/obj/item/clothing/glasses/godeye/Initialize() +/obj/item/clothing/glasses/godeye/equipped(mob/user, slot) . = ..() - ADD_TRAIT(src, TRAIT_NODROP, EYE_OF_GOD_TRAIT) + if(ishuman(user) && slot == ITEM_SLOT_EYES) + ADD_TRAIT(src, TRAIT_NODROP, EYE_OF_GOD_TRAIT) + + pain(user) + +/obj/item/clothing/glasses/godeye/dropped(mob/user) + . = ..() + // Behead someone, their "glasses" drop on the floor + // and thus, the god eye should no longer be sticky + REMOVE_TRAIT(src, TRAIT_NODROP, EYE_OF_GOD_TRAIT) /obj/item/clothing/glasses/godeye/attackby(obj/item/W as obj, mob/user as mob, params) - if(istype(W, src) && W != src && W.loc == user) - if(W.icon_state == "godeye") - W.icon_state = "doublegodeye" - W.inhand_icon_state = "doublegodeye" - W.desc = "A pair of strange eyes, said to have been torn from an omniscient creature that used to roam the wastes. There's no real reason to have two, but that isn't stopping you." + if(istype(W, /obj/item/clothing/glasses/godeye) && W != src && W.loc == user) + if(!double) + var/obj/item/clothing/glasses/godeye/double/T = /obj/item/clothing/glasses/godeye/double + + icon_state = initial(T.icon_state) + inhand_icon_state = initial(T.inhand_icon_state) + if(iscarbon(user)) var/mob/living/carbon/C = user - C.update_inv_wear_mask() + C.update_inv_glasses() + + // Apply pain now, so message is still for solo eye bore + if(C.glasses == src) + pain(C) + + name = initial(T.name) + desc = initial(T.desc) + double = TRUE else - to_chat(user, "The eye winks at you and vanishes into the abyss, you feel really unlucky.") - qdel(src) + to_chat(user, "[W] winks at you and vanishes into the abyss, you feel really unlucky.") + qdel(W) ..() -/obj/item/clothing/glasses/AltClick(mob/user) - if(glass_colour_type && ishuman(user)) - var/mob/living/carbon/human/H = user - if(H.client) - if(H.client.prefs) - if(src == H.glasses) - H.client.prefs.uses_glasses_colour = !H.client.prefs.uses_glasses_colour - if(H.client.prefs.uses_glasses_colour) - to_chat(H, "You will now see glasses colors.") - else - to_chat(H, "You will no longer see glasses colors.") - H.update_glasses_color(src, 1) - else - return ..() +/obj/item/clothing/glasses/godeye/proc/pain(mob/living/victim) + // If pain/pain immunity ever implemented, check for it here. -/obj/item/clothing/glasses/proc/change_glass_color(mob/living/carbon/human/H, datum/client_colour/glass_colour/new_color_type) - var/old_colour_type = glass_colour_type - if(!new_color_type || ispath(new_color_type)) //the new glass colour type must be null or a path. - glass_colour_type = new_color_type - if(H && H.glasses == src) - if(old_colour_type) - H.remove_client_colour(old_colour_type) - if(glass_colour_type) - H.update_glasses_color(src, 1) + to_chat(victim, "You experience blinding pain, as [src] [double ? "burrow" : "burrows"] into your skull.") + victim.emote("scream") + victim.flash_act() +/obj/item/clothing/glasses/godeye/double + name = "eyes of god" + desc = "A pair of strange eyes, said to have been torn from an omniscient creature that used to roam the wastes. There's no real reason to have two, but that isn't stopping you." + icon_state = "doublegodeye" + inhand_icon_state = "doublegodeye" + + double = TRUE -/mob/living/carbon/human/proc/update_glasses_color(obj/item/clothing/glasses/G, glasses_equipped) - if(client?.prefs.uses_glasses_colour && glasses_equipped) - add_client_colour(G.glass_colour_type) - else - remove_client_colour(G.glass_colour_type) /obj/item/clothing/glasses/debug name = "debug glasses" diff --git a/code/modules/surgery/bodyparts/dismemberment.dm b/code/modules/surgery/bodyparts/dismemberment.dm index cc3418c3c8c..6528b3118a9 100644 --- a/code/modules/surgery/bodyparts/dismemberment.dm +++ b/code/modules/surgery/bodyparts/dismemberment.dm @@ -288,7 +288,7 @@ //Drop all worn head items for(var/X in list(owner.glasses, owner.ears, owner.wear_mask, owner.head)) var/obj/item/I = X - owner.dropItemToGround(I, TRUE) + owner.dropItemToGround(I, force = TRUE) qdel(owner.GetComponent(/datum/component/creamed)) //clean creampie overlay