mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 02:09:41 +00:00
Reimplemented floor lights as a machine built at the autolathe.
This commit is contained in:
@@ -373,6 +373,7 @@
|
||||
#include "code\game\machinery\doppler_array.dm"
|
||||
#include "code\game\machinery\flasher.dm"
|
||||
#include "code\game\machinery\floodlight.dm"
|
||||
#include "code\game\machinery\floor_light.dm"
|
||||
#include "code\game\machinery\floorlayer.dm"
|
||||
#include "code\game\machinery\hologram.dm"
|
||||
#include "code\game\machinery\holosign.dm"
|
||||
@@ -636,8 +637,6 @@
|
||||
#include "code\game\objects\items\stacks\rods.dm"
|
||||
#include "code\game\objects\items\stacks\stack.dm"
|
||||
#include "code\game\objects\items\stacks\sheets\leather.dm"
|
||||
#include "code\game\objects\items\stacks\sheets\light.dm"
|
||||
#include "code\game\objects\items\stacks\tiles\light.dm"
|
||||
#include "code\game\objects\items\stacks\tiles\tile_types.dm"
|
||||
#include "code\game\objects\items\weapons\AI_modules.dm"
|
||||
#include "code\game\objects\items\weapons\autopsy.dm"
|
||||
|
||||
@@ -37,6 +37,11 @@
|
||||
path = /obj/item/device/flashlight
|
||||
category = "General"
|
||||
|
||||
/datum/autolathe/recipe/floor_light
|
||||
name = "floor light"
|
||||
path = /obj/machinery/floor_light
|
||||
category = "General"
|
||||
|
||||
/datum/autolathe/recipe/extinguisher
|
||||
name = "extinguisher"
|
||||
path = /obj/item/weapon/extinguisher
|
||||
|
||||
154
code/game/machinery/floor_light.dm
Normal file
154
code/game/machinery/floor_light.dm
Normal file
@@ -0,0 +1,154 @@
|
||||
var/list/floor_light_cache = list()
|
||||
|
||||
/obj/machinery/floor_light
|
||||
name = "floor light"
|
||||
icon = 'icons/obj/machines/floor_light.dmi'
|
||||
icon_state = "base"
|
||||
desc = "A backlit floor panel."
|
||||
layer = TURF_LAYER+0.001
|
||||
anchored = 0
|
||||
use_power = 2
|
||||
idle_power_usage = 2
|
||||
active_power_usage = 20
|
||||
power_channel = LIGHT
|
||||
matter = list(DEFAULT_WALL_MATERIAL = 2500, "glass" = 2750)
|
||||
|
||||
var/on
|
||||
var/damaged
|
||||
var/default_light_range = 4
|
||||
var/default_light_power = 2
|
||||
var/default_light_colour = "#FFFFFF"
|
||||
|
||||
/obj/machinery/floor_light/attackby(var/obj/item/W, var/mob/user)
|
||||
if(istype(W, /obj/item/weapon/screwdriver))
|
||||
anchored = !anchored
|
||||
visible_message("<span class='notice'>\The [user] has [anchored ? "attached" : "detached"] \the [src].</span>")
|
||||
else if(istype(W, /obj/item/weapon/weldingtool) && (damaged || (stat & BROKEN)))
|
||||
var/obj/item/weapon/weldingtool/WT = W
|
||||
if(!WT.remove_fuel(0, user))
|
||||
user << "<span class='warning'>\The [src] must be on to complete this task.</span>"
|
||||
return
|
||||
playsound(src.loc, 'sound/items/Welder.ogg', 50, 1)
|
||||
if(!do_after(user, 20))
|
||||
return
|
||||
if(!src || !WT.isOn())
|
||||
return
|
||||
visible_message("<span class='notice'>\The [user] has repaired \the [src].</span>")
|
||||
stat &= ~BROKEN
|
||||
damaged = null
|
||||
update_brightness()
|
||||
else if(W.force && user.a_intent == "hurt")
|
||||
attack_hand(user)
|
||||
return
|
||||
|
||||
/obj/machinery/floor_light/attack_hand(var/mob/user)
|
||||
|
||||
if(user.a_intent == "hurt" && !user.small)
|
||||
if(!isnull(damaged) && !(stat & BROKEN))
|
||||
visible_message("<span class='danger'>\The [user] smashes \the [src]!</span>")
|
||||
playsound(src, "shatter", 70, 1)
|
||||
stat |= BROKEN
|
||||
else
|
||||
visible_message("<span class='danger'>\The [user] attacks \the [src]!</span>")
|
||||
playsound(src.loc, 'sound/effects/Glasshit.ogg', 75, 1)
|
||||
if(isnull(damaged)) damaged = 0
|
||||
update_brightness()
|
||||
return
|
||||
else
|
||||
|
||||
if(!anchored)
|
||||
user << "<span class='warning'>\The [src] must be screwed down first.</span>"
|
||||
return
|
||||
|
||||
if(stat & BROKEN)
|
||||
user << "<span class='warning'>\The [src] is too damaged to be functional.</span>"
|
||||
return
|
||||
|
||||
if(stat & NOPOWER)
|
||||
user << "<span class='warning'>\The [src] is unpowered.</span>"
|
||||
return
|
||||
|
||||
on = !on
|
||||
if(on) use_power = 2
|
||||
visible_message("<span class='notice'>\The [user] turns \the [src] [on ? "on" : "off"].</span>")
|
||||
update_brightness()
|
||||
return
|
||||
|
||||
/obj/machinery/floor_light/process()
|
||||
..()
|
||||
var/need_update
|
||||
if((!anchored || broken()) && on)
|
||||
use_power = 0
|
||||
on = 0
|
||||
need_update = 1
|
||||
else if(use_power && !on)
|
||||
use_power = 0
|
||||
need_update = 1
|
||||
if(need_update)
|
||||
update_brightness()
|
||||
|
||||
/obj/machinery/floor_light/proc/update_brightness()
|
||||
if(on && use_power == 2)
|
||||
if(light_range != default_light_range || light_power != default_light_power || light_color != default_light_colour)
|
||||
set_light(default_light_range, default_light_power, default_light_colour)
|
||||
else
|
||||
use_power = 0
|
||||
if(light_range || light_power)
|
||||
set_light(0)
|
||||
|
||||
active_power_usage = ((light_range + light_power) * 10)
|
||||
update_icon()
|
||||
|
||||
/obj/machinery/floor_light/update_icon()
|
||||
overlays.Cut()
|
||||
if(use_power && !broken())
|
||||
if(isnull(damaged))
|
||||
var/cache_key = "floorlight-[default_light_colour]"
|
||||
if(!floor_light_cache[cache_key])
|
||||
var/image/I = image("on")
|
||||
I.color = default_light_colour
|
||||
I.layer = layer+0.001
|
||||
floor_light_cache[cache_key] = I
|
||||
overlays |= floor_light_cache[cache_key]
|
||||
else
|
||||
if(damaged == 0) //Needs init.
|
||||
damaged = rand(1,4)
|
||||
var/cache_key = "floorlight-broken[damaged]-[default_light_colour]"
|
||||
if(!floor_light_cache[cache_key])
|
||||
var/image/I = image("flicker[damaged]")
|
||||
I.color = default_light_colour
|
||||
I.layer = layer+0.001
|
||||
floor_light_cache[cache_key] = I
|
||||
overlays |= floor_light_cache[cache_key]
|
||||
|
||||
/obj/machinery/floor_light/proc/broken()
|
||||
return (stat & (BROKEN|NOPOWER))
|
||||
|
||||
/obj/machinery/floor_light/ex_act(severity)
|
||||
switch(severity)
|
||||
if(1)
|
||||
qdel(src)
|
||||
if(2)
|
||||
if (prob(50))
|
||||
qdel(src)
|
||||
else if(prob(20))
|
||||
stat |= BROKEN
|
||||
else
|
||||
if(isnull(damaged))
|
||||
damaged = 0
|
||||
if(3)
|
||||
if (prob(5))
|
||||
qdel(src)
|
||||
else if(isnull(damaged))
|
||||
damaged = 0
|
||||
return
|
||||
|
||||
/obj/machinery/floor_light/Destroy()
|
||||
var/area/A = get_area(src)
|
||||
if(A)
|
||||
on = 0
|
||||
..()
|
||||
|
||||
/obj/machinery/floor_light/cultify()
|
||||
default_light_colour = "#FF0000"
|
||||
update_brightness()
|
||||
@@ -1,33 +0,0 @@
|
||||
/obj/item/stack/light_w
|
||||
name = "wired glass tile"
|
||||
singular_name = "wired glass floor tile"
|
||||
desc = "A glass tile, which is wired, somehow."
|
||||
icon_state = "glass_wire"
|
||||
w_class = 3.0
|
||||
force = 3.0
|
||||
throwforce = 5.0
|
||||
throw_speed = 5
|
||||
throw_range = 20
|
||||
flags = CONDUCT
|
||||
max_amount = 60
|
||||
|
||||
/obj/item/stack/light_w/attackby(var/obj/item/O as obj, var/mob/user as mob)
|
||||
..()
|
||||
if(istype(O,/obj/item/weapon/wirecutters))
|
||||
var/obj/item/stack/cable_coil/CC = new/obj/item/stack/cable_coil(user.loc)
|
||||
CC.amount = 5
|
||||
amount--
|
||||
new/obj/item/stack/material/glass(user.loc)
|
||||
if(amount <= 0)
|
||||
user.drop_from_inventory(src)
|
||||
qdel(src)
|
||||
|
||||
if(istype(O,/obj/item/stack/material) && O.get_material_name() == DEFAULT_WALL_MATERIAL)
|
||||
var/obj/item/stack/M = O
|
||||
if (M.use(1))
|
||||
use(1)
|
||||
new/obj/item/stack/tile/light(get_turf(user))
|
||||
user << "<span class='notice'>You make a light tile.</span>"
|
||||
else
|
||||
user << "<span class='warning'>You need one metal sheet to finish the light tile.</span>"
|
||||
return
|
||||
@@ -1,36 +0,0 @@
|
||||
/obj/item/stack/tile/light
|
||||
name = "light tile"
|
||||
singular_name = "light floor tile"
|
||||
desc = "A floor tile, made out off glass. It produces light."
|
||||
icon_state = "tile_e"
|
||||
w_class = 3.0
|
||||
force = 3.0
|
||||
throwforce = 5.0
|
||||
throw_speed = 5
|
||||
throw_range = 20
|
||||
flags = CONDUCT
|
||||
max_amount = 60
|
||||
attack_verb = list("bashed", "battered", "bludgeoned", "thrashed", "smashed")
|
||||
var/on = 1
|
||||
var/state //0 = fine, 1 = flickering, 2 = breaking, 3 = broken
|
||||
|
||||
/obj/item/stack/tile/light/New(var/loc, var/amount=null)
|
||||
..()
|
||||
if(prob(5))
|
||||
state = 3 //broken
|
||||
else if(prob(5))
|
||||
state = 2 //breaking
|
||||
else if(prob(10))
|
||||
state = 1 //flickering occasionally
|
||||
else
|
||||
state = 0 //fine
|
||||
|
||||
/obj/item/stack/tile/light/attackby(var/obj/item/O as obj, var/mob/user as mob)
|
||||
..()
|
||||
if(istype(O,/obj/item/weapon/crowbar))
|
||||
new/obj/item/stack/material/steel(user.loc)
|
||||
amount--
|
||||
new/obj/item/stack/light_w(user.loc)
|
||||
if(amount <= 0)
|
||||
user.drop_from_inventory(src)
|
||||
qdel(src)
|
||||
@@ -361,7 +361,6 @@ var/list/name_to_material
|
||||
destruction_desc = "shatters"
|
||||
window_options = list("One Direction" = 1, "Full Window" = 4)
|
||||
created_window = /obj/structure/window/basic
|
||||
wire_product = /obj/item/stack/light_w
|
||||
rod_product = /obj/item/stack/material/glass/reinforced
|
||||
|
||||
/material/glass/build_windows(var/mob/living/user, var/obj/item/stack/used_stack)
|
||||
|
||||
BIN
icons/obj/machines/floor_light.dmi
Normal file
BIN
icons/obj/machines/floor_light.dmi
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 38 KiB |
Reference in New Issue
Block a user