Make Darksight Great Again (#4626)

* Polaris port of darksight adjusting

* I really need to stop doing this, don't I?
This commit is contained in:
Aronai Sieyes
2018-01-25 18:01:33 -06:00
committed by Anewbe
parent f060cc2a1f
commit 52fe8ba6e4
9 changed files with 84 additions and 23 deletions
+25
View File
@@ -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))
+17
View File
@@ -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"
@@ -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!
+2
View File
@@ -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 .
+9 -3
View File
@@ -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