From f5f15881c24b08a067121ea46d3d05d9ae5f302b Mon Sep 17 00:00:00 2001 From: Krausus Date: Fri, 15 May 2015 01:07:08 -0400 Subject: [PATCH] Fixes luminosity checks They should now be more in-line with how they worked under the old lighting system. --- code/game/dna/genes/goon_powers.dm | 2 +- code/game/gamemodes/vampire/vampire_powers.dm | 6 +++--- code/game/objects/structures/spirit_board.dm | 4 ++-- code/modules/hydroponics/seed.dm | 2 +- code/modules/hydroponics/trays/tray.dm | 2 +- code/modules/lighting/lighting_overlay.dm | 9 +++++++++ code/modules/mob/living/carbon/human/life.dm | 4 ++-- code/modules/mob/living/carbon/monkey/life.dm | 4 ++-- code/modules/mob/living/simple_animal/hostile/statue.dm | 6 +++--- 9 files changed, 24 insertions(+), 15 deletions(-) diff --git a/code/game/dna/genes/goon_powers.dm b/code/game/dna/genes/goon_powers.dm index febbc302eaa..5411fb3edae 100644 --- a/code/game/dna/genes/goon_powers.dm +++ b/code/game/dna/genes/goon_powers.dm @@ -59,7 +59,7 @@ var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T var/light_available if(L) - light_available = max(0,min(10,L.lum_r + L.lum_g + L.lum_b)-5) + light_available = L.get_clamped_lum()*10 else light_available = 5 if(light_available <= 2) diff --git a/code/game/gamemodes/vampire/vampire_powers.dm b/code/game/gamemodes/vampire/vampire_powers.dm index 8a59cb6d147..a3285863d0e 100644 --- a/code/game/gamemodes/vampire/vampire_powers.dm +++ b/code/game/gamemodes/vampire/vampire_powers.dm @@ -273,9 +273,9 @@ var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T var/light_available if(L) - light_available = max(0,min(10,L.lum_r + L.lum_g + L.lum_b)-5) + light_available = L.get_clamped_lum(0.5)*10 else - light_available = 5 + light_available = 10 if(!istype(T)) return 0 @@ -446,7 +446,7 @@ if(T.y>world.maxy-outer_tele_radius || T.y max_lum) continue diff --git a/code/game/objects/structures/spirit_board.dm b/code/game/objects/structures/spirit_board.dm index 8ddfa279ea1..664bbaf1c18 100644 --- a/code/game/objects/structures/spirit_board.dm +++ b/code/game/objects/structures/spirit_board.dm @@ -64,9 +64,9 @@ var/turf/T = get_turf(src) var/atom/movable/lighting_overlay/LO = locate(/atom/movable/lighting_overlay) in T if(LO) - light_amount = max(0,min(10,LO.lum_r + LO.lum_g + LO.lum_b)-5) + light_amount = LO.get_clamped_lum(0.5)*10 else - light_amount = 5 + light_amount = 10 if(light_amount > 2) M << "It's too bright here to use [src.name]!" diff --git a/code/modules/hydroponics/seed.dm b/code/modules/hydroponics/seed.dm index 0e4e7d56ac1..c11d46154f2 100644 --- a/code/modules/hydroponics/seed.dm +++ b/code/modules/hydroponics/seed.dm @@ -281,7 +281,7 @@ if(!light_supplied) var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in current_turf if(L) - light_supplied = max(0,min(10,L.lum_r + L.lum_g + L.lum_b)-5) + light_supplied = L.get_clamped_lum()*10 else light_supplied = 5 diff --git a/code/modules/hydroponics/trays/tray.dm b/code/modules/hydroponics/trays/tray.dm index 23e7afa0fd7..2dae36c58d0 100644 --- a/code/modules/hydroponics/trays/tray.dm +++ b/code/modules/hydroponics/trays/tray.dm @@ -810,7 +810,7 @@ var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T var/light_available if(L) - light_available = max(0,min(10,L.lum_r + L.lum_g + L.lum_b)) + light_available = L.get_clamped_lum()*10 else light_available = 5 light_string = "a light level of [light_available] lumens" diff --git a/code/modules/lighting/lighting_overlay.dm b/code/modules/lighting/lighting_overlay.dm index 932eee6461a..9110619a4fa 100644 --- a/code/modules/lighting/lighting_overlay.dm +++ b/code/modules/lighting/lighting_overlay.dm @@ -25,6 +25,15 @@ . = ..() verbs.Cut() +/atom/movable/lighting_overlay/proc/get_clamped_lum(var/minlum = 0, var/maxlum = 1) + var/lum = max(lum_r, lum_g, lum_b) + if(lum <= minlum) + return 0 + else if(lum >= maxlum) + return 1 + else + return (lum - minlum) / (maxlum - minlum) + /atom/movable/lighting_overlay/proc/update_lumcount(delta_r, delta_g, delta_b) lum_r += delta_r lum_g += delta_g diff --git a/code/modules/mob/living/carbon/human/life.dm b/code/modules/mob/living/carbon/human/life.dm index e51a4e3c357..dfc38cdd389 100644 --- a/code/modules/mob/living/carbon/human/life.dm +++ b/code/modules/mob/living/carbon/human/life.dm @@ -746,7 +746,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc var/turf/T = loc var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T if(L) - light_amount = min(10,L.lum_r + L.lum_g + L.lum_b) - 5 //hardcapped so it's not abused by having a ton of flashlights + light_amount = (L.get_clamped_lum()*10) - 5 //hardcapped so it's not abused by having a ton of flashlights else light_amount = 5 nutrition += light_amount @@ -768,7 +768,7 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc var/turf/T = loc var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T if(L) - light_amount = L.lum_r + L.lum_g + L.lum_b //hardcapped so it's not abused by having a ton of flashlights + light_amount = L.get_clamped_lum()*10 else light_amount = 10 if(light_amount > species.light_dam) //if there's enough light, start dying diff --git a/code/modules/mob/living/carbon/monkey/life.dm b/code/modules/mob/living/carbon/monkey/life.dm index 6b555052d6b..ec2c33983af 100644 --- a/code/modules/mob/living/carbon/monkey/life.dm +++ b/code/modules/mob/living/carbon/monkey/life.dm @@ -442,7 +442,7 @@ var/turf/T = loc var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T if(L) - light_amount = min(10,L.lum_r + L.lum_g + L.lum_b) - 5 //hardcapped so it's not abused by having a ton of flashlights + light_amount = (L.get_clamped_lum()*10) - 5 //hardcapped so it's not abused by having a ton of flashlights else light_amount = 5 @@ -672,4 +672,4 @@ proc/handle_wetness() if(mob_master.current_cycle%20==2) //dry off a bit once every 20 ticks or so wetlevel = max(wetlevel - 1,0) - return + return diff --git a/code/modules/mob/living/simple_animal/hostile/statue.dm b/code/modules/mob/living/simple_animal/hostile/statue.dm index dc52bc78c2c..5121a96ffac 100644 --- a/code/modules/mob/living/simple_animal/hostile/statue.dm +++ b/code/modules/mob/living/simple_animal/hostile/statue.dm @@ -116,19 +116,19 @@ var/DLlight_amount var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T if(L) - light_amount = min(10,L.lum_r + L.lum_g + L.lum_b) - 5 //hardcapped so it's not abused by having a ton of flashlights + light_amount = L.lum_r + L.lum_g + L.lum_b else light_amount = 5 var/atom/movable/lighting_overlay/DL = locate(/atom/movable/lighting_overlay) in destination if(DL) - DLlight_amount = min(10,L.lum_r + L.lum_g + L.lum_b) - 5 //hardcapped so it's not abused by having a ton of flashlights + DLlight_amount = L.lum_r + L.lum_g + L.lum_b else DLlight_amount = 5 if(T && destination) // Don't check it twice if our destination is the tile we are on or we can't even get to our destination if(T == destination) destination = null - else if(light_amount <= 1 && DLlight_amount <= 1) // No one can see us in the darkness, right? + else if(light_amount < 0.1 && DLlight_amount < 0.1) // No one can see us in the darkness, right? return null // We aren't in darkness, loop for viewers.