Files
CHOMPStation2/code/game/machinery/floodlight.dm
CHOMPStation2StaffMirrorBot 5961af3835 [MIRROR] Adds a new redgate map: The Casino Canal (#11868)
Co-authored-by: Ryumi <ghosttehspychecka@gmail.com>
Co-authored-by: C.L. <killer65311@gmail.com>
2025-10-26 18:23:47 -04:00

143 lines
3.2 KiB
Plaintext

/obj/machinery/floodlight
name = "Emergency Floodlight"
desc = "Let there be light!"
icon = 'icons/obj/machines/floodlight.dmi'
icon_state = "flood00"
density = TRUE
light_system = MOVABLE_LIGHT_DIRECTIONAL
light_cone_y_offset = 8
var/on = 0
var/obj/item/cell/cell = null
var/use = 200 // 200W light
var/unlocked = 0
var/open = 0
var/brightness_on = 8 //can't remember what the maxed out value is
/obj/machinery/floodlight/Initialize(mapload)
. = ..()
cell = new(src)
AddElement(/datum/element/climbable)
/obj/machinery/floodlight/update_icon()
cut_overlays()
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(1)
return
// If the cell is almost empty rarely "flicker" the light. Aesthetic only.
if((cell.percent() < 10) && prob(5))
set_light_range(brightness_on/2)
set_light_power(brightness_on/4)
spawn(20)
if(on)
set_light_range(brightness_on)
set_light_power(brightness_on/2)
cell.use(use*CELLRATE)
// Returns 0 on failure and 1 on success
/obj/machinery/floodlight/proc/turn_on(var/loud = 0)
if(!cell)
return 0
if(cell.charge < (use * CELLRATE))
return 0
on = 1
set_light_range(brightness_on)
set_light_power(brightness_on/2)
set_light_on(TRUE)
update_icon()
if(loud)
visible_message("\The [src] turns on.")
return 1
/obj/machinery/floodlight/proc/turn_off(var/loud = 0)
on = 0
set_light_on(FALSE)
update_icon()
if(loud)
visible_message("\The [src] shuts down.")
/obj/machinery/floodlight/attack_ai(mob/user as mob)
if(isrobot(user) && Adjacent(user))
return attack_hand(user)
if(on)
turn_off(1)
else
if(!turn_on(1))
to_chat(user, "You try to turn on \the [src] but it does not work.")
/obj/machinery/floodlight/attack_hand(mob/user as mob)
if(open && cell)
if(ishuman(user))
if(!user.get_active_hand())
user.put_in_hands(cell)
cell.loc = user.loc
else
cell.loc = src.loc
cell.add_fingerprint(user)
cell.update_icon()
cell = null
on = 0
set_light(0)
to_chat(user, "You remove the power cell")
update_icon()
return
if(on)
turn_off(1)
else
if(!turn_on(1))
to_chat(user, "You try to turn on \the [src] but it does not work.")
update_icon()
/obj/machinery/floodlight/attackby(obj/item/W as obj, mob/user as mob)
if(W.has_tool_quality(TOOL_SCREWDRIVER))
if(!open)
if(unlocked)
unlocked = 0
to_chat(user, "You screw the battery panel in place.")
else
unlocked = 1
to_chat(user, "You unscrew the battery panel.")
if(W.has_tool_quality(TOOL_CROWBAR))
if(unlocked)
if(open)
open = 0
overlays = null
to_chat(user, "You crowbar the battery panel in place.")
else
if(unlocked)
open = 1
to_chat(user, "You remove the battery panel.")
if(istype(W, /obj/item/cell))
if(open)
if(cell)
to_chat(user, "There is a power cell already installed.")
else
user.drop_item()
W.loc = src
cell = W
to_chat(user, "You insert the power cell.")
update_icon()
/obj/machinery/floodlight/starts_on
icon_state = "flood01"
/obj/machinery/floodlight/starts_on/Initialize(mapload)
. = ..()
turn_on()