diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index c3f367b766..6b162504b9 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -231,27 +231,28 @@ //Vision flags, for dealing with plane visibility #define VIS_FULLBRIGHT 1 -#define VIS_GHOSTS 2 -#define VIS_AI_EYE 3 +#define VIS_LIGHTING 2 +#define VIS_GHOSTS 3 +#define VIS_AI_EYE 4 -#define VIS_CH_STATUS 4 -#define VIS_CH_HEALTH 5 -#define VIS_CH_LIFE 6 -#define VIS_CH_ID 7 -#define VIS_CH_WANTED 8 -#define VIS_CH_IMPLOYAL 9 -#define VIS_CH_IMPTRACK 10 -#define VIS_CH_IMPCHEM 11 -#define VIS_CH_SPECIAL 12 -#define VIS_CH_STATUS_OOC 13 +#define VIS_CH_STATUS 5 +#define VIS_CH_HEALTH 6 +#define VIS_CH_LIFE 7 +#define VIS_CH_ID 8 +#define VIS_CH_WANTED 9 +#define VIS_CH_IMPLOYAL 10 +#define VIS_CH_IMPTRACK 11 +#define VIS_CH_IMPCHEM 12 +#define VIS_CH_SPECIAL 13 +#define VIS_CH_STATUS_OOC 14 -#define VIS_D_COLORBLIND 14 -#define VIS_D_COLORBLINDI 15 +#define VIS_D_COLORBLIND 15 +#define VIS_D_COLORBLINDI 16 -#define VIS_ADMIN1 16 -#define VIS_ADMIN2 17 -#define VIS_ADMIN3 18 +#define VIS_ADMIN1 17 +#define VIS_ADMIN2 18 +#define VIS_ADMIN3 19 -#define VIS_MESONS 19 +#define VIS_MESONS 20 -#define VIS_COUNT 19 //Must be highest number from above. \ No newline at end of file +#define VIS_COUNT 20 //Must be highest number from above. \ No newline at end of file diff --git a/code/_onclick/hud/hud.dm b/code/_onclick/hud/hud.dm index a9676782eb..786c7cdd04 100644 --- a/code/_onclick/hud/hud.dm +++ b/code/_onclick/hud/hud.dm @@ -27,6 +27,7 @@ var/list/global_huds = list( var/obj/screen/whitense var/list/vimpaired var/list/darkMask + var/obj/screen/darksight var/obj/screen/nvg var/obj/screen/thermal var/obj/screen/meson @@ -64,6 +65,13 @@ var/list/global_huds = list( whitense.icon = 'icons/effects/static.dmi' whitense.icon_state = "1 light" + //darksight 'hanger' for attached icons + darksight = new /obj/screen() + darksight.icon = null + darksight.screen_loc = "1,1" + darksight.plane = PLANE_LIGHTING + darksight.plane = LIGHTING_LAYER + 0.1 + nvg = setup_overlay("nvg_hud") thermal = setup_overlay("thermal_hud") meson = setup_overlay("meson_hud") diff --git a/code/modules/lighting/lighting_overlay.dm b/code/modules/lighting/lighting_overlay.dm index 51451e832a..094d781cf2 100644 --- a/code/modules/lighting/lighting_overlay.dm +++ b/code/modules/lighting/lighting_overlay.dm @@ -11,7 +11,7 @@ color = LIGHTING_BASE_MATRIX icon_state = "light1" auto_init = 0 // doesn't need special init - blend_mode = BLEND_MULTIPLY + blend_mode = BLEND_OVERLAY var/lum_r = 0 var/lum_g = 0 diff --git a/code/modules/mob/living/life.dm b/code/modules/mob/living/life.dm index da13bb0155..c825008837 100644 --- a/code/modules/mob/living/life.dm +++ b/code/modules/mob/living/life.dm @@ -173,6 +173,7 @@ ..() handle_vision() + handle_darksight() handle_hud_icons() return 1 @@ -212,3 +213,27 @@ set_light(0) return FALSE +/mob/living/proc/handle_darksight() + var/darksightedness = min(see_in_dark/world.view,1.0) //A ratio of how good your darksight is, from 'nada' to 'really darn good' + var/current = dsoverlay.alpha/255 //Our current adjustedness + + var/brightness = 0.0 //We'll assume it's superdark if we can't find something else. + + if(isturf(loc)) + var/turf/T = loc //Will be true 99% of the time, thus avoiding the whole elif chain + brightness = T.get_lumcount() + + //Snowflake treatment of potential locations + else if(istype(loc,/obj/mecha)) //I imagine there's like displays and junk in there. Use the lights! + brightness = 1 + else if(istype(loc,/obj/item/weapon/holder)) //Poor carried teshari and whatnot should adjust appropriately + var/turf/T = get_turf(src) + brightness = T.get_lumcount() + + var/darkness = 1-brightness //Silly, I know, but 'alpha' and 'darkness' go the same direction on a number line + var/adjust_to = min(darkness,darksightedness)//Capped by how darksighted they are + var/distance = abs(current-adjust_to) //Used for how long to animate for + if(distance < 0.01) return //We're already all set + + //world << "[src] in B:[round(brightness,0.1)] C:[round(current,0.1)] A2:[round(adjust_to,0.1)] D:[round(distance,0.01)] T:[round(distance*10 SECONDS,0.1)]" + animate(dsoverlay, alpha = (adjust_to*255), time = (distance*10 SECONDS)) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 90ef8ff3cc..8399c224ce 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1,3 +1,20 @@ +/mob/living/New() + ..() + + //I'll just hang my coat up over here + dsoverlay = image('icons/mob/darksight.dmi',global_hud.darksight) //This is a secret overlay! Go look at the file, you'll see. + var/mutable_appearance/dsma = new(dsoverlay) //Changing like ten things, might as well. + dsma.alpha = 0 + dsma.plane = PLANE_LIGHTING + dsma.layer = LIGHTING_LAYER + 0.1 + dsma.blend_mode = BLEND_ADD + dsoverlay.appearance = dsma + +/mob/living/Destroy() + dsoverlay.loc = null //I'll take my coat with me + dsoverlay = null + return ..() + //mob verbs are faster than object verbs. See mob/verb/examine. /mob/living/verb/pulled(atom/movable/AM as mob|obj in oview(1)) set name = "Pull" diff --git a/code/modules/mob/living/living_defines.dm b/code/modules/mob/living/living_defines.dm index 87f39b9026..d1deeebffd 100644 --- a/code/modules/mob/living/living_defines.dm +++ b/code/modules/mob/living/living_defines.dm @@ -47,6 +47,8 @@ var/evasion = 0 // Makes attacks harder to land. Each number equals 15% more likely to miss. Negative numbers increase hit chance. var/force_max_speed = 0 // If 1, the mob runs extremely fast and cannot be slowed. + + var/image/dsoverlay = null //Overlay used for darksight eye adjustments var/glow_toggle = 0 // If they're glowing! var/glow_color = "#FFFFFF" // The color they're glowing! diff --git a/code/modules/mob/living/login.dm b/code/modules/mob/living/login.dm index b41baabef9..275e88be08 100644 --- a/code/modules/mob/living/login.dm +++ b/code/modules/mob/living/login.dm @@ -6,4 +6,6 @@ mind.active = 1 //indicates that the mind is currently synced with a client //If they're SSD, remove it so they can wake back up. update_antag_icons(mind) + client.screen |= global_hud.darksight + client.images |= dsoverlay return . diff --git a/code/modules/mob/mob_planes.dm b/code/modules/mob/mob_planes.dm index 5f7beceafe..048992c380 100644 --- a/code/modules/mob/mob_planes.dm +++ b/code/modules/mob/mob_planes.dm @@ -12,6 +12,7 @@ //It'd be nice to lazy init these but some of them are important to just EXIST. Like without ghost planemaster, you can see ghosts. Go figure. plane_masters[VIS_FULLBRIGHT] = new /obj/screen/plane_master/fullbright //Lighting system (lighting_overlay objects) + plane_masters[VIS_LIGHTING] = new /obj/screen/plane_master/lighting //Lighting system (but different!) plane_masters[VIS_GHOSTS] = new /obj/screen/plane_master/ghosts //Ghosts! plane_masters[VIS_AI_EYE] = new /obj/screen/plane_master{plane = PLANE_AI_EYE} //AI Eye! @@ -131,12 +132,17 @@ //Lighting is weird and has matrix shenanigans. Think of this as turning on/off darkness. /obj/screen/plane_master/fullbright plane = PLANE_LIGHTING - layer = LIGHTING_LAYER + layer = LIGHTING_LAYER+1 color = null //To break lighting when visible (this is sorta backwards) - alpha = 255 //Starts full opaque - invisibility = 101 //But invisible + alpha = 0 //Starts full opaque + invisibility = 101 invis_toggle = TRUE +/obj/screen/plane_master/lighting + plane = PLANE_LIGHTING + blend_mode = BLEND_MULTIPLY + alpha = 255 + ///////////////// //Ghosts has a special alpha level /obj/screen/plane_master/ghosts diff --git a/icons/mob/darksight.dmi b/icons/mob/darksight.dmi new file mode 100644 index 0000000000..0752453422 Binary files /dev/null and b/icons/mob/darksight.dmi differ