mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-07-21 04:48:18 +01:00
8998842f7a
I spent the entirety of today's event looking at hard dels with my new digital minions. This was *nearly* every Hard Del that came up during 2/7/2026's event. It turns out that AI is extremely well suited to hunting down circular references like this across an entire repo. This PR was made with Antigravity-Gemini3Pro. I have not yet tested this PR. --------- Signed-off-by: VMSolidus <evilexecutive@gmail.com> Co-authored-by: Wildkins <john.wildkins@gmail.com>
147 lines
4.0 KiB
Plaintext
147 lines
4.0 KiB
Plaintext
|
|
/obj/machinery/floodlight
|
|
name = "industrial floodlight"
|
|
desc = "A series of large LEDs housed in a reflective frame, this is a cheap and easy way of lighting large areas during construction."
|
|
icon = 'icons/obj/machinery/floodlight.dmi'
|
|
icon_state = "flood00"
|
|
density = TRUE
|
|
obj_flags = OBJ_FLAG_ROTATABLE
|
|
light_system = DIRECTIONAL_LIGHT
|
|
light_range = 6
|
|
light_color = LIGHT_COLOR_TUNGSTEN
|
|
|
|
var/on = FALSE
|
|
var/obj/item/cell/cell = null
|
|
var/use = 200 // 200W light
|
|
var/unlocked = FALSE
|
|
var/open = FALSE
|
|
|
|
/obj/machinery/floodlight/feedback_hints(mob/user, distance, is_adjacent)
|
|
. += ..()
|
|
if(!cell.charge)
|
|
. += SPAN_WARNING("The installed [cell.name] is completely flat!")
|
|
return
|
|
else
|
|
. += SPAN_WARNING("\The [src] has no cell installed!")
|
|
. += SPAN_NOTICE("The installed [cell.name] has [Percent(cell.charge, cell.maxcharge)]% charge remaining.")
|
|
|
|
/obj/machinery/floodlight/Initialize()
|
|
. = ..()
|
|
cell = new /obj/item/cell(src)
|
|
|
|
/obj/machinery/floodlight/Destroy()
|
|
QDEL_NULL(cell)
|
|
return ..()
|
|
|
|
/obj/machinery/floodlight/update_icon()
|
|
ClearOverlays()
|
|
icon_state = "flood[open ? "o" : ""][open && cell ? "b" : ""]0[on]"
|
|
|
|
/obj/machinery/floodlight/process()
|
|
if(!on)
|
|
return
|
|
|
|
if(!cell || (cell.charge < (use * CELLRATE)))
|
|
turn_off(TRUE)
|
|
return
|
|
|
|
// If the cell is almost empty rarely "flicker" the light. Aesthetic only.
|
|
if((cell.percent() < 10) && prob(5))
|
|
set_light_range_power_color(light_range/3, 0.5, light_color)
|
|
addtimer(CALLBACK(src, PROC_REF(stop_flicker)), 5, TIMER_UNIQUE)
|
|
|
|
cell.use(use*CELLRATE)
|
|
|
|
/obj/machinery/floodlight/proc/stop_flicker()
|
|
if(on)
|
|
set_light_range_power_color(light_range, 1, light_color)
|
|
|
|
// Returns 0 on failure and 1 on success
|
|
/obj/machinery/floodlight/proc/turn_on(var/loud = FALSE)
|
|
if(!cell)
|
|
return FALSE
|
|
if(cell.charge < (use * CELLRATE))
|
|
return FALSE
|
|
|
|
on = TRUE
|
|
set_light_on(on)
|
|
update_icon()
|
|
if(loud)
|
|
visible_message(SPAN_NOTICE("\The [src] turns on."))
|
|
return TRUE
|
|
|
|
/obj/machinery/floodlight/proc/turn_off(var/loud = FALSE)
|
|
on = FALSE
|
|
set_light_on(on)
|
|
update_icon()
|
|
if(loud)
|
|
visible_message(SPAN_NOTICE("\The [src] shuts down."))
|
|
|
|
/obj/machinery/floodlight/attack_ai(mob/user)
|
|
if(istype(user, /mob/living/silicon/robot) && Adjacent(user))
|
|
return attack_hand(user)
|
|
|
|
if(on)
|
|
turn_off(TRUE)
|
|
else
|
|
if(!turn_on(TRUE))
|
|
to_chat(user, SPAN_WARNING("You try to turn on \the [src] but it does not work."))
|
|
|
|
/obj/machinery/floodlight/attack_hand(mob/user)
|
|
if(open && cell)
|
|
user.put_in_hands(cell)
|
|
cell.add_fingerprint(user)
|
|
cell.update_icon()
|
|
cell = null
|
|
|
|
on = FALSE
|
|
set_light(0)
|
|
to_chat(user, SPAN_NOTICE("You remove the power cell."))
|
|
update_icon()
|
|
return
|
|
|
|
if(on)
|
|
turn_off(TRUE)
|
|
else
|
|
if(!turn_on(TRUE))
|
|
to_chat(user, SPAN_WARNING("You try to turn on \the [src] but it does not work."))
|
|
|
|
update_icon()
|
|
|
|
/obj/machinery/floodlight/attackby(obj/item/attacking_item, mob/user)
|
|
if(attacking_item.tool_behaviour == TOOL_SCREWDRIVER)
|
|
if(!open)
|
|
unlocked = !unlocked
|
|
var/msg = unlocked ? "You unscrew the battery panel." : "You screw the battery panel into place."
|
|
to_chat(user, SPAN_NOTICE(msg))
|
|
else
|
|
to_chat(user, SPAN_WARNING("\The [src]'s battery panel is open and cannot be screwed down!"))
|
|
return TRUE
|
|
if(attacking_item.tool_behaviour == TOOL_CROWBAR)
|
|
if(unlocked)
|
|
open = !open
|
|
var/msg = open ? "You remove the battery panel." : "You crowbar the battery panel into place."
|
|
to_chat(user, SPAN_NOTICE(msg))
|
|
else
|
|
to_chat(user, SPAN_WARNING("\The [src]'s battery panel is still screwed shut!"))
|
|
return TRUE
|
|
if(istype(attacking_item, /obj/item/cell))
|
|
if(open)
|
|
if(cell)
|
|
to_chat(user, SPAN_WARNING("There is a power cell already installed."))
|
|
return
|
|
else
|
|
user.drop_from_inventory(attacking_item, src)
|
|
cell = attacking_item
|
|
to_chat(user, SPAN_NOTICE("You insert the power cell."))
|
|
return TRUE
|
|
update_icon()
|
|
|
|
/obj/machinery/floodlight/randomcharge
|
|
// Intentionally left empty as it's the same as the parent, but the cell is randomized.
|
|
|
|
/obj/machinery/floodlight/randomcharge/Initialize()
|
|
. = ..()
|
|
if(cell)
|
|
cell.charge = rand(1, cell.maxcharge)
|