New lighting, it's essentially just the old DAL system with a queue.

Comments for lighting:
	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.

	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 is a hardcoded maximum luminosity. This is to discourage coders using large luminosity values
	for dynamic lighting, as the cost of lighting grows rapidly at large luminosity levels (especially when changing opacity
	at runtime)

	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 hopefully it's worth the hassle for the greater control we
	gain. Besides, there are far far worse uses of needless lists in the game, it'd be worth pruning some of them to offset
	costs.

	Known Issues/TODO:
		admin-spawned turfs will have broken lumcounts. Not willing to fix it at this moment
		mob luminosity will be lower than expected when one of multiple light sources is dropped after exceeding the maximum luminosity
		Shuttles still do not have support for dynamic lighting (I hope to fix this at some point)
		No directional lighting support. Fairly easy to add this and the code is ready.
		When opening airlocks etc, lighting does not always update to account for the change in opacity.

Explosions now cause lighting to cease processing temporarily.

Moved controller datums to the code/controllers directory. I plan on standardising them.
"Master","Ticker","Lighting","Air","Jobs","Sun","Radio","Supply Shuttle","Emergency Shuttle","Configuration","pAI" controller datums can be accessed via the debug controller verb (used to be the debug master controller verb)
Supply shuttle now uses a controller datum. Shuttles tend to arrive up to 30 seconds late, this is not a bug.

git-svn-id: http://tgstation13.googlecode.com/svn/trunk@4537 316c924e-a436-60f5-8080-3fe189b3f50e
This commit is contained in:
elly1989@rocketmail.com
2012-08-25 16:06:57 +00:00
parent 676079cdba
commit 6e274cd395
89 changed files with 1519 additions and 2245 deletions

View File

@@ -222,7 +222,7 @@
//verbs += /proc/togglebuildmode --Merged with view variables
//verbs += /client/proc/cmd_modify_object_variables --Merged with view variables
verbs += /client/proc/togglebuildmodeself
verbs += /client/proc/debug_master_controller
verbs += /client/proc/debug_controller
else return
//Game Admin
@@ -243,7 +243,7 @@
verbs += /client/proc/make_sound
verbs += /client/proc/play_local_sound
verbs += /client/proc/send_space_ninja
verbs += /client/proc/restartcontroller //Can call via aproccall --I_hate_easy_things.jpg, Mport --Agouri
verbs += /client/proc/restart_controller //Can call via aproccall --I_hate_easy_things.jpg, Mport --Agouri
verbs += /client/proc/Blobize //I need to remember to move/remove this later
verbs += /client/proc/Blobcount //I need to remember to move/remove this later
verbs += /client/proc/toggle_clickproc //TODO ERRORAGE (Temporary proc while the new clickproc is being tested)
@@ -388,7 +388,7 @@
verbs -= /client/proc/air_report
verbs -= /client/proc/cmd_admin_say
verbs -= /client/proc/cmd_admin_gib_self
verbs -= /client/proc/restartcontroller
verbs -= /client/proc/restart_controller
verbs -= /client/proc/play_local_sound
verbs -= /client/proc/enable_debug_verbs
verbs -= /client/proc/toggleprayers
@@ -429,7 +429,7 @@
//verbs -= /client/proc/cmd_switch_radio --removed because tcommsat is staying
verbs -= /client/proc/togglebuildmodeself
verbs -= /client/proc/kill_airgroup
verbs -= /client/proc/debug_master_controller
verbs -= /client/proc/debug_controller
verbs -= /client/proc/check_ai_laws
verbs -= /client/proc/cmd_debug_mob_lists
return

View File

@@ -213,7 +213,7 @@
if(new_value == null) return
if(variable=="luminosity")
O.sd_SetLuminosity(new_value)
O.SetLuminosity(new_value)
else
O.vars[variable] = new_value
@@ -222,7 +222,7 @@
for(var/mob/M in mob_list)
if ( istype(M , O.type) )
if(variable=="luminosity")
M.sd_SetLuminosity(new_value)
M.SetLuminosity(new_value)
else
M.vars[variable] = O.vars[variable]
@@ -230,7 +230,7 @@
for(var/obj/A in world)
if ( istype(A , O.type) )
if(variable=="luminosity")
A.sd_SetLuminosity(new_value)
A.SetLuminosity(new_value)
else
A.vars[variable] = O.vars[variable]
@@ -238,7 +238,7 @@
for(var/turf/A in world)
if ( istype(A , O.type) )
if(variable=="luminosity")
A.sd_SetLuminosity(new_value)
A.SetLuminosity(new_value)
else
A.vars[variable] = O.vars[variable]
@@ -247,7 +247,7 @@
for(var/mob/M in mob_list)
if (M.type == O.type)
if(variable=="luminosity")
M.sd_SetLuminosity(new_value)
M.SetLuminosity(new_value)
else
M.vars[variable] = O.vars[variable]
@@ -255,7 +255,7 @@
for(var/obj/A in world)
if (A.type == O.type)
if(variable=="luminosity")
A.sd_SetLuminosity(new_value)
A.SetLuminosity(new_value)
else
A.vars[variable] = O.vars[variable]
@@ -263,7 +263,7 @@
for(var/turf/A in world)
if (A.type == O.type)
if(variable=="luminosity")
A.sd_SetLuminosity(new_value)
A.SetLuminosity(new_value)
else
A.vars[variable] = O.vars[variable]

View File

@@ -458,7 +458,7 @@ var/list/forbidden_varedit_object_types = list(
if(variable=="luminosity")
var/var_new = input("Enter new number:","Num",O.vars[variable]) as null|num
if(var_new == null) return
O.sd_SetLuminosity(var_new)
O.SetLuminosity(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

View File

@@ -19,22 +19,20 @@
icon_state = "hardhat[on]_[color]"
item_state = "hardhat[on]_[color]"
if(on)
user.total_luminosity += brightness_on
else
user.total_luminosity -= brightness_on
if(on) user.SetLuminosity(user.luminosity + brightness_on)
else user.SetLuminosity(user.luminosity - brightness_on)
pickup(mob/user)
if(on)
user.total_luminosity += brightness_on
user.UpdateLuminosity()
src.sd_SetLuminosity(0)
user.SetLuminosity(user.luminosity + brightness_on)
// user.UpdateLuminosity() //TODO: Carn
SetLuminosity(0)
dropped(mob/user)
if(on)
user.total_luminosity -= brightness_on
user.UpdateLuminosity()
src.sd_SetLuminosity(brightness_on)
user.SetLuminosity(user.luminosity - brightness_on)
// user.UpdateLuminosity()
SetLuminosity(brightness_on)
/obj/item/clothing/head/hardhat/orange

View File

@@ -133,22 +133,20 @@
icon_state = "hardhat[on]_[color]"
item_state = "hardhat[on]_[color]"
if(on)
user.total_luminosity += brightness_on
else
user.total_luminosity -= brightness_on
if(on) user.SetLuminosity(user.luminosity + brightness_on)
else user.SetLuminosity(user.luminosity - brightness_on)
pickup(mob/user)
if(on)
user.total_luminosity += brightness_on
user.UpdateLuminosity()
src.sd_SetLuminosity(0)
user.SetLuminosity(user.luminosity + brightness_on)
// user.UpdateLuminosity()
SetLuminosity(0)
dropped(mob/user)
if(on)
user.total_luminosity -= brightness_on
user.UpdateLuminosity()
src.sd_SetLuminosity(brightness_on)
user.SetLuminosity(user.luminosity - brightness_on)
// user.UpdateLuminosity()
SetLuminosity(brightness_on)
/*
* Kitty ears

View File

@@ -19,22 +19,20 @@
icon_state = "rig[on]-[color]"
// item_state = "rig[on]-[color]"
if(on)
user.total_luminosity += brightness_on
else
user.total_luminosity -= brightness_on
if(on) user.SetLuminosity(user.luminosity + brightness_on)
else user.SetLuminosity(user.luminosity - brightness_on)
pickup(mob/user)
if(on)
user.total_luminosity += brightness_on
user.UpdateLuminosity()
src.sd_SetLuminosity(0)
user.SetLuminosity(user.luminosity + brightness_on)
// user.UpdateLuminosity()
SetLuminosity(0)
dropped(mob/user)
if(on)
user.total_luminosity -= brightness_on
user.UpdateLuminosity()
src.sd_SetLuminosity(brightness_on)
user.SetLuminosity(user.luminosity - brightness_on)
// user.UpdateLuminosity()
SetLuminosity(brightness_on)
/obj/item/clothing/suit/space/rig
name = "engineering hardsuit"

View File

@@ -185,17 +185,16 @@
shroom.pixel_x = 0
shroom.pixel_y = 0
W = new /turf/simulated/floor/plating/airless/asteroid( locate(src.x, src.y, src.z) )
W.dir = old_dir
W.fullUpdateMineralOverlays()
var/old_lumcount = lighting_lumcount - initial(lighting_lumcount)
W = new /turf/simulated/floor/plating/airless/asteroid(src)
W.lighting_lumcount += old_lumcount
if(old_lumcount != W.lighting_lumcount)
W.lighting_changed = 1
lighting_controller.changed_turfs += W
/*
W.icon_old = old_icon
if(old_icon) W.icon_state = old_icon
*/
W.opacity = 1
W.sd_SetOpacity(0)
W.sd_LumReset()
W.dir = old_dir
W.fullUpdateMineralOverlays()
W.levelupdate()
return W

View File

@@ -87,9 +87,6 @@
//stuff in the stomach
handle_stomach()
//Flashlights and such
UpdateLuminosity()
//Status updates, death etc.
handle_regular_status_updates() //TODO: optimise ~Carn
update_canmove()
@@ -745,13 +742,16 @@
if(dna && dna.mutantrace == "plant") //couldn't think of a better place to place it, since it handles nutrition -- Urist
var/light_amount = 0 //how much light there is in the place, affects receiving nutrition and healing
if(istype(loc,/turf)) //else, there's considered to be no light
light_amount = min(10,loc:sd_lumcount) - 5 //hardcapped so it's not abused by having a ton of flashlights
if(istype(loc,/turf/simulated/shuttle))//Now not only will potatomen not starve on the shuttle, they will actually be fed
light_amount = 5
if(nutrition < 500) //so they can't store nutrition to survive without light forever
nutrition += light_amount
if(light_amount > 0) //if there's enough light, heal
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
nutrition += light_amount
if(nutrition > 500)
nutrition = 500
if(light_amount > 2) //if there's enough light, heal
heal_overall_damage(1,1)
adjustToxLoss(-1)
adjustOxyLoss(-1)
@@ -1150,7 +1150,7 @@
//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.sd_lumcount)
if(!currentTurf.lighting_lumcount)
playsound_local(src,pick(scarySounds),50, 1, -1)
proc/handle_virus_updates()

View File

@@ -53,9 +53,6 @@
if(environment) // More error checking -- TLE
handle_environment(environment)
//Flashlights and such
UpdateLuminosity()
//Status updates, death etc.
handle_regular_status_updates()
update_canmove()

View File

@@ -429,12 +429,13 @@
/mob/living/silicon/ai/reset_view(atom/A)
if(current)
current.sd_SetLuminosity(0)
current.SetLuminosity(0)
if(istype(A,/obj/machinery/camera))
current = A
..()
if(istype(A,/obj/machinery/camera))
A.sd_SetLuminosity(camera_light_on * AI_CAMERA_LUMINOSITY)
if(camera_light_on) A.SetLuminosity(AI_CAMERA_LUMINOSITY)
else A.SetLuminosity(0)
/mob/living/silicon/ai/proc/switchCamera(var/obj/machinery/camera/C)
@@ -641,7 +642,7 @@
src << "Camera lights [camera_light_on ? "activated" : "deactivated"]."
if(!camera_light_on)
if(src.current)
src.current.sd_SetLuminosity(0)
src.current.SetLuminosity(0)
else
src.lightNearbyCamera()
@@ -656,16 +657,16 @@
// I have to use range instead of view or the darkness gets in the way.
var/camera = near_range_camera(src.eyeobj)
if(camera && src.current != camera)
src.current.sd_SetLuminosity(0)
src.current.SetLuminosity(0)
src.current = camera
src.current.sd_SetLuminosity(lum)
src.current.SetLuminosity(lum)
else if(isnull(camera))
src.current.sd_SetLuminosity(0)
src.current.SetLuminosity(0)
src.current = null
camera_light_on = world.timeofday + 1 * 10 // Update the light every 2 seconds.
else
src.current = near_range_camera(src.eyeobj)
if(src.current) src.current.sd_SetLuminosity(lum)
if(src.current) src.current.SetLuminosity(lum)
#undef AI_CAMERA_LUMINOSITY

View File

@@ -90,7 +90,7 @@
for(var/turf/t in visRemoved)
if(t in obscuredTurfs)
if(!t.obscured)
t.obscured = image('effects/cameravis.dmi', t, "black", 15)
t.obscured = image('icons/effects/cameravis.dmi', t, "black", 15)
obscured += t.obscured
for(var/mob/aiEye/m in seenby)
@@ -129,7 +129,7 @@
for(var/turf/t in obscuredTurfs)
if(!t.obscured)
t.obscured = image('effects/cameravis.dmi', t, "black", 15)
t.obscured = image('icons/effects/cameravis.dmi', t, "black", 15)
obscured += t.obscured
#undef UPDATE_BUFFER

View File

@@ -62,7 +62,7 @@
if(src.can_use())
cameranet.addCamera(src)
else
src.sd_SetLuminosity(0)
src.SetLuminosity(0)
cameranet.removeCamera(src)
/obj/machinery/camera/New()

View File

@@ -13,7 +13,6 @@
handle_regular_status_updates()
if(client)
UpdateLuminosity()
handle_regular_hud_updates()
update_items()
if (src.stat != DEAD) //still using power

View File

@@ -78,7 +78,7 @@
emote_hear = list("barks", "woofs", "yaps","pants")
emote_see = list("shakes its head", "shivers")
desc = "It's a corgi."
src.sd_SetLuminosity(0)
SetLuminosity(0)
inventory_head.loc = src.loc
inventory_head = null
else
@@ -214,7 +214,7 @@
name = "Rudolph the Red-Nosed Corgi"
emote_hear = list("barks christmas songs", "yaps")
desc = "He has a very shiny nose."
src.sd_SetLuminosity(6)
SetLuminosity(6)
if(/obj/item/clothing/head/soft)
name = "Corgi Tech [real_name]"
speak = list("Needs a stamp!", "Request DENIED!", "Fill these out in triplicate!")

View File

@@ -505,11 +505,6 @@ var/list/slot_equipment_priority = list( \
// ..()
return
/mob/proc/UpdateLuminosity()
if(src.total_luminosity == src.last_luminosity) return 0//nothing to do here
src.last_luminosity = src.total_luminosity
sd_SetLuminosity(min(src.total_luminosity,7))//Current hardcode max at 7, should likely be a const somewhere else
return 1
/mob/MouseDrop(mob/M as mob)
..()

View File

@@ -31,9 +31,6 @@
var/obj/screen/pressure = null
var/obj/screen/damageoverlay = null
var/total_luminosity = 0 //This controls luminosity for mobs, when you pick up lights and such this is edited. If you want the mob to use lights it must update its lum in its life proc or such. Note clamp this value around 7 or such to prevent massive light lag.
var/last_luminosity = 0
/*A bunch of this stuff really needs to go under their own defines instead of being globally attached to mob.
A variable should only be globally attached to turfs/objects/whatever, when it is in fact needed as such.
The current method unnecessarily clusters up the variable list, especially for humans (although rearranging won't really clean it up a lot but the difference will be noticable for other mobs).

View File

@@ -177,7 +177,7 @@
// update the APC icon to show the three base states
// also add overlays for indicator lights
/obj/machinery/power/apc/proc/updateicon()
src.overlays = null
overlays.Cut()
if(opened)
var/basestate = "apc[ cell ? "2" : "1" ]" // if opened, show cell if it's inserted
if (opened==1)
@@ -199,13 +199,10 @@
else
icon_state = "apc0"
// if closed, update overlays for channel status
if (!(stat & (BROKEN|MAINT)))
overlays += image('icons/obj/power.dmi', "apcox-[locked]") // 0=blue 1=red
overlays += image('icons/obj/power.dmi', "apco3-[charging]") // 0=red, 1=yellow/black 2=green
if(!(stat & (BROKEN|MAINT)))
overlays.Add("apcox-[locked]","apco3-[charging]") // 0=blue 1=red // 0=red, 1=yellow/black 2=green
if(operating)
overlays += image('icons/obj/power.dmi', "apco0-[equipment]") // 0=red, 1=green, 2=blue
overlays += image('icons/obj/power.dmi', "apco1-[lighting]")
overlays += image('icons/obj/power.dmi', "apco2-[environ]")
overlays.Add("apco0-[equipment]","apco1-[lighting]","apco2-[environ]") // 0=red, 1=green, 2=blue
//attack with an item - open/close cover, insert cell, or (un)lock interface

View File

@@ -215,7 +215,7 @@
icon_state = "bulb1"
base_state = "bulb"
fitting = "bulb"
brightness = 3
brightness = 4
desc = "A small lighting fixture."
light_type = /obj/item/weapon/light/bulb
@@ -224,7 +224,7 @@
name = "spotlight"
fitting = "large tube"
light_type = /obj/item/weapon/light/tube/large
brightness = 15
brightness = 12
/obj/machinery/light/built/New()
status = LIGHT_EMPTY
@@ -280,34 +280,28 @@
/obj/machinery/light/proc/update(var/trigger = 1)
update_icon()
if(!on)
use_power = 1
if(on)
if(luminosity != brightness)
switchcount++
if(rigged)
if(status == LIGHT_OK && trigger)
explode()
else if( prob( min(60, switchcount*switchcount*0.01) ) )
if(status == LIGHT_OK && trigger)
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
on = 0
SetLuminosity(0)
else
use_power = 2
SetLuminosity(brightness)
else
use_power = 2
var/oldlum = luminosity
use_power = 1
SetLuminosity(0)
//luminosity = on * brightness
sd_SetLuminosity(on * brightness) // *DAL*
// if the state changed, inc the switching counter
if(oldlum != luminosity)
switchcount++
// now check to see if the bulb is burned out
if(status == LIGHT_OK && trigger)
if(on && rigged)
explode()
if( prob( min(60, switchcount*switchcount*0.01) ) )
status = LIGHT_BURNED
icon_state = "[base_state]-burned"
on = 0
sd_SetLuminosity(0)
active_power_usage = (luminosity * 20)
active_power_usage = (luminosity * 10)
if(on != on_gs)
on_gs = on
// var/area/A = get_area(src)
// if(A)
// A.update_lights()
// attempt to set the light's on/off status

View File

@@ -1,596 +0,0 @@
/* Overview of sd_DynamicAreaLighting as modified for SS13
*
*
* Use sd_SetLuminosity(value) to change the luminosity of an atom
* rather than setting the luminosity var directly.
* Avoid having luminous objects at compile-time since this can mess up
* the lighting system during map load. Instead use sd_SetLuminosity() in
* the atom's New() proc after a small spawn delay.
*
* Use sd_SetOpacity(value) to change the opacity of an atom (e.g. doors)
* rather than setting the opacity var directly. This ensures that lighting
* will be blocked/unblocked as necessary.
*
* If creating a new opaque atom (e.g. a wall) at runtime, create the atom,
* set its opacity var to zero, then perform sd_SetOpacity(1)
* e.g.:
*
* var/obj/block/B = new(loc)
* B.opacity = 0
* B.sd_SetOpacity(1)
*
*
* The library creates multiple instances of each /area to split a mapped area
* into different lighting levels. Each area created has a "master" variable
* which is a reference to the original un-split area, and a "related" variable
* which is a reference to the list of split areas.
*/
/********************************************************************\
sd_DynamicAreaLighting.dm
Shadowdarke (shadowdarke@hotmail.com)
December 12, 2002
The sd_DynamicAreaLighting library provides dynamic lighting
with minimal cpu and bandwidth usage by shifting turfs between
five areas which represent varying shades of darkness.
**********************************************************************
Using sd_DynamicAreaLighting
This library uses BYOND's built in luminousity variable. In most
cases, all you have to do is set luminosity and let the library
worry about the work.
There are three cases that the library does not automatically
compensate for, so you will need to use library procs:
1) Luminosity changes at run time.
If your program makes changes in luminosity while it is
running, you need to use sd_SetLuminosity(new_luminosity)
so the library can remove the effect of the old luminosity
and apply the new effect.
2) Opacity changes at run time.
As with luminosity changes, you need to use
sd_SetOpacity(new_opacity) if your program changes the opacity
of atoms at runtime.
3) New atoms that change the opacity of a location.
This is somewhat more complex, and the library doesn't
have a simple proc to take care of it yet. You should use
sd_StripLocalLum() to strip the luminosity effect of
anything shining on that space, create the new atom, then
use sd_ApplyLocalLum() to reapply the luminosity effect.
Examine the sd_SetOpacity() proc for an example of the
procedure.
All areas will automatically use the sd_DynamicAreaLighting
library when it is included in your project. You may disable
lighting effect in an area by specifically setting the area's
sd_lighting var to 0. For example:
area/always_lit
luminosity = 1
sd_lighting = 0
This library chops areas into 5 separate areas of differing
light effect, so you may want to modify area Enter(), Exit(),
Entered(), and Exited() procs to make sure the atom has moved
from a different area instead of a different light zone of the
same area.
IMPORTANT NOTE: Since sd_DynamicAreaLighting uses the view()
proc, large luminosity settings may cause strange effect. You
should limit luminosity to (world.view * 2) or less.
----------------------------------------------------------------------
CUSTOM DARKNESS ICONS
sd_DynamicAreaLighting was designed in a barbaric age when BYOND
did not support alpha transperency. Thankfully that age is over.
I left the old icon as the default, since not everyone has
upgraded to BYOND 4.0 or in some cases like software graphics
mode, in which case the old dithered icon is the better choice.
The dithered icon used 4 standard dithers for the darkness shades
and I saw little reason to allow variation. Starting with sd_DAL
version 10, the library can support more or less shades of
darkness as well.
To change the icon and/or number of shades of darkness for your
game, just call the sd_SetDarkIcon(dark_icon, num_shades) proc,
where dark_icon is the new icon and num_shades is the number of
shades of darkness in the icon. This is best done in the
world.New() proc, to set it once for the entire game instance.
For example, to make the included 7 shade alpha transparency icon
your game's darkness icon, use the following code in your game.
world
New()
..()
sd_SetDarkIcon('sd_dark_alpha7.dmi', 7)
There are several demo icons included with this library:
sd_darkstates.dmi - the original 4 shade dithered icon
sd_dark_dither3.dmi - 3 shade dithered icon
sd_dark_alpha4.dmi - 4 shade alpha transparency icon
sd_dark_alpha4b.dmi - lighter version 4 shade alpha
transparency icon
sd_dark_alpha7.dmi - 7 shade alpha transparency icon
If you want to design your own custom darkness icons, they
have to follow a specific format for the library to use them
properly. The shades of darkness should have be numbered from 0
as the darkest shade to the number of shades minus one as the
lightest shade.
For example, the four shade 4 shade transparent icon
sd_dark_alpha4.dmi has 4 icon states:
"0" is black with 204 alpha (80% darkness)
"1" is black with 153 alpha (60% darkness)
"2" is black with 102 alpha (40% darkness)
"3" is black with 51 alpha (20% darkness)
The lightest shade ("3" in this case) is NOT completely clear.
There will be no darkness overlay for completely lit areas. The
lightest shade will only be used for places that are just beginning
to get dark.
The darkest shade ("0") likewise is not 100% obscured. "0" will
be used in completely dark areas, but by leaving it slightly
transparent, characters will be able to barely make out their
immediate surroundings in the darkness (based on the mob
see_in_dark var.) You might prefer to lighten the darkness for
this purpose, like in demo icon sd_dark_alpha4b.dmi.
----------------------------------------------------------------------
DAY/NIGHT CYCLES
sd_DynamicAreaLighting allows for separate indoor and outdoor
lighting. Areas used for outdoor light cycles should be
designated by setting the area's sd_outside var to 1. For example:
area/outside
sd_outside = 1
You will need to write your own routine for the day/night
cycle so that you can control the timing and degree of lighting
changes. There is an example routine in lightingdemo.dm.
After your routine determines the amount of light outdoors,
call sd_OutsideLight(light_level) to update the light levels in
all outside areas. light_level should be a value from 0 to
sd_dark_shades, where 0 is darkest and sd_dark_shades is full
light.
The sd_OutsideLight() proc does not automatically detect a
range out of bounds in case you want to use nonstandard values
for interesting effect. For instance, you could use a negative
value to dampen light sources.
If you want daylight to spill indoors:
You will need to add turfs to sd_light_spill_turfs. The
library will automatically add any turf created with
sd_light_spill set, or you may add the turfs yourself at
runtime.
The turfs in this list act as a source of daylight, shining
into the any areas that are not flagged with sd_outside.
**********************************************************************
LIBRARY PROCS:
Except in the cases noted above, you shouldn't need to use the procs
in this library. This reference is provided for advanced users.
Global vars and procs:
var
sd_dark_icon
This is the icon used for the darkness in your world.
DEFAULT VALUE: 'sd_darkstates.dmi' (A dithered icon
designed for BYOND releases before 4.0.)
sd_dark_shades
The number of darkness icon states in your sd_dark_icon.
DEFAULT VALUE: 4
sd_light_layer
The graphic layer that darkness overlays appear on.
This should be higher than anything on the map, but
lower than any HUD displays.
DEFAULT VALUE: 50
sd_light_outside
This var is how bright it currently is outside. It
should be a number between 0 and sd_dark_shades.
DEFAULT VALUE: 0
sd_top_luminosity
keeps track of the highest luminosity in the world to
prevent getting larger lists than necessary.
list/sd_outside
A list of outside areas.
list/sd_light_spill_turfs
A list of turfs where light spills from outside areas into
inside areas.
proc/sd_OutsideLight(n as num)
Changes the level of light outside (sd_light_outside) to n
and updates all the atoms in sd_outside.
proc/sd_SetDarkIcon(icon, shades)
Changes the darkness icon and the number shades of darkness
in that icon.
All atoms have the following procs:
sd_ApplyLum(list/V = view(luminosity,src), center = src)
This proc adds a value to the sd_lumcount of all the
turfs in V, depending on src.luminosity and the
distance between the turf and center.
sd_StripLum(list/V = view(luminosity,src), center = src)
The reverse of sd_ApplyLum(), sd_StripLum removes luminosity
effect.
sd_ApplyLocalLum(list/affected = viewers(20,src))
Applies the lighting effect of all atoms in affected. This
proc is used with sd_StripLocalLum() for effect that may
change the opacity of a turf.
sd_StripLocalLum()
Strips effect of all local luminous atoms.
RETURNS: list of all the luminous atoms stripped
IMPORTANT! Each sd_StripLocalLum() call should have a matching
sd_ApplyLocalLum() to restore the local effect.
sd_SetLuminosity(new_luminosity as num)
Sets the atom's luminosity, making adjustments to the
sd_lumcount of local turfs.
sd_SetOpacity(new_opacity as num)
Sets the atom's opacity, making adjustments to the
sd_lumcount of local turfs.
Areas have one additional proc and 4 variables:
var
sd_lighting
Turn this flag off to prevent sd_DynamicAreaLighting
from effecting this area.
DEFAULT VALUE: 1 (allow dynamic lighting)
sd_outside
Set this flag to automatically add this area to the
list of outside areas.
DEAFAULT VALUE: 0 (not an outside area)
sd_light_level
The current light level of the area. You should use
the sd_LightLevel() proc to set this value, so the
darkness overlays will be changed as well.
DEFAULT VALUE: 0
sd_darkimage
Tracks the darkness image of the area for easy
removal in the sd_LightLevel() proc
proc
sd_LightLevel(level = sd_light_level as num,keep = 1)
Updates the darkness overlay of the area.
If keep = 1, it also updates the area's
sd_light_level var.
Turfs have these additional procs and vars:
var
sd_lumcount
Used to track the brightness of a turf.
sd_light_spill
If set, the turf will automatically be added to the
global list sd_light_spill_turfs when created.
DEFAULT VALUE: 0
proc
sd_LumUpdate()
Places the turf in the appropriate sd_dark area,
depending on its brightness (sd_lumcount).
sd_LumReset()
Resets a turf's lumcount by stripping local luminosity,
zeroing the lumcount, then reapplying local luminosity.
sd_ApplySpill()
Applies to effect of daylight spilling into inside
areas in view of this turf.
sd_StripSpill()
Removes to effect of daylight spilling into inside
areas in view of this turf.
\********************************************************************/
var/const/sd_dark_icon = 'icons/effects/ss13_dark_alpha7.dmi' // icon used for darkness
var/const/sd_dark_shades = 7 // number of icon state in sd_dark_icon
var/const/sd_light_layer = 10 // graphics layer for light effect
var/sd_top_luminosity = 0
// since we're not using these, comment out all occurances to save CPU
/*
list
sd_outside_areas = list() // list of outside areas
sd_light_spill_turfs = list() // list of turfs to calculate light spill from
*/
// slog = file("DALlog.txt")
/*
proc
sd_OutsideLight(n as num)
// set the brightness of the outside sunlight
if(sd_light_outside == n) return // same level, no update
if(sd_light_outside)
for(var/turf/T in sd_light_spill_turfs)
T.sd_StripSpill()
sd_light_outside = n
// make all the outside areas update themselves
for(var/area/A in sd_outside_areas)
A.sd_LightLevel(sd_light_outside + A.sd_light_level,0)
if(n)
for(var/turf/T in sd_light_spill_turfs)
T.sd_ApplySpill()
*/
/*
proc/sd_SetDarkIcon(icon, shades)
// reset the darkness icon and number of shades of darkness
sd_dark_icon = icon
sd_dark_shades = shades
// change existing areas
for(var/area/A)
if(A.sd_darkimage) A.sd_LightLevel(A.sd_light_level,0)
*/
atom/New()
..()
// if this is not an area and is luminous
if(!isarea(src)&&(luminosity>0))
spawn(1) // delay to allow map load
sd_ApplyLum()
atom/Del()
// if this is not an area and is luminous
if(!isarea(src)&&(luminosity>0))
sd_StripLum()
..()
atom/proc/sd_ApplyLum(list/V = view(luminosity,src), center = src)
if(src.luminosity>sd_top_luminosity)
sd_top_luminosity = src.luminosity
// loop through all the turfs in V
for(var/turf/T in V)
/* increase the turf's brightness depending on the
brightness and distance of the lightsource */
T.sd_lumcount += (luminosity-get_dist(center,T))
T.sd_LumUpdate()
atom/proc/sd_StripLum(list/V = view(luminosity,src), center = src)
// loop through all the turfs in V
for(var/turf/T in V)
/* increase the turf's brightness depending on the
brightness and distance of the lightsource */
T.sd_lumcount -= (luminosity-get_dist(center,T))
// T.sd_lumcount = max(0, T.sd_lumcount)
// update the turf's area
T.sd_LumUpdate()
atom/proc/sd_ApplyLocalLum(list/affected = view(sd_top_luminosity,src))
// Reapplies the lighting effect of all atoms in affected.
for(var/atom/A in affected)
if(A.luminosity) A.sd_ApplyLum()
atom/proc/sd_StripLocalLum()
/* strips all local luminosity
RETURNS: list of all the luminous atoms stripped
IMPORTANT! Each sd_StripLocalLum() call should have a matching
sd_ApplyLocalLum() to restore the local effect. */
var/list/affected = list()
for(var/atom/A in view(sd_top_luminosity,src))
var/turfflag = (isturf(src)?1:0)
if(A.luminosity && (get_dist(src,A) <= A.luminosity + turfflag))
A.sd_StripLum()
affected += A
return affected
atom/proc/sd_SetLuminosity(new_luminosity as num)
/* This proc should be called everytime you want to change the
luminosity of an atom instead of setting it directly.
new_luminosity is the new value for luminosity. */
if(luminosity>0)
sd_StripLum()
luminosity = new_luminosity
if(luminosity>0)
sd_ApplyLum()
atom/proc/sd_SetOpacity(new_opacity as num)
if(opacity == (new_opacity ? 1 : 0)) return
var/list/affected = new
var/atom/A
var/turf/T
var/turf/ATurf
for(A in range(sd_top_luminosity,src))
T = A
while(T && !istype(T)) T = T.loc
if(T)
var/list/V = view(A.luminosity,T)
if(!(src in V)) continue
var/turfflag = 0
if(A == T) turfflag = 1
if(A.luminosity && get_dist(A,src)<=A.luminosity+turfflag)
affected[A] = V
opacity = new_opacity
if(opacity)
for(A in affected)
ATurf = A
while(ATurf && !istype(ATurf)) ATurf = ATurf.loc
if(ATurf)
for(T in affected[A]-view(A.luminosity, ATurf))
T.sd_lumcount -= (A.luminosity-get_dist(A,T))
// T.sd_lumcount = max(0, T.sd_lumcount)
T.sd_LumUpdate()
else
for(A in affected)
ATurf = A
while(ATurf && !istype(ATurf)) ATurf = ATurf.loc
if(ATurf)
for(T in view(A.luminosity, ATurf) - affected[A])
T.sd_lumcount += (A.luminosity-get_dist(A,T))
T.sd_LumUpdate()
///
atom/proc/sd_NewOpacity(var/new_opacity)
if(opacity != new_opacity)
var/list/affected = sd_StripLocalLum()
opacity = new_opacity
var/atom/T = src
while(T && !isturf(T))
T = T.loc
if(T)
T:sd_lumcount = 0
sd_ApplyLocalLum(affected)
///
turf
var/tmp/sd_lumcount = 0 // the brightness of the turf
turf/proc/sd_LumReset()
/* Clear local lum, reset this turf's sd_lumcount, and
re-apply local lum*/
var/list/affected = sd_StripLocalLum()
sd_lumcount = 0
sd_ApplyLocalLum(affected)
turf/proc/sd_LumUpdate()
set background = 1
var/area/Loc = loc
if(!istype(Loc) || !Loc.sd_lighting) return
// change the turf's area depending on its brightness
// restrict light to valid levels
var/light = min(max(sd_lumcount,0),sd_dark_shades)
var/ltag = copytext(Loc.tag,1,findtext(Loc.tag,"sd_L")) + "sd_L[light]"
if(Loc.tag!=ltag) //skip if already in this area
var/area/A = locate(ltag) // find an appropriate area
if(!A)
A = new Loc.type() // create area if it wasn't found
// replicate vars
for(var/V in Loc.vars-"contents")
if(issaved(Loc.vars[V])) A.vars[V] = Loc.vars[V]
A.tag = ltag
A.sd_LightLevel(light)
A.contents += src // move the turf into the area
atom/movable/Move() // when something moves
var/turf/oldloc = loc // remember for range calculations
// list turfs in view and luminosity range of old loc
var/list/oldview
if(luminosity>0) // if atom is luminous
if(isturf(loc))
oldview = view(luminosity,loc)
else
oldview = list()
. = ..()
if(.&&(luminosity>0)) // if the atom actually moved
if(istype(oldloc))
sd_StripLum(oldview,oldloc)
oldloc.sd_lumcount++ // correct "off by 1" error in oldloc
sd_ApplyLum()
area
var/sd_lighting = 1 //Turn this flag off to prevent sd_DynamicAreaLighting from affecting this area
var/sd_light_level = 0 //This is the current light level of the area
var/sd_darkimage //This tracks the darkness image of the area for easy removal
area/proc/sd_LightLevel(slevel = sd_light_level as num, keep = 1)
if(!src) return
overlays -= sd_darkimage
if(keep) sd_light_level = slevel
// slevel = min(max(slevel,0),sd_dark_shades) // restrict range
if(slevel > 0)
luminosity = 1
else
luminosity = 0
sd_darkimage = image(sd_dark_icon,,num2text(slevel),sd_light_layer)
overlays += sd_darkimage
area/proc/sd_New(sd_created)
if(!tag) tag = "[type]"
spawn(1) // wait a tick
if(sd_lighting)
// see if this area was created by the library
if(!sd_created)
/* show the dark overlay so areas outside of luminous regions
won't be bright as day when they should be dark. */
sd_LightLevel()
area/Del()
..()
related -= src
/* extend the mob procs to compensate for sight settings. */
mob/sd_ApplyLum(list/V, center = src)
if(!V)
if(isturf(loc))
V = view(luminosity,loc)
else
V = view(luminosity,get_turf(src))
. = ..(V, center)
mob/sd_StripLum(list/V, center = src)
if(!V)
if(isturf(loc))
V = view(luminosity,loc)
else
V = view(luminosity,get_turf(src))
. = ..(V, center)
mob/sd_ApplyLocalLum(list/affected)
if(!affected)
if(isturf(loc))
affected = view(sd_top_luminosity,loc)
else
affected = view(sd_top_luminosity,src)
. = ..(affected)

View File

@@ -9,15 +9,11 @@
density = 0
unacidable = 1
use_power = 0
luminosity = 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.
/obj/machinery/containment_field/New()
spawn(1)
src.sd_SetLuminosity(5)
/obj/machinery/containment_field/Del()
if(FG1 && !FG1.clean_up)
FG1.cleanup()

View File

@@ -13,6 +13,7 @@ var/global/list/uneatable = list(
anchored = 1
density = 1
layer = 6
luminosity = 6
unacidable = 1 //Don't comment this out.
use_power = 0
var/current_size = 1
@@ -279,7 +280,7 @@ var/global/list/uneatable = list(
continue
if(O.invisibility == 101)
src.consume(O)
A:ReplaceWithSpace()
T.ReplaceWithSpace()
gain = 2
src.energy += gain
return

View File

@@ -61,6 +61,6 @@
log_game("[key_name_admin(user)] used a grenade ([src.name]).")
F.active = 1
F.icon_state = initial(icon_state) + "_active"
playsound(user.loc, 'armbomb.ogg', 75, 1, -3)
playsound(user.loc, 'sound/weapons/armbomb.ogg', 75, 1, -3)
spawn(15)
F.prime()

View File

@@ -61,7 +61,7 @@
return
/obj/item/weapon/reagent_containers/borghypo/attack_self(mob/user as mob)
playsound(src.loc, 'pop.ogg', 50, 0) //Change the mode
playsound(src.loc, 'sound/effects/pop.ogg', 50, 0) //Change the mode
if(mode == 1)
mode = 2
charge_tick = 0 //Prevents wasted chems/cell charge if you're cycling through modes.

View File

@@ -33,7 +33,7 @@
spawn(5)
reagents.trans_to(M, 10)
playsound(M.loc,'drink.ogg', rand(10,50), 1)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
return 1
else if( istype(M, /mob/living/carbon/human) )
@@ -54,7 +54,7 @@
spawn(5)
reagents.trans_to(M, 10)
playsound(M.loc,'drink.ogg', rand(10,50), 1)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
return 1
return 0

View File

@@ -33,7 +33,7 @@
spawn(5)
reagents.trans_to(M, gulp_size)
playsound(M.loc,'drink.ogg', rand(10,50), 1)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
return 1
else if( istype(M, /mob/living/carbon/human) )
@@ -61,7 +61,7 @@
spawn(600)
R.add_reagent(refill, fillevel)
playsound(M.loc,'drink.ogg', rand(10,50), 1)
playsound(M.loc,'sound/items/drink.ogg', rand(10,50), 1)
return 1
return 0

View File

@@ -75,7 +75,7 @@
return
if(reagents) //Handle ingestion of the reagent.
playsound(M.loc,'eatfood.ogg', rand(10,50), 1)
playsound(M.loc,'sound/items/eatfood.ogg', rand(10,50), 1)
if(reagents.total_volume)
reagents.reaction(M, INGEST)
spawn(5)

View File

@@ -216,16 +216,16 @@
/obj/item/weapon/reagent_containers/food/snacks/grown/glowberries/Del()
if(istype(loc,/mob))
loc.sd_SetLuminosity(loc.luminosity - potency/5)
loc.SetLuminosity(round(loc.luminosity - potency/5,1))
..()
/obj/item/weapon/reagent_containers/food/snacks/grown/glowberries/pickup(mob/user)
src.sd_SetLuminosity(0)
user.total_luminosity += potency/5
src.SetLuminosity(0)
user.SetLuminosity(round(user.luminosity + (potency/5),1))
/obj/item/weapon/reagent_containers/food/snacks/grown/glowberries/dropped(mob/user)
user.total_luminosity -= potency/5
src.sd_SetLuminosity(potency/5)
user.SetLuminosity(round(user.luminosity - (potency/5),1))
src.SetLuminosity(round(potency/5,1))
/obj/item/weapon/reagent_containers/food/snacks/grown/cocoapod
seed = "/obj/item/seeds/cocoapodseed"
@@ -771,7 +771,7 @@
if(istype(src.loc,/mob))
pickup(src.loc)
else
src.sd_SetLuminosity(potency/10)
src.SetLuminosity(round(potency/10,1))
lifespan = 120 //ten times that is the delay
endurance = 30
maturation = 15
@@ -795,16 +795,16 @@
/obj/item/weapon/reagent_containers/food/snacks/grown/mushroom/glowshroom/Del()
if(istype(loc,/mob))
loc.sd_SetLuminosity(loc.luminosity - potency/10)
loc.SetLuminosity(round(loc.luminosity - potency/10,1))
..()
/obj/item/weapon/reagent_containers/food/snacks/grown/mushroom/glowshroom/pickup(mob/user)
src.sd_SetLuminosity(0)
user.total_luminosity += potency/10
SetLuminosity(0)
user.SetLuminosity(round(user.luminosity + (potency/10),1))
/obj/item/weapon/reagent_containers/food/snacks/grown/mushroom/glowshroom/dropped(mob/user)
user.total_luminosity -= potency/10
src.sd_SetLuminosity(potency/10)
user.SetLuminosity(round(user.luminosity + (potency/10),1))
SetLuminosity(round(potency/10,1))
// *************************************
// Complex Grown Object Defines -

View File

@@ -58,7 +58,7 @@
sleep(3)
del(D)
playsound(src.loc, 'spray2.ogg', 50, 1, -6)
playsound(src.loc, 'sound/effects/spray2.ogg', 50, 1, -6)
if(reagents.has_reagent("sacid"))
message_admins("[key_name_admin(user)] fired sulphuric acid from a spray bottle.")
@@ -181,7 +181,7 @@
sleep(2)
del(D)
playsound(src.loc, 'spray2.ogg', 50, 1, -6)
playsound(src.loc, 'sound/effects/spray2.ogg', 50, 1, -6)
if(reagents.has_reagent("sacid"))
message_admins("[key_name_admin(user)] fired sulphuric acid from a chem sprayer.")

View File

@@ -56,7 +56,7 @@
del(S)
D.icon_state = "syringeproj"
D.name = "syringe"
playsound(user.loc, 'syringeproj.ogg', 50, 1)
playsound(user.loc, 'sound/items/syringeproj.ogg', 50, 1)
for(var/i=0, i<6, i++)
if(!D) break