/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/weapon/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/New() cell = new(src) ..() /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(istype(user, /mob/living/silicon/robot) && 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/weapon/W as obj, mob/user as mob) if(W.is_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.is_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/weapon/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()