diff --git a/code/modules/power/lighting.dm b/code/modules/power/lighting.dm index e9e899a90d5..230f738ca88 100644 --- a/code/modules/power/lighting.dm +++ b/code/modules/power/lighting.dm @@ -1,31 +1,40 @@ // The lighting system -// -// consists of light fixtures (/obj/machinery/light) and light tube/bulb items (/obj/item/weapon/light) +// Consists of: +// - light fixtures (/obj/machinery/light) +// - light tube/bulb items (/obj/item/weapon/light) -// status values shared between lighting fixtures and items +// Status values shared between lighting fixtures and items #define LIGHT_OK 0 #define LIGHT_EMPTY 1 #define LIGHT_BROKEN 2 #define LIGHT_BURNED 3 -// the standard tube light fixture +#define TUBE_BRIGHT_MIN 6 +#define TUBE_BRIGHT_MAX 8 +#define BULB_BRIGHT_MIN 4 +#define BULB_BRIGHT_MAX 5 +#define LARGETUBE_BRIGHT 15 + +// The standard tube light fixture /obj/machinery/light name = "light fixture" icon = 'lighting.dmi' - var/base_state = "tube" // base description and icon_state icon_state = "tube1" desc = "A lighting fixture." anchored = 1 layer = 5 // They were appearing under mobs which is a little weird - Ostaf + use_power = 2 idle_power_usage = 2 active_power_usage = 20 - power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list + power_channel = LIGHT //Lights are calc'd via area so they dont need to be in the machine list + + var/base_state = "tube" // base description and icon_state var/on = 0 // 1 if on, 0 if off - var/on_gs = 0 - var/brightness = 8 // luminosity when on, also used in power calculation +// var/on_gs = 0 + var/brightness // luminosity when on, also used in power calculation var/status = LIGHT_OK // LIGHT_OK, _EMPTY, _BURNED or _BROKEN var/light_type = /obj/item/weapon/light/tube // the type of light item @@ -35,19 +44,15 @@ var/rigged = 0 // true if rigged to explode -// the smaller bulb light fixture + /obj/machinery/light/small icon_state = "bulb1" base_state = "bulb" fitting = "bulb" - brightness = 3 desc = "A small lighting fixture." light_type = /obj/item/weapon/light/bulb -/obj/machinery/light/small/spot - brightness = 5 - /obj/machinery/light/spot name = "spotlight" fitting = "large tube" @@ -60,7 +65,6 @@ icon_state = "lamp1" base_state = "lamp" fitting = "bulb" - brightness = 7 desc = "A desk lamp" light_type = /obj/item/weapon/light/bulb var/switchon = 0 // independent switching for lamps - not controlled by area lightswitch @@ -83,11 +87,11 @@ var/area/A = src.loc.loc brightness = A.area_lights_luminosity else - brightness = rand(6,7) + brightness = rand(TUBE_BRIGHT_MIN, TUBE_BRIGHT_MAX) if(prob(5)) broken(1) if("bulb") - brightness = rand(4,5) + brightness = rand(BULB_BRIGHT_MIN, BULB_BRIGHT_MAX) if(prob(15)) broken(1) spawn(1) @@ -139,8 +143,8 @@ on = 0 ul_SetLuminosity(0) active_power_usage = (luminosity * 20) - if(on != on_gs) - on_gs = on +// if(on != on_gs) +// on_gs = on // var/area/A = get_area(src) // if(A) // A.update_lights() @@ -169,7 +173,6 @@ // attack with item - insert light (if right type), otherwise try to break the light - /obj/machinery/light/attackby(obj/item/W, mob/user) // attempt to insert light @@ -459,46 +462,21 @@ w_class = 1 var/status = 0 // LIGHT_OK, LIGHT_BURNED or LIGHT_BROKEN var/base_state - var/switchcount = 0 // number of times switched + var/switchcount = 0 // Number of times switched m_amt = 60 - var/rigged = 0 // true if rigged to explode - var/brightness = 2 //how much light it gives off + var/rigged = 0 // True if rigged to explode + var/brightness // How much light it gives off var/repair_state = 0 -/obj/item/weapon/light/tube - name = "light tube" - desc = "A replacement light tube." - icon_state = "ltube" - base_state = "ltube" - item_state = "c_tube" - g_amt = 200 - brightness = 8 + New() + ..() + switch(name) + if("light tube") + brightness = rand(TUBE_BRIGHT_MIN,TUBE_BRIGHT_MAX) + if("light bulb") + brightness = rand(BULB_BRIGHT_MIN,BULB_BRIGHT_MAX) + update() - large - w_class = 2 - name = "large light tube" - brightness = 15 - -/obj/item/weapon/light/bulb - name = "light bulb" - desc = "A replacement light bulb." - icon_state = "lbulb" - base_state = "lbulb" - item_state = "contvapour" - g_amt = 100 - brightness = 5 - -/obj/item/weapon/light/bulb/fire - name = "fire bulb" - desc = "A replacement fire bulb." - icon_state = "fbulb" - base_state = "fbulb" - item_state = "egg4" - g_amt = 100 - brightness = 5 - -// update the icon state and description of the light -/obj/item/weapon/light proc/update() switch(status) if(LIGHT_OK) @@ -517,15 +495,34 @@ else if(repair_state == 2) desc += " It has had new wires put in." +/obj/item/weapon/light/tube + name = "light tube" + desc = "A replacement light tube." + icon_state = "ltube" + base_state = "ltube" + item_state = "c_tube" + g_amt = 200 -/obj/item/weapon/light/New() - ..() - switch(name) - if("light tube") - brightness = rand(6,9) - if("light bulb") - brightness = rand(4,6) - update() +/obj/item/weapon/light/tube/large + name = "large light tube" + w_class = 2 + brightness = LARGETUBE_BRIGHT + +/obj/item/weapon/light/bulb + name = "light bulb" + desc = "A replacement light bulb." + icon_state = "lbulb" + base_state = "lbulb" + item_state = "contvapour" + g_amt = 100 + +/obj/item/weapon/light/bulb/fire + name = "fire bulb" + desc = "A replacement fire bulb." + icon_state = "fbulb" + base_state = "fbulb" + item_state = "egg4" + brightness = BULB_BRIGHT_MAX // attack bulb/tube with object @@ -540,7 +537,6 @@ user << "You inject the solution into the [src]." if(S.reagents.has_reagent("plasma", 5)) - log_attack("[user.name] ([user.ckey]) injected a light with plasma.") log_admin("ATTACK: [user] ([user.ckey]) injected a light with plasma.") message_admins("ATTACK: [user] ([user.ckey]) injected a light with plasma.") @@ -549,6 +545,7 @@ S.reagents.clear_reagents() return + if(status != 0) if(istype(I, /obj/item/weapon/cable_coil) && repair_state == 0) user << "You put some new wiring into the [src]." @@ -556,6 +553,7 @@ repair_state = 1 update() return + if(istype(I, /obj/item/weapon/screwdriver) && repair_state == 1) user << "You attach the new wiring." playsound(src.loc, 'Screwdriver.ogg', 100, 1) @@ -566,6 +564,7 @@ repair_state = 2 update() return + if(istype(I, /obj/item/stack/sheet/glass) && status == LIGHT_BROKEN) user << "You repair the glass of the [src]." //this is worded terribly I:use(1) @@ -581,9 +580,7 @@ return // called after an attack with a light item -// shatter light, unless it was an attempt to put it in a light socket -// now only shatter if the intent was harm - +// shatter light if intent is harm, unless it was an attempt to put it in a light socket /obj/item/weapon/light/afterattack(atom/target, mob/user) if(istype(target, /obj/machinery/light)) return @@ -600,7 +597,6 @@ // a box of replacement light items - /obj/item/weapon/storage/lightbox name = "replacement bulbs" icon = 'storage.dmi' @@ -637,6 +633,8 @@ for(var/i = 0; i < 7; i++) new /obj/item/weapon/light/bulb(src) + + /obj/structure/light_frame name = "Light Fixture Frame" icon = 'lighting.dmi' @@ -666,6 +664,7 @@ usr << "\blue You secure the light fixture." anchored = 1 name = "Secured Light Fixture Frame" + else if(istype(W, /obj/item/weapon/wrench) && anchored) playsound(src.loc, 'Ratchet.ogg', 100, 1) var/turf/T = get_turf(user) @@ -675,6 +674,7 @@ usr << "\blue You unsecure the light fixture." anchored = 0 name = "Light Fixture Frame" + else if(istype(W, /obj/item/weapon/cable_coil) && anchored) var/turf/T = get_turf(user) user.visible_message("[user] wires the light fixture.", "You start to wire the light fixture.") @@ -688,11 +688,13 @@ L.status = LIGHT_EMPTY L.update() del(src) + else if(istype(W, /obj/item/weapon/screwdriver) && !anchored) playsound(src.loc, 'Screwdriver.ogg', 100, 1) usr << "\blue You take apart the light fixture." new /obj/item/stack/sheet/metal(loc) del(src) + else ..()