From 9a7675ce5a1290d321dfa5e36a20856635c50171 Mon Sep 17 00:00:00 2001 From: "vageyenaman@gmail.com" Date: Fri, 29 Jun 2012 03:43:30 +0000 Subject: [PATCH] Implemented Tobba's new lighting system. This grants some infrastructure to allow for colored light sources. It should also, theoretically, but more efficient. Created a quick variable to let projectiles automatically illuminate. Implemented some of Ausops' sprites. git-svn-id: http://tgstation13.googlecode.com/svn/trunk@3944 316c924e-a436-60f5-8080-3fe189b3f50e --- code/game/area/areas.dm | 5 +- code/game/master_controller.dm | 3 + code/game/objects/devices/PDA/PDA.dm | 2 + code/game/objects/devices/flashlight.dm | 2 + code/modules/mob/inventory.dm | 8 +- code/modules/power/sd_DynamicAreaLighting.dm | 831 ++++-------------- code/modules/projectiles/projectile.dm | 5 + code/modules/projectiles/projectile/beams.dm | 48 +- code/modules/projectiles/projectile/change.dm | 5 + code/modules/projectiles/projectile/energy.dm | 10 + .../modules/projectiles/projectile/special.dm | 9 + html/changelog.html | 4 + icons/obj/stock_parts.dmi | Bin 6403 -> 8394 bytes 13 files changed, 285 insertions(+), 647 deletions(-) diff --git a/code/game/area/areas.dm b/code/game/area/areas.dm index 758df9b4fd3..279c97cb604 100644 --- a/code/game/area/areas.dm +++ b/code/game/area/areas.dm @@ -28,9 +28,11 @@ requires_power = 1 always_unpowered = 1 sd_SetLuminosity(1) + sd_lighting = 0 power_light = 0 power_equip = 0 power_environ = 0 + luminosity = 1 //has_gravity = 0 // Space has gravity. Because.. because. if(!requires_power) @@ -40,7 +42,8 @@ luminosity = 1 sd_lighting = 0 // *DAL* else - luminosity = 0 + if(name != "Space") + luminosity = 0 area_lights_luminosity = rand(6,9) //sd_SetLuminosity(0) // *DAL* diff --git a/code/game/master_controller.dm b/code/game/master_controller.dm index f61bf43d57f..c865fe8dc0b 100644 --- a/code/game/master_controller.dm +++ b/code/game/master_controller.dm @@ -138,6 +138,9 @@ datum/controller/game_controller sun.calc_position() sun_ready = 1 + spawn(0) + sd_Update() + sleep(-1) spawn(0) diff --git a/code/game/objects/devices/PDA/PDA.dm b/code/game/objects/devices/PDA/PDA.dm index 5659dbce867..a07ed42f439 100644 --- a/code/game/objects/devices/PDA/PDA.dm +++ b/code/game/objects/devices/PDA/PDA.dm @@ -177,11 +177,13 @@ var/global/list/obj/item/device/pda/PDAs = list() if (fon) sd_SetLuminosity(0) user.total_luminosity += f_lum + sd_Update() /obj/item/device/pda/dropped(mob/user) if (fon) user.total_luminosity -= f_lum sd_SetLuminosity(f_lum) + sd_Update() /obj/item/device/pda/New() ..() diff --git a/code/game/objects/devices/flashlight.dm b/code/game/objects/devices/flashlight.dm index acf53cdc2de..505375f83ba 100644 --- a/code/game/objects/devices/flashlight.dm +++ b/code/game/objects/devices/flashlight.dm @@ -85,12 +85,14 @@ if(on) user.total_luminosity += brightness_on src.sd_SetLuminosity(0) + sd_Update() /obj/item/device/flashlight/dropped(mob/user) if(on) user.total_luminosity -= brightness_on src.sd_SetLuminosity(brightness_on) + sd_Update() /obj/item/device/flashlight/pen diff --git a/code/modules/mob/inventory.dm b/code/modules/mob/inventory.dm index 2a8e2f720a0..9cfe1349898 100644 --- a/code/modules/mob/inventory.dm +++ b/code/modules/mob/inventory.dm @@ -94,8 +94,8 @@ if(client) client.screen -= l_hand l_hand.layer = initial(l_hand.layer) - if(Target) l_hand.loc = Target.loc - else l_hand.loc = loc + if(Target) l_hand.Move(Target.loc) + else l_hand.Move(loc) var/turf/T = get_turf(loc) if(isturf(T)) @@ -113,8 +113,8 @@ if(client) client.screen -= r_hand r_hand.layer = initial(r_hand.layer) - if(Target) r_hand.loc = Target.loc - else r_hand.loc = loc + if(Target) r_hand.Move(Target.loc) + else r_hand.Move(loc) var/turf/T = get_turf(Target) if(istype(T)) diff --git a/code/modules/power/sd_DynamicAreaLighting.dm b/code/modules/power/sd_DynamicAreaLighting.dm index 7388288af2d..bde6d1238c5 100644 --- a/code/modules/power/sd_DynamicAreaLighting.dm +++ b/code/modules/power/sd_DynamicAreaLighting.dm @@ -1,580 +1,163 @@ -/* 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. - -\********************************************************************/ +// ROBUST LIGHTING +// Made by Tobba, submitted to #coderbus vultures +// CREDITS TO WHOEVER THE FUCK WROTE THAT PEICE OF SHIT THAT IS SD LIGHITING THAT I RIPPED APART AND MADE ACTUALLY WORK var - sd_dark_icon = 'ss13_dark_alpha7.dmi' // icon used for darkness - sd_dark_shades = 7 // number of icon state in sd_dark_icon sd_light_layer = 10 // graphics layer for light effect - sd_light_outside = 0 // how bright it is outside 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 - */ + sd_FastRoot = list() + sd_OpacityUpdates = list() + sd_ToUpdate = list() -// 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) + sd_Update() + var/list/blankList = list() + for (var/atom/Affected in sd_OpacityUpdates) + var/oldOpacity = sd_OpacityUpdates[Affected] + var/newOpacity = Affected.opacity + Affected.opacity = oldOpacity + for (var/atom/A in view(sd_top_luminosity, Affected)) + if (!isarea(A) && A.luminosity > 0 && !blankList[A]) + blankList[A] = 1 + A.sd_StripLum() + Affected.opacity = newOpacity + for (var/atom/Affected in blankList) + Affected.sd_ApplyLum() + for (var/i = 1; i <= sd_ToUpdate.len; i++) + var/turf/Affected = sd_ToUpdate[i] + if (!istype(Affected)) + continue + Affected.sd_LumUpdate() + sd_ToUpdate.len = 0 + sd_OpacityUpdates.len = 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() Del() // if this is not an area and is luminous - if(!isarea(src)&&(luminosity>0)) - sd_StripLum() + if(!isarea(src) && luminosity > 0) + sd_StripLum(,,1) ..() + var + sd_ColorRed = 0.9 + sd_ColorGreen = 0.9 + sd_ColorBlue = 0.9 + proc - sd_ApplyLum(list/V = view(luminosity,src), center = src) - if(src.luminosity>sd_top_luminosity) + sd_ApplyLum(list/V = view(luminosity, src), center = src, updateMode = 0) + if (isarea(src)) + return + if(src.luminosity > sd_top_luminosity) sd_top_luminosity = src.luminosity - // loop through all the turfs in V + var/list/affected = list() + var + d = max(sd_ColorRed, sd_ColorGreen, sd_ColorBlue) + r = sd_ColorRed / d + g = sd_ColorGreen / d + b = sd_ColorBlue / d 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)) - // update the turf's area + var/falloff = 0 + if (luminosity > 0) + falloff = sd_FalloffAmount(T) - // - //if(T.tag == "sdd") - // slog << "\red lc+([luminosity-get_dist(center,T)]) from [center] ([center:x],[center:y])" - // slog << "now [T.sd_lumcount]" + if (falloff > luminosity) + continue; + falloff = (luminosity - falloff) / luminosity + T.sd_LightsAlpha[src] = falloff * d + T.sd_LightsRed[src] = r + T.sd_LightsGreen[src] = g + T.sd_LightsBlue[src] = b + if (updateMode == 0) + sd_ToUpdate[T] = 1 + else + T.sd_LumUpdate() + affected += T + return affected - T.sd_LumUpdate() - - sd_StripLum(list/V = view(luminosity,src), center = src) - // loop through all the turfs in V + sd_StripLum(list/V = view(luminosity,src), center = src, updateMode = 0) + if (isarea(src)) + return + var/list/affected = list() 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_LightsAlpha -= src + T.sd_LightsRed -= src + T.sd_LightsGreen -= src + T.sd_LightsBlue -= src + if (updateMode == 0) + sd_ToUpdate[T] = 1 + else + T.sd_LumUpdate() + affected += T + return affected - //if(T.tag == "sdd") - // slog << "\red lc-([luminosity-get_dist(center,T)]) from [center] ([center:x],[center:y])" - // slog << "now [T.sd_lumcount]" - - - // update the turf's area - T.sd_LumUpdate() + sd_FalloffAmount(var/atom/ref) // Borrowed from Ultralight + var/x = (ref.x - src.x) + var/y = (ref.y - src.y) + if ((x*x + y*y + 1) > sd_FastRoot.len) + for(var/i = sd_FastRoot.len, i <= x*x+y*y, i++) + sd_FastRoot += sqrt(x*x+y*y) - 0.5 + return round(sd_FastRoot[x*x + y*y + 1], 1) 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() - //if(sd_light_outside && (A in sd_light_spill_turfs)) - // A:sd_ApplySpill() - 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)) + if(A.luminosity) A.sd_StripLum() affected += A - //if(sd_light_outside && (A in sd_light_spill_turfs)) - // A:sd_StripSpill() - // affected += A - return affected 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. + if (luminosity == new_luminosity) + return - new_luminosity is the new value for luminosity. */ - if(luminosity>0) + if(luminosity > 0) sd_StripLum() luminosity = new_luminosity - if(luminosity>0) + if(luminosity > 0) sd_ApplyLum() + sd_SetColor(r as num, g as num, b as num) + sd_StripLum() + sd_ColorRed = r + sd_ColorGreen = g + sd_ColorBlue = b + sd_ApplyLum() sd_SetOpacity(new_opacity as num) - /* if(opacity != new_opacity) - var/list/affected = sd_StripLocalLum() + if (opacity != new_opacity) + sd_OpacityUpdates[src] = opacity opacity = new_opacity - sd_ApplyLocalLum(affected) */ - if(opacity == (new_opacity ? 1 : 0)) return - var - list - affected = new - //spill - atom/A - turf - T - ATurf - affected = new - 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 - //if(sd_light_outside && (A in sd_light_spill_turfs)) - // if(!spill) spill=new - // spill[A] = view(sd_light_outside, T) - 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)) - - //if(T.tag == "sdd") - // slog << "\red lc(1)-([A.luminosity-get_dist(A,T)]) from [A] ([A.x],[A.y])" - // slog << "now [T.sd_lumcount]" - - - T.sd_LumUpdate() - /* - for(A in spill) - if(A.opacity && A!=src) continue - ATurf = A - while(ATurf && !istype(ATurf)) ATurf = ATurf.loc - if(ATurf) - //spill[A] -= view(sd_light_outside, A) - for(T in (A==src)?spill[A]:(spill[A]-view(sd_light_outside,ATurf))) - if(T.loc:sd_outside) continue - T.sd_lumcount -= (sd_light_outside-get_dist(A,T)) - - //if(T.tag == "sdd") - // slog << "\red lc(O)-([sd_light_outside-get_dist(A,T)]) from [A] ([A:x],[A:y])" - // slog << "now [T.sd_lumcount]" - - - T.sd_LumUpdate() - */ - - // end new_opacity = 1 block - - 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)) - //if(T.tag == "sdd") - // slog << "\red lc(1)+([A.luminosity-get_dist(A,T)]) from [A] ([A.x],[A.y])" - // slog << "now [T.sd_lumcount]" - - T.sd_LumUpdate() - /* - for(A in spill) - if(A.opacity) continue - ATurf = A - while(ATurf && !istype(ATurf)) ATurf = ATurf.loc - if(ATurf) - for(T in (A==src)?spill[A]:(view(sd_light_outside, ATurf)-spill[A])) - if(T.loc:sd_outside) continue - T.sd_lumcount += (sd_light_outside-get_dist(A,T)) - //if(T.tag == "sdd") - // slog << "\red lc(O)+([sd_light_outside-get_dist(A,T)]) from [A] ([A:x],[A:y])" - // slog << "now [T.sd_lumcount]" - - T.sd_LumUpdate() - - */ - // end new_opacity = 0 block - - -/// + sd_Update() 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) - -/// + sd_SetOpacity(new_opacity) turf var - // set to 1 to have outside light spill indoors from this turf - sd_light_spill = 0 tmp - sd_lumcount = 0 // the brightness of the turf - + list + sd_LightsAlpha = list() + sd_LightsRed = list() + sd_LightsGreen = list() + sd_LightsBlue = list() + sd_LevelRed = 0 + sd_LevelGreen = 0 + sd_LevelBlue = 0 + sd_lumcount = 0 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 - //if(src.tag == "sdd") - // slog << "\red lc(LR)=0" - sd_ApplyLocalLum(affected) sd_LumUpdate() @@ -582,88 +165,72 @@ turf 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]" + var/light_r = 0 + var/light_g = 0 + var/light_b = 0 - if(Loc.tag!=ltag) //skip if already in this area - var/area/A = locate(ltag) // find an appropriate area + sd_LevelRed = 0 + sd_LevelGreen = 0 + sd_LevelBlue = 0 + + var/alpha = 0 + + for (var/i = 1; i <= sd_LightsAlpha.len; i++) + var/a = sd_LightsAlpha[sd_LightsAlpha[i]] + var/r = sd_LightsRed[sd_LightsRed[i]] + var/g = sd_LightsGreen[sd_LightsGreen[i]] + var/b = sd_LightsBlue[sd_LightsBlue[i]] + alpha = 1 - ((1 - a) * (1 - alpha)) + sd_LevelRed += r * a + sd_LevelGreen += g * a + sd_LevelBlue += b * a + + if (src.density > 0) + var/a = (sd_LevelRed + sd_LevelGreen + sd_LevelBlue)/3 + sd_LevelRed = a + sd_LevelGreen = a + sd_LevelBlue = a + + var/d = max(sd_LevelRed, sd_LevelGreen, sd_LevelBlue) + if (d > 0) + sd_LevelRed /= d + sd_LevelGreen /= d + sd_LevelBlue /= d + else + sd_LevelRed = 1 + sd_LevelGreen = 1 + sd_LevelBlue = 1 + sd_LevelRed *= alpha + sd_LevelGreen *= alpha + sd_LevelBlue *= alpha + + light_r = round(sd_LevelRed * 7) + light_g = round(sd_LevelGreen * 7) + light_b = round(sd_LevelBlue * 7) + + sd_lumcount = light_r + light_g + light_b + + var/ltag = copytext(Loc.tag,1,findtext(Loc.tag,"sd_L")) + "sd_L[light_r]-[light_g]-[light_b]" + + if (Loc.tag != ltag) + var/area/A = locate(ltag) if(!A) - A = new Loc.type() // create area if it wasn't found + A = new Loc.type() A.tag = ltag // replicate vars for(var/V in Loc.vars-"contents") if(issaved(Loc.vars[V])) A.vars[V] = Loc.vars[V] - - A.tag = ltag - /* - if(A.sd_outside) - if(!(A in sd_outside_areas)) - sd_outside_areas += A - A.sd_light_level = light - A.sd_LightLevel(light + sd_light_outside,0) - else - */ - A.sd_LightLevel(light) - // endelse + A.sd_LightLevel(light_r, light_g, light_b) - A.contents += src // move the turf into the area -/* - sd_ApplySpill() - if(opacity) return - var/oldlum = luminosity - luminosity = sd_light_outside - // loop through all the turfs in V - for(var/turf/T in view(sd_light_outside,src)) - var/area/A = T.loc - if(!istype(A) || A.sd_outside) continue - /* increase the turf's brightness depending on the - brightness and distance of the lightsource */ - T.sd_lumcount += (sd_light_outside-get_dist(src,T)) - //if(T.tag == "sdd") - // slog << "\red lc(AS)+([sd_light_outside-get_dist(src,T)]) from [src] ([src:x],[src:y])" - // slog << "now [T.sd_lumcount]" + A.contents += src - // update the turf's area - T.sd_LumUpdate() - luminosity = oldlum - - sd_StripSpill() - if(opacity) return - var/oldlum = luminosity - luminosity = sd_light_outside - // loop through all the turfs in V - for(var/turf/T in view(sd_light_outside,src)) - var/area/A = T.loc - if(!istype(A) || A.sd_outside) continue - /* increase the turf's brightness depending on the - brightness and distance of the lightsource */ - T.sd_lumcount -= (sd_light_outside-get_dist(src,T)) - //if(T.tag == "sdd") - // slog << "\red lc(AS)-([sd_light_outside-get_dist(src,T)]) from [src] ([src:x],[src:y])" - // slog << "now [T.sd_lumcount]" - - // update the turf's area - T.sd_LumUpdate() - luminosity = oldlum - - New() - ..() - if(sd_light_spill) - sd_light_spill_turfs += src -*/ -atom/movable/Move() // when something moves - - //world << "[src]: sd_Move: ([loc.x],[loc.y])" - - var/turf/oldloc = loc // remember for range calculations - // list turfs in view and luminosity range of old loc +atom/movable/Move() + var/turf/oldloc = loc var/list/oldview - if(luminosity>0) // if atom is luminous + if(luminosity > 0) // if atom is luminous if(isturf(loc)) oldview = view(luminosity,loc) else @@ -671,96 +238,79 @@ atom/movable/Move() // when something moves . = ..() - //world << "[src]: sd_Move: .=[.]" - - - if(.&&(luminosity>0)) // if the atom actually moved - //world << "[src](luminosity) moved" + if(. && luminosity > 0) if(istype(oldloc)) - sd_StripLum(oldview,oldloc) - oldloc.sd_lumcount++ // correct "off by 1" error in oldloc - sd_ApplyLum() + var/list/Affected1 = sd_StripLum(oldview,oldloc, 2) + var/list/Affected2 + if (!loc.opacity) + Affected2 = sd_ApplyLum(,,2) + else + Affected2 = list() + var/list/Affected3 = list() + for (var/turf/T in Affected1) + Affected3[T] = 1 + for (var/turf/T in Affected2) + Affected3[T] = 1 + for (var/i = 1; i <= Affected3.len; i++) + var/turf/T = Affected3[i] + T.sd_LumUpdate() + area var - /* Turn this flag off to prevent sd_DynamicAreaLighting from affecting - this area */ sd_lighting = 1 - /* This var determines if an area is outside (affected by sunlight) or - not. */ - sd_outside = 0 - - sd_light_level = 0 // the current light level of the area - + sd_LevelRed = 0 // the current light level of the area + sd_LevelGreen = 0 + sd_LevelBlue = 0 sd_darkimage // tracks the darkness image of the area for easy removal proc - sd_LightLevel(slevel = sd_light_level as num, keep = 1) - if(!src) return + sd_LightLevel(rlevel = sd_LevelRed as num, glevel = sd_LevelGreen as num, blevel = sd_LevelBlue as num, keep = 1) + if (!src) return overlays -= sd_darkimage - if(keep) sd_light_level = slevel + if(keep) + sd_LevelRed = rlevel + sd_LevelGreen = glevel + sd_LevelBlue = blevel - slevel = min(max(slevel,0),sd_dark_shades) // restrict range - - if(slevel > 0) + if(rlevel > 0 || glevel > 0 || blevel > 0) luminosity = 1 else luminosity = 0 - sd_darkimage = image(sd_dark_icon,,num2text(slevel),sd_light_layer) + sd_darkimage = image('ULIcons.dmi',,"[rlevel]-[glevel]-[blevel]",sd_light_layer) overlays += sd_darkimage - /* - New() - ..() - if(!tag) tag = "[type]" - spawn(1) // wait a tick - if(sd_lighting) - // see if this area was created by the library - if(!findtext(tag, "sd_L")) - /* show the dark overlay so areas outside of luminous regions - won't be bright as day when they should be dark. */ - sd_LightLevel() - if(sd_outside) - sd_outside_areas += src - */ 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() - //if(sd_outside) - // sd_outside_areas += src Del() ..() related -= src mob - /* extend the mob procs to compensate for sight settings. */ - sd_ApplyLum(list/V, center = src) + sd_ApplyLum(list/V, center = src, updateMode) if(!V) if(isturf(loc)) V = view(luminosity,loc) else V = view(luminosity,src) - . = ..(V, center) + . = ..(V, center, updateMode) - sd_StripLum(list/V, center = src) + sd_StripLum(list/V, center = src, updateMode) if(!V) if(isturf(loc)) V = view(luminosity,loc) else V = view(luminosity,src) - . = ..(V, center) + . = ..(V, center, updateMode) sd_ApplyLocalLum(list/affected) if(!affected) @@ -768,5 +318,4 @@ mob affected = view(sd_top_luminosity,loc) else affected = view(sd_top_luminosity,src) - . = ..(affected) - + . = ..(affected) \ No newline at end of file diff --git a/code/modules/projectiles/projectile.dm b/code/modules/projectiles/projectile.dm index bf7e6cb242c..e7932ce2195 100644 --- a/code/modules/projectiles/projectile.dm +++ b/code/modules/projectiles/projectile.dm @@ -46,7 +46,12 @@ var/stutter = 0 var/eyeblur = 0 var/drowsy = 0 + var/glowstr = 0 // set to nonzero if you want this projectile to emit light (recommend no greater than 4) + New() + ..() + if(glowstr > 0) + sd_SetLuminosity(glowstr) proc/on_hit(var/atom/target, var/blocked = 0) if(blocked >= 2) return 0//Full block diff --git a/code/modules/projectiles/projectile/beams.dm b/code/modules/projectiles/projectile/beams.dm index db8971a1b3c..a82c122d196 100644 --- a/code/modules/projectiles/projectile/beams.dm +++ b/code/modules/projectiles/projectile/beams.dm @@ -7,6 +7,11 @@ flag = "laser" eyeblur = 2 + glowstr = 3 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.1 + sd_ColorRed = 0.7 + /obj/item/projectile/practice name = "laser" icon_state = "laser" @@ -16,33 +21,59 @@ flag = "laser" eyeblur = 2 + glowstr = 3 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.1 + sd_ColorRed = 0.7 /obj/item/projectile/beam/heavylaser name = "heavy laser" icon_state = "heavylaser" damage = 40 + glowstr = 4 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.1 + sd_ColorRed = 0.8 + /obj/item/projectile/beam/xray name = "xray beam" icon_state = "xray" damage = 30 + glowstr = 3 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.7 + sd_ColorRed = 0.1 + /obj/item/projectile/beam/pulse name = "pulse" icon_state = "u_laser" damage = 50 + glowstr = 4 + sd_ColorBlue = 0.9 + sd_ColorGreen = 0.2 + sd_ColorRed = 0.1 /obj/item/projectile/beam/deathlaser name = "death laser" icon_state = "heavylaser" damage = 60 + glowstr = 4 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.1 + sd_ColorRed = 0.8 + /obj/item/projectile/beam/emitter name = "emitter beam" icon_state = "emitter" - + glowstr = 4 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.7 + sd_ColorRed = 0.2 /obj/item/projectile/bluetag name = "lasertag beam" @@ -52,6 +83,11 @@ damage_type = BURN flag = "laser" + glowstr = 3 + sd_ColorBlue = 0.7 + sd_ColorGreen = 0.1 + sd_ColorRed = 0.1 + on_hit(var/atom/target, var/blocked = 0) if(istype(target, /mob/living/carbon/human)) var/mob/living/carbon/human/M = target @@ -67,6 +103,11 @@ damage_type = BURN flag = "laser" + glowstr = 3 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.1 + sd_ColorRed = 0.7 + on_hit(var/atom/target, var/blocked = 0) if(istype(target, /mob/living/carbon/human)) var/mob/living/carbon/human/M = target @@ -82,6 +123,11 @@ damage_type = BURN flag = "laser" + glowstr = 3 + sd_ColorBlue = 0.9 + sd_ColorGreen = 0.3 + sd_ColorRed = 0.1 + on_hit(var/atom/target, var/blocked = 0) if(istype(target, /mob/living/carbon/human)) var/mob/living/carbon/human/M = target diff --git a/code/modules/projectiles/projectile/change.dm b/code/modules/projectiles/projectile/change.dm index 44529ff3ee9..fb110afe453 100644 --- a/code/modules/projectiles/projectile/change.dm +++ b/code/modules/projectiles/projectile/change.dm @@ -6,6 +6,11 @@ nodamage = 1 flag = "energy" + glowstr = 3 + sd_ColorBlue = 0.9 + sd_ColorGreen = 0.3 + sd_ColorRed = 0.1 + on_hit(var/atom/change) wabbajack(change) diff --git a/code/modules/projectiles/projectile/energy.dm b/code/modules/projectiles/projectile/energy.dm index 07ecdcb710b..e5a2c05c10f 100644 --- a/code/modules/projectiles/projectile/energy.dm +++ b/code/modules/projectiles/projectile/energy.dm @@ -14,6 +14,11 @@ weaken = 10 stutter = 10 + glowstr = 2 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.5 + sd_ColorRed = 0.5 + /obj/item/projectile/energy/declone name = "declown" @@ -22,6 +27,11 @@ damage_type = CLONE irradiate = 40 + glowstr = 3 + sd_ColorBlue = 0.1 + sd_ColorGreen = 0.5 + sd_ColorRed = 0.1 + /obj/item/projectile/energy/dart name = "dart" diff --git a/code/modules/projectiles/projectile/special.dm b/code/modules/projectiles/projectile/special.dm index 3ea6d135a93..563947a5df7 100644 --- a/code/modules/projectiles/projectile/special.dm +++ b/code/modules/projectiles/projectile/special.dm @@ -6,6 +6,10 @@ nodamage = 1 flag = "energy" + glowstr = 3 + sd_ColorBlue = 0.9 + sd_ColorGreen = 0.3 + sd_ColorRed = 0.1 on_hit(var/atom/target, var/blocked = 0) empulse(target, 1, 1) @@ -32,6 +36,11 @@ flag = "energy" var/temperature = 300 + glowstr = 3 + sd_ColorBlue = 0.9 + sd_ColorGreen = 0.3 + sd_ColorRed = 0.1 + on_hit(var/atom/target, var/blocked = 0)//These two could likely check temp protection on the mob if(istype(target, /mob/living)) diff --git a/html/changelog.html b/html/changelog.html index 1645b3de489..e472f38edc0 100644 --- a/html/changelog.html +++ b/html/changelog.html @@ -56,6 +56,10 @@ should be listed in the changelog upon commit tho. Thanks. -->