From 91ec7e3f10a30ab1588f5bc14fbff678a8f898e4 Mon Sep 17 00:00:00 2001 From: TheGoret Date: Fri, 3 Jan 2020 19:22:48 +0100 Subject: [PATCH] Port the T-ray scanner from Bay (#7870) Basically took the t-ray scanner from Bay and adapted it to our codebase. Works fine and is available on 7x7 tiles. Flickering is gone too and people should use it more now. Also fixes #7860 --- code/game/objects/items/devices/t_scanner.dm | 51 +++++++++++++++----- html/changelogs/goret-tray-port.yml | 41 ++++++++++++++++ 2 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 html/changelogs/goret-tray-port.yml diff --git a/code/game/objects/items/devices/t_scanner.dm b/code/game/objects/items/devices/t_scanner.dm index c547a24e368..9fbda490693 100644 --- a/code/game/objects/items/devices/t_scanner.dm +++ b/code/game/objects/items/devices/t_scanner.dm @@ -9,27 +9,41 @@ item_state = "electronic" matter = list(DEFAULT_WALL_MATERIAL = 150) origin_tech = list(TECH_MAGNET = 1, TECH_ENGINEERING = 1) + action_button_name = "Toggle T-Ray scanner" - var/scan_range = 1 + var/scan_range = 3 var/on = 0 var/list/active_scanned = list() //assoc list of objects being scanned, mapped to their overlay var/client/user_client //since making sure overlays are properly added and removed is pretty important, so we track the current user explicitly - var/flicker = 0 var/global/list/overlay_cache = list() //cache recent overlays +/obj/item/device/t_scanner/Destroy() + . = ..() + if(on) + set_active(FALSE) + /obj/item/device/t_scanner/update_icon() icon_state = "t-ray[on]" +/obj/item/device/t_scanner/emp_act() + audible_message(src, span("notice", "\The [src] buzzes oddly.")) + set_active(FALSE) + /obj/item/device/t_scanner/attack_self(mob/user) set_active(!on) + user.update_action_buttons() + +/obj/item/device/t_scanner/afterattack(atom/target, mob/user, proximity_flag, click_parameters) + var/obj/structure/disposalpipe/D = target + if(D && istype(D)) + to_chat(user, span("info", "Pipe segment integrity: [(D.health / 10) * 100]%")) /obj/item/device/t_scanner/proc/set_active(var/active) on = active if(on) START_PROCESSING(SSprocessing, src) - flicker = 0 else STOP_PROCESSING(SSprocessing, src) set_user_client(null) @@ -65,15 +79,6 @@ user_client.images -= active_scanned[O] active_scanned -= O - //Flicker effect - for(var/obj/O in active_scanned) - var/image/overlay = active_scanned[O] - if(flicker) - overlay.alpha = 0 - else - overlay.alpha = 128 - flicker = !flicker - //creates a new overlay for a scanned object /obj/item/device/t_scanner/proc/get_overlay(obj/scanned) //Use a cache so we don't create a whole bunch of new images just because someone's walking back and forth in a room. @@ -88,6 +93,19 @@ var/obj/machinery/atmospherics/pipe/P = scanned I.color = P.pipe_color I.overlays += P.overlays + I.underlays += P.underlays + + if(ismob(scanned)) + if(ishuman(scanned)) + var/mob/living/carbon/human/H = scanned + if(H.species.appearance_flags & HAS_SKIN_COLOR) + I.color = rgb(H.r_skin, H.g_skin, H.b_skin) + I.icon = 'icons/mob/mob.dmi' + I.icon_state = "phaseout" + var/mob/M = scanned + I.color = M.color + I.overlays += M.overlays + I.underlays += M.underlays I.alpha = 128 I.mouse_opacity = 0 @@ -105,6 +123,12 @@ if(!center) return for(var/turf/T in range(scan_range, center)) + for(var/mob/M in T.contents) + if(M.alpha < 255) + . += M + else if(round_is_spooky() && isobserver(M)) + . += M + if(!!T.is_plating()) continue @@ -115,6 +139,8 @@ continue //if it's already visible don't need an overlay for it . += O + + /obj/item/device/t_scanner/proc/set_user_client(var/client/new_client) if(new_client == user_client) return @@ -131,5 +157,6 @@ /obj/item/device/t_scanner/dropped(mob/user) set_user_client(null) + ..() #undef OVERLAY_CACHE_LEN diff --git a/html/changelogs/goret-tray-port.yml b/html/changelogs/goret-tray-port.yml new file mode 100644 index 00000000000..e802a2b4d1e --- /dev/null +++ b/html/changelogs/goret-tray-port.yml @@ -0,0 +1,41 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: Goret + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Ported the t-ray from Baystation. It should now give back an interest into using it, and now has a range of 7x7." \ No newline at end of file