Lighting overhaul.

This commit overhauls the lighting system to Bay12 standards. It is better
in pretty much every way.
This commit is contained in:
Tigercat2000
2015-05-10 12:03:27 -07:00
parent 73838ac55d
commit e1249fc640
141 changed files with 1195 additions and 1449 deletions
+4 -5
View File
@@ -1325,11 +1325,10 @@ obj/machinery/power/apc/proc/autoset(var/val, var/on)
if( cell && cell.charge>=20)
cell.use(20);
spawn(0)
for(var/area/A in area.related)
for(var/obj/machinery/light/L in A)
L.on = 1
L.broken()
sleep(1)
for(var/obj/machinery/light/L in area)
L.on = 1
L.broken()
sleep(1)
/obj/machinery/power/apc/Destroy()
if(malfai && operating)
+1 -1
View File
@@ -91,7 +91,7 @@
powernet.cut_cable(src) // update the powernets
cable_list -= src
/* if(istype(attached))
attached.SetLuminosity(0)
attached.set_light(0)
attached.icon_state = "powersink0"
attached.mode = 0
processing_objects.Remove(attached)
+47 -26
View File
@@ -141,7 +141,9 @@
power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list
var/on = 0 // 1 if on, 0 if off
var/on_gs = 0
var/brightness = 8 // luminosity when on, also used in power calculation
var/brightness_range = 8 // luminosity when on, also used in power calculation
var/brightness_power = 3
var/brightness_color = null
var/status = LIGHT_OK // LIGHT_OK, _EMPTY, _BURNED or _BROKEN
var/flickering = 0
var/light_type = /obj/item/weapon/light/tube // the type of light item
@@ -157,7 +159,9 @@
icon_state = "bulb1"
base_state = "bulb"
fitting = "bulb"
brightness = 4
brightness_range = 4
brightness_power = 2
brightness_color = "#a0a080"
desc = "A small lighting fixture."
light_type = /obj/item/weapon/light/bulb
@@ -178,7 +182,8 @@
name = "spotlight"
fitting = "large tube"
light_type = /obj/item/weapon/light/tube/large
brightness = 12
brightness_range = 12
brightness_power = 4
/obj/machinery/light/built/New()
status = LIGHT_EMPTY
@@ -195,13 +200,20 @@
..()
spawn(2)
var/area/A = get_area(src)
if(A && !A.requires_power)
on = 1
switch(fitting)
if("tube")
brightness = 8
brightness_range = 8
brightness_power = 3
if(prob(2))
broken(1)
if("bulb")
brightness = 4
brightness_range = 4
brightness_power = 2
brightness_color = "#a0a080"
if(prob(5))
broken(1)
spawn(1)
@@ -235,7 +247,7 @@
update_icon()
if(on)
if(luminosity != brightness)
if(light_range != brightness_range || light_power != brightness_power || light_color != brightness_color)
switchcount++
if(rigged)
if(status == LIGHT_OK && trigger)
@@ -249,15 +261,15 @@
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
on = 0
SetLuminosity(0)
set_light(0)
else
use_power = 2
SetLuminosity(brightness)
set_light(brightness_range, brightness_power, brightness_color)
else
use_power = 1
SetLuminosity(0)
set_light(0)
active_power_usage = (luminosity * 10)
active_power_usage = ((light_range + light_power) * 10)
if(on != on_gs)
on_gs = on
@@ -309,8 +321,9 @@
user << "You insert the [L.name]."
switchcount = L.switchcount
rigged = L.rigged
brightness = L.brightness
l_color = L.color
brightness_range = L.brightness_range
brightness_power = L.brightness_power
brightness_color = L.brightness_color
on = has_power()
update()
@@ -387,7 +400,7 @@
// true if area has power and lightswitch is on
/obj/machinery/light/proc/has_power()
var/area/A = src.loc.loc
return A.master.lightswitch && A.master.power_light
return A.lightswitch && A.power_light
/obj/machinery/light/proc/flicker(var/amount = rand(10, 20))
if(flickering) return
@@ -474,8 +487,9 @@
var/obj/item/weapon/light/L = new light_type()
L.status = status
L.rigged = rigged
L.brightness = src.brightness
L.color = l_color
L.brightness_range = brightness_range
L.brightness_power = brightness_power
L.brightness_color = brightness_color
// light item inherits the switchcount, then zero it
L.switchcount = switchcount
@@ -501,8 +515,9 @@
var/obj/item/weapon/light/L = new light_type()
L.status = status
L.rigged = rigged
L.brightness = brightness
L.color = l_color
L.brightness_range = brightness_range
L.brightness_power = brightness_power
L.brightness_color = brightness_color
// light item inherits the switchcount, then zero it
L.switchcount = switchcount
@@ -533,7 +548,6 @@
if(status == LIGHT_OK)
return
status = LIGHT_OK
brightness = initial(brightness)
on = 1
update()
@@ -568,7 +582,7 @@
/*
/obj/machinery/light/process()//TODO: remove/add this from machines to save on processing as needed ~Carn PRIORITY
if(on)
use_power(luminosity * LIGHTING_POWER_FACTOR, LIGHT)
use_power(light_range * LIGHTING_POWER_FACTOR, LIGHT)
*/
// called when area power state changes
@@ -608,7 +622,9 @@
var/switchcount = 0 // number of times switched
m_amt = 60
var/rigged = 0 // true if rigged to explode
var/brightness = 2 //how much light it gives off
var/brightness_range = 2 //how much light it gives off
var/brightness_power = 1
var/brightness_color = null
/obj/item/weapon/light/tube
name = "light tube"
@@ -617,12 +633,14 @@
base_state = "ltube"
item_state = "c_tube"
g_amt = 100
brightness = 8
brightness_range = 8
brightness_power = 3
/obj/item/weapon/light/tube/large
w_class = 2
name = "large light tube"
brightness = 15
brightness_range = 15
brightness_power = 4
/obj/item/weapon/light/bulb
name = "light bulb"
@@ -631,7 +649,9 @@
base_state = "lbulb"
item_state = "contvapour"
g_amt = 100
brightness = 5
brightness_range = 5
brightness_power = 2
brightness_color = "#a0a080"
/obj/item/weapon/light/throw_impact(atom/hit_atom)
..()
@@ -644,7 +664,8 @@
base_state = "fbulb"
item_state = "egg4"
g_amt = 100
brightness = 5
brightness_range = 5
brightness_power = 2
// update the icon state and description of the light
@@ -665,9 +686,9 @@
..()
switch(name)
if("light tube")
brightness = rand(6,9)
brightness_range = rand(6,9)
if("light bulb")
brightness = rand(4,6)
brightness_range = rand(4,6)
update()
+9 -20
View File
@@ -46,31 +46,20 @@
return 1
var/area/A = src.loc.loc // make sure it's in an area
if(!A || !isarea(A) || !A.master)
if(!A || !isarea(A))
return 0 // if not, then not powered
if(chan == -1)
chan = power_channel
return A.master.powered(chan) // return power status of the area
return A.powered(chan) // return power status of the area
// increment the power usage stats for an area
/obj/machinery/proc/use_power(var/amount, var/chan = -1, var/autocalled = 0) // defaults to power_channel
var/A = getArea()
/obj/machinery/proc/use_power(var/amount, var/chan = -1) // defaults to power_channel
var/area/A = get_area(src) // make sure it's in an area
if(!A || !isarea(A))
return
var/area/B = A
if (!B.master)
return
if (-1 == chan)
if(chan == -1)
chan = power_channel
B.master.use_power(amount, chan)
A.use_power(amount, chan)
/obj/machinery/proc/power_change() // called whenever the power settings of the containing area change
// by default, check equipment channel & set flag
@@ -445,9 +434,9 @@
return null
/area/proc/get_apc()
for(var/area/RA in src.related)
if (RA.apc.len >= 1)
return RA.apc[1]
var/obj/machinery/power/apc/FINDME = locate() in src
if (FINDME)
return FINDME
//Determines how strong could be shock, deals damage to mob, uses power.
@@ -9,7 +9,7 @@
density = 0
unacidable = 1
use_power = 0
luminosity = 4
light_range = 4
var/obj/machinery/field_generator/FG1 = null
var/obj/machinery/field_generator/FG2 = null
var/hasShocked = 0 //Used to add a delay between shocks. In some cases this used to crash servers by spawning hundreds of sparks every second.
@@ -18,7 +18,7 @@ var/global/list/uneatable = list(
anchored = 1
density = 1
layer = 6
luminosity = 6
light_range = 6
unacidable = 1 //Don't comment this out.
use_power = 0
var/current_size = 1