Fixes to lighting

-Fixed #2005 (for sure!)
-Fixed the stacking of brightness. Now the most bright item turned ON will be the one where the user gets its luminosity of.
-Cleaned the code a bit. Now only one var controls the on/off switch of light, and another holds the value of brightness when on.
This commit is contained in:
SweeperM
2012-11-29 21:08:58 +00:00
parent c0a5b83623
commit b8a12b0b52
15 changed files with 271 additions and 122 deletions
@@ -294,6 +294,66 @@ area
//show the dark overlay so areas, not yet in a lighting subarea, won't be bright as day and look silly.
SetLightLevel(4)
atom
var/light_on = 0 //Am I emitting light?
var/brightness_on = 0 //Luminosity when the above: light_on = 1
//Called when turning off or dropping a flashlight for ex.
//It checks the users slots for another source of light, and return the appropriate brightness. 0 if no other source is found
proc/search_light(mob/M, obj/item/W as obj)
var/list/slots
var/obj/item/I
var brightness = 0 //the new brightness to be returned
if (istype(M, /mob/living/carbon/human))
var/mob/living/carbon/human/H = M
slots = list (
"l_hand",
"r_hand",
"belt",
"head",
"l_pocket",
"r_pocket",
"s_store")
for (var/slot in slots)
switch(slot)
if("belt")
I = H.belt
if("head")
I = H.head
if("l_hand")
I = H.l_hand
if("r_hand")
I = H.r_hand
if("l_pocket")
I = H.l_store
if("r_pocket")
I = H.r_store
if("s_store")
I = H.s_store
if (I)
if ((I.light_on) && (I != W)) //an item emitting light other than itself
if (I.brightness_on > brightness)
brightness = I.brightness_on
else if (istype(M, /mob/living/carbon/monkey))
slots = list (
"l_hand",
"r_hand")
for (var/slot in slots)
switch(slot)
if("l_hand")
I = M.l_hand
if("r_hand")
I = M.r_hand
if (I)
if ((I.light_on) && (I != W)) //an item emitting light other than itself
if (I.brightness_on > brightness)
brightness = I.brightness_on
return brightness
#undef LIGHTING_MAX_LUMINOSITY
#undef LIGHTING_MAX_LUMINOSITY_MOB