Merge pull request #1314 from SkyMarshal/Lighting

Ultralight, Sped up how fast fires burn and use fuel, Removed deletion logging (Speeds up world shudown),  added icon for welder fuel.
This commit is contained in:
SkyMarshal
2012-06-18 20:43:22 -07:00
55 changed files with 703 additions and 659 deletions
+7 -7
View File
@@ -213,7 +213,7 @@
if(new_value == null) return
if(variable=="luminosity")
O.sd_SetLuminosity(new_value)
O.ul_SetLuminosity(new_value)
else
O.vars[variable] = new_value
@@ -222,7 +222,7 @@
for(var/mob/M in world)
if ( istype(M , O.type) )
if(variable=="luminosity")
M.sd_SetLuminosity(new_value)
M.ul_SetLuminosity(new_value)
else
M.vars[variable] = O.vars[variable]
@@ -230,7 +230,7 @@
for(var/obj/A in world)
if ( istype(A , O.type) )
if(variable=="luminosity")
A.sd_SetLuminosity(new_value)
A.ul_SetLuminosity(new_value)
else
A.vars[variable] = O.vars[variable]
@@ -238,7 +238,7 @@
for(var/turf/A in world)
if ( istype(A , O.type) )
if(variable=="luminosity")
A.sd_SetLuminosity(new_value)
A.ul_SetLuminosity(new_value)
else
A.vars[variable] = O.vars[variable]
@@ -247,7 +247,7 @@
for(var/mob/M in world)
if (M.type == O.type)
if(variable=="luminosity")
M.sd_SetLuminosity(new_value)
M.ul_SetLuminosity(new_value)
else
M.vars[variable] = O.vars[variable]
@@ -255,7 +255,7 @@
for(var/obj/A in world)
if (A.type == O.type)
if(variable=="luminosity")
A.sd_SetLuminosity(new_value)
A.ul_SetLuminosity(new_value)
else
A.vars[variable] = O.vars[variable]
@@ -263,7 +263,7 @@
for(var/turf/A in world)
if (A.type == O.type)
if(variable=="luminosity")
A.sd_SetLuminosity(new_value)
A.ul_SetLuminosity(new_value)
else
A.vars[variable] = O.vars[variable]
+1 -1
View File
@@ -531,7 +531,7 @@ var/list/forbidden_varedit_object_types = list(
if(variable=="luminosity")
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
if(var_new == null) return
O.sd_SetLuminosity(var_new)
O.ul_SetLuminosity(var_new)
else
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
if(var_new==null) return
+2 -2
View File
@@ -199,8 +199,8 @@
if(old_icon) W.icon_state = old_icon
*/
W.opacity = 1
W.sd_SetOpacity(0)
W.sd_LumReset()
W.ul_SetOpacity(0)
W.ul_Recalculate()
W.levelupdate()
return W
+4 -3
View File
@@ -125,8 +125,8 @@
G.process()
if(isturf(loc) && rand(1,1000) == 1) //0.1% chance of playing a scary sound to someone who's in complete darkness
var/turf/currentTurf = loc
if(!currentTurf.sd_lumcount)
var/turf/currentTurf = get_turf(src)
if(!max(currentTurf.ul_GetRed(), currentTurf.ul_GetGreen(), currentTurf.ul_GetBlue()))
playsound_local(src,pick(scarySounds),50, 1, -1)
src.moved_recently = max(0, moved_recently-1)
@@ -825,7 +825,8 @@
if(mutantrace == "plant") //couldn't think of a better place to place it, since it handles nutrition -- Urist
var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing
if(istype(loc,/turf)) //else, there's considered to be no light
light_amount = min(10,loc:sd_lumcount) - 5 //hardcapped so it's not abused by having a ton of flashlights
var/turf/currentTurf = get_turf(src)
light_amount = min(10,max(currentTurf.ul_GetRed(), currentTurf.ul_GetGreen(), currentTurf.ul_GetBlue())) - 5 //hardcapped so it's not abused by having a ton of flashlights
if(nutrition < 500) //so they can't store nutrition to survive without light forever
nutrition += light_amount
if(light_amount > 0) //if there's enough light, heal
+1 -3
View File
@@ -673,9 +673,7 @@
return health
/mob/proc/UpdateLuminosity()
if(total_luminosity == last_luminosity) return 0//nothing to do here
last_luminosity = total_luminosity
sd_SetLuminosity(min(total_luminosity,7))//Current hardcode max at 7, should likely be a const somewhere else
ul_SetLuminosity(LuminosityRed, LuminosityGreen, LuminosityBlue)//Current hardcode max at 7, should likely be a const somewhere else
return 1
/mob/MouseDrop(mob/M as mob)
+2 -2
View File
@@ -55,8 +55,8 @@
var/obj/screen/gun/run/gun_run_icon = null
var/obj/screen/gun/mode/gun_setting_icon = null
var/total_luminosity = 0 //This controls luminosity for mobs, when you pick up lights and such this is edited. If you want the mob to use lights it must update its lum in its life proc or such. Note clamp this value around 7 or such to prevent massive light lag.
var/last_luminosity = 0
// var/total_luminosity = 0 //This controls luminosity for mobs, when you pick up lights and such this is edited. If you want the mob to use lights it must update its lum in its life proc or such. Note clamp this value around 7 or such to prevent massive light lag.
// var/last_luminosity = 0
/*A bunch of this stuff really needs to go under their own defines instead of being globally attached to mob.
A variable should only be globally attached to turfs/objects/whatever, when it is in fact needed as such.
+2 -2
View File
@@ -104,7 +104,7 @@
emote_hear = list("barks", "woofs", "yaps","pants")
emote_see = list("shakes its head", "shivers")
desc = "It's a corgi."
src.sd_SetLuminosity(0)
src.ul_SetLuminosity(0)
inventory_head.loc = src.loc
inventory_head = null
else
@@ -239,7 +239,7 @@
name = "Rudolph the Red-Nosed Corgi"
emote_hear = list("barks christmas songs", "yaps")
desc = "He has a very shiny nose."
src.sd_SetLuminosity(6)
src.ul_SetLuminosity(6)
if(/obj/item/clothing/head/cargosoft)
name = "Corgi Tech [real_name]"
speak = list("Needs a stamp!", "Request DENIED!", "Fill these out in triplicate!")
+6 -6
View File
@@ -83,12 +83,12 @@
var/area/A = src.loc.loc
brightness = A.area_lights_luminosity
else
brightness = rand(6,9)
if(prob(10))
brightness = rand(5,7)
if(prob(5))
broken(1)
if("bulb")
brightness = 3
if(prob(25))
brightness = rand(4,5)
if(prob(15))
broken(1)
spawn(1)
update()
@@ -123,7 +123,7 @@
var/oldlum = luminosity
//luminosity = on * brightness
sd_SetLuminosity(on * brightness) // *DAL*
ul_SetLuminosity(on * brightness, on * brightness, ( fitting != "bulb" ? on * brightness : on ) ) // *DAL*
// if the state changed, inc the switching counter
if(oldlum != luminosity)
@@ -137,7 +137,7 @@
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
on = 0
sd_SetLuminosity(0)
ul_SetLuminosity(0)
active_power_usage = (luminosity * 20)
if(on != on_gs)
on_gs = on
+21 -21
View File
@@ -1,23 +1,23 @@
/* Overview of sd_DynamicAreaLighting as modified for SS13
*
*
* Use sd_SetLuminosity(value) to change the luminosity of an atom
* Use ul_SetLuminosity(value) to change the luminosity of an atom
* rather than setting the luminosity var directly.
* Avoid having luminous objects at compile-time since this can mess up
* the lighting system during map load. Instead use sd_SetLuminosity() in
* the lighting system during map load. Instead use ul_SetLuminosity() in
* the atom's New() proc after a small spawn delay.
*
* Use sd_SetOpacity(value) to change the opacity of an atom (e.g. doors)
* Use ul_SetOpacity(value) to change the opacity of an atom (e.g. doors)
* rather than setting the opacity var directly. This ensures that lighting
* will be blocked/unblocked as necessary.
*
* If creating a new opaque atom (e.g. a wall) at runtime, create the atom,
* set its opacity var to zero, then perform sd_SetOpacity(1)
* set its opacity var to zero, then perform ul_SetOpacity(1)
* e.g.:
*
* var/obj/block/B = new(loc)
* B.opacity = 0
* B.sd_SetOpacity(1)
* B.ul_SetOpacity(1)
*
*
* The library creates multiple instances of each /area to split a mapped area
@@ -52,13 +52,13 @@ Using sd_DynamicAreaLighting
1) Luminosity changes at run time.
If your program makes changes in luminosity while it is
running, you need to use sd_SetLuminosity(new_luminosity)
running, you need to use ul_SetLuminosity(new_luminosity)
so the library can remove the effect of the old luminosity
and apply the new effect.
2) Opacity changes at run time.
As with luminosity changes, you need to use
sd_SetOpacity(new_opacity) if your program changes the opacity
ul_SetOpacity(new_opacity) if your program changes the opacity
of atoms at runtime.
3) New atoms that change the opacity of a location.
@@ -67,17 +67,17 @@ Using sd_DynamicAreaLighting
sd_StripLocalLum() to strip the luminosity effect of
anything shining on that space, create the new atom, then
use sd_ApplyLocalLum() to reapply the luminosity effect.
Examine the sd_SetOpacity() proc for an example of the
Examine the ul_SetOpacity() proc for an example of the
procedure.
All areas will automatically use the sd_DynamicAreaLighting
library when it is included in your project. You may disable
lighting effect in an area by specifically setting the area's
sd_lighting var to 0. For example:
ul_Lighting var to 0. For example:
area/always_lit
luminosity = 1
sd_lighting = 0
ul_Lighting = 0
This library chops areas into 5 separate areas of differing
light effect, so you may want to modify area Enter(), Exit(),
@@ -253,17 +253,17 @@ All atoms have the following procs:
IMPORTANT! Each sd_StripLocalLum() call should have a matching
sd_ApplyLocalLum() to restore the local effect.
sd_SetLuminosity(new_luminosity as num)
ul_SetLuminosity(new_luminosity as num)
Sets the atom's luminosity, making adjustments to the
sd_lumcount of local turfs.
sd_SetOpacity(new_opacity as num)
ul_SetOpacity(new_opacity as num)
Sets the atom's opacity, making adjustments to the
sd_lumcount of local turfs.
Areas have one additional proc and 4 variables:
var
sd_lighting
ul_Lighting
Turn this flag off to prevent sd_DynamicAreaLighting
from effecting this area.
DEFAULT VALUE: 1 (allow dynamic lighting)
@@ -304,7 +304,7 @@ Turfs have these additional procs and vars:
Places the turf in the appropriate sd_dark area,
depending on its brightness (sd_lumcount).
sd_LumReset()
ul_Recalculate()
Resets a turf's lumcount by stripping local luminosity,
zeroing the lumcount, then reapplying local luminosity.
@@ -436,7 +436,7 @@ atom
return affected
sd_SetLuminosity(new_luminosity as num)
ul_SetLuminosity(new_luminosity as num)
/* This proc should be called everytime you want to change the
luminosity of an atom instead of setting it directly.
@@ -448,7 +448,7 @@ atom
sd_ApplyLum()
sd_SetOpacity(new_opacity as num)
ul_SetOpacity(new_opacity as num)
/* if(opacity != new_opacity)
var/list/affected = sd_StripLocalLum()
opacity = new_opacity
@@ -567,7 +567,7 @@ turf
sd_lumcount = 0 // the brightness of the turf
proc
sd_LumReset()
ul_Recalculate()
/* Clear local lum, reset this turf's sd_lumcount, and
re-apply local lum*/
var/list/affected = sd_StripLocalLum()
@@ -580,7 +580,7 @@ turf
sd_LumUpdate()
set background = 1
var/area/Loc = loc
if(!istype(Loc) || !Loc.sd_lighting) return
if(!istype(Loc) || !Loc.ul_Lighting) return
// change the turf's area depending on its brightness
// restrict light to valid levels
@@ -685,7 +685,7 @@ area
var
/* Turn this flag off to prevent sd_DynamicAreaLighting from affecting
this area */
sd_lighting = 1
ul_Lighting = 1
/* This var determines if an area is outside (affected by sunlight) or
not. */
@@ -718,7 +718,7 @@ area
..()
if(!tag) tag = "[type]"
spawn(1) // wait a tick
if(sd_lighting)
if(ul_Lighting)
// see if this area was created by the library
if(!findtext(tag, "sd_L"))
/* show the dark overlay so areas outside of luminous regions
@@ -731,7 +731,7 @@ area
if(!tag) tag = "[type]"
spawn(1) // wait a tick
if(sd_lighting)
if(ul_Lighting)
// see if this area was created by the library
if(!sd_created)
/* show the dark overlay so areas outside of luminous regions
@@ -14,7 +14,7 @@
New()
spawn(1)
src.sd_SetLuminosity(5)
src.ul_SetLuminosity(5)
Del()