mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
new object-based lighting system
Signed-off-by: Mloc <colmohici@gmail.com>
This commit is contained in:
@@ -85,15 +85,12 @@
|
||||
#include "code\ATMOSPHERICS\components\unary\unary_base.dm"
|
||||
#include "code\ATMOSPHERICS\components\unary\vent_pump.dm"
|
||||
#include "code\ATMOSPHERICS\components\unary\vent_scrubber.dm"
|
||||
#include "code\controllers\_DynamicAreaLighting_TG.dm"
|
||||
#include "code\controllers\autotransfer.dm"
|
||||
#include "code\controllers\communications.dm"
|
||||
#include "code\controllers\configuration.dm"
|
||||
#include "code\controllers\emergency_shuttle_controller.dm"
|
||||
#include "code\controllers\failsafe.dm"
|
||||
#include "code\controllers\hooks-defs.dm"
|
||||
#include "code\controllers\hooks.dm"
|
||||
#include "code\controllers\lighting_controller.dm"
|
||||
#include "code\controllers\master_controller.dm"
|
||||
#include "code\controllers\shuttle_controller.dm"
|
||||
#include "code\controllers\subsystems.dm"
|
||||
@@ -106,7 +103,6 @@
|
||||
#include "code\controllers\Processes\event.dm"
|
||||
#include "code\controllers\Processes\garbage.dm"
|
||||
#include "code\controllers\Processes\inactivity.dm"
|
||||
#include "code\controllers\Processes\lighting.dm"
|
||||
#include "code\controllers\Processes\machinery.dm"
|
||||
#include "code\controllers\Processes\mob.dm"
|
||||
#include "code\controllers\Processes\nanoui.dm"
|
||||
@@ -1030,6 +1026,14 @@
|
||||
#include "code\modules\library\lib_items.dm"
|
||||
#include "code\modules\library\lib_machines.dm"
|
||||
#include "code\modules\library\lib_readme.dm"
|
||||
#include "code\modules\lighting\_lighting_defs.dm"
|
||||
#include "code\modules\lighting\light_source.dm"
|
||||
#include "code\modules\lighting\lighting_atom.dm"
|
||||
#include "code\modules\lighting\lighting_overlay.dm"
|
||||
#include "code\modules\lighting\lighting_process.dm"
|
||||
#include "code\modules\lighting\lighting_system.dm"
|
||||
#include "code\modules\lighting\lighting_turf.dm"
|
||||
#include "code\modules\lighting\~lighting_undefs.dm"
|
||||
#include "code\modules\liquid\splash_simulation.dm"
|
||||
#include "code\modules\maps\dmm_suite.dm"
|
||||
#include "code\modules\maps\reader.dm"
|
||||
|
||||
@@ -95,7 +95,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
|
||||
|
||||
icon = 'icons/effects/fire.dmi'
|
||||
icon_state = "1"
|
||||
l_color = "#ED9200"
|
||||
light_color = "#ED9200"
|
||||
layer = TURF_LAYER
|
||||
|
||||
var/firelevel = 10000 //Calculated by gas_mixture.calculate_firelevel()
|
||||
@@ -114,13 +114,13 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
|
||||
|
||||
if(firelevel > 6)
|
||||
icon_state = "3"
|
||||
SetLuminosity(7)
|
||||
set_light(7)
|
||||
else if(firelevel > 2.5)
|
||||
icon_state = "2"
|
||||
SetLuminosity(5)
|
||||
set_light(5)
|
||||
else
|
||||
icon_state = "1"
|
||||
SetLuminosity(3)
|
||||
set_light(3)
|
||||
|
||||
//im not sure how to implement a version that works for every creature so for now monkeys are firesafe
|
||||
for(var/mob/living/L in loc)
|
||||
@@ -165,7 +165,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
|
||||
qdel(src)
|
||||
|
||||
set_dir(pick(cardinal))
|
||||
SetLuminosity(3)
|
||||
set_light(3)
|
||||
firelevel = fl
|
||||
air_master.active_hotspots.Add(src)
|
||||
|
||||
@@ -178,7 +178,7 @@ turf/proc/hotspot_expose(exposed_temperature, exposed_volume, soh = 0)
|
||||
|
||||
/obj/fire/proc/RemoveFire()
|
||||
if (istype(loc, /turf))
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
|
||||
loc = null
|
||||
air_master.active_hotspots.Remove(src)
|
||||
|
||||
@@ -69,18 +69,6 @@
|
||||
/proc/isNotAdminLevel(var/level)
|
||||
return !isAdminLevel(level)
|
||||
|
||||
//Magic constants obtained by using linear regression on right-angled triangles of sides 0<x<1, 0<y<1
|
||||
//They should approximate pythagoras theorem well enough for our needs.
|
||||
#define k1 0.934
|
||||
#define k2 0.427
|
||||
/proc/cheap_hypotenuse(Ax,Ay,Bx,By) // T is just the second atom to check distance to center with
|
||||
var/dx = abs(Ax - Bx) //sides of right-angled triangle
|
||||
var/dy = abs(Ay - By)
|
||||
if(dx>=dy) return (k1*dx) + (k2*dy) //No sqrt or powers :)
|
||||
else return (k2*dx) + (k1*dy)
|
||||
#undef k1
|
||||
#undef k2
|
||||
|
||||
/proc/circlerange(center=usr,radius=3)
|
||||
|
||||
var/turf/centerturf = get_turf(center)
|
||||
|
||||
@@ -1,450 +0,0 @@
|
||||
/*
|
||||
Modified DynamicAreaLighting for TGstation - Coded by Carnwennan
|
||||
|
||||
This is TG's 'new' lighting system. It's basically a heavily modified combination of Forum_Account's and
|
||||
ShadowDarke's respective lighting libraries. Credits, where due, to them.
|
||||
|
||||
Like sd_DAL (what we used to use), it changes the shading overlays of areas by splitting each type of area into sub-areas
|
||||
by using the var/tag variable and moving turfs into the contents list of the correct sub-area. This method is
|
||||
much less costly than using overlays or objects.
|
||||
|
||||
Unlike sd_DAL however it uses a queueing system. Everytime we call a change to opacity or luminosity
|
||||
(through SetOpacity() or SetLuminosity()) we are simply updating variables and scheduling certain lights/turfs for an
|
||||
update. Actual updates are handled periodically by the lighting_controller. This carries additional overheads, however it
|
||||
means that each thing is changed only once per lighting_controller.processing_interval ticks. Allowing for greater control
|
||||
over how much priority we'd like lighting updates to have. It also makes it possible for us to simply delay updates by
|
||||
setting lighting_controller.processing = 0 at say, the start of a large explosion, waiting for it to finish, and then
|
||||
turning it back on with lighting_controller.processing = 1.
|
||||
|
||||
Unlike our old system there are hardcoded maximum luminositys (different for certain atoms).
|
||||
This is to cap the cost of creating lighting effects.
|
||||
(without this, an atom with luminosity of 20 would have to update 41^2 turfs!) :s
|
||||
|
||||
Also, in order for the queueing system to work, each light remembers the effect it casts on each turf. This is going to
|
||||
have larger memory requirements than our previous system but it's easily worth the hassle for the greater control we
|
||||
gain. It also reduces cost of removing lighting effects by a lot!
|
||||
|
||||
Known Issues/TODO:
|
||||
Shuttles still do not have support for dynamic lighting (I hope to fix this at some point)
|
||||
No directional lighting support. (prototype looked ugly)
|
||||
*/
|
||||
|
||||
#define LIGHTING_CIRCULAR 1 //comment this out to use old square lighting effects.
|
||||
#define LIGHTING_LAYER 10 //Drawing layer for lighting overlays
|
||||
#define LIGHTING_ICON 'icons/effects/ss13_dark_alpha6.dmi' //Icon used for lighting shading effects
|
||||
|
||||
datum/light_source
|
||||
var/atom/owner
|
||||
var/changed = 1
|
||||
var/list/effect = list()
|
||||
var/__x = 0 //x coordinate at last update
|
||||
var/__y = 0 //y coordinate at last update
|
||||
var/__z = 0 //z coordinate at last update
|
||||
|
||||
var/_l_color //do not use directly, only used as reference for updating
|
||||
var/col_r
|
||||
var/col_g
|
||||
var/col_b
|
||||
|
||||
|
||||
New(atom/A)
|
||||
if(!istype(A))
|
||||
CRASH("The first argument to the light object's constructor must be the atom that is the light source. Expected atom, received '[A]' instead.")
|
||||
..()
|
||||
owner = A
|
||||
readrgb(owner.l_color)
|
||||
__x = owner.x
|
||||
__y = owner.y
|
||||
__z = owner.z
|
||||
// the lighting object maintains a list of all light sources
|
||||
lighting_controller.lights += src
|
||||
|
||||
|
||||
//Check a light to see if its effect needs reprocessing. If it does, remove any old effect and create a new one
|
||||
proc/check()
|
||||
if(!owner)
|
||||
remove_effect()
|
||||
return 1 //causes it to be removed from our list of lights. The garbage collector will then destroy it.
|
||||
|
||||
// check to see if we've moved since last update
|
||||
if(owner.x != __x || owner.y != __y || owner.z != __z)
|
||||
__x = owner.x
|
||||
__y = owner.y
|
||||
__z = owner.z
|
||||
changed = 1
|
||||
|
||||
if (owner.l_color != _l_color)
|
||||
readrgb(owner.l_color)
|
||||
changed = 1
|
||||
|
||||
if(changed)
|
||||
changed = 0
|
||||
remove_effect()
|
||||
return add_effect()
|
||||
return 0
|
||||
|
||||
|
||||
proc/remove_effect()
|
||||
// before we apply the effect we remove the light's current effect.
|
||||
for(var/turf/T in effect) // negate the effect of this light source
|
||||
T.update_lumcount(-effect[T], col_r, col_g, col_b, 1)
|
||||
effect.Cut() // clear the effect list
|
||||
|
||||
proc/add_effect()
|
||||
// only do this if the light is turned on and is on the map
|
||||
if(owner.loc && owner.luminosity > 0)
|
||||
readrgb(owner.l_color)
|
||||
effect = list()
|
||||
for(var/turf/T in view(owner.get_light_range(),get_turf(owner)))
|
||||
var/delta_lumen = lum(T)
|
||||
if(delta_lumen > 0)
|
||||
effect[T] = delta_lumen
|
||||
T.update_lumcount(delta_lumen, col_r, col_g, col_b, 0)
|
||||
|
||||
return 0
|
||||
else
|
||||
owner.light = null
|
||||
return 1 //cause the light to be removed from the lights list and garbage collected once it's no
|
||||
//longer referenced by the queue
|
||||
|
||||
proc/lum(turf/A)
|
||||
if (owner.trueLuminosity < 1)
|
||||
return 0
|
||||
var/dist
|
||||
if(!A)
|
||||
dist = 0
|
||||
else
|
||||
#ifdef LIGHTING_CIRCULAR
|
||||
dist = cheap_hypotenuse(A.x, A.y, __x, __y)
|
||||
#else
|
||||
dist = max(abs(A.x - __x), abs(A.y - __y))
|
||||
#endif
|
||||
if (owner.trueLuminosity > 100) // This will never happen... right?
|
||||
return sqrt(owner.trueLuminosity) - dist
|
||||
else
|
||||
return sqrtTable[owner.trueLuminosity] - dist
|
||||
|
||||
proc/readrgb(col)
|
||||
_l_color = col
|
||||
if(col)
|
||||
col_r = GetRedPart(col)
|
||||
col_g = GetGreenPart(col)
|
||||
col_b = GetBluePart(col)
|
||||
else
|
||||
col_r = null
|
||||
|
||||
atom
|
||||
var/datum/light_source/light
|
||||
var/trueLuminosity = 0 // Typically 'luminosity' squared. The builtin luminosity must remain linear.
|
||||
// We may read it, but NEVER set it directly.
|
||||
var/l_color
|
||||
|
||||
//Turfs with opacity when they are constructed will trigger nearby lights to update
|
||||
//Turfs and atoms with luminosity when they are constructed will create a light_source automatically
|
||||
turf/New()
|
||||
..()
|
||||
if(luminosity)
|
||||
if(light) WARNING("[type] - Don't set lights up manually during New(), We do it automatically.")
|
||||
trueLuminosity = luminosity * luminosity
|
||||
light = new(src)
|
||||
|
||||
//Movable atoms with opacity when they are constructed will trigger nearby lights to update
|
||||
//Movable atoms with luminosity when they are constructed will create a light_source automatically
|
||||
atom/movable/New()
|
||||
..()
|
||||
if(opacity)
|
||||
if(isturf(loc))
|
||||
if(loc:lighting_lumcount > 1)
|
||||
UpdateAffectingLights()
|
||||
if(luminosity)
|
||||
if(light) WARNING("[type] - Don't set lights up manually during New(), We do it automatically.")
|
||||
trueLuminosity = luminosity * luminosity
|
||||
light = new(src)
|
||||
|
||||
//Sets our luminosity.
|
||||
//If we have no light it will create one.
|
||||
//If we are setting luminosity to 0 the light will be cleaned up by the controller and garbage collected once all its
|
||||
//queues are complete.
|
||||
//if we have a light already it is merely updated, rather than making a new one.
|
||||
atom/proc/SetLuminosity(new_luminosity, trueLum = FALSE)
|
||||
if(new_luminosity < 0)
|
||||
new_luminosity = 0
|
||||
if(!trueLum)
|
||||
new_luminosity *= new_luminosity
|
||||
if(light)
|
||||
if(trueLuminosity != new_luminosity) //non-luminous lights are removed from the lights list in add_effect()
|
||||
light.changed = 1
|
||||
else
|
||||
if(new_luminosity)
|
||||
light = new(src)
|
||||
trueLuminosity = new_luminosity
|
||||
if (trueLuminosity < 1)
|
||||
luminosity = 0
|
||||
else if (trueLuminosity <= 100)
|
||||
luminosity = sqrtTable[trueLuminosity]
|
||||
else
|
||||
luminosity = sqrt(trueLuminosity)
|
||||
|
||||
atom/proc/AddLuminosity(delta_luminosity)
|
||||
if(delta_luminosity > 0)
|
||||
SetLuminosity(trueLuminosity + delta_luminosity*delta_luminosity, TRUE)
|
||||
else if(delta_luminosity < 0)
|
||||
SetLuminosity(trueLuminosity - delta_luminosity*delta_luminosity, TRUE)
|
||||
|
||||
area/SetLuminosity(new_luminosity) //we don't want dynamic lighting for areas
|
||||
luminosity = !!new_luminosity
|
||||
trueLuminosity = luminosity
|
||||
|
||||
|
||||
//change our opacity (defaults to toggle), and then update all lights that affect us.
|
||||
atom/proc/SetOpacity(new_opacity)
|
||||
if(new_opacity == null)
|
||||
new_opacity = !opacity //default = toggle opacity
|
||||
else if(opacity == new_opacity)
|
||||
return 0 //opacity hasn't changed! don't bother doing anything
|
||||
opacity = new_opacity //update opacity, the below procs now call light updates.
|
||||
return 1
|
||||
|
||||
turf/SetOpacity(new_opacity)
|
||||
if(..()==1) //only bother if opacity changed
|
||||
if(lighting_lumcount) //only bother with an update if our turf is currently affected by a light
|
||||
UpdateAffectingLights()
|
||||
|
||||
/atom/movable/SetOpacity(new_opacity)
|
||||
if(..()==1) //only bother if opacity changed
|
||||
if(isturf(loc)) //only bother with an update if we're on a turf
|
||||
var/turf/T = loc
|
||||
if(T.lighting_lumcount) //only bother with an update if our turf is currently affected by a light
|
||||
UpdateAffectingLights()
|
||||
|
||||
|
||||
turf
|
||||
var/lighting_lumcount = 0
|
||||
var/lighting_changed = 0
|
||||
var/color_lighting_lumcount = 0
|
||||
|
||||
var/lumcount_r = 0
|
||||
var/lumcount_g = 0
|
||||
var/lumcount_b = 0
|
||||
var/light_col_sources = 0
|
||||
|
||||
turf/space
|
||||
lighting_lumcount = 4 //starlight
|
||||
|
||||
turf/proc/update_lumcount(amount, col_r, col_g, col_b, removing = 0)
|
||||
lighting_lumcount += amount
|
||||
|
||||
if(!isnull(col_r)) //col_r is the "key" var, if it's null so will the rest
|
||||
if(removing)
|
||||
light_col_sources--
|
||||
lumcount_r -= col_r
|
||||
lumcount_g -= col_g
|
||||
lumcount_b -= col_b
|
||||
else
|
||||
light_col_sources++
|
||||
lumcount_r += col_r
|
||||
lumcount_g += col_g
|
||||
lumcount_b += col_b
|
||||
|
||||
if(light_col_sources)
|
||||
var/r_avg = max(0, min(255, round(lumcount_r / light_col_sources, 16) + 15))
|
||||
var/g_avg = max(0, min(255, round(lumcount_g / light_col_sources, 16) + 15))
|
||||
var/b_avg = max(0, min(255, round(lumcount_b / light_col_sources, 16) + 15))
|
||||
l_color = rgb(r_avg, g_avg, b_avg)
|
||||
else
|
||||
l_color = null
|
||||
|
||||
color_lighting_lumcount = max(color_lighting_lumcount + amount, 0) // Minimum of 0.
|
||||
|
||||
if(!lighting_changed)
|
||||
lighting_controller.changed_turfs += src
|
||||
lighting_changed = 1
|
||||
|
||||
turf/proc/lighting_tag(const/level)
|
||||
var/area/A = loc
|
||||
return A.tagbase + "sd_L[level]"
|
||||
|
||||
turf/proc/build_lighting_area(const/tag, const/level, const/color_light)
|
||||
var/area/Area = loc
|
||||
var/area/A = new Area.type() // create area if it wasn't found
|
||||
// replicate vars
|
||||
for(var/V in Area.vars)
|
||||
switch(V)
|
||||
if ("contents","lighting_overlay", "color_overlay", "overlays")
|
||||
continue
|
||||
else
|
||||
if(issaved(Area.vars[V])) A.vars[V] = Area.vars[V]
|
||||
|
||||
A.tag = tag
|
||||
A.lighting_subarea = 1
|
||||
A.lighting_space = 0 // in case it was copied from a space subarea
|
||||
|
||||
if (l_color != A.l_color)
|
||||
A.l_color = l_color
|
||||
//color_light = min(max(round(color_lighting_lumcount, 1), 0), lighting_controller.lighting_states)
|
||||
//world << "[color_light] [color_lighting_lumcount]"
|
||||
|
||||
A.SetLightLevel(level, color_light)
|
||||
Area.related += A
|
||||
return A
|
||||
|
||||
turf/proc/shift_to_subarea()
|
||||
lighting_changed = 0
|
||||
var/area/Area = loc
|
||||
|
||||
if(!istype(Area) || !Area.lighting_use_dynamic) return
|
||||
|
||||
var/level = min(max(round(lighting_lumcount,1),0),lighting_controller.lighting_states)
|
||||
var/new_tag = lighting_tag(level)
|
||||
|
||||
// pomf - If we have a lighting color that is not null, apply the new tag to seperate the areas.
|
||||
if (l_color)
|
||||
// pomf - We append the (rounded!) color lighting lumcount so we can have colored lights.
|
||||
new_tag += "[l_color][min(max(round(color_lighting_lumcount,1),0),lighting_controller.lighting_states)]"
|
||||
|
||||
if(Area.tag!=new_tag) //skip if already in this area
|
||||
var/area/A = locate(new_tag) // find an appropriate area
|
||||
var/color_light = min(max(round(color_lighting_lumcount,1),0),lighting_controller.lighting_states)
|
||||
|
||||
if (!A)
|
||||
A = build_lighting_area(new_tag, level, color_light)
|
||||
else if (l_color != A.l_color)
|
||||
A.l_color = l_color
|
||||
//color_light = min(max(round(color_lighting_lumcount, 1), 0), lighting_controller.lighting_states)
|
||||
A.SetLightLevel(level, color_light)
|
||||
|
||||
A.contents += src // move the turf into the area
|
||||
universe.OnTurfTick(src)
|
||||
|
||||
// Dedicated lighting sublevel for space turfs
|
||||
// helps us depower things in space, remove space fire alarms,
|
||||
// and evens out space lighting
|
||||
turf/space/lighting_tag(var/level)
|
||||
var/area/A = loc
|
||||
return A.tagbase + "sd_L_space"
|
||||
turf/space/build_lighting_area(var/tag,var/level)
|
||||
var/area/A = ..(tag,4)
|
||||
A.lighting_space = 1
|
||||
A.SetLightLevel(4)
|
||||
A.icon_state = null
|
||||
return A
|
||||
|
||||
|
||||
area
|
||||
var/lighting_use_dynamic = 1 //Turn this flag off to prevent sd_DynamicAreaLighting from affecting this area
|
||||
var/image/lighting_overlay //tracks the darkness image of the area for easy removal
|
||||
var/lighting_subarea = 0 //tracks whether we're a lighting sub-area
|
||||
var/lighting_space = 0 // true for space-only lighting subareas
|
||||
var/tagbase
|
||||
var/image/color_overlay //Tracks the color image.
|
||||
|
||||
proc/SetLightLevel(light, color_light = 0)
|
||||
if(!src) return
|
||||
if(light <= 0)
|
||||
light = 0
|
||||
luminosity = 0
|
||||
else
|
||||
if(light > lighting_controller.lighting_states)
|
||||
light = lighting_controller.lighting_states
|
||||
luminosity = 1
|
||||
|
||||
if(lighting_overlay)
|
||||
overlays -= lighting_overlay
|
||||
lighting_overlay.icon_state = "[light]"
|
||||
else
|
||||
lighting_overlay = image(LIGHTING_ICON,,num2text(light),LIGHTING_LAYER)
|
||||
|
||||
if (color_overlay)
|
||||
overlays.Remove(color_overlay)
|
||||
color_overlay.icon_state = "5"
|
||||
else
|
||||
if (l_color)
|
||||
color_overlay = image('icons/effects/effects.dmi', ,"5", 10.1)
|
||||
//color_overlay = image('icons/effects/effects.dmi', ,"white", 10.1)
|
||||
|
||||
if (istype(color_overlay))
|
||||
color_overlay.color = l_color
|
||||
|
||||
|
||||
switch (color_light)
|
||||
if (6)
|
||||
color_overlay.icon_state = "5"
|
||||
//color_overlay.alpha = 180
|
||||
if (5)
|
||||
color_overlay.icon_state = "4"
|
||||
//color_overlay.alpha = 150
|
||||
if (4)
|
||||
color_overlay.icon_state = "3"
|
||||
//color_overlay.alpha = 120
|
||||
if (3)
|
||||
color_overlay.icon_state = "2"
|
||||
//color_overlay.alpha = 90
|
||||
if (2)
|
||||
color_overlay.icon_state = "1"
|
||||
//color_overlay.alpha = 60
|
||||
if (1)
|
||||
color_overlay.icon_state = "1"
|
||||
color_overlay.alpha = 200
|
||||
//color_overlay.alpha = 30
|
||||
if (-INFINITY to 0)
|
||||
//world << "Zero or below, [color_light]."
|
||||
color_overlay.alpha = 0
|
||||
else
|
||||
//world << "Setting the alpha to max... color_light [color_light]."
|
||||
color_overlay.alpha = 180
|
||||
|
||||
color_overlay.blend_mode = BLEND_ADD
|
||||
if (color_overlay.color)
|
||||
overlays.Add(color_overlay)
|
||||
|
||||
if (isnull(color_overlay))
|
||||
overlays.Add(lighting_overlay)
|
||||
else if (light < 6)
|
||||
overlays.Add(lighting_overlay)
|
||||
|
||||
proc/SetDynamicLighting()
|
||||
|
||||
src.lighting_use_dynamic = 1
|
||||
for(var/turf/T in src.contents)
|
||||
T.update_lumcount(0)
|
||||
|
||||
proc/InitializeLighting() //TODO: could probably improve this bit ~Carn
|
||||
tagbase = "[type]"
|
||||
if(!tag) tag = tagbase
|
||||
if(!lighting_use_dynamic)
|
||||
if(!lighting_subarea) // see if this is a lighting subarea already
|
||||
//show the dark overlay so areas, not yet in a lighting subarea, won't be bright as day and look silly.
|
||||
SetLightLevel(4)
|
||||
|
||||
//#undef LIGHTING_LAYER
|
||||
#undef LIGHTING_CIRCULAR
|
||||
//#undef LIGHTING_ICON
|
||||
|
||||
#define LIGHTING_MAX_LUMINOSITY_STATIC 8 //Maximum luminosity to reduce lag.
|
||||
#define LIGHTING_MAX_LUMINOSITY_MOBILE 5 //Moving objects have a lower max luminosity since these update more often. (lag reduction)
|
||||
#define LIGHTING_MAX_LUMINOSITY_TURF 1 //turfs have a severely shortened range to protect from inevitable floor-lighttile spam.
|
||||
|
||||
//set the changed status of all lights which could have possibly lit this atom.
|
||||
//We don't need to worry about lights which lit us but moved away, since they will have change status set already
|
||||
//This proc can cause lots of lights to be updated. :(
|
||||
atom/proc/UpdateAffectingLights()
|
||||
for(var/atom/A in oview(LIGHTING_MAX_LUMINOSITY_STATIC-1,src))
|
||||
if(A.light)
|
||||
A.light.changed = 1 //force it to update at next process()
|
||||
|
||||
//caps luminosity effects max-range based on what type the light's owner is.
|
||||
atom/proc/get_light_range()
|
||||
return min(luminosity, LIGHTING_MAX_LUMINOSITY_STATIC)
|
||||
|
||||
atom/movable/get_light_range()
|
||||
return min(luminosity, LIGHTING_MAX_LUMINOSITY_MOBILE)
|
||||
|
||||
obj/machinery/light/get_light_range()
|
||||
return min(luminosity, LIGHTING_MAX_LUMINOSITY_STATIC)
|
||||
|
||||
turf/get_light_range()
|
||||
return min(luminosity, LIGHTING_MAX_LUMINOSITY_TURF)
|
||||
|
||||
#undef LIGHTING_MAX_LUMINOSITY_STATIC
|
||||
#undef LIGHTING_MAX_LUMINOSITY_MOBILE
|
||||
#undef LIGHTING_MAX_LUMINOSITY_TURF
|
||||
@@ -25,7 +25,6 @@ var/datum/controller/failsafe/Failsafe
|
||||
set background = 1
|
||||
while(1) //more efficient than recursivly calling ourself over and over. background = 1 ensures we do not trigger an infinite loop
|
||||
if(!master_controller) new /datum/controller/game_controller() //replace the missing master_controller! This should never happen.
|
||||
if(!lighting_controller) new /datum/controller/lighting() //replace the missing lighting_controller
|
||||
|
||||
if(processing)
|
||||
if(lighting_controller.processing)
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
var/datum/controller/lighting/lighting_controller = new ()
|
||||
|
||||
datum/controller/lighting
|
||||
var/processing = 0
|
||||
var/processing_interval = 5 //setting this too low will probably kill the server. Don't be silly with it!
|
||||
var/process_cost = 0
|
||||
var/iteration = 0
|
||||
|
||||
var/lighting_states = 7
|
||||
|
||||
var/list/lights = list()
|
||||
var/lights_workload_max = 0
|
||||
|
||||
// var/list/changed_lights() //TODO: possibly implement this to reduce on overheads?
|
||||
|
||||
var/list/changed_turfs = list()
|
||||
var/changed_turfs_workload_max = 0
|
||||
|
||||
|
||||
datum/controller/lighting/New()
|
||||
lighting_states = max( 0, length(icon_states(LIGHTING_ICON))-1 )
|
||||
if(lighting_controller != src)
|
||||
if(istype(lighting_controller,/datum/controller/lighting))
|
||||
Recover() //if we are replacing an existing lighting_controller (due to a crash) we attempt to preserve as much as we can
|
||||
qdel(lighting_controller)
|
||||
lighting_controller = src
|
||||
|
||||
|
||||
//Workhorse of lighting. It cycles through each light to see which ones need their effects updating. It updates their
|
||||
//effects and then processes every turf in the queue, moving the turfs to the corresponing lighting sub-area.
|
||||
//All queue lists prune themselves, which will cause lights with no luminosity to be garbage collected (cheaper and safer
|
||||
//than deleting them). Processing interval should be roughly half a second for best results.
|
||||
//By using queues we are ensuring we don't perform more updates than are necessary
|
||||
datum/controller/lighting/proc/process()
|
||||
processing = 1
|
||||
spawn(0)
|
||||
set background = 1
|
||||
while(1)
|
||||
if(processing)
|
||||
iteration++
|
||||
var/started = world.timeofday
|
||||
|
||||
lights_workload_max = max(lights_workload_max,lights.len)
|
||||
for(var/i=1, i<=lights.len, i++)
|
||||
var/datum/light_source/L = lights[i]
|
||||
if(L && !L.check())
|
||||
continue
|
||||
lights.Cut(i,i+1)
|
||||
i--
|
||||
|
||||
sleep(-1)
|
||||
|
||||
changed_turfs_workload_max = max(changed_turfs_workload_max,changed_turfs.len)
|
||||
for(var/i=1, i<=changed_turfs.len, i++)
|
||||
var/turf/T = changed_turfs[i]
|
||||
if(T && T.lighting_changed)
|
||||
T.shift_to_subarea()
|
||||
changed_turfs.Cut() // reset the changed list
|
||||
|
||||
process_cost = (world.timeofday - started)
|
||||
|
||||
sleep(processing_interval)
|
||||
|
||||
//same as above except it attempts to shift ALL turfs in the world regardless of lighting_changed status
|
||||
//Does not loop. Should be run prior to process() being called for the first time.
|
||||
//Note: if we get additional z-levels at runtime (e.g. if the gateway thin ever gets finished) we can initialize specific
|
||||
//z-levels with the z_level argument
|
||||
datum/controller/lighting/proc/initializeLighting(var/z_level)
|
||||
processing = 0
|
||||
spawn(-1)
|
||||
set background = 1
|
||||
for(var/i=1, i<=lights.len, i++)
|
||||
var/datum/light_source/L = lights[i]
|
||||
if(L.check())
|
||||
lights.Cut(i,i+1)
|
||||
i--
|
||||
|
||||
var/z_start = 1
|
||||
var/z_finish = world.maxz
|
||||
if(z_level)
|
||||
z_level = round(z_level,1)
|
||||
if(z_level > 0 && z_level <= world.maxz)
|
||||
z_start = z_level
|
||||
z_finish = z_level
|
||||
|
||||
for(var/k=z_start,k<=z_finish,k++)
|
||||
for(var/i=1,i<=world.maxx,i++)
|
||||
for(var/j=1,j<=world.maxy,j++)
|
||||
var/turf/T = locate(i,j,k)
|
||||
if(T) T.shift_to_subarea()
|
||||
|
||||
changed_turfs.Cut() // reset the changed list
|
||||
|
||||
|
||||
//Used to strip valid information from an existing controller and transfer it to a replacement
|
||||
//It works by using spawn(-1) to transfer the data, if there is a runtime the data does not get transfered but the loop
|
||||
//does not crash
|
||||
datum/controller/lighting/proc/Recover()
|
||||
if(!istype(lighting_controller.changed_turfs,/list))
|
||||
lighting_controller.changed_turfs = list()
|
||||
if(!istype(lighting_controller.lights,/list))
|
||||
lighting_controller.lights = list()
|
||||
|
||||
for(var/i=1, i<=lighting_controller.lights.len, i++)
|
||||
var/datum/light_source/L = lighting_controller.lights[i]
|
||||
if(istype(L))
|
||||
spawn(-1) //so we don't crash the loop (inefficient)
|
||||
L.check()
|
||||
lights += L //If we didn't runtime then this will get transferred over
|
||||
|
||||
for(var/i=1, i<=lighting_controller.changed_turfs.len, i++)
|
||||
var/turf/T = lighting_controller.changed_turfs[i]
|
||||
if(istype(T) && T.lighting_changed)
|
||||
spawn(-1)
|
||||
T.shift_to_subarea()
|
||||
|
||||
var/msg = "## DEBUG: [time2text(world.timeofday)] lighting_controller restarted. Reports:\n"
|
||||
for(var/varname in lighting_controller.vars)
|
||||
switch(varname)
|
||||
if("tag","bestF","type","parent_type","vars") continue
|
||||
else
|
||||
var/varval1 = lighting_controller.vars[varname]
|
||||
var/varval2 = vars[varname]
|
||||
if(istype(varval1,/list))
|
||||
varval1 = "/list([length(varval1)])"
|
||||
varval2 = "/list([length(varval2)])"
|
||||
msg += "\t [varname] = [varval1] -> [varval2]\n"
|
||||
world.log << msg
|
||||
|
||||
#undef LIGHTING_ICON
|
||||
@@ -30,7 +30,7 @@
|
||||
var/tz = input("Z? (default 1)") as text|null
|
||||
new map_datum(seed,tx,ty,tz)
|
||||
|
||||
/client/proc/restart_controller(controller in list("Master","Failsafe","Lighting","Supply"))
|
||||
/client/proc/restart_controller(controller in list("Supply"))
|
||||
set category = "Debug"
|
||||
set name = "Restart Controller"
|
||||
set desc = "Restart one of the various periodic loop controllers for the game (be careful!)"
|
||||
@@ -39,13 +39,6 @@
|
||||
usr = null
|
||||
src = null
|
||||
switch(controller)
|
||||
if("Failsafe")
|
||||
new /datum/controller/failsafe()
|
||||
feedback_add_details("admin_verb","RFailsafe")
|
||||
if("Lighting")
|
||||
new /datum/controller/lighting()
|
||||
lighting_controller.process()
|
||||
feedback_add_details("admin_verb","RLighting")
|
||||
if("Supply")
|
||||
supply_controller.process()
|
||||
feedback_add_details("admin_verb","RSupply")
|
||||
@@ -62,7 +55,7 @@
|
||||
usr.client.debug_variables(antag)
|
||||
message_admins("Admin [key_name_admin(usr)] is debugging the [antag.role_text] template.")
|
||||
|
||||
/client/proc/debug_controller(controller in list("Master","Failsafe","Ticker","Ticker Process","Lighting","Air","Jobs","Sun","Radio","Supply","Shuttles","Emergency Shuttle","Configuration","pAI", "Cameras", "Transfer Controller", "Gas Data","Event","Plants","Alarm","Nano"))
|
||||
/client/proc/debug_controller(controller in list("Master","Ticker","Ticker Process","Air","Jobs","Sun","Radio","Supply","Shuttles","Emergency Shuttle","Configuration","pAI", "Cameras", "Transfer Controller", "Gas Data","Event","Plants","Alarm","Nano"))
|
||||
set category = "Debug"
|
||||
set name = "Debug Controller"
|
||||
set desc = "Debug the various periodic loop controllers for the game (be careful!)"
|
||||
@@ -72,18 +65,12 @@
|
||||
if("Master")
|
||||
debug_variables(master_controller)
|
||||
feedback_add_details("admin_verb","DMC")
|
||||
if("Failsafe")
|
||||
debug_variables(Failsafe)
|
||||
feedback_add_details("admin_verb","DFailsafe")
|
||||
if("Ticker")
|
||||
debug_variables(ticker)
|
||||
feedback_add_details("admin_verb","DTicker")
|
||||
if("Ticker Process")
|
||||
debug_variables(tickerProcess)
|
||||
feedback_add_details("admin_verb","DTickerProcess")
|
||||
if("Lighting")
|
||||
debug_variables(lighting_controller)
|
||||
feedback_add_details("admin_verb","DLighting")
|
||||
if("Air")
|
||||
debug_variables(air_master)
|
||||
feedback_add_details("admin_verb","DAir")
|
||||
|
||||
@@ -26,8 +26,8 @@ NOTE: there are two lists of areas in the end of this file: centcom and station
|
||||
icon = 'icons/turf/areas.dmi'
|
||||
icon_state = "unknown"
|
||||
layer = 10
|
||||
luminosity = 1
|
||||
mouse_opacity = 0
|
||||
invisibility = INVISIBILITY_LIGHTING
|
||||
var/lightswitch = 1
|
||||
|
||||
var/eject = null
|
||||
@@ -99,7 +99,6 @@ var/list/ghostteleportlocs = list()
|
||||
icon_state = "space"
|
||||
requires_power = 1
|
||||
always_unpowered = 1
|
||||
lighting_use_dynamic = 1
|
||||
power_light = 0
|
||||
power_equip = 0
|
||||
power_environ = 0
|
||||
@@ -142,10 +141,8 @@ area/space/atmosalert()
|
||||
//place to another. Look at escape shuttle for example.
|
||||
//All shuttles should now be under shuttle since we have smooth-wall code.
|
||||
|
||||
/area/shuttle //DO NOT TURN THE lighting_use_dynamic STUFF ON FOR SHUTTLES. IT BREAKS THINGS.
|
||||
/area/shuttle
|
||||
requires_power = 0
|
||||
luminosity = 1
|
||||
lighting_use_dynamic = 0
|
||||
|
||||
/area/shuttle/arrival
|
||||
name = "\improper Arrival Shuttle"
|
||||
@@ -246,15 +243,11 @@ area/space/atmosalert()
|
||||
icon_state = "shuttle"
|
||||
name = "\improper Alien Shuttle Base"
|
||||
requires_power = 1
|
||||
luminosity = 0
|
||||
lighting_use_dynamic = 1
|
||||
|
||||
/area/shuttle/alien/mine
|
||||
icon_state = "shuttle"
|
||||
name = "\improper Alien Shuttle Mine"
|
||||
requires_power = 1
|
||||
luminosity = 0
|
||||
lighting_use_dynamic = 1
|
||||
|
||||
/area/shuttle/prison/
|
||||
name = "\improper Prison Shuttle"
|
||||
@@ -340,7 +333,6 @@ area/space/atmosalert()
|
||||
name = "start area"
|
||||
icon_state = "start"
|
||||
requires_power = 0
|
||||
luminosity = 1
|
||||
lighting_use_dynamic = 0
|
||||
has_gravity = 1
|
||||
|
||||
@@ -358,6 +350,7 @@ area/space/atmosalert()
|
||||
icon_state = "centcom"
|
||||
requires_power = 0
|
||||
unlimited_power = 1
|
||||
lighting_use_dynamic = 0
|
||||
|
||||
/area/centcom/control
|
||||
name = "\improper Centcom Control"
|
||||
@@ -396,6 +389,7 @@ area/space/atmosalert()
|
||||
icon_state = "syndie-ship"
|
||||
requires_power = 0
|
||||
unlimited_power = 1
|
||||
lighting_use_dynamic = 0
|
||||
|
||||
/area/syndicate_mothership/control
|
||||
name = "\improper Mercenary Control Room"
|
||||
@@ -1006,7 +1000,6 @@ area/space/atmosalert()
|
||||
/area/holodeck
|
||||
name = "\improper Holodeck"
|
||||
icon_state = "Holodeck"
|
||||
luminosity = 1
|
||||
lighting_use_dynamic = 0
|
||||
|
||||
/area/holodeck/alphadeck
|
||||
@@ -1136,7 +1129,6 @@ area/space/atmosalert()
|
||||
/area/solar
|
||||
requires_power = 1
|
||||
always_unpowered = 1
|
||||
luminosity = 1
|
||||
lighting_use_dynamic = 0
|
||||
|
||||
auxport
|
||||
|
||||
@@ -13,20 +13,15 @@
|
||||
uid = ++global_uid
|
||||
all_areas += src
|
||||
|
||||
if(requires_power)
|
||||
luminosity = 0
|
||||
else
|
||||
if(!requires_power)
|
||||
power_light = 0 //rastaf0
|
||||
power_equip = 0 //rastaf0
|
||||
power_environ = 0 //rastaf0
|
||||
luminosity = 1
|
||||
lighting_use_dynamic = 0
|
||||
|
||||
..()
|
||||
|
||||
// spawn(15)
|
||||
power_change() // all machines set to current power level, also updates lighting icon
|
||||
InitializeLighting()
|
||||
|
||||
/area/proc/get_contents()
|
||||
return contents
|
||||
@@ -145,7 +140,7 @@
|
||||
return
|
||||
|
||||
/area/proc/updateicon()
|
||||
if ((fire || eject || party) && (!requires_power||power_environ) && !lighting_space)//If it doesn't require power, can still activate this proc.
|
||||
if ((fire || eject || party) && (!requires_power||power_environ) && !istype(src, /area/space))//If it doesn't require power, can still activate this proc.
|
||||
if(fire && !eject && !party)
|
||||
icon_state = "blue"
|
||||
/*else if(atmosalm && !fire && !eject && !party)
|
||||
@@ -173,8 +168,6 @@
|
||||
return 1
|
||||
if(always_unpowered)
|
||||
return 0
|
||||
if(src.lighting_space)
|
||||
return 0 // Nope sorry
|
||||
switch(chan)
|
||||
if(EQUIP)
|
||||
return power_equip
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
/atom/Destroy()
|
||||
. = ..()
|
||||
density = 0
|
||||
SetOpacity(0)
|
||||
set_opacity(0)
|
||||
|
||||
if(reagents)
|
||||
qdel(reagents)
|
||||
|
||||
@@ -30,15 +30,10 @@
|
||||
..()
|
||||
|
||||
/atom/movable/Destroy()
|
||||
if(opacity)
|
||||
if(isturf(loc))
|
||||
if(loc:lighting_lumcount > 1)
|
||||
UpdateAffectingLights()
|
||||
. = ..()
|
||||
|
||||
loc = null
|
||||
|
||||
..()
|
||||
|
||||
|
||||
/atom/movable/proc/initialize()
|
||||
return
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
name = "blob"
|
||||
icon = 'icons/mob/blob.dmi'
|
||||
icon_state = "blob"
|
||||
luminosity = 3
|
||||
light_range = 3
|
||||
desc = "Some blob creature thingy"
|
||||
density = 1
|
||||
opacity = 0
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
desc = "A floating crystal that hums with an unearthly energy"
|
||||
icon_state = "pylon"
|
||||
var/isbroken = 0
|
||||
luminosity = 5
|
||||
l_color = "#3e0000"
|
||||
light_range = 5
|
||||
light_color = "#3e0000"
|
||||
var/obj/item/wepon = null
|
||||
|
||||
/obj/structure/cult/pylon/attack_hand(mob/M as mob)
|
||||
@@ -47,7 +47,7 @@
|
||||
isbroken = 1
|
||||
density = 0
|
||||
icon_state = "pylon-broken"
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
else
|
||||
user << "You hit the pylon!"
|
||||
playsound(get_turf(src), 'sound/effects/Glasshit.ogg', 75, 1)
|
||||
@@ -66,13 +66,12 @@
|
||||
isbroken = 0
|
||||
density = 1
|
||||
icon_state = "pylon"
|
||||
SetLuminosity(5)
|
||||
set_light(5)
|
||||
|
||||
/obj/structure/cult/tome
|
||||
name = "Desk"
|
||||
desc = "A desk covered in arcane manuscripts and tomes in unknown languages. Looking at the text makes your skin crawl"
|
||||
icon_state = "tomealtar"
|
||||
// luminosity = 5
|
||||
|
||||
//sprites for this no longer exist -Pete
|
||||
//(they were stolen from another game anyway)
|
||||
@@ -105,8 +104,8 @@
|
||||
return
|
||||
|
||||
/obj/effect/gateway/active
|
||||
luminosity=5
|
||||
l_color="#ff0000"
|
||||
light_range=5
|
||||
light_color="#ff0000"
|
||||
spawnable=list(
|
||||
/mob/living/simple_animal/hostile/scarybat,
|
||||
/mob/living/simple_animal/hostile/creature,
|
||||
@@ -114,8 +113,8 @@
|
||||
)
|
||||
|
||||
/obj/effect/gateway/active/cult
|
||||
luminosity=5
|
||||
l_color="#ff0000"
|
||||
light_range=5
|
||||
light_color="#ff0000"
|
||||
spawnable=list(
|
||||
/mob/living/simple_animal/hostile/scarybat/cult,
|
||||
/mob/living/simple_animal/hostile/creature/cult,
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
narsimage = image('icons/obj/narsie.dmi',src.loc,"narsie",9,1)
|
||||
narsimage.mouse_opacity = 0
|
||||
if(!narglow) //Create narglow
|
||||
narglow = image('icons/obj/narsie.dmi',narsimage.loc,"glow-narsie",LIGHTING_LAYER+2,1)
|
||||
narglow = image('icons/obj/narsie.dmi',narsimage.loc,"glow-narsie",12,1)
|
||||
narglow.mouse_opacity = 0
|
||||
//Else if no dir is given, simply send them the image of narsie
|
||||
var/new_x = 32 * (N.x - src.x) + N.pixel_x
|
||||
|
||||
@@ -73,9 +73,8 @@ In short:
|
||||
spess.overlays += I
|
||||
|
||||
/datum/universal_state/hell/proc/AmbientSet()
|
||||
for(var/turf/T in world)
|
||||
if(istype(T, /turf/space)) continue
|
||||
T.update_lumcount(1, 255, 0, 0, 0)
|
||||
for(var/atom/movable/lighting_overlay/L in world)
|
||||
L.update_lumcount(1, 0, 0)
|
||||
|
||||
/datum/universal_state/hell/proc/MiscSet()
|
||||
for(var/turf/simulated/floor/T in world)
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
//luminosity = 5
|
||||
//l_color="#0066FF"
|
||||
layer = LIGHTING_LAYER+1
|
||||
layer = 11
|
||||
|
||||
var/spawned=0 // DIR mask
|
||||
var/next_check=0
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
announce=0
|
||||
narnar=0
|
||||
|
||||
layer=LIGHTING_LAYER+2 // ITS SO BRIGHT
|
||||
layer=12 // ITS SO BRIGHT
|
||||
|
||||
consume_range = 6
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
/mob/proc/see_rift(var/obj/singularity/narsie/large/exit/R)
|
||||
if((R.z == src.z) && (get_dist(R,src) <= (R.consume_range+10)) && !(R in view(src)))
|
||||
if(!riftimage)
|
||||
riftimage = image('icons/obj/rift.dmi',src.loc,"rift",LIGHTING_LAYER+2,1)
|
||||
riftimage = image('icons/obj/rift.dmi',src.loc,"rift",12,1)
|
||||
riftimage.mouse_opacity = 0
|
||||
|
||||
var/new_x = 32 * (R.x - src.x) + R.pixel_x
|
||||
|
||||
@@ -110,10 +110,9 @@ AUTOMATED ALERT: Link to [command_name()] lost."}
|
||||
spess.overlays += "end01"
|
||||
|
||||
/datum/universal_state/supermatter_cascade/proc/AmbientSet()
|
||||
for(var/turf/T in world)
|
||||
if(istype(T, /turf/space)) continue
|
||||
if(!(T.z in config.admin_levels))
|
||||
T.update_lumcount(1, 160, 255, 0, 0)
|
||||
for(var/atom/movable/lighting_overlay/L in world)
|
||||
if(!(L.z in config.admin_levels))
|
||||
L.update_lumcount(0.5, 1, 0)
|
||||
|
||||
/datum/universal_state/supermatter_cascade/proc/MiscSet()
|
||||
for (var/obj/machinery/firealarm/alm in world)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
/obj/machinery/bot
|
||||
icon = 'icons/obj/aibots.dmi'
|
||||
layer = MOB_LAYER
|
||||
luminosity = 3
|
||||
light_range = 3
|
||||
use_power = 0
|
||||
var/obj/item/weapon/card/id/botcard // the ID card that the bot "holds"
|
||||
var/on = 1
|
||||
@@ -18,12 +18,12 @@
|
||||
/obj/machinery/bot/proc/turn_on()
|
||||
if(stat) return 0
|
||||
on = 1
|
||||
SetLuminosity(initial(luminosity))
|
||||
set_light(initial(light_range))
|
||||
return 1
|
||||
|
||||
/obj/machinery/bot/proc/turn_off()
|
||||
on = 0
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
|
||||
/obj/machinery/bot/proc/explode()
|
||||
qdel(src)
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
if(!isEmpProof())
|
||||
if(prob(100/severity))
|
||||
stat |= EMPED
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
kick_viewers()
|
||||
triggerCameraAlarm(30 / severity)
|
||||
update_icon()
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
src.density = 0
|
||||
update_nearby_tiles()
|
||||
src.update_icon()
|
||||
src.SetOpacity(0)
|
||||
src.set_opacity(0)
|
||||
sleep(15)
|
||||
src.layer = open_layer
|
||||
src.operating = 0
|
||||
@@ -71,7 +71,7 @@
|
||||
src.density = 1
|
||||
update_nearby_tiles()
|
||||
src.update_icon()
|
||||
src.SetOpacity(initial(opacity))
|
||||
src.set_opacity(initial(opacity))
|
||||
sleep(15)
|
||||
src.operating = 0
|
||||
|
||||
|
||||
@@ -35,11 +35,11 @@
|
||||
..()
|
||||
|
||||
spawn(20)
|
||||
for(var/obj/machinery/door/window/brigdoor/M in world)
|
||||
for(var/obj/machinery/door/window/brigdoor/M in machines)
|
||||
if (M.id == src.id)
|
||||
targets += M
|
||||
|
||||
for(var/obj/machinery/flasher/F in world)
|
||||
for(var/obj/machinery/flasher/F in machines)
|
||||
if(F.id == src.id)
|
||||
targets += F
|
||||
|
||||
|
||||
@@ -394,14 +394,14 @@
|
||||
|
||||
do_animate("opening")
|
||||
icon_state = "door0"
|
||||
src.SetOpacity(0)
|
||||
set_opacity(0)
|
||||
sleep(3)
|
||||
src.density = 0
|
||||
sleep(7)
|
||||
src.layer = open_layer
|
||||
explosion_resistance = 0
|
||||
update_icon()
|
||||
SetOpacity(0)
|
||||
set_opacity(0)
|
||||
update_nearby_tiles()
|
||||
operating = 0
|
||||
|
||||
@@ -427,7 +427,7 @@
|
||||
sleep(7)
|
||||
update_icon()
|
||||
if(visible && !glass)
|
||||
SetOpacity(1) //caaaaarn!
|
||||
set_opacity(1) //caaaaarn!
|
||||
operating = 0
|
||||
update_nearby_tiles()
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
else
|
||||
on = 0
|
||||
updateicon()
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
src.visible_message("<span class='warning'>[src] shuts down due to lack of power!</span>")
|
||||
return
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
if(on)
|
||||
on = 0
|
||||
user << "\blue You turn off the light"
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
else
|
||||
if(!cell)
|
||||
return
|
||||
@@ -58,7 +58,7 @@
|
||||
return
|
||||
on = 1
|
||||
user << "\blue You turn on the light"
|
||||
SetLuminosity(brightness_on)
|
||||
set_light(brightness_on)
|
||||
|
||||
updateicon()
|
||||
|
||||
|
||||
@@ -120,10 +120,10 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
|
||||
hologram.layer = FLY_LAYER//Above all the other objects/mobs. Or the vast majority of them.
|
||||
hologram.anchored = 1//So space wind cannot drag it.
|
||||
hologram.name = "[A.name] (Hologram)"//If someone decides to right click.
|
||||
hologram.SetLuminosity(2) //hologram lighting
|
||||
hologram.set_light(2) //hologram lighting
|
||||
hologram.color = color //painted holopad gives coloured holograms
|
||||
masters[A] = hologram
|
||||
SetLuminosity(2) //pad lighting
|
||||
set_light(2) //pad lighting
|
||||
icon_state = "holopad1"
|
||||
A.holo = src
|
||||
return 1
|
||||
@@ -134,7 +134,7 @@ For the other part of the code, check silicon say.dm. Particularly robot talk.*/
|
||||
qdel(masters[user])//Get rid of user's hologram
|
||||
masters -= user //Discard AI from the list of those who use holopad
|
||||
if (!masters.len)//If no users left
|
||||
SetLuminosity(0) //pad lighting (hologram lighting will be handled automatically since its owner was deleted)
|
||||
set_light(0) //pad lighting (hologram lighting will be handled automatically since its owner was deleted)
|
||||
icon_state = "holopad0"
|
||||
return 1
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ var/list/obj/machinery/newscaster/allCasters = list() //Global list that will co
|
||||
var/c_locked=0; //Will our new channel be locked to public submissions?
|
||||
var/hitstaken = 0 //Death at 3 hits from an item with force>=15
|
||||
var/datum/feed_channel/viewing_channel = null
|
||||
luminosity = 0
|
||||
light_range = 0
|
||||
anchored = 1
|
||||
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
var/message = "";
|
||||
var/dpt = ""; //the department which will be receiving the message
|
||||
var/priority = -1 ; //Priority of the message being sent
|
||||
luminosity = 0
|
||||
light_range = 0
|
||||
var/datum/announcement/announcement = new
|
||||
|
||||
/obj/machinery/requests_console/power_change()
|
||||
@@ -176,7 +176,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
if (Console.department == department)
|
||||
Console.newmessagepriority = 0
|
||||
Console.icon_state = "req_comp0"
|
||||
Console.luminosity = 1
|
||||
Console.set_light(1)
|
||||
newmessagepriority = 0
|
||||
icon_state = "req_comp0"
|
||||
for(var/msg in messages)
|
||||
@@ -320,7 +320,7 @@ var/list/obj/machinery/requests_console/allConsoles = list()
|
||||
Console.messages += "<B>Message from <A href='?src=\ref[Console];write=[ckey(department)]'>[department]</A></FONT></B><BR>[message]"
|
||||
|
||||
screen = 6
|
||||
Console.luminosity = 2
|
||||
Console.set_light(2)
|
||||
messages += "<B>Message sent to [dpt]</B><BR>[message]"
|
||||
else
|
||||
for (var/mob/O in hearers(4, src.loc))
|
||||
|
||||
@@ -1004,8 +1004,8 @@
|
||||
set popup_menu = 0
|
||||
if(usr!=occupant) return
|
||||
lights = !lights
|
||||
if(lights) SetLuminosity(luminosity + lights_power)
|
||||
else SetLuminosity(luminosity - lights_power)
|
||||
if(lights) set_light(light_range + lights_power)
|
||||
else set_light(light_range - lights_power)
|
||||
src.occupant_message("Toggled lights [lights?"on":"off"].")
|
||||
log_message("Toggled lights [lights?"on":"off"].")
|
||||
return
|
||||
|
||||
@@ -164,7 +164,7 @@
|
||||
name = "purple sac"
|
||||
desc = "Weird purple octopus-like thing."
|
||||
layer = 3
|
||||
luminosity = NODERANGE
|
||||
light_range = NODERANGE
|
||||
var/node_range = NODERANGE
|
||||
|
||||
/obj/effect/alien/weeds/node/New()
|
||||
|
||||
@@ -58,7 +58,7 @@
|
||||
density = 0
|
||||
anchored = 1
|
||||
layer = 2
|
||||
luminosity = 1
|
||||
light_range = 1
|
||||
icon = 'icons/effects/effects.dmi'
|
||||
icon_state = "greenglow"
|
||||
|
||||
|
||||
@@ -244,7 +244,7 @@ steam.start() -- spawns the effect
|
||||
/obj/effect/effect/smoke/illumination/New(var/newloc, var/brightness=15, var/lifetime=10)
|
||||
time_to_live=lifetime
|
||||
..()
|
||||
SetLuminosity(brightness)
|
||||
set_light(brightness)
|
||||
|
||||
/////////////////////////////////////////////
|
||||
// Bad smoke
|
||||
|
||||
@@ -37,4 +37,4 @@
|
||||
name = "Bluespace"
|
||||
icon = 'icons/turf/space.dmi'
|
||||
icon_state = "bluespacify"
|
||||
layer = LIGHTING_LAYER
|
||||
layer = 10
|
||||
|
||||
@@ -68,8 +68,8 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
|
||||
message_admins("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ([epicenter.x],[epicenter.y],[epicenter.z]) (<A HREF='?_src_=holder;adminplayerobservecoodjump=1;X=[epicenter.x];Y=[epicenter.y];Z=[epicenter.z]'>JMP</a>)")
|
||||
log_game("Explosion with size ([devastation_range], [heavy_impact_range], [light_impact_range]) in area [epicenter.loc.name] ")
|
||||
|
||||
var/lighting_controller_was_processing = lighting_controller.processing //Pause the lighting updates for a bit
|
||||
lighting_controller.processing = 0
|
||||
// var/lighting_controller_was_processing = lighting_controller.processing //Pause the lighting updates for a bit
|
||||
// lighting_controller.processing = 0
|
||||
|
||||
|
||||
var/approximate_intensity = (devastation_range * 3) + (heavy_impact_range * 2) + light_impact_range
|
||||
@@ -87,8 +87,8 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
|
||||
var/y0 = epicenter.y
|
||||
var/z0 = epicenter.z
|
||||
|
||||
for(var/turf/T in range(epicenter, max_range))
|
||||
var/dist = cheap_pythag(T.x - x0,T.y - y0)
|
||||
for(var/turf/T in trange(max_range, epicenter))
|
||||
var/dist = sqrt((T.x - x0)**2 + (T.y - y0)**2)
|
||||
|
||||
if(dist < devastation_range) dist = 1
|
||||
else if(dist < heavy_impact_range) dist = 2
|
||||
@@ -99,7 +99,7 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
|
||||
if(T)
|
||||
for(var/atom_movable in T.contents) //bypass type checking since only atom/movable can be contained by turfs anyway
|
||||
var/atom/movable/AM = atom_movable
|
||||
if(AM) AM.ex_act(dist)
|
||||
if(AM && AM.simulated) AM.ex_act(dist)
|
||||
|
||||
var/took = (world.timeofday-start)/10
|
||||
//You need to press the DebugGame verb to see these now....they were getting annoying and we've collected a fair bit of data. Just -test- changes to explosion code using this please so we can compare
|
||||
@@ -113,7 +113,7 @@ proc/explosion(turf/epicenter, devastation_range, heavy_impact_range, light_impa
|
||||
|
||||
sleep(8)
|
||||
|
||||
if(!lighting_controller.processing) lighting_controller.processing = lighting_controller_was_processing
|
||||
// if(!lighting_controller.processing) lighting_controller.processing = lighting_controller_was_processing
|
||||
if(!powernet_rebuild_was_deferred_already && defer_powernet_rebuild)
|
||||
makepowernets()
|
||||
defer_powernet_rebuild = 0
|
||||
|
||||
@@ -121,7 +121,6 @@ move an amendment</a> to the drawing.</p>
|
||||
return
|
||||
var/area/A = new
|
||||
A.name = str
|
||||
A.tagbase = "[A.type]_[md5(str)]" // without this dynamic light system ruin everithing
|
||||
//var/ma
|
||||
//ma = A.master ? "[A.master]" : "(null)"
|
||||
//world << "DEBUG: create_area: <br>A.name=[A.name]<br>A.tag=[A.tag]<br>A.master=[ma]"
|
||||
@@ -132,9 +131,6 @@ move an amendment</a> to the drawing.</p>
|
||||
move_turfs_to_area(turfs, A)
|
||||
|
||||
A.always_unpowered = 0
|
||||
for(var/turf/T in A.contents)
|
||||
T.lighting_changed = 1
|
||||
lighting_controller.changed_turfs += T
|
||||
|
||||
spawn(5)
|
||||
//ma = A.master ? "[A.master]" : "(null)"
|
||||
|
||||
@@ -308,15 +308,6 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
/*
|
||||
* The Actual PDA
|
||||
*/
|
||||
/obj/item/device/pda/pickup(mob/user)
|
||||
if(fon)
|
||||
SetLuminosity(0)
|
||||
user.SetLuminosity(user.luminosity + f_lum)
|
||||
|
||||
/obj/item/device/pda/dropped(mob/user)
|
||||
if(fon)
|
||||
user.SetLuminosity(user.luminosity - f_lum)
|
||||
SetLuminosity(f_lum)
|
||||
|
||||
/obj/item/device/pda/New()
|
||||
..()
|
||||
@@ -644,12 +635,10 @@ var/global/list/obj/item/device/pda/PDAs = list()
|
||||
if("Light")
|
||||
if(fon)
|
||||
fon = 0
|
||||
if(src in U.contents) U.SetLuminosity(U.luminosity - f_lum)
|
||||
else SetLuminosity(0)
|
||||
set_light(0)
|
||||
else
|
||||
fon = 1
|
||||
if(src in U.contents) U.SetLuminosity(U.luminosity + f_lum)
|
||||
else SetLuminosity(f_lum)
|
||||
set_light(f_lum)
|
||||
if("Medical Scan")
|
||||
if(scanmode == 1)
|
||||
scanmode = 0
|
||||
|
||||
@@ -18,24 +18,17 @@
|
||||
..()
|
||||
if(on)
|
||||
icon_state = "[initial(icon_state)]-on"
|
||||
SetLuminosity(brightness_on)
|
||||
set_light(brightness_on)
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
|
||||
/obj/item/device/flashlight/proc/update_brightness(var/mob/user = null)
|
||||
if(on)
|
||||
icon_state = "[initial(icon_state)]-on"
|
||||
if(loc == user)
|
||||
user.SetLuminosity(user.luminosity + brightness_on)
|
||||
else if(isturf(loc))
|
||||
SetLuminosity(brightness_on)
|
||||
set_light(brightness_on)
|
||||
else
|
||||
icon_state = initial(icon_state)
|
||||
if(loc == user)
|
||||
user.SetLuminosity(user.luminosity - brightness_on)
|
||||
else if(isturf(loc))
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
|
||||
/obj/item/device/flashlight/attack_self(mob/user)
|
||||
if(!isturf(user.loc))
|
||||
@@ -88,19 +81,6 @@
|
||||
else
|
||||
return ..()
|
||||
|
||||
|
||||
/obj/item/device/flashlight/pickup(mob/user)
|
||||
if(on)
|
||||
user.SetLuminosity(user.luminosity + brightness_on)
|
||||
SetLuminosity(0)
|
||||
|
||||
|
||||
/obj/item/device/flashlight/dropped(mob/user)
|
||||
if(on)
|
||||
user.SetLuminosity(user.luminosity - brightness_on)
|
||||
SetLuminosity(brightness_on)
|
||||
|
||||
|
||||
/obj/item/device/flashlight/pen
|
||||
name = "penlight"
|
||||
desc = "A pen-sized light, used by medical staff."
|
||||
@@ -217,7 +197,7 @@
|
||||
on = 1 //Bio-luminesence has one setting, on.
|
||||
|
||||
/obj/item/device/flashlight/slime/New()
|
||||
SetLuminosity(brightness_on)
|
||||
set_light(brightness_on)
|
||||
spawn(1) //Might be sloppy, but seems to be necessary to prevent further runtimes and make these work as intended... don't judge me!
|
||||
update_brightness()
|
||||
icon_state = initial(icon_state)
|
||||
|
||||
@@ -140,7 +140,9 @@
|
||||
var/obj/item/weapon/light/L1 = new target.light_type(target.loc)
|
||||
L1.status = target.status
|
||||
L1.rigged = target.rigged
|
||||
L1.brightness = target.brightness
|
||||
L1.brightness_range = target.brightness_range
|
||||
L1.brightness_power = target.brightness_power
|
||||
L1.brightness_color = target.brightness_color
|
||||
L1.switchcount = target.switchcount
|
||||
target.switchcount = 0
|
||||
L1.update()
|
||||
@@ -153,7 +155,9 @@
|
||||
target.status = L2.status
|
||||
target.switchcount = L2.switchcount
|
||||
target.rigged = emagged
|
||||
target.brightness = L2.brightness
|
||||
target.brightness_range = L2.brightness_range
|
||||
target.brightness_power = L2.brightness_power
|
||||
target.brightness_color = L2.brightness_color
|
||||
target.on = target.has_power()
|
||||
target.update()
|
||||
qdel(L2)
|
||||
|
||||
@@ -52,7 +52,7 @@
|
||||
anchored = 0
|
||||
mode = 0
|
||||
src.visible_message("<span class='notice'>[user] detaches [src] from the cable!</span>")
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
icon_state = "powersink0"
|
||||
|
||||
return
|
||||
@@ -74,7 +74,7 @@
|
||||
if(2) //This switch option wasn't originally included. It exists now. --NeoFite
|
||||
src.visible_message("<span class='notice'>[user] deactivates [src]!</span>")
|
||||
mode = 1
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
icon_state = "powersink0"
|
||||
processing_objects.Remove(src)
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
if(!PN)
|
||||
return
|
||||
|
||||
SetLuminosity(12)
|
||||
set_light(12)
|
||||
PN.trigger_warning()
|
||||
// found a powernet, so drain up to max power from it
|
||||
drained = PN.draw_power(drain_rate)
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
//src.damtype = "fire"
|
||||
for(var/mob/O in viewers(usr, null))
|
||||
O.show_message(flavor_text, 1)
|
||||
SetLuminosity(CANDLE_LUM)
|
||||
set_light(CANDLE_LUM)
|
||||
processing_objects.Add(src)
|
||||
|
||||
|
||||
@@ -66,22 +66,8 @@
|
||||
var/turf/T = loc
|
||||
T.hotspot_expose(700, 5)
|
||||
|
||||
|
||||
/obj/item/weapon/flame/candle/attack_self(mob/user as mob)
|
||||
if(lit)
|
||||
lit = 0
|
||||
update_icon()
|
||||
SetLuminosity(0)
|
||||
user.SetLuminosity(user.luminosity - CANDLE_LUM)
|
||||
|
||||
|
||||
/obj/item/weapon/flame/candle/pickup(mob/user)
|
||||
if(lit)
|
||||
SetLuminosity(0)
|
||||
user.SetLuminosity(user.luminosity + CANDLE_LUM)
|
||||
|
||||
|
||||
/obj/item/weapon/flame/candle/dropped(mob/user)
|
||||
if(lit)
|
||||
user.SetLuminosity(user.luminosity - CANDLE_LUM)
|
||||
SetLuminosity(CANDLE_LUM)
|
||||
set_light(0)
|
||||
|
||||
@@ -456,7 +456,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
user.apply_damage(2,BURN,"r_hand")
|
||||
user.visible_message("<span class='notice'>After a few attempts, [user] manages to light the [src], they however burn their finger in the process.</span>")
|
||||
|
||||
user.SetLuminosity(user.luminosity + 2)
|
||||
set_light(2)
|
||||
processing_objects.Add(src)
|
||||
else
|
||||
lit = 0
|
||||
@@ -467,7 +467,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
else
|
||||
user.visible_message("<span class='notice'>[user] quietly shuts off the [src].")
|
||||
|
||||
user.SetLuminosity(user.luminosity - 2)
|
||||
set_light(0)
|
||||
processing_objects.Remove(src)
|
||||
else
|
||||
return ..()
|
||||
@@ -496,17 +496,3 @@ CIGARETTE PACKETS ARE IN FANCY.DM
|
||||
if(location)
|
||||
location.hotspot_expose(700, 5)
|
||||
return
|
||||
|
||||
|
||||
/obj/item/weapon/flame/lighter/pickup(mob/user)
|
||||
if(lit)
|
||||
SetLuminosity(0)
|
||||
user.SetLuminosity(user.luminosity+2)
|
||||
return
|
||||
|
||||
|
||||
/obj/item/weapon/flame/lighter/dropped(mob/user)
|
||||
if(lit)
|
||||
user.SetLuminosity(user.luminosity-2)
|
||||
SetLuminosity(2)
|
||||
return
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
var/list/climbers = list()
|
||||
|
||||
/obj/structure/Destroy()
|
||||
if(opacity)
|
||||
UpdateAffectingLights()
|
||||
if(parts)
|
||||
new parts(loc)
|
||||
..()
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
flick("[mineral]fwall_opening", src)
|
||||
sleep(15)
|
||||
src.density = 0
|
||||
SetOpacity(0)
|
||||
set_opacity(0)
|
||||
opening = 0
|
||||
else
|
||||
opening = 1
|
||||
@@ -70,7 +70,7 @@
|
||||
icon_state = "[mineral]0"
|
||||
density = 1
|
||||
sleep(15)
|
||||
SetOpacity(1)
|
||||
set_opacity(1)
|
||||
src.relativewall()
|
||||
opening = 0
|
||||
|
||||
@@ -186,7 +186,7 @@
|
||||
flick("frwall_opening", src)
|
||||
sleep(15)
|
||||
density = 0
|
||||
SetOpacity(0)
|
||||
set_opacity(0)
|
||||
opening = 0
|
||||
else
|
||||
opening = 1
|
||||
@@ -194,7 +194,7 @@
|
||||
flick("frwall_closing", src)
|
||||
density = 1
|
||||
sleep(15)
|
||||
SetOpacity(1)
|
||||
set_opacity(1)
|
||||
relativewall()
|
||||
opening = 0
|
||||
|
||||
|
||||
@@ -168,7 +168,7 @@
|
||||
/obj/structure/mineral_door/uranium
|
||||
mineralType = "uranium"
|
||||
hardness = 3
|
||||
luminosity = 2
|
||||
light_range = 2
|
||||
|
||||
/obj/structure/mineral_door/sandstone
|
||||
mineralType = "sandstone"
|
||||
|
||||
@@ -479,10 +479,10 @@
|
||||
/obj/structure/window/reinforced/polarized/proc/toggle()
|
||||
if(opacity)
|
||||
animate(src, color="#FFFFFF", time=5)
|
||||
SetOpacity(0)
|
||||
set_opacity(0)
|
||||
else
|
||||
animate(src, color="#222222", time=5)
|
||||
SetOpacity(1)
|
||||
set_opacity(1)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -26,18 +26,14 @@ var/list/mechtoys = list(
|
||||
/obj/item/weapon/paper/manifest
|
||||
name = "supply manifest"
|
||||
|
||||
/area/supply/station //DO NOT TURN THE lighting_use_dynamic STUFF ON FOR SHUTTLES. IT BREAKS THINGS.
|
||||
/area/supply/station
|
||||
name = "Supply Shuttle"
|
||||
icon_state = "shuttle3"
|
||||
luminosity = 1
|
||||
lighting_use_dynamic = 0
|
||||
requires_power = 0
|
||||
|
||||
/area/supply/dock //DO NOT TURN THE lighting_use_dynamic STUFF ON FOR SHUTTLES. IT BREAKS THINGS.
|
||||
/area/supply/dock
|
||||
name = "Supply Shuttle"
|
||||
icon_state = "shuttle3"
|
||||
luminosity = 1
|
||||
lighting_use_dynamic = 0
|
||||
requires_power = 0
|
||||
|
||||
/obj/structure/plasticflaps //HOW DO YOU CALL THOSE THINGS ANYWAY
|
||||
|
||||
@@ -133,19 +133,19 @@ turf/simulated/floor/proc/update_icon()
|
||||
switch(get_lightfloor_state())
|
||||
if(LIGHTFLOOR_STATE_OK)
|
||||
icon_state = "light_on"
|
||||
SetLuminosity(5)
|
||||
set_light(5)
|
||||
if(LIGHTFLOOR_STATE_FLICKER)
|
||||
var/num = pick("1","2","3","4")
|
||||
icon_state = "light_on_flicker[num]"
|
||||
SetLuminosity(5)
|
||||
set_light(5)
|
||||
if(LIGHTFLOOR_STATE_BREAKING)
|
||||
icon_state = "light_on_broken"
|
||||
SetLuminosity(5)
|
||||
set_light(5)
|
||||
if(LIGHTFLOOR_STATE_BROKEN)
|
||||
icon_state = "light_off"
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
else
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
icon_state = "light_off"
|
||||
else if(is_grass_floor())
|
||||
if(!broken && !burnt)
|
||||
@@ -339,7 +339,7 @@ turf/simulated/floor/proc/update_icon()
|
||||
|
||||
if(!floor_type) return
|
||||
icon_plating = "plating"
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
floor_type = null
|
||||
intact = 0
|
||||
broken = 0
|
||||
@@ -355,7 +355,7 @@ turf/simulated/floor/proc/update_icon()
|
||||
broken = 0
|
||||
burnt = 0
|
||||
intact = 1
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
if(T)
|
||||
if(istype(T,/obj/item/stack/tile/plasteel))
|
||||
floor_type = T.type
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
/turf/simulated/floor/light
|
||||
name = "Light floor"
|
||||
luminosity = 5
|
||||
light_range = 5
|
||||
icon_state = "light_on"
|
||||
floor_type = /obj/item/stack/tile/light
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ var/list/accessible_z_levels = list("1" = 5, "3" = 10, "4" = 15, "5" = 10, "6" =
|
||||
icon = 'icons/turf/space.dmi'
|
||||
name = "\proper space"
|
||||
icon_state = "0"
|
||||
dynamic_lighting = 0
|
||||
|
||||
temperature = T20C
|
||||
thermal_conductivity = OPEN_HEAT_TRANSFER_COEFFICIENT
|
||||
@@ -20,9 +21,9 @@ var/list/accessible_z_levels = list("1" = 5, "3" = 10, "4" = 15, "5" = 10, "6" =
|
||||
if(!config.starlight)
|
||||
return
|
||||
if(locate(/turf/simulated) in orange(src,1))
|
||||
SetLuminosity(config.starlight)
|
||||
set_light(config.starlight)
|
||||
else
|
||||
SetLuminosity(0)
|
||||
set_light(0)
|
||||
|
||||
/turf/space/attackby(obj/item/C as obj, mob/user as mob)
|
||||
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
// holy water
|
||||
var/holy = 0
|
||||
|
||||
var/dynamic_lighting = 1
|
||||
|
||||
/turf/New()
|
||||
..()
|
||||
for(var/atom/movable/AM as mob|obj in src)
|
||||
@@ -218,8 +220,10 @@
|
||||
return W
|
||||
///// Z-Level Stuff
|
||||
|
||||
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
|
||||
var/obj/fire/old_fire = fire
|
||||
var/old_opacity = opacity
|
||||
var/old_dynamic_lighting = dynamic_lighting
|
||||
var/list/old_affecting_lights = affecting_lights
|
||||
|
||||
//world << "Replacing [src.type] with [N]"
|
||||
|
||||
@@ -237,11 +241,6 @@
|
||||
var/turf/simulated/W = new N( locate(src.x, src.y, src.z) )
|
||||
//W.Assimilate_Air()
|
||||
|
||||
W.lighting_lumcount += old_lumcount
|
||||
if((old_lumcount != W.lighting_lumcount) || (loc.name != "Space" && force_lighting_update))
|
||||
W.lighting_changed = 1
|
||||
lighting_controller.changed_turfs += W
|
||||
|
||||
if(old_fire)
|
||||
fire = old_fire
|
||||
|
||||
@@ -258,15 +257,11 @@
|
||||
S.update_starlight()
|
||||
|
||||
W.levelupdate()
|
||||
return W
|
||||
. = W
|
||||
|
||||
else
|
||||
|
||||
var/turf/W = new N( locate(src.x, src.y, src.z) )
|
||||
W.lighting_lumcount += old_lumcount
|
||||
if((old_lumcount != W.lighting_lumcount) || (loc.name != "Space" && force_lighting_update))
|
||||
W.lighting_changed = 1
|
||||
lighting_controller.changed_turfs += W
|
||||
|
||||
if(old_fire)
|
||||
old_fire.RemoveFire()
|
||||
@@ -281,7 +276,16 @@
|
||||
S.update_starlight()
|
||||
|
||||
W.levelupdate()
|
||||
return W
|
||||
. = W
|
||||
|
||||
affecting_lights = old_affecting_lights
|
||||
if((old_opacity != opacity) || (dynamic_lighting != old_dynamic_lighting) || force_lighting_update)
|
||||
reconsider_lights()
|
||||
if(dynamic_lighting != old_dynamic_lighting)
|
||||
if(dynamic_lighting)
|
||||
lighting_build_overlays()
|
||||
else
|
||||
lighting_clear_overlays()
|
||||
|
||||
|
||||
//Commented out by SkyMarshal 5/10/13 - If you are patching up space, it should be vacuum.
|
||||
|
||||
@@ -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]
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,10 +277,9 @@
|
||||
|
||||
// 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)
|
||||
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)
|
||||
@@ -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))
|
||||
|
||||
@@ -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,11 +596,10 @@
|
||||
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)
|
||||
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"
|
||||
|
||||
@@ -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)
|
||||
set_light(0)
|
||||
return
|
||||
67
code/modules/lighting/__lighting_docs.dm
Normal file
67
code/modules/lighting/__lighting_docs.dm
Normal 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
code/modules/lighting/_lighting_defs.dm
Normal file
10
code/modules/lighting/_lighting_defs.dm
Normal 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
code/modules/lighting/light_source.dm
Normal file
169
code/modules/lighting/light_source.dm
Normal 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
code/modules/lighting/lighting_atom.dm
Normal file
81
code/modules/lighting/lighting_atom.dm
Normal 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
code/modules/lighting/lighting_overlay.dm
Normal file
48
code/modules/lighting/lighting_overlay.dm
Normal 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
code/modules/lighting/lighting_process.dm
Normal file
29
code/modules/lighting/lighting_process.dm
Normal 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
code/modules/lighting/lighting_system.dm
Normal file
47
code/modules/lighting/lighting_system.dm
Normal 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
code/modules/lighting/lighting_turf.dm
Normal file
29
code/modules/lighting/lighting_turf.dm
Normal 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
code/modules/lighting/~lighting_undefs.dm
Normal file
10
code/modules/lighting/~lighting_undefs.dm
Normal 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
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -110,13 +110,13 @@
|
||||
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()
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -954,3 +954,5 @@ var/list/be_special_flags = list(
|
||||
#define LANGUAGE_ROOTSPEAK "Rootspeak"
|
||||
#define LANGUAGE_TRADEBAND "Tradeband"
|
||||
#define LANGUAGE_GUTTER "Gutter"
|
||||
|
||||
#define CLAMP01(x) max(0, min(1, x))
|
||||
|
||||
BIN
icons/effects/lighting_overlay.dmi
Normal file
BIN
icons/effects/lighting_overlay.dmi
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 260 B |
Reference in New Issue
Block a user