new object-based lighting system

Signed-off-by: Mloc <colmohici@gmail.com>
This commit is contained in:
Mloc
2015-05-10 20:54:25 +01:00
parent 733c6a4fb5
commit 16d50c645d
90 changed files with 790 additions and 1004 deletions
+15 -15
View File
@@ -208,8 +208,8 @@
O.vars[variable]) as num|null
if(new_value == null) return
if(variable=="luminosity")
O.SetLuminosity(new_value)
if(variable=="light_range")
O.set_light(new_value)
else
O.vars[variable] = new_value
@@ -217,24 +217,24 @@
if(istype(O, /mob))
for(var/mob/M in mob_list)
if ( istype(M , O.type) )
if(variable=="luminosity")
M.SetLuminosity(new_value)
if(variable=="light_range")
M.set_light(new_value)
else
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
if ( istype(A , O.type) )
if(variable=="luminosity")
A.SetLuminosity(new_value)
if(variable=="light_range")
A.set_light(new_value)
else
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
if ( istype(A , O.type) )
if(variable=="luminosity")
A.SetLuminosity(new_value)
if(variable=="light_range")
A.set_light(new_value)
else
A.vars[variable] = O.vars[variable]
@@ -242,24 +242,24 @@
if(istype(O, /mob))
for(var/mob/M in mob_list)
if (M.type == O.type)
if(variable=="luminosity")
M.SetLuminosity(new_value)
if(variable=="light_range")
M.set_light(new_value)
else
M.vars[variable] = O.vars[variable]
else if(istype(O, /obj))
for(var/obj/A in world)
if (A.type == O.type)
if(variable=="luminosity")
A.SetLuminosity(new_value)
if(variable=="light_range")
A.set_light(new_value)
else
A.vars[variable] = O.vars[variable]
else if(istype(O, /turf))
for(var/turf/A in world)
if (A.type == O.type)
if(variable=="luminosity")
A.SetLuminosity(new_value)
if(variable=="light_range")
A.set_light(new_value)
else
A.vars[variable] = O.vars[variable]
@@ -372,4 +372,4 @@
A.vars[variable] = O.vars[variable]
log_admin("[key_name(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]")
message_admins("[key_name_admin(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]", 1)
message_admins("[key_name_admin(src)] mass modified [original_name]'s [variable] to [O.vars[variable]]", 1)
+2 -2
View File
@@ -455,10 +455,10 @@ var/list/forbidden_varedit_object_types = list(
O.vars[variable] = var_new
if("num")
if(variable=="luminosity")
if(variable=="light_range")
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
if(var_new == null) return
O.SetLuminosity(var_new)
O.set_light(var_new)
else if(variable=="stat")
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
if(var_new == null) return
+4 -34
View File
@@ -264,37 +264,19 @@ BLIND // can't see anything
return
on = !on
user << "You [on ? "enable" : "disable"] the helmet light."
update_light(user)
update_flashlight(user)
else
return ..(user)
/obj/item/clothing/head/proc/update_light(var/mob/user = null)
/obj/item/clothing/head/proc/update_flashlight(var/mob/user = null)
if(on && !light_applied)
if(loc == user)
user.SetLuminosity(user.luminosity + brightness_on)
SetLuminosity(brightness_on)
set_light(brightness_on)
light_applied = 1
else if(!on && light_applied)
if(loc == user)
user.SetLuminosity(user.luminosity - brightness_on)
SetLuminosity(0)
set_light(0)
light_applied = 0
update_icon(user)
/obj/item/clothing/head/equipped(mob/user)
..()
spawn(1)
if(on && loc == user && !light_applied)
user.SetLuminosity(user.luminosity + brightness_on)
light_applied = 1
/obj/item/clothing/head/dropped(mob/user)
..()
spawn(1)
if(on && loc != user && light_applied)
user.SetLuminosity(user.luminosity - brightness_on)
light_applied = 0
/obj/item/clothing/head/update_icon(var/mob/user)
overlays.Cut()
@@ -308,18 +290,6 @@ BLIND // can't see anything
var/mob/living/carbon/human/H = user
H.update_inv_head()
/obj/item/clothing/head/equipped(mob/user)
..()
update_light(user)
/obj/item/clothing/head/pickup(mob/user)
..()
update_light(user)
/obj/item/clothing/head/dropped(mob/user)
..()
update_light(user)
/obj/item/clothing/head/update_clothing_icon()
if (ismob(src.loc))
var/mob/M = src.loc
+1 -1
View File
@@ -400,7 +400,7 @@
/mob/living/simple_animal/hostile/carp/holodeck/New()
..()
SetLuminosity(2) //hologram lighting
set_light(2) //hologram lighting
/mob/living/simple_animal/hostile/carp/holodeck/proc/set_safety(var/safe)
if (safe)
-9
View File
@@ -341,9 +341,6 @@
..()
if(!seed)
return
if(seed.get_trait(TRAIT_BIOLUM))
user.SetLuminosity(user.luminosity + seed.get_trait(TRAIT_BIOLUM))
SetLuminosity(0)
if(seed.get_trait(TRAIT_STINGS))
var/mob/living/carbon/human/H = user
if(istype(H) && H.gloves)
@@ -354,12 +351,6 @@
seed.do_thorns(H,src)
seed.do_sting(H,src,pick("r_hand","l_hand"))
/obj/item/weapon/reagent_containers/food/snacks/grown/dropped(mob/user)
..()
if(seed && seed.get_trait(TRAIT_BIOLUM))
user.SetLuminosity(user.luminosity - seed.get_trait(TRAIT_BIOLUM))
SetLuminosity(seed.get_trait(TRAIT_BIOLUM))
// Predefined types for placing on the map.
/obj/item/weapon/reagent_containers/food/snacks/grown/mushroom/libertycap
+11 -10
View File
@@ -165,9 +165,10 @@
if(!istype(splat)) // Plants handle their own stuff.
splat.name = "[thrown.name] [pick("smear","smudge","splatter")]"
if(get_trait(TRAIT_BIOLUM))
var/clr
if(get_trait(TRAIT_BIOLUM_COLOUR))
splat.l_color = get_trait(TRAIT_BIOLUM_COLOUR)
splat.SetLuminosity(get_trait(TRAIT_BIOLUM))
clr = get_trait(TRAIT_BIOLUM_COLOUR)
splat.set_light(get_trait(TRAIT_BIOLUM), l_color = clr)
if(get_trait(TRAIT_PRODUCT_COLOUR))
splat.color = get_trait(TRAIT_PRODUCT_COLOUR)
@@ -276,12 +277,11 @@
// Handle light requirements.
if(!light_supplied)
var/area/A = get_area(current_turf)
if(A)
if(A.lighting_use_dynamic)
light_supplied = max(0,min(10,current_turf.lighting_lumcount)-5)
else
light_supplied = 5
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)
else
light_supplied = 5
if(light_supplied)
if(abs(light_supplied - get_trait(TRAIT_IDEAL_LIGHT)) > get_trait(TRAIT_LIGHT_TOLERANCE))
health_change += rand(1,3) * HYDRO_SPEED_MULTIPLIER
@@ -696,9 +696,10 @@
product.desc += " On second thought, something about this one looks strange."
if(get_trait(TRAIT_BIOLUM))
var/clr
if(get_trait(TRAIT_BIOLUM_COLOUR))
product.l_color = get_trait(TRAIT_BIOLUM_COLOUR)
product.SetLuminosity(get_trait(TRAIT_BIOLUM))
clr = get_trait(TRAIT_BIOLUM_COLOUR)
product.set_light(get_trait(TRAIT_BIOLUM), l_color = clr)
//Handle spawning in living, mobile products (like dionaea).
if(istype(product,/mob/living))
@@ -145,14 +145,13 @@
color = icon_colour
// Apply colour and light from seed datum.
if(seed.get_trait(TRAIT_BIOLUM))
SetLuminosity(1+round(seed.get_trait(TRAIT_POTENCY)/20))
var/clr
if(seed.get_trait(TRAIT_BIOLUM_COLOUR))
l_color = seed.get_trait(TRAIT_BIOLUM_COLOUR)
else
l_color = null
clr = seed.get_trait(TRAIT_BIOLUM_COLOUR)
set_light(1+round(seed.get_trait(TRAIT_POTENCY)/20), l_color = clr)
return
else
SetLuminosity(0)
set_light(0)
/obj/effect/plant/proc/refresh_icon()
var/growth = min(max_growth,round(health/growth_threshold))
+6 -7
View File
@@ -350,7 +350,7 @@
usr << "There is no label to remove."
return
/obj/machinery/portable_atmospherics/hydroponics/verb/set_light()
/obj/machinery/portable_atmospherics/hydroponics/verb/setlight()
set name = "Set Light"
set category = "Object"
set src in view(1)
@@ -596,13 +596,12 @@
if(closed_system && mechanical)
light_string = "that the internal lights are set to [tray_light] lumens"
else
var/area/A = T.loc
var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T
var/light_available
if(A)
if(A.lighting_use_dynamic)
light_available = max(0,min(10,T.lighting_lumcount)-5)
else
light_available = 5
if(L)
light_available = max(0,min(10,L.lum_r + L.lum_g + L.lum_b)-5)
else
light_available = 5
light_string = "a light level of [light_available] lumens"
usr << "The tray's sensor suite is reporting [light_string] and a temperature of [environment.temperature]K."
+1 -1
View File
@@ -16,7 +16,7 @@
..()
verbs -= /obj/machinery/portable_atmospherics/hydroponics/verb/close_lid_verb
verbs -= /obj/machinery/portable_atmospherics/hydroponics/verb/remove_label
verbs -= /obj/machinery/portable_atmospherics/hydroponics/verb/set_light
verbs -= /obj/machinery/portable_atmospherics/hydroponics/verb/setlight
/obj/machinery/portable_atmospherics/hydroponics/soil/CanPass()
return 1
@@ -73,12 +73,11 @@
// Update bioluminescence.
if(seed)
if(seed.get_trait(TRAIT_BIOLUM))
SetLuminosity(round(seed.get_trait(TRAIT_POTENCY)/10))
var/clr
if(seed.get_trait(TRAIT_BIOLUM_COLOUR))
l_color = seed.get_trait(TRAIT_BIOLUM_COLOUR)
else
l_color = null
clr = seed.get_trait(TRAIT_BIOLUM_COLOUR)
set_light(round(seed.get_trait(TRAIT_POTENCY)/10), l_color = clr)
return
SetLuminosity(0)
return
set_light(0)
return
+67
View File
@@ -0,0 +1,67 @@
/*
BS12 object based lighting system
*/
/*
Changes from tg DAL:
- Lighting is done using objects instead of subareas.
- Animated transitions. (newer tg DAL has this)
- Full colours with mixing.
- Support for lights on shuttles.
- Code:
- Instead of one flat luminosity var, light is represented by 3 atom vars:
- light_range; range in tiles of the light, used for calculating falloff,
- light_power; multiplier for the brightness of lights,
- light_color; hex string representing the RGB colour of the light.
- SetLuminosity() is now set_light() and takes the three variables above.
- Variables can be left as null to not update them.
- SetOpacity() is now set_opacity().
- Areas have luminosity set to 1 permanently, no hard-lighting.
- Objects inside other objects can have lights and they properly affect the turf. (flashlights)
- area/master and area/list/related have been eviscerated since subareas aren't needed.
*/
/*
Relevant vars/procs:
atom: (lighting_atom.dm)
- var/light_range; range in tiles of the light, used for calculating falloff
- var/light_power; multiplier for the brightness of lights
- var/light_color; hex string representing the RGB colour of the light
- var/datum/light_source/light; light source datum for this atom, only present if light_range && light_power
- var/list/light_sources; light sources in contents that are shining through this object, including this object
- proc/set_light(l_range, l_power, l_color):
- Sets light_range/power/color to non-null args and calls update_light()
- proc/set_opacity(new_opacity):
- Sets opacity to new_opacity.
- If opacity has changed, call turf.reconsider_lights() to fix light occlusion
- proc/update_light():
- Updates the light var on this atom, deleting or creating as needed and calling .update()
turf: (lighting_turf.dm)
- var/list/affecting_lights; list of light sources that are shining onto this turf
- proc/reconsider_lights():
- Force all light sources shining onto this turf to update
- proc/lighting_clear_overlays():
- Delete (manual GC) all light overlays on this turf, used when changing turf to space
- proc/lighting_build_overlays():
- Create lighting overlays for this turf
atom/movable/lighting_overlay: (lighting_overlay.dm)
- var/lum_r, var/lum_g, var/lum_b; lumcounts of each colour
- var/needs_update; set on update_lumcount, checked by lighting process
- var/xoffset, var/yoffset; (only present when using sub-tile overlays) fractional offset of this overlay in the tile
- proc/update_lumcount(delta_r, delta_g, delta_b):
- Change the lumcount vars and queue the overlay for update
- proc/update_overlay()
- Called by the lighting process to update the color of the overlay
*/
+10
View File
@@ -0,0 +1,10 @@
#define LIGHTING_INTERVAL 5 // frequency, in 1/10ths of a second, of the lighting process
#define LIGHTING_FALLOFF 1 // type of falloff to use for lighting; 1 for circular, 2 for square
#define LIGHTING_LAMBERTIAN 1 // use lambertian shading for light sources
#define LIGHTING_HEIGHT 1 // height off the ground of light sources on the pseudo-z-axis, you should probably leave this alone
#define LIGHTING_TRANSITIONS 1 // smooth, animated transitions, similar to /tg/station
#define LIGHTING_RESOLUTION 1 // resolution of the lighting overlays, powers of 2 only, max of 32
#define LIGHTING_LAYER 10 // drawing layer for lighting overlays
#define LIGHTING_ICON 'icons/effects/lighting_overlay.dmi' // icon used for lighting shading effects
+169
View File
@@ -0,0 +1,169 @@
/datum/light_source
var/atom/top_atom
var/atom/source_atom
var/turf/source_turf
var/light_power
var/light_range
var/light_color // string, decomposed by parse_light_color()
var/lum_r
var/lum_g
var/lum_b
var/list/effect_r
var/list/effect_g
var/list/effect_b
var/list/effect_turf
var/applied
var/needs_update
var/destroyed
var/force_update
/datum/light_source/New(atom/owner, atom/top)
source_atom = owner
if(!source_atom.light_sources) source_atom.light_sources = list()
source_atom.light_sources += src
top_atom = top
if(top_atom != source_atom)
if(!top.light_sources) top.light_sources = list()
top_atom.light_sources += src
source_turf = top_atom
light_power = source_atom.light_power
light_range = source_atom.light_range
light_color = source_atom.light_color
parse_light_color()
effect_r = list()
effect_g = list()
effect_b = list()
effect_turf = list()
update()
return ..()
/datum/light_source/proc/destroy()
destroyed = 1
force_update()
if(source_atom) source_atom.light_sources -= src
if(top_atom) top_atom.light_sources -= src
/datum/light_source/proc/update(atom/new_top_atom)
if(new_top_atom && new_top_atom != top_atom)
if(top_atom != source_atom) top_atom.light_sources -= src
top_atom = new_top_atom
if(top_atom != source_atom)
if(!top_atom.light_sources) top_atom.light_sources = list()
top_atom.light_sources += src
lighting_update_lights += src
needs_update = 1
/datum/light_source/proc/force_update()
needs_update = 1
force_update = 1
lighting_update_lights += src
/datum/light_source/proc/check()
if(!source_atom)
destroy()
return 1
if(!top_atom)
top_atom = source_atom
. = 1
if(istype(top_atom, /turf))
if(source_turf != top_atom)
source_turf = top_atom
. = 1
else if(top_atom.loc != source_turf)
source_turf = top_atom.loc
. = 1
if(source_atom.light_power != light_power)
light_power = source_atom.light_power
. = 1
if(source_atom.light_range != light_range)
light_range = source_atom.light_range
. = 1
if(source_atom.light_color != light_color)
light_color = source_atom.light_color
parse_light_color()
. = 1
if(light_range && light_power && !applied)
. = 1
/datum/light_source/proc/parse_light_color()
if(light_color)
lum_r = GetRedPart(light_color) / 255
lum_g = GetGreenPart(light_color) / 255
lum_b = GetBluePart(light_color) / 255
else
lum_r = 1
lum_g = 1
lum_b = 1
/datum/light_source/proc/falloff(atom/movable/lighting_overlay/O)
#if LIGHTING_FALLOFF == 1 // circular
#if LIGHTING_RESOLUTION == 1
. = (O.x - source_turf.x)**2 + (O.y - source_turf.y)**2 + LIGHTING_HEIGHT
#else
. = (O.x - source_turf.x + O.xoffset)**2 + (O.y - source_turf.y + O.yoffset)**2 + LIGHTING_HEIGHT
#endif
#if LIGHTING_LAMBERTIAN == 1
. = CLAMP01((1 - CLAMP01(sqrt(.) / light_range)) * (1 / (sqrt(. + 1))))
#else
. = 1 - CLAMP01(sqrt(.) / light_range)
#endif
#elif LIGHTING_FALLOFF == 2 // square
#if LIGHTING_RESOLUTION == 1
. = abs(O.x - source_turf.x) + abs(O.y - source_turf.y) + LIGHTING_HEIGHT
#else
. = abs(O.x - source_turf.x + O.xoffset) + abs(O.y - source_turf.y + O.yoffset) + LIGHTING_HEIGHT
#endif
#if LIGHTING_LAMBERTIAN == 1
. = CLAMP01((1 - CLAMP01(. / light_range)) * (1 / (sqrt(.)**2 + )))
#else
. = 1 - CLAMP01(. / light_range)
#endif
#endif
/datum/light_source/proc/apply_lum()
applied = 1
if(istype(source_turf))
for(var/atom/movable/lighting_overlay/O in view(light_range, source_turf))
var/strength = light_power * falloff(O)
effect_r[O] = lum_r * strength
effect_g[O] = lum_g * strength
effect_b[O] = lum_b * strength
O.update_lumcount(lum_r * strength, lum_g * strength, lum_b * strength)
for(var/turf/T in view(light_range, source_turf))
if(!T.affecting_lights) T.affecting_lights = list()
T.affecting_lights += src
effect_turf += T
/datum/light_source/proc/remove_lum()
applied = 0
for(var/atom/movable/lighting_overlay/O in effect_r)
O.update_lumcount(-effect_r[O], -effect_g[O], -effect_b[O])
for(var/turf/T in effect_turf)
if(T.affecting_lights) T.affecting_lights -= src
effect_r.Cut()
effect_g.Cut()
effect_b.Cut()
effect_turf.Cut()
+81
View File
@@ -0,0 +1,81 @@
/atom
var/light_power = 1 // intensity of the light
var/light_range = 0 // range in tiles of the light
var/light_color // RGB string representing the colour of the light
var/datum/light_source/light
var/list/light_sources
/atom/proc/set_light(l_range, l_power, l_color)
if(l_power != null) light_power = l_power
if(l_range != null) light_range = l_range
if(l_color != null) light_color = l_color
update_light()
/atom/proc/update_light()
if(!light_power || !light_range)
if(light)
light.destroy()
light = null
else
if(!istype(loc, /atom/movable))
. = src
else
. = loc
if(light)
light.update(.)
else
light = new /datum/light_source(src, .)
/atom/New()
. = ..()
if(light_power && light_range)
update_light()
/atom/Destroy()
if(light)
light.destroy()
light = null
return ..()
/atom/movable/Destroy()
var/turf/T = loc
if(opacity && istype(T))
T.reconsider_lights()
return ..()
/atom/movable/Move()
var/turf/old_loc = loc
. = ..()
if(loc != old_loc)
for(var/datum/light_source/L in light_sources)
L.source_atom.update_light()
var/turf/new_loc = loc
if(istype(old_loc) && opacity)
old_loc.reconsider_lights()
if(istype(new_loc) && opacity)
new_loc.reconsider_lights()
/atom/proc/set_opacity(new_opacity)
var/old_opacity = opacity
opacity = new_opacity
var/turf/T = loc
if(old_opacity != new_opacity && istype(T))
T.reconsider_lights()
/obj/item/equipped()
. = ..()
update_light()
/obj/item/pickup()
. = ..()
update_light()
/obj/item/dropped()
. = ..()
update_light()
+48
View File
@@ -0,0 +1,48 @@
/atom/movable/lighting_overlay
name = ""
mouse_opacity = 0
simulated = 0
anchored = 1
icon = LIGHTING_ICON
layer = LIGHTING_LAYER
invisibility = INVISIBILITY_LIGHTING
blend_mode = BLEND_MULTIPLY
color = "#000000"
var/lum_r
var/lum_g
var/lum_b
#if LIGHTING_RESOLUTION != 1
var/xoffset
var/yoffset
#endif
var/needs_update
/atom/movable/lighting_overlay/New()
. = ..()
verbs.Cut()
/atom/movable/lighting_overlay/proc/update_lumcount(delta_r, delta_g, delta_b)
lum_r += delta_r
lum_g += delta_g
lum_b += delta_b
needs_update = 1
lighting_update_overlays += src
/atom/movable/lighting_overlay/proc/update_overlay()
var/mx = max(lum_r, lum_g, lum_b)
. = 1 // factor
if(mx > 1)
. = 1/mx
#if LIGHTING_TRANSITIONS == 1
animate(src,
color = rgb(lum_r * 255 * ., lum_g * 255 * ., lum_b * 255 * .),
LIGHTING_INTERVAL - 1
)
#else
color = rgb(lum_r * 255 * ., lum_g * 255 * ., lum_b * 255 * .)
#endif
+29
View File
@@ -0,0 +1,29 @@
/datum/controller/process/lighting/setup()
name = "lighting"
schedule_interval = LIGHTING_INTERVAL
create_lighting_overlays()
/datum/controller/process/lighting/doWork()
for(var/datum/light_source/L in lighting_update_lights)
if(L.needs_update)
if(L.destroyed)
L.remove_lum()
else if(L.check() || L.force_update)
L.remove_lum()
L.apply_lum()
L.force_update = 0
L.needs_update = 0
scheck()
lighting_update_lights.Cut()
for(var/atom/movable/lighting_overlay/O in lighting_update_overlays)
if(O.needs_update)
O.update_overlay()
O.needs_update = 0
scheck()
lighting_update_overlays.Cut()
+47
View File
@@ -0,0 +1,47 @@
/var/list/lighting_update_lights = list()
/var/list/lighting_update_overlays = list()
/area/var/lighting_use_dynamic = 1
// duplicates lots of code, but this proc needs to be as fast as possible.
/proc/create_lighting_overlays(zlevel = 0)
var/state = "light[LIGHTING_RESOLUTION]"
var/area/A
if(zlevel == 0) // populate all zlevels
for(var/turf/T in world)
if(T.dynamic_lighting)
A = T.loc
if(A.lighting_use_dynamic)
#if LIGHTING_RESOLUTION == 1
var/atom/movable/lighting_overlay/O = new(T)
O.icon_state = state
#else
for(var/i = 0; i < LIGHTING_RESOLUTION; i++)
for(var/j = 0; j < LIGHTING_RESOLUTION; j++)
var/atom/movable/lighting_overlay/O = new(T)
O.pixel_x = i * (32 / LIGHTING_RESOLUTION)
O.pixel_y = j * (32 / LIGHTING_RESOLUTION)
O.xoffset = (((2*i + 1) / (LIGHTING_RESOLUTION * 2)) - 0.5)
O.yoffset = (((2*j + 1) / (LIGHTING_RESOLUTION * 2)) - 0.5)
O.icon_state = state
#endif
else
for(var/x = 1; x <= world.maxx; x++)
for(var/y = 1; y <= world.maxy; y++)
var/turf/T = locate(x, y, zlevel)
if(T.dynamic_lighting)
A = T.loc
if(A.lighting_use_dynamic)
#if LIGHTING_RESOLUTION == 1
var/atom/movable/lighting_overlay/O = new(T)
O.icon_state = state
#else
for(var/i = 0; i < LIGHTING_RESOLUTION; i++)
for(var/j = 0; j < LIGHTING_RESOLUTION; j++)
var/atom/movable/lighting_overlay/O = new(T)
O.pixel_x = i * (32 / LIGHTING_RESOLUTION)
O.pixel_y = j * (32 / LIGHTING_RESOLUTION)
O.xoffset = (((2*i + 1) / (LIGHTING_RESOLUTION * 2)) - 0.5)
O.yoffset = (((2*j + 1) / (LIGHTING_RESOLUTION * 2)) - 0.5)
O.icon_state = state
#endif
+29
View File
@@ -0,0 +1,29 @@
/turf
var/list/affecting_lights
/turf/proc/reconsider_lights()
for(var/datum/light_source/L in affecting_lights)
L.force_update()
/turf/proc/lighting_clear_overlays()
for(var/atom/movable/lighting_overlay/L in src)
L.loc = null
/turf/proc/lighting_build_overlays()
if(!locate(/atom/movable/lighting_overlay) in src)
var/state = "light[LIGHTING_RESOLUTION]"
var/area/A = loc
if(A.lighting_use_dynamic)
#if LIGHTING_RESOLUTION == 1
var/atom/movable/lighting_overlay/O = new(src)
O.icon_state = state
#else
for(var/i = 0; i < LIGHTING_RESOLUTION; i++)
for(var/j = 0; j < LIGHTING_RESOLUTION; j++)
var/atom/movable/lighting_overlay/O = new(src)
O.pixel_x = i * (32 / LIGHTING_RESOLUTION)
O.pixel_y = j * (32 / LIGHTING_RESOLUTION)
O.xoffset = (((2*i + 1) / (LIGHTING_RESOLUTION * 2)) - 0.5)
O.yoffset = (((2*j + 1) / (LIGHTING_RESOLUTION * 2)) - 0.5)
O.icon_state = state
#endif
+10
View File
@@ -0,0 +1,10 @@
#undef LIGHTING_INTERVAL
#undef LIGHTING_FALLOFF
#undef LIGHTING_LAMBERTIAN
#undef LIGHTING_HEIGHT
#undef LIGHTING_TRANSITIONS
#undef LIGHTING_RESOLUTION
#undef LIGHTING_LAYER
#undef LIGHTING_ICON
+2 -2
View File
@@ -104,7 +104,7 @@
icon_state = "furnace"
density = 1
anchored = 1
luminosity = 3
light_range = 3
var/obj/machinery/mineral/input = null
var/obj/machinery/mineral/output = null
var/obj/machinery/mineral/console = null
@@ -231,4 +231,4 @@
else
continue
console.updateUsrDialog()
console.updateUsrDialog()
+1 -1
View File
@@ -5,7 +5,7 @@
name = "Light-emtter"
anchored = 1
unacidable = 1
luminosity = 8
light_range = 8
/**********************Miner Lockers**************************/
@@ -28,7 +28,7 @@
if(src.can_use())
cameranet.addCamera(src)
else
src.SetLuminosity(0)
src.set_light(0)
cameranet.removeCamera(src)
/obj/machinery/camera/New()
+3 -3
View File
@@ -110,14 +110,14 @@
if(stat)
return 0
on = 1
SetLuminosity(light_strength)
set_light(light_strength)
update_icons()
return 1
/mob/living/bot/proc/turn_off()
on = 0
SetLuminosity(0)
set_light(0)
update_icons()
/mob/living/bot/proc/explode()
qdel(src)
qdel(src)
@@ -4,10 +4,12 @@
var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing
if(isturf(loc)) //else, there's considered to be no light
var/turf/T = loc
var/area/A = T.loc
if(A)
if(A.lighting_use_dynamic) light_amount = min(10,T.lighting_lumcount) - 5 //hardcapped so it's not abused by having a ton of flashlights
else light_amount = 5
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
else
light_amount = 5
nutrition += light_amount
+13 -10
View File
@@ -877,10 +877,11 @@
var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing
if(isturf(loc)) //else, there's considered to be no light
var/turf/T = loc
var/area/A = T.loc
if(A)
if(A.lighting_use_dynamic) light_amount = min(10,T.lighting_lumcount) - 5 //hardcapped so it's not abused by having a ton of flashlights
else light_amount = 5
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
else
light_amount = 5
nutrition += light_amount
traumatic_shock -= light_amount
@@ -898,10 +899,11 @@
var/light_amount = 0
if(isturf(loc))
var/turf/T = loc
var/area/A = T.loc
if(A)
if(A.lighting_use_dynamic) light_amount = T.lighting_lumcount
else light_amount = 10
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
else
light_amount = 10
if(light_amount > species.light_dam) //if there's enough light, start dying
take_overall_damage(1,1)
else //heal in the dark
@@ -1418,8 +1420,9 @@
//0.1% chance of playing a scary sound to someone who's in complete darkness
if(isturf(loc) && rand(1,1000) == 1)
var/turf/currentTurf = loc
if(!currentTurf.lighting_lumcount)
var/turf/T = loc
var/atom/movable/lighting_overlay/L = locate(/atom/movable/lighting_overlay) in T
if(L && L.lum_r + L.lum_g + L.lum_b == 0)
playsound_local(src,pick(scarySounds),50, 1, -1)
proc/handle_stomach()
+7 -7
View File
@@ -139,7 +139,7 @@
var/obj/item/I = O
mass = I.w_class/THROWNOBJ_KNOCKBACK_DIVISOR
var/momentum = speed*mass
if(O.throw_source && momentum >= THROWNOBJ_KNOCKBACK_SPEED)
var/dir = get_dir(O.throw_source, src)
@@ -200,14 +200,14 @@
/mob/living/proc/IgniteMob()
if(fire_stacks > 0 && !on_fire)
on_fire = 1
src.AddLuminosity(3)
set_light(light_range + 3)
update_fire()
/mob/living/proc/ExtinguishMob()
if(on_fire)
on_fire = 0
fire_stacks = 0
src.AddLuminosity(-3)
set_light(max(0, light_range - 3))
update_fire()
/mob/living/proc/update_fire()
@@ -219,18 +219,18 @@
/mob/living/proc/handle_fire()
if(fire_stacks < 0)
fire_stacks = max(0, fire_stacks++) //If we've doused ourselves in water to avoid fire, dry off slowly
if(!on_fire)
return 1
else if(fire_stacks <= 0)
ExtinguishMob() //Fire's been put out.
return 1
var/datum/gas_mixture/G = loc.return_air() // Check if we're standing in an oxygenless environment
if(G.gas["oxygen"] < 1)
ExtinguishMob() //If there's no oxygen in the tile we're on, put out the fire
return 1
var/turf/location = get_turf(src)
location.hotspot_expose(fire_burn_temperature(), 50, 1)
@@ -242,6 +242,6 @@
/mob/living/proc/fire_burn_temperature()
if (fire_stacks <= 0)
return 0
//Scale quadratically so that single digit numbers of fire stacks don't burn ridiculously hot.
return round(FIRESUIT_MAX_HEAT_PROTECTION_TEMPERATURE*(fire_stacks/FIRE_MAX_FIRESUIT_STACKS)**2)
+8 -8
View File
@@ -468,13 +468,13 @@ var/list/ai_verbs_default = list(
/mob/living/silicon/ai/reset_view(atom/A)
if(camera)
camera.SetLuminosity(0)
camera.set_light(0)
if(istype(A,/obj/machinery/camera))
camera = A
..()
if(istype(A,/obj/machinery/camera))
if(camera_light_on) A.SetLuminosity(AI_CAMERA_LUMINOSITY)
else A.SetLuminosity(0)
if(camera_light_on) A.set_light(AI_CAMERA_LUMINOSITY)
else A.set_light(0)
/mob/living/silicon/ai/proc/switchCamera(var/obj/machinery/camera/C)
@@ -612,7 +612,7 @@ var/list/ai_verbs_default = list(
src << "Camera lights [camera_light_on ? "activated" : "deactivated"]."
if(!camera_light_on)
if(camera)
camera.SetLuminosity(0)
camera.set_light(0)
camera = null
else
lightNearbyCamera()
@@ -627,20 +627,20 @@ var/list/ai_verbs_default = list(
if(src.camera)
var/obj/machinery/camera/camera = near_range_camera(src.eyeobj)
if(camera && src.camera != camera)
src.camera.SetLuminosity(0)
src.camera.set_light(0)
if(!camera.light_disabled)
src.camera = camera
src.camera.SetLuminosity(AI_CAMERA_LUMINOSITY)
src.camera.set_light(AI_CAMERA_LUMINOSITY)
else
src.camera = null
else if(isnull(camera))
src.camera.SetLuminosity(0)
src.camera.set_light(0)
src.camera = null
else
var/obj/machinery/camera/camera = near_range_camera(src.eyeobj)
if(camera && !camera.light_disabled)
src.camera = camera
src.camera.SetLuminosity(AI_CAMERA_LUMINOSITY)
src.camera.set_light(AI_CAMERA_LUMINOSITY)
camera_light_on = world.timeofday + 1 * 20 // Update the light every 2 seconds.
@@ -58,7 +58,7 @@
src.has_power = 0
if(lights_on) // Light is on but there is no power!
lights_on = 0
SetLuminosity(0)
set_light(0)
/mob/living/silicon/robot/proc/handle_regular_status_updates()
@@ -367,9 +367,9 @@
lights_on = !lights_on
usr << "You [lights_on ? "enable" : "disable"] your integrated light."
if(lights_on)
SetLuminosity(integrated_light_power) // 1.5x luminosity of flashlight
set_light(integrated_light_power) // 1.5x luminosity of flashlight
else
SetLuminosity(0)
set_light(0)
/mob/living/silicon/robot/verb/self_diagnosis_verb()
set category = "Robot Commands"
@@ -240,7 +240,7 @@
////////////////Glow//////////////////
/mob/living/simple_animal/construct/proc/add_glow()
overlays = 0
var/overlay_layer = LIGHTING_LAYER+1
var/overlay_layer = 11
if(layer != MOB_LAYER)
overlay_layer=TURF_LAYER+0.2
@@ -94,7 +94,7 @@
emote_hear = list("clicks")
emote_see = list("clacks")
desc = "Free crabs!"
src.sd_SetLuminosity(0)
src.sd_set_light(0)
inventory_head.loc = src.loc
inventory_head = null
else
+42 -25
View File
@@ -199,7 +199,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
@@ -215,7 +217,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
@@ -224,7 +228,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
@@ -247,11 +252,14 @@
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)
@@ -285,7 +293,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)
@@ -299,15 +307,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
@@ -368,8 +376,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()
@@ -515,8 +524,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
@@ -541,8 +551,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
@@ -575,7 +586,6 @@
if(status == LIGHT_OK)
return
status = LIGHT_OK
brightness = initial(brightness)
on = 1
update()
@@ -610,7 +620,7 @@
/obj/machinery/light/process()
if(on)
use_power(luminosity * LIGHTING_POWER_FACTOR, LIGHT)
use_power(light_range * LIGHTING_POWER_FACTOR, LIGHT)
// called when area power state changes
@@ -650,7 +660,9 @@
var/switchcount = 0 // number of times switched
matter = list("metal" = 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"
@@ -659,12 +671,14 @@
base_state = "ltube"
item_state = "c_tube"
matter = list("glass" = 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"
@@ -673,7 +687,9 @@
base_state = "lbulb"
item_state = "contvapour"
matter = list("glass" = 100)
brightness = 5
brightness_range = 5
brightness_power = 2
brightness_color = "#a0a080"
/obj/item/weapon/light/throw_impact(atom/hit_atom)
..()
@@ -686,7 +702,8 @@
base_state = "fbulb"
item_state = "egg4"
matter = list("glass" = 100)
brightness = 5
brightness_range = 5
brightness_power = 2
// update the icon state and description of the light
@@ -707,9 +724,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,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.
+4 -4
View File
@@ -31,8 +31,8 @@ var/global/list/narsie_list = list()
// Pixel stuff centers Narsie.
pixel_x = -236
pixel_y = -256
luminosity = 1
l_color = "#3e0000"
light_range = 1
light_color = "#3e0000"
current_size = 12
consume_range = 12 // How many tiles out do we eat.
@@ -144,7 +144,7 @@ var/global/list/narsie_list = list()
if(T.icon_state != "cult-narsie")
T.desc = "something that goes beyond your understanding went this way"
T.icon_state = "cult-narsie"
T.luminosity = 1
T.set_light(1)
/obj/singularity/narsie/proc/narsiewall(var/turf/T)
T.desc = "An opening has been made on that wall, but who can say if what you seek truly lies on the other side?"
@@ -152,7 +152,7 @@ var/global/list/narsie_list = list()
T.icon_state = "cult-narsie"
T.opacity = 0
T.density = 0
luminosity = 1
set_light(1)
/obj/singularity/narsie/large/consume(const/atom/A) //Has its own consume proc because it doesn't need energy and I don't want BoHs to explode it. --NEO
//NEW BEHAVIOUR
@@ -8,7 +8,7 @@
anchored = 1
density = 1
layer = 6
luminosity = 6
light_range = 6
unacidable = 1 //Don't comment this out.
var/current_size = 1
+1 -1
View File
@@ -228,7 +228,7 @@
anchored = 1
density = 1
unacidable = 1
luminosity = 3
light_range = 3
var/needs_power = 0
var/active = 1
// var/power = 10
@@ -130,8 +130,8 @@
name = "Juggerwall"
icon = 'icons/effects/effects.dmi'
icon_state = "m_shield_cult"
l_color = "#B40000"
luminosity = 2
light_color = "#B40000"
light_range = 2
/obj/effect/forcefield/cult/cultify()
return
+5 -7
View File
@@ -37,7 +37,7 @@
icon_state = "darkmatter"
density = 1
anchored = 0
luminosity = 4
light_range = 4
var/gasefficency = 0.25
@@ -54,7 +54,7 @@
var/emergency_alert = "CRYSTAL DELAMINATION IMMINENT."
var/explosion_point = 1000
l_color = "#8A8A00"
light_color = "#8A8A00"
var/warning_color = "#B8B800"
var/emergency_color = "#D9D900"
@@ -117,10 +117,8 @@
//Changes color and luminosity of the light to these values if they were not already set
/obj/machinery/power/supermatter/proc/shift_light(var/lum, var/clr)
if(l_color != clr)
l_color = clr
if(luminosity != lum)
SetLuminosity(lum)
if(lum != light_range || clr != light_color)
set_light(lum, l_color = clr)
/obj/machinery/power/supermatter/proc/announce_warning()
var/integrity = damage / explosion_point
@@ -174,7 +172,7 @@
if(!istype(L, /turf/space) && (world.timeofday - lastwarning) >= WARNING_DELAY * 10)
announce_warning()
else
shift_light(4,initial(l_color))
shift_light(4,initial(light_color))
if(grav_pulling)
supermatter_pull()
+4 -4
View File
@@ -11,7 +11,7 @@
density = 1
anchored = 1
animate_movement=1
luminosity = 3
light_range = 3
can_buckle = 1
buckle_movable = 1
@@ -181,13 +181,13 @@
if(powered && cell.charge < charge_use)
return 0
on = 1
luminosity = initial(luminosity)
set_light(initial(light_range))
update_icon()
return 1
/obj/vehicle/proc/turn_off()
on = 0
luminosity = 0
set_light(0)
update_icon()
/obj/vehicle/proc/Emag(mob/user as mob)
@@ -367,4 +367,4 @@
if(prob(10))
new /obj/effect/decal/cleanable/blood/oil(src.loc)
spawn(1) healthcheck()
return 1
return 1