From 03a3944f36dc60a1290cf786f8b67b633adf4f72 Mon Sep 17 00:00:00 2001 From: Novacat <35587478+Novacat@users.noreply.github.com> Date: Tue, 18 Jun 2019 19:56:30 -0400 Subject: [PATCH] An assortment of Lighting Stuff --- code/__defines/lighting.dm | 4 +- .../objects/items/devices/lightreplacer.dm | 50 +-- code/modules/lighting/lighting_corner.dm | 6 +- code/modules/lighting/lighting_source.dm | 2 +- code/modules/power/lighting.dm | 376 +++++++++--------- html/changelogs/Novacat - Lighting.yml | 37 ++ .../surface_submaps/mountains/deadBeacon.dmm | 4 +- 7 files changed, 242 insertions(+), 237 deletions(-) create mode 100644 html/changelogs/Novacat - Lighting.yml diff --git a/code/__defines/lighting.dm b/code/__defines/lighting.dm index bf8f5129f5..0425c3fa63 100644 --- a/code/__defines/lighting.dm +++ b/code/__defines/lighting.dm @@ -16,6 +16,8 @@ #define LIGHTING_SOFT_THRESHOLD 0.05 // If the max of the lighting lumcounts of each spectrum drops below this, disable luminosity on the lighting overlays. This also should be the transparancy of the "soft_dark" icon state. +#define LIGHTING_MULT_FACTOR 0.5 + // If I were you I'd leave this alone. #define LIGHTING_BASE_MATRIX \ list \ @@ -77,7 +79,7 @@ //Lighting values used by the station lights #define LIGHT_COLOR_FLUORESCENT_TUBE "#E0EFFF" #define LIGHT_COLOR_FLUORESCENT_FLASHLIGHT "#CDDDFF" -#define LIGHT_COLOR_INCANDESCENT_TUBE "#FFEEDD" +#define LIGHT_COLOR_INCANDESCENT_TUBE "#FFFEB8" #define LIGHT_COLOR_INCANDESCENT_BULB "#FFDDBB" #define LIGHT_COLOR_INCANDESCENT_FLASHLIGHT "#FFCC66" diff --git a/code/game/objects/items/devices/lightreplacer.dm b/code/game/objects/items/devices/lightreplacer.dm index 7e2b054165..4686aee807 100644 --- a/code/game/objects/items/devices/lightreplacer.dm +++ b/code/game/objects/items/devices/lightreplacer.dm @@ -121,48 +121,18 @@ /obj/item/device/lightreplacer/proc/ReplaceLight(var/obj/machinery/light/target, var/mob/living/U) - if(target.status != LIGHT_OK) - if(CanUse(U)) - if(!Use(U)) return - U << "You replace the [target.fitting] with the [src]." + if(target.status == LIGHT_OK) + to_chat(U, "There is a working [target.get_fitting_name()] already inserted.") + else if(!CanUse(U)) + to_chat(U, failmsg) + else if(Use(U)) + to_chat(U, "You replace the [target.get_fitting_name()] with the [src].") - if(target.status != LIGHT_EMPTY) + if(target.status != LIGHT_EMPTY) + target.remove_bulb() - var/obj/item/weapon/light/L1 = new target.light_type(target.loc) - L1.status = target.status - L1.rigged = target.rigged - 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() - - target.status = LIGHT_EMPTY - target.update() - - var/obj/item/weapon/light/L2 = new target.light_type() - - target.status = L2.status - target.switchcount = L2.switchcount - target.rigged = emagged - 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) - - if(target.on && target.rigged) - target.explode() - return - - else - U << failmsg - return - else - U << "There is a working [target.fitting] already inserted." - return + var/obj/item/weapon/light/L = new target.light_type() + target.insert_bulb(L) /obj/item/device/lightreplacer/emag_act(var/remaining_charges, var/mob/user) emagged = !emagged diff --git a/code/modules/lighting/lighting_corner.dm b/code/modules/lighting/lighting_corner.dm index 088c53e521..30230a69e0 100644 --- a/code/modules/lighting/lighting_corner.dm +++ b/code/modules/lighting/lighting_corner.dm @@ -99,9 +99,9 @@ /datum/lighting_corner/proc/update_overlays() // Cache these values a head of time so 4 individual lighting overlays don't all calculate them individually. - var/lum_r = src.lum_r - var/lum_g = src.lum_g - var/lum_b = src.lum_b + var/lum_r = src.lum_r > 0 ? LIGHTING_MULT_FACTOR * sqrt(src.lum_r) : src.lum_r + var/lum_g = src.lum_g > 0 ? LIGHTING_MULT_FACTOR * sqrt(src.lum_g) : src.lum_g + var/lum_b = src.lum_b > 0 ? LIGHTING_MULT_FACTOR * sqrt(src.lum_b) : src.lum_b var/mx = max(lum_r, lum_g, lum_b) // Scale it so 1 is the strongest lum, if it is above 1. . = 1 // factor if (mx > 1) diff --git a/code/modules/lighting/lighting_source.dm b/code/modules/lighting/lighting_source.dm index d878d8c4b6..451b8273c8 100644 --- a/code/modules/lighting/lighting_source.dm +++ b/code/modules/lighting/lighting_source.dm @@ -189,7 +189,7 @@ ); // This is the define used to calculate falloff. -#define LUM_FALLOFF(C, T)(1 - CLAMP01(sqrt((C.x - T.x) ** 2 +(C.y - T.y) ** 2 + LIGHTING_HEIGHT) / max(1, light_range))) +#define LUM_FALLOFF(C, T)(1 - CLAMP01(((C.x - T.x) ** 2 +(C.y - T.y) ** 2 + LIGHTING_HEIGHT) ** 0.6 / max(1, light_range))) /datum/light_source/proc/apply_lum() var/static/update_gen = 1 diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index 24132d2988..2756ed8405 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -9,6 +9,14 @@ #define LIGHT_BROKEN 2 #define LIGHT_BURNED 3 #define LIGHT_BULB_TEMPERATURE 400 //K - used value for a 60W bulb +#define LIGHTING_POWER_FACTOR 5 //5W per luminosity * range + +var/global/list/light_type_cache = list() +/proc/get_light_type_instance(var/light_type) + . = light_type_cache[light_type] + if(!.) + . = new light_type + light_type_cache[light_type] = . /obj/machinery/light_construct name = "light fixture frame" @@ -19,16 +27,26 @@ plane = MOB_PLANE layer = ABOVE_MOB_LAYER var/stage = 1 - var/fixture_type = "tube" + var/fixture_type = /obj/machinery/light var/sheets_refunded = 2 - var/obj/machinery/light/newlight = null -/obj/machinery/light_construct/New() - ..() - if (fixture_type == "bulb") - icon_state = "bulb-construct-stage1" - if (fixture_type == "flamp") - icon_state = "flamp-construct-stage1" +/obj/machinery/light_construct/New(atom/newloc, obj/machinery/light/fixture = null) + ..(newloc) + if(fixture) + fixture_type = fixture.type + fixture.transfer_fingerprints_to(src) + set_dir(fixture.dir) + stage = 2 + update_icon() + +/obj/machinery/light_construct/update_icon() + switch(stage) + if(1) + icon_state = "tube-construct-stage1" + if(2) + icon_state = "tube-construct-stage2" + if(3) + icon_state = "tube-empty" /obj/machinery/light_construct/examine(mob/user) if(!..(user, 2)) @@ -36,21 +54,18 @@ switch(src.stage) if(1) - user << "It's an empty frame." - return + to_chat(user, "It's an empty frame.") if(2) - user << "It's wired." - return + to_chat(user, "It's wired.") if(3) - user << "The casing is closed." - return + to_chat(user, "The casing is closed.") /obj/machinery/light_construct/attackby(obj/item/weapon/W as obj, mob/user as mob) src.add_fingerprint(user) if (W.is_wrench()) if (src.stage == 1) playsound(src, W.usesound, 75, 1) - usr << "You begin deconstructing [src]." + to_chat(usr, "You begin deconstructing [src].") if (!do_after(usr, 30 * W.toolspeed)) return new /obj/item/stack/material/steel( get_turf(src.loc), sheets_refunded ) @@ -59,23 +74,17 @@ playsound(src.loc, 'sound/items/Deconstruct.ogg', 75, 1) qdel(src) if (src.stage == 2) - usr << "You have to remove the wires first." + to_chat(usr, "You have to remove the wires first.") return if (src.stage == 3) - usr << "You have to unscrew the case first." + to_chat(usr, "You have to unscrew the case first.") return if(W.is_wirecutter()) if (src.stage != 2) return src.stage = 1 - switch(fixture_type) - if ("tube") - src.icon_state = "tube-construct-stage1" - if("bulb") - src.icon_state = "bulb-construct-stage1" - if("flamp") - src.icon_state = "flamp-construct-stage1" + src.update_icon() new /obj/item/stack/cable_coil(get_turf(src.loc), 1, "red") user.visible_message("[user.name] removes the wiring from [src].", \ "You remove the wiring from [src].", "You hear a noise.") @@ -86,42 +95,22 @@ if (src.stage != 1) return var/obj/item/stack/cable_coil/coil = W if (coil.use(1)) - switch(fixture_type) - if ("tube") - src.icon_state = "tube-construct-stage2" - if("bulb") - src.icon_state = "bulb-construct-stage2" - if("flamp") - src.icon_state = "flamp-construct-stage2" src.stage = 2 + src.update_icon() user.visible_message("[user.name] adds wires to [src].", \ "You add wires to [src].") return if(W.is_screwdriver()) if (src.stage == 2) - switch(fixture_type) - if ("tube") - src.icon_state = "tube-empty" - if("bulb") - src.icon_state = "bulb-empty" - if("flamp") - src.icon_state = "flamp-empty" src.stage = 3 + src.update_icon() user.visible_message("[user.name] closes [src]'s casing.", \ "You close [src]'s casing.", "You hear a noise.") playsound(src, W.usesound, 75, 1) - switch(fixture_type) - - if("tube") - newlight = new /obj/machinery/light/built(src.loc) - if ("bulb") - newlight = new /obj/machinery/light/small/built(src.loc) - if ("flamp") - newlight = new /obj/machinery/light/flamp/built(src.loc) - - newlight.dir = src.dir + var/obj/machinery/light/newlight = new fixture_type(src.loc, src) + newlight.set_dir(src.dir) src.transfer_fingerprints_to(newlight) qdel(src) return @@ -134,9 +123,18 @@ icon_state = "bulb-construct-stage1" anchored = 1 stage = 1 - fixture_type = "bulb" + fixture_type = /obj/machinery/light/small sheets_refunded = 1 +/obj/machinery/light_construct/small/update_icon() + switch(stage) + if(1) + icon_state = "bulb-construct-stage1" + if(2) + icon_state = "bulb-construct-stage2" + if(3) + icon_state = "bulb-empty" + /obj/machinery/light_construct/flamp name = "floor light fixture frame" desc = "A floor light fixture under construction." @@ -146,9 +144,18 @@ plane = OBJ_PLANE layer = OBJ_LAYER stage = 1 - fixture_type = "flamp" + fixture_type = /obj/machinery/light/flamp sheets_refunded = 2 +/obj/machinery/light_construct/flamp/update_icon() + switch(stage) + if(1) + icon_state = "flamp-construct-stage1" + if(2) + icon_state = "flamp-construct-stage2" + if(3) + icon_state = "flamp-empty" + // the standard tube light fixture /obj/machinery/light name = "light fixture" @@ -164,13 +171,19 @@ active_power_usage = 20 // VOREStation Edit - Keep lights at 20 power 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 +<<<<<<< HEAD var/brightness_range = 10 // luminosity when on, also used in power calculation //VOREStation Edit - 8->10 var/brightness_power = 0.8 var/brightness_color = LIGHT_COLOR_FLUORESCENT_TUBE //VOREStation Edit - Our tubes are whiter +======= + var/brightness_range + var/brightness_power + var/brightness_color +>>>>>>> 584a9a4... An assortment of Lighting Stuff (#6196) 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 - var/fitting = "tube" + var/construct_type = /obj/machinery/light_construct var/switchcount = 0 // count of number of times switched on/off // this is used to calc the probability the light burns out @@ -189,12 +202,18 @@ /obj/machinery/light/small icon_state = "bulb1" base_state = "bulb" +<<<<<<< HEAD fitting = "bulb" brightness_range = 5 //VOREStation Edit - 4->5 brightness_color = LIGHT_COLOR_INCANDESCENT_BULB desc = "A small lighting fixture." light_type = /obj/item/weapon/light/bulb shows_alerts = FALSE +======= + desc = "A small lighting fixture." + light_type = /obj/item/weapon/light/bulb + construct_type = /obj/machinery/light_construct/small +>>>>>>> 584a9a4... An assortment of Lighting Stuff (#6196) /obj/machinery/light/small/flicker auto_flicker = TRUE @@ -203,14 +222,20 @@ icon = 'icons/obj/lighting.dmi' icon_state = "flamp1" base_state = "flamp" +<<<<<<< HEAD fitting = "bulb" brightness_range = 8 //VOREStation Edit - 4->8 +======= +>>>>>>> 584a9a4... An assortment of Lighting Stuff (#6196) plane = OBJ_PLANE layer = OBJ_LAYER - brightness_color = LIGHT_COLOR_INCANDESCENT_BULB desc = "A floor lamp." light_type = /obj/item/weapon/light/bulb +<<<<<<< HEAD shows_alerts = FALSE +======= + construct_type = /obj/machinery/light_construct/flamp +>>>>>>> 584a9a4... An assortment of Lighting Stuff (#6196) var/lamp_shade = 1 /obj/machinery/light/flamp/flicker @@ -218,8 +243,7 @@ /obj/machinery/light/small/emergency - brightness_range = 4 - brightness_color = "#da0205" + light_type = /obj/item/weapon/light/bulb/red /obj/machinery/light/small/emergency/flicker auto_flicker = TRUE @@ -227,15 +251,18 @@ /obj/machinery/light/spot name = "spotlight" - fitting = "large tube" light_type = /obj/item/weapon/light/tube/large +<<<<<<< HEAD shows_alerts = FALSE brightness_range = 12 brightness_power = 0.9 +======= +>>>>>>> 584a9a4... An assortment of Lighting Stuff (#6196) /obj/machinery/light/spot/flicker auto_flicker = TRUE +<<<<<<< HEAD /obj/machinery/light/built/New() status = LIGHT_EMPTY @@ -258,22 +285,25 @@ update(0) ..() //VOREStation Add End +======= +>>>>>>> 584a9a4... An assortment of Lighting Stuff (#6196) // create a new lighting fixture -/obj/machinery/light/New() - ..() +/obj/machinery/light/New(atom/newloc, obj/machinery/light_construct/construct = null) + ..(newloc) - spawn(2) - on = has_power() + if(construct) + status = LIGHT_EMPTY + construct_type = construct.type + construct.transfer_fingerprints_to(src) + set_dir(construct.dir) + else + var/obj/item/weapon/light/L = get_light_type_instance(light_type) + update_from_bulb(L) + if(prob(L.broken_chance)) + broken(1) - switch(fitting) - if("tube") - if(prob(2)) - broken(1) - if("bulb") - if(prob(5)) - broken(1) - spawn(1) - update(0) + on = powered() + update(0) /obj/machinery/light/Destroy() var/area/A = get_area(src) @@ -342,7 +372,7 @@ if(on) update() -// update the icon_state and luminosity of the light depending on its state +// update lighting /obj/machinery/light/proc/update(var/trigger = 1) update_icon() if(!on) @@ -375,14 +405,14 @@ use_power = 1 set_light(0) - active_power_usage = light_range * light_power + active_power_usage = ((light_range * light_power) * LIGHTING_POWER_FACTOR) /obj/machinery/light/attack_generic(var/mob/user, var/damage) if(!damage) return if(status == LIGHT_EMPTY||status == LIGHT_BROKEN) - user << "That object is useless to you." + to_chat(user, "That object is useless to you.") return if(!(status == LIGHT_OK||status == LIGHT_BURNED)) return @@ -402,20 +432,52 @@ // examine verb /obj/machinery/light/examine(mob/user) + var/fitting = get_fitting_name() switch(status) if(LIGHT_OK) - user << "[desc] It is turned [on? "on" : "off"]." + to_chat(user, "[desc] It is turned [on? "on" : "off"].") if(LIGHT_EMPTY) - user << "[desc] The [fitting] has been removed." + to_chat(user, "[desc] The [fitting] has been removed.") if(LIGHT_BURNED) - user << "[desc] The [fitting] is burnt out." + to_chat(user, "[desc] The [fitting] is burnt out.") if(LIGHT_BROKEN) - user << "[desc] The [fitting] has been smashed." + to_chat(user, "[desc] The [fitting] has been smashed.") +/obj/machinery/light/proc/get_fitting_name() + var/obj/item/weapon/light/L = light_type + return initial(L.name) +/obj/machinery/light/proc/update_from_bulb(obj/item/weapon/light/L) + status = L.status + switchcount = L.switchcount + rigged = L.rigged + brightness_range = L.brightness_range + brightness_power = L.brightness_power + brightness_color = L.brightness_color // attack with item - insert light (if right type), otherwise try to break the light +/obj/machinery/light/proc/insert_bulb(obj/item/weapon/light/L) + update_from_bulb(L) + qdel(L) + + on = powered() + update() + + if(on && rigged) + + log_admin("LOG: Rigged light explosion, last touched by [fingerprintslast]") + message_admins("LOG: Rigged light explosion, last touched by [fingerprintslast]") + + explode() + +/obj/machinery/light/proc/remove_bulb() + . = new light_type(src.loc, src) + + switchcount = 0 + status = LIGHT_EMPTY + update() + /obj/machinery/light/attackby(obj/item/W, mob/user) //Light replacer code @@ -429,34 +491,15 @@ // attempt to insert light if(istype(W, /obj/item/weapon/light)) if(status != LIGHT_EMPTY) - user << "There is a [fitting] already inserted." + to_chat(user, "There is a [get_fitting_name()] already inserted.") + return + if(!istype(W, light_type)) + to_chat(user, "This type of light requires a [get_fitting_name()].") return - else - src.add_fingerprint(user) - var/obj/item/weapon/light/L = W - if(istype(L, light_type)) - status = L.status - user << "You insert the [L.name]." - switchcount = L.switchcount - rigged = L.rigged - brightness_range = L.brightness_range - brightness_power = L.brightness_power - brightness_color = L.brightness_color - on = has_power() - update() - user.drop_item() //drop the item to update overlays and such - qdel(L) - - if(on && rigged) - - log_admin("LOG: Rigged light explosion, last touched by [fingerprintslast]") - message_admins("LOG: Rigged light explosion, last touched by [fingerprintslast]") - - explode() - else - user << "This type of light requires a [fitting]." - return + to_chat(user, "You insert [W].") + insert_bulb(W) + src.add_fingerprint(user) // attempt to break the light //If xenos decide they want to smash a light bulb with a toolbox, who am I to stop them? /N @@ -466,7 +509,7 @@ if(prob(1+W.force * 5)) - user << "You hit the light, and it smashes!" + to_chat(user, "You hit the light, and it smashes!") for(var/mob/M in viewers(src)) if(M == user) continue @@ -478,7 +521,7 @@ broken() else - user << "You hit the light!" + to_chat(user, "You hit the light!") // attempt to stick weapon into light socket else if(status == LIGHT_EMPTY) @@ -486,29 +529,11 @@ playsound(src, W.usesound, 75, 1) user.visible_message("[user.name] opens [src]'s casing.", \ "You open [src]'s casing.", "You hear a noise.") - var/obj/machinery/light_construct/newlight = null - switch(fitting) - if("tube") - newlight = new /obj/machinery/light_construct(src.loc) - newlight.icon_state = "tube-construct-stage2" - - if("bulb") - newlight = new /obj/machinery/light_construct/small(src.loc) - newlight.icon_state = "bulb-construct-stage2" - - if("flamp") - newlight = new /obj/machinery/light_construct/flamp(src.loc) - newlight.icon_state = "flamp-construct-stage2" - - newlight.dir = src.dir - newlight.stage = 2 - newlight.fingerprints = src.fingerprints - newlight.fingerprintshidden = src.fingerprintshidden - newlight.fingerprintslast = src.fingerprintslast + new construct_type(src.loc, src) qdel(src) return - user << "You stick \the [W] into the light socket!" + to_chat(user, "You stick \the [W] into the light socket!") if(has_power() && !(W.flags & NOCONDUCT)) var/datum/effect/effect/system/spark_spread/s = new /datum/effect/effect/system/spark_spread s.set_up(3, 1, src) @@ -521,7 +546,7 @@ if(W.is_wrench()) anchored = !anchored playsound(src, W.usesound, 50, 1) - user << "You [anchored ? "wrench" : "unwrench"] \the [src]." + to_chat(user, "You [anchored ? "wrench" : "unwrench"] \the [src].") if(!lamp_shade) if(istype(W, /obj/item/weapon/lampshade)) @@ -586,7 +611,7 @@ add_fingerprint(user) if(status == LIGHT_EMPTY) - user << "There is no [fitting] in this light." + to_chat(user, "There is no [get_fitting_name()] in this light.") return if(istype(user,/mob/living/carbon/human)) @@ -615,39 +640,22 @@ prot = 1 if(prot > 0 || (COLD_RESISTANCE in user.mutations)) - user << "You remove the light [fitting]" + to_chat(user, "You remove the light [get_fitting_name()]") else if(TK in user.mutations) - user << "You telekinetically remove the light [fitting]." + to_chat(user, "You telekinetically remove the light [get_fitting_name()].") else - user << "You try to remove the light [fitting], but it's too hot and you don't want to burn your hand." + to_chat(user, "You try to remove the light [get_fitting_name()], but it's too hot and you don't want to burn your hand.") return // if burned, don't remove the light else - user << "You remove the light [fitting]." + to_chat(user, "You remove the light [get_fitting_name()].") // create a light tube/bulb item and put it in the user's hand - var/obj/item/weapon/light/L = new light_type() - L.status = status - L.rigged = rigged - 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 - switchcount = 0 - - L.update() - L.add_fingerprint(user) - - user.put_in_active_hand(L) //puts it in our active hand - - status = LIGHT_EMPTY - update() + user.put_in_active_hand(remove_bulb()) //puts it in our active hand /obj/machinery/light/flamp/attack_hand(mob/user) if(lamp_shade) if(status == LIGHT_EMPTY) - user << "There is no [fitting] in this light." + to_chat(user, "There is no [get_fitting_name()] in this light.") return if(on) @@ -662,28 +670,11 @@ /obj/machinery/light/attack_tk(mob/user) if(status == LIGHT_EMPTY) - user << "There is no [fitting] in this light." + to_chat(user, "There is no [get_fitting_name()] in this light.") return - user << "You telekinetically remove the light [fitting]." - // create a light tube/bulb item and put it in the user's hand - var/obj/item/weapon/light/L = new light_type() - L.status = status - L.rigged = rigged - 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 - switchcount = 0 - - L.update() - L.add_fingerprint(user) - L.loc = loc - - status = LIGHT_EMPTY - update() + to_chat(user, "You telekinetically remove the light [get_fitting_name()].") + remove_bulb() // break the light and make sparks if was on @@ -730,13 +721,7 @@ // timed process // use power -#define LIGHTING_POWER_FACTOR 20 //20W per unit luminosity - - /obj/machinery/light/process() - if(on) - use_power(light_range * LIGHTING_POWER_FACTOR, LIGHT) - if(auto_flicker && !flickering) if(check_for_player_proximity(src, radius = 12, ignore_ghosts = FALSE, ignore_afk = TRUE)) seton(TRUE) // Lights must be on to flicker. @@ -744,7 +729,6 @@ else seton(FALSE) // Otherwise keep it dark and spooky for when someone shows up. - // called when area power state changes /obj/machinery/light/power_change() spawn(10) @@ -781,8 +765,10 @@ var/switchcount = 0 // number of times switched matter = list(DEFAULT_WALL_MATERIAL = 60) var/rigged = 0 // true if rigged to explode + var/broken_chance = 2 + var/brightness_range = 2 //how much light it gives off - var/brightness_power = 0.8 + var/brightness_power = 1 var/brightness_color = LIGHT_COLOR_INCANDESCENT_TUBE /obj/item/weapon/light/tube @@ -792,13 +778,14 @@ base_state = "ltube" item_state = "c_tube" matter = list("glass" = 100) - brightness_range = 8 + brightness_range = 6 // luminosity when on, also used in power calculation + brightness_power = 6 /obj/item/weapon/light/tube/large w_class = ITEMSIZE_SMALL name = "large light tube" brightness_range = 15 - brightness_power = 0.9 + brightness_power = 9 /obj/item/weapon/light/bulb name = "light bulb" @@ -808,12 +795,18 @@ item_state = "contvapour" matter = list("glass" = 100) brightness_range = 5 + brightness_power = 4 brightness_color = LIGHT_COLOR_INCANDESCENT_BULB /obj/item/weapon/light/throw_impact(atom/hit_atom) ..() shatter() +/obj/item/weapon/light/bulb/red + brightness_range = 4 + color = "#da0205" + brightness_color = "#da0205" + /obj/item/weapon/light/bulb/fire name = "fire bulb" desc = "A replacement fire bulb." @@ -821,11 +814,9 @@ base_state = "fbulb" item_state = "egg4" matter = list("glass" = 100) - brightness_range = 5 // update the icon state and description of the light - -/obj/item/weapon/light/proc/update() +/obj/item/weapon/light/update_icon() switch(status) if(LIGHT_OK) icon_state = base_state @@ -838,14 +829,19 @@ desc = "A broken [name]." -/obj/item/weapon/light/New() +/obj/item/weapon/light/New(atom/newloc, obj/machinery/light/fixture = null) ..() - switch(name) - if("light tube") - brightness_range = rand(6,9) - if("light bulb") - brightness_range = rand(4,6) - update() + if(fixture) + status = fixture.status + rigged = fixture.rigged + switchcount = fixture.switchcount + fixture.transfer_fingerprints_to(src) + + //shouldn't be necessary to copy these unless someone varedits stuff, but just in case + brightness_range = fixture.brightness_range + brightness_power = fixture.brightness_power + brightness_color = fixture.brightness_color + update_icon() // attack bulb/tube with object @@ -855,7 +851,7 @@ if(istype(I, /obj/item/weapon/reagent_containers/syringe)) var/obj/item/weapon/reagent_containers/syringe/S = I - user << "You inject the solution into the [src]." + to_chat(user, "You inject the solution into the [src].") if(S.reagents.has_reagent("phoron", 5)) @@ -889,7 +885,7 @@ force = 5 sharp = 1 playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1) - update() + update_icon() //Lamp Shade /obj/item/weapon/lampshade diff --git a/html/changelogs/Novacat - Lighting.yml b/html/changelogs/Novacat - Lighting.yml new file mode 100644 index 0000000000..eba91c1d21 --- /dev/null +++ b/html/changelogs/Novacat - Lighting.yml @@ -0,0 +1,37 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +################################# + +# Your name. +author: Novacat + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - tweak: "Attempts to make lighting less uniform" + - tweak: "Cleans up lighting code" diff --git a/maps/submaps/surface_submaps/mountains/deadBeacon.dmm b/maps/submaps/surface_submaps/mountains/deadBeacon.dmm index 85eefad2c5..2a32fb4f64 100644 --- a/maps/submaps/surface_submaps/mountains/deadBeacon.dmm +++ b/maps/submaps/surface_submaps/mountains/deadBeacon.dmm @@ -10,7 +10,7 @@ "j" = (/obj/structure/table/steel,/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) "k" = (/obj/structure/loot_pile/maint/technical,/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) "l" = (/obj/item/weapon/material/shard,/turf/simulated/floor/plating,/area/submap/cave/deadBeacon) -"m" = (/obj/structure/table/steel,/obj/item/weapon/circuitboard/comm_server,/obj/machinery/light/built{dir = 8; fitting = ""},/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) +"m" = (/obj/structure/table/steel,/obj/item/weapon/circuitboard/comm_server,/obj/machinery/light{dir = 8; status = LIGHT_EMPTY},/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) "n" = (/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) "o" = (/obj/item/weapon/paper/crumpled{info = "Sampatti Relay Sif-833
Decryption Key for 12-04-2488:
849B0022FBA920C244
Eyes Only.
The insider who knows all the secrets can bring down Lanka."; name = "Dusty Note"},/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) "p" = (/obj/structure/door_assembly/door_assembly_ext,/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) @@ -27,7 +27,7 @@ "A" = (/obj/item/weapon/circuitboard/broken,/turf/simulated/mineral/floor/ignore_mapgen,/area/submap/cave/deadBeacon) "B" = (/obj/structure/grille/broken,/obj/structure/window/reinforced{dir = 4},/turf/simulated/floor/plating,/area/submap/cave/deadBeacon) "C" = (/obj/structure/loot_pile/maint/junk,/turf/simulated/floor/plating,/area/submap/cave/deadBeacon) -"D" = (/obj/item/weapon/cigbutt,/obj/item/weapon/tool/wrench,/obj/machinery/light/built,/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) +"D" = (/obj/item/weapon/cigbutt,/obj/item/weapon/tool/wrench,/obj/machinery/light,/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) "E" = (/obj/item/weapon/material/shard,/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) "F" = (/obj/machinery/recharge_station,/turf/simulated/floor/tiled/asteroid_steel,/area/submap/cave/deadBeacon) "G" = (/obj/structure/grille,/obj/structure/window/reinforced{dir = 4},/obj/structure/window/reinforced{dir = 8},/obj/structure/window/reinforced,/turf/simulated/floor/plating,/area/submap/cave/deadBeacon)