From c889e5ebe28efc02bc2089f49cf1ae966cb524f0 Mon Sep 17 00:00:00 2001 From: Atermonera Date: Sat, 1 Aug 2020 21:05:07 -0700 Subject: [PATCH] Adds Area-Based Meson Obfuscation --- code/game/area/areas.dm | 19 +++++- code/modules/clothing/glasses/glasses.dm | 59 +++++++++++++------ code/modules/mob/living/carbon/human/human.dm | 22 +++++++ code/modules/mob/living/carbon/human/life.dm | 5 ++ code/modules/mob/living/living.dm | 5 ++ code/modules/mob/living/silicon/robot/life.dm | 11 +++- .../modules/mob/living/silicon/robot/robot.dm | 16 +++++ 7 files changed, 115 insertions(+), 22 deletions(-) diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 49c481be157..c3488149442 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -49,6 +49,7 @@ var/sound_env = STANDARD_STATION var/turf/base_turf //The base turf type of the area, which can be used to override the z-level's base turf var/forbid_events = FALSE // If true, random events will not start inside this area. + var/no_spoilers = FALSE // If true, makes it much more difficult to see what is inside an area with things like mesons. /area/Initialize() . = ..() @@ -64,6 +65,8 @@ power_equip = 0 power_environ = 0 power_change() // all machines set to current power level, also updates lighting icon + if(no_spoilers) + set_spoiler_obfuscation(TRUE) return INITIALIZE_HINT_LATELOAD // Changes the area of T to A. Do not do this manually. @@ -368,6 +371,8 @@ var/list/mob/living/forced_ambiance_list = new L.lastarea = newarea play_ambience(L) + if(no_spoilers) + L.disable_spoiler_vision() /area/proc/play_ambience(var/mob/living/L) // Ambience goes down here -- make sure to list each area seperately for ease of adding things in later, thanks! Note: areas adjacent to each other should have the same sounds to prevent cutoff when possible.- LastyScratch @@ -500,4 +505,16 @@ var/list/ghostteleportlocs = list() /area/proc/get_name() if(secret_name) return "Unknown Area" - return name \ No newline at end of file + return name + +GLOBAL_DATUM(spoiler_obfuscation_image, /image) + +/area/proc/set_spoiler_obfuscation(should_obfuscate) + if(!GLOB.spoiler_obfuscation_image) + GLOB.spoiler_obfuscation_image = image(icon = 'icons/misc/static.dmi') + GLOB.spoiler_obfuscation_image.plane = PLANE_MESONS + + if(should_obfuscate) + add_overlay(GLOB.spoiler_obfuscation_image) + else + cut_overlay(GLOB.spoiler_obfuscation_image) \ No newline at end of file diff --git a/code/modules/clothing/glasses/glasses.dm b/code/modules/clothing/glasses/glasses.dm index 4b82cbbe25b..fdbc1c257df 100644 --- a/code/modules/clothing/glasses/glasses.dm +++ b/code/modules/clothing/glasses/glasses.dm @@ -39,28 +39,49 @@ BLIND // can't see anything var/mob/M = src.loc M.update_inv_glasses() +/obj/item/clothing/glasses/proc/can_toggle(mob/living/user) + if(!toggleable) + return FALSE + + // Prevent people from just turning their goggles back on. + if(!active && (vision_flags & (SEE_TURFS|SEE_OBJS))) + var/area/A = get_area(src) + if(A.no_spoilers) + return FALSE + + return TRUE + +/obj/item/clothing/glasses/proc/toggle_active(mob/living/user) + if(active) + active = FALSE + icon_state = off_state + user.update_inv_glasses() + flash_protection = FLASH_PROTECTION_NONE + tint = TINT_NONE + away_planes = enables_planes + enables_planes = null + + else + active = TRUE + icon_state = initial(icon_state) + user.update_inv_glasses() + flash_protection = initial(flash_protection) + tint = initial(tint) + enables_planes = away_planes + away_planes = null + user.update_action_buttons() + user.recalculate_vis() + /obj/item/clothing/glasses/attack_self(mob/user) if(toggleable) - if(active) - active = 0 - icon_state = off_state - user.update_inv_glasses() - flash_protection = FLASH_PROTECTION_NONE - tint = TINT_NONE - away_planes = enables_planes - enables_planes = null - to_chat(usr, "You deactivate the optical matrix on the [src].") + if(!can_toggle(user)) + to_chat(user, span("warning", "You don't seem to be able to toggle \the [src] here.")) else - active = 1 - icon_state = initial(icon_state) - user.update_inv_glasses() - flash_protection = initial(flash_protection) - tint = initial(tint) - enables_planes = away_planes - away_planes = null - to_chat(usr, "You activate the optical matrix on the [src].") - user.update_action_buttons() - user.recalculate_vis() + toggle_active(user) + if(active) + to_chat(user, span("notice", "You activate the optical matrix on the [src].")) + else + to_chat(user, span("notice", "You deactivate the optical matrix on the [src].")) ..() /obj/item/clothing/glasses/meson diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index b0d7bacc991..5b5667afde1 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1687,7 +1687,29 @@ T.add_blood(src) . = ..() +<<<<<<< HEAD /mob/living/carbon/human/reduce_cuff_time() if(istype(gloves, /obj/item/clothing/gloves/gauntlets/rig)) return 2 return ..() +======= +// Tries to turn off item-based things that let you see through walls, like mesons. +// Certain stuff like genetic xray vision is allowed to be kept on. +/mob/living/carbon/human/disable_spoiler_vision() + // Glasses. + if(istype(glasses, /obj/item/clothing/glasses)) + var/obj/item/clothing/glasses/goggles = glasses + if(goggles.active && (goggles.vision_flags & (SEE_TURFS|SEE_OBJS))) + goggles.toggle_active(src) + to_chat(src, span("warning", "Your [goggles.name] have suddenly turned off!")) + + // RIGs. + var/obj/item/weapon/rig/rig = get_rig() + if(istype(rig) && rig.visor?.active && rig.visor.vision?.glasses) + var/obj/item/clothing/glasses/rig_goggles = rig.visor.vision.glasses + if(rig_goggles.vision_flags & (SEE_TURFS|SEE_OBJS)) + rig.visor.deactivate() + to_chat(src, span("warning", "\The [rig]'s visor has shuddenly deactivated!")) + + ..() +>>>>>>> bef865b... Merge pull request #7383 from Neerti/meson_obfuscation diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index 847bdeceb81..b29afe4da52 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -1328,6 +1328,11 @@ sight &= ~(SEE_TURFS|SEE_MOBS|SEE_OBJS) see_invisible = see_in_dark>2 ? SEE_INVISIBLE_LEVEL_ONE : see_invisible_default + // Do this early so certain stuff gets turned off before vision is assigned. + var/area/A = get_area(src) + if(A?.no_spoilers) + disable_spoiler_vision() + if(XRAY in mutations) sight |= SEE_TURFS|SEE_MOBS|SEE_OBJS see_in_dark = 8 diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 60cc4484cbb..e8e5fd3361b 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1435,3 +1435,8 @@ default behaviour is: clear_alert("weightless") else throw_alert("weightless", /obj/screen/alert/weightless) + +// Tries to turn off things that let you see through walls, like mesons. +// Each mob does vision a bit differently so this is just for inheritence and also so overrided procs can make the vision apply instantly if they call `..()`. +/mob/living/proc/disable_spoiler_vision() + handle_vision() \ No newline at end of file diff --git a/code/modules/mob/living/silicon/robot/life.dm b/code/modules/mob/living/silicon/robot/life.dm index fd9ca757cd1..6db31e60daa 100644 --- a/code/modules/mob/living/silicon/robot/life.dm +++ b/code/modules/mob/living/silicon/robot/life.dm @@ -153,7 +153,13 @@ /mob/living/silicon/robot/handle_regular_hud_updates() var/fullbright = FALSE var/seemeson = FALSE - if (src.stat == 2 || (XRAY in mutations) || (src.sight_mode & BORGXRAY)) + + var/area/A = get_area(src) + if(A?.no_spoilers) + disable_spoiler_vision() + + + if (src.stat == DEAD || (XRAY in mutations) || (src.sight_mode & BORGXRAY)) src.sight |= SEE_TURFS src.sight |= SEE_MOBS src.sight |= SEE_OBJS @@ -187,13 +193,14 @@ src.sight &= ~SEE_OBJS src.see_in_dark = 8 src.see_invisible = SEE_INVISIBLE_NOLIGHTING - else if (src.stat != 2) + else if (src.stat != DEAD) src.sight &= ~SEE_MOBS src.sight &= ~SEE_TURFS src.sight &= ~SEE_OBJS src.see_in_dark = 8 // see_in_dark means you can FAINTLY see in the dark, humans have a range of 3 or so, tajaran have it at 8 src.see_invisible = SEE_INVISIBLE_LIVING // This is normal vision (25), setting it lower for normal vision means you don't "see" things like darkness since darkness // has a "invisible" value of 15 + plane_holder.set_vis(VIS_FULLBRIGHT,fullbright) plane_holder.set_vis(VIS_MESONS,seemeson) ..() diff --git a/code/modules/mob/living/silicon/robot/robot.dm b/code/modules/mob/living/silicon/robot/robot.dm index ce46e83447a..6383449e0a6 100644 --- a/code/modules/mob/living/silicon/robot/robot.dm +++ b/code/modules/mob/living/silicon/robot/robot.dm @@ -1140,3 +1140,19 @@ if(module_active && istype(module_active,/obj/item/weapon/gripper)) var/obj/item/weapon/gripper/G = module_active G.drop_item_nm() + +/mob/living/silicon/robot/disable_spoiler_vision() + if(sight_mode & (BORGMESON|BORGMATERIAL|BORGXRAY)) // Whyyyyyyyy have seperate defines. + var/i = 0 + // Borg inventory code is very . . interesting and as such, unequiping a specific item requires jumping through some (for) loops. + var/current_selection_index = get_selected_module() // Will be 0 if nothing is selected. + for(var/thing in list(module_state_1, module_state_2, module_state_3)) + i++ + if(istype(thing, /obj/item/borg/sight)) + var/obj/item/borg/sight/S = thing + if(S.sight_mode & (BORGMESON|BORGMATERIAL|BORGXRAY)) + select_module(i) + uneq_active() + + if(current_selection_index) // Select what the player had before if possible. + select_module(current_selection_index) \ No newline at end of file