diff --git a/code/__DEFINES/construction.dm b/code/__DEFINES/construction.dm
index 6711c52b0ae..aeae88a328c 100644
--- a/code/__DEFINES/construction.dm
+++ b/code/__DEFINES/construction.dm
@@ -57,7 +57,6 @@
#define FLOODLIGHT_NEEDS_WIRES 0
#define FLOODLIGHT_NEEDS_LIGHTS 1
#define FLOODLIGHT_NEEDS_SECURING 2
-#define FLOODLIGHT_NEEDS_WRENCHING 3
//other construction-related things
diff --git a/code/modules/power/floodlight.dm b/code/modules/power/floodlight.dm
index 68a417c2804..3aa7bef97d3 100644
--- a/code/modules/power/floodlight.dm
+++ b/code/modules/power/floodlight.dm
@@ -1,20 +1,20 @@
+#define FLOODLIGHT_OFF 1
+#define FLOODLIGHT_LOW 2
+#define FLOODLIGHT_MED 3
+#define FLOODLIGHT_HIGH 4
+
/obj/structure/floodlight_frame
name = "floodlight frame"
- desc = "A bare metal frame looking vaguely like a floodlight. Requires wrenching down."
+ desc = "A bare metal frame looking vaguely like a floodlight. Requires wiring."
max_integrity = 100
icon = 'icons/obj/lighting.dmi'
icon_state = "floodlight_c1"
density = TRUE
- var/state = FLOODLIGHT_NEEDS_WRENCHING
+ var/state = FLOODLIGHT_NEEDS_WIRES
/obj/structure/floodlight_frame/attackby(obj/item/O, mob/user, params)
- if(O.tool_behaviour == TOOL_WRENCH && (state == FLOODLIGHT_NEEDS_WRENCHING))
- to_chat(user, "You secure [src].")
- anchored = TRUE
- state = FLOODLIGHT_NEEDS_WIRES
- desc = "A bare metal frame looking vaguely like a floodlight. Requires wiring."
- else if(istype(O, /obj/item/stack/cable_coil) && (state == FLOODLIGHT_NEEDS_WIRES))
+ if(istype(O, /obj/item/stack/cable_coil) && state == FLOODLIGHT_NEEDS_WIRES)
var/obj/item/stack/S = O
if(S.use(5))
to_chat(user, "You wire [src].")
@@ -22,19 +22,36 @@
desc = "A bare metal frame looking vaguely like a floodlight. Requires securing with a screwdriver."
icon_state = "floodlight_c2"
state = FLOODLIGHT_NEEDS_SECURING
- else if(istype(O, /obj/item/light/tube) && (state == FLOODLIGHT_NEEDS_LIGHTS))
- if(user.transferItemToLoc(O))
- to_chat(user, "You put lights in [src].")
- new /obj/machinery/power/floodlight(src.loc)
- qdel(src)
- else if(O.tool_behaviour == TOOL_SCREWDRIVER && (state == FLOODLIGHT_NEEDS_SECURING))
+ return
+ else
+ to_chat(user, "You need 5 cables to wire [src].")
+ return
+ if(O.tool_behaviour == TOOL_SCREWDRIVER && state == FLOODLIGHT_NEEDS_SECURING)
to_chat(user, "You fasten the wiring and electronics in [src].")
name = "secured [name]"
- desc = "A bare metal frame that looks like a floodlight. Requires light tubes."
+ desc = "A bare metal frame that looks like a floodlight. Requires a light tube to complete."
icon_state = "floodlight_c3"
state = FLOODLIGHT_NEEDS_LIGHTS
- else
- ..()
+ return
+ if(istype(O, /obj/item/light/tube))
+ var/obj/item/light/tube/L = O
+ if(state == FLOODLIGHT_NEEDS_LIGHTS && L.status != 2) //Ready for a light tube, and not broken.
+ to_chat(user, "You put lights in [src].")
+ new /obj/machinery/power/floodlight(loc)
+ qdel(src)
+ qdel(O)
+ return
+ else //A minute of silence for all the accidentally broken light tubes.
+ return
+ if(istype(O, /obj/item/lightreplacer))
+ var/obj/item/lightreplacer/L = O
+ if(state == FLOODLIGHT_NEEDS_LIGHTS && L.CanUse(user))
+ L.Use(user)
+ to_chat(user, "You put lights in [src].")
+ new /obj/machinery/power/floodlight(loc)
+ qdel(src)
+ return
+ ..()
/obj/machinery/power/floodlight
name = "floodlight"
@@ -46,31 +63,39 @@
integrity_failure = 0.8
idle_power_usage = 100
active_power_usage = 1000
- var/list/light_setting_list = list(0, 5, 10, 15)
- var/light_power_coefficient = 300
- var/setting = 1
+ anchored = FALSE
light_power = 1.75
+ var/list/light_setting_list = list(0, 5, 10, 15)
+ var/light_power_coefficient = 200
+ var/setting = FLOODLIGHT_OFF
/obj/machinery/power/floodlight/process()
- if(avail(active_power_usage))
- add_load(active_power_usage)
- else
- change_setting(1)
+ var/turf/T = get_turf(src)
+ var/obj/structure/cable/C = locate() in T
+ if(!C && powernet)
+ disconnect_from_network()
+ if(setting > FLOODLIGHT_OFF) //If on
+ if(avail(active_power_usage))
+ add_load(active_power_usage)
+ else
+ change_setting(FLOODLIGHT_OFF)
+ else if(avail(idle_power_usage))
+ add_load(idle_power_usage)
-/obj/machinery/power/floodlight/proc/change_setting(val, mob/user)
- if((val < 1) || (val > light_setting_list.len))
+/obj/machinery/power/floodlight/proc/change_setting(newval, mob/user)
+ if((newval < FLOODLIGHT_OFF) || (newval > light_setting_list.len))
return
- active_power_usage = light_setting_list[val]
- if(!avail(active_power_usage))
- return change_setting(val - 1)
- setting = val
- set_light(light_setting_list[val])
+ setting = newval
+ active_power_usage = light_setting_list[setting] * light_power_coefficient
+ if(!avail(active_power_usage) && setting > FLOODLIGHT_OFF)
+ return change_setting(setting - 1)
+ set_light(light_setting_list[setting], light_power)
var/setting_text = ""
- if(val > 1)
+ if(setting > FLOODLIGHT_OFF)
icon_state = "[initial(icon_state)]_on"
else
icon_state = initial(icon_state)
- switch(val)
+ switch(setting)
if(1)
setting_text = "OFF"
if(2)