This repository was archived by the owner on May 22, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 458
Expand file tree
/
Copy pathfloodlight.dm
More file actions
122 lines (113 loc) · 3.78 KB
/
floodlight.dm
File metadata and controls
122 lines (113 loc) · 3.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/obj/structure/floodlight_frame
name = "floodlight frame"
desc = "A bare metal frame looking vaguely like a floodlight. Requires wrenching down."
max_integrity = 100
icon = 'icons/obj/lighting.dmi'
icon_state = "floodlight_c1"
density = TRUE
var/state = FLOODLIGHT_NEEDS_WRENCHING
/obj/structure/floodlight_frame/attackby(obj/item/O, mob/user, params)
if(O.tool_behaviour == TOOL_WRENCH && (state == FLOODLIGHT_NEEDS_WRENCHING))
O.play_tool_sound(src, 50)
to_chat(user, span_notice("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))
var/obj/item/stack/S = O
if(S.use(5))
to_chat(user, span_notice("You wire [src]."))
name = "wired [name]"
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, span_notice("You put lights in [src]."))
var/obj/machinery/power/floodlight/light = new(src.loc)
light.connect_to_network()
qdel(src)
else if(O.tool_behaviour == TOOL_SCREWDRIVER && (state == FLOODLIGHT_NEEDS_SECURING))
O.play_tool_sound(src, 50)
to_chat(user, span_notice("You fasten the wiring and electronics in [src]."))
name = "secured [name]"
desc = "A bare metal frame that looks like a floodlight. Requires light tubes."
icon_state = "floodlight_c3"
state = FLOODLIGHT_NEEDS_LIGHTS
else
..()
/obj/machinery/power/floodlight
name = "floodlight"
desc = "A pole with powerful mounted lights on it. Due to its high power draw, it must be powered by a direct connection to a wire node."
icon = 'icons/obj/lighting.dmi'
icon_state = "floodlight"
density = TRUE
max_integrity = 100
integrity_failure = 80
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
light_power = 1.75
/obj/machinery/power/floodlight/process()
if(avail(active_power_usage))
add_load(active_power_usage)
else
change_setting(1)
/obj/machinery/power/floodlight/proc/change_setting(val, mob/user)
if((val < 1) || (val > light_setting_list.len))
return
active_power_usage = light_setting_list[val]
if(active_power_usage && !avail(active_power_usage))
return change_setting(val - 1)
setting = val
set_light(light_setting_list[val])
var/setting_text = ""
if(val > 1)
icon_state = "[initial(icon_state)]_on"
else
icon_state = initial(icon_state)
switch(val)
if(1)
setting_text = "OFF"
if(2)
setting_text = "low power"
if(3)
setting_text = "standard lighting"
if(4)
setting_text = "high power"
if(user)
to_chat(user, "You set [src] to [setting_text].")
/obj/machinery/power/floodlight/attackby(obj/item/O, mob/user, params)
if(O.tool_behaviour == TOOL_WRENCH)
default_unfasten_wrench(user, O, time = 20)
change_setting(1)
if(anchored)
connect_to_network()
else
disconnect_from_network()
else
. = ..()
/obj/machinery/power/floodlight/attack_hand(mob/user)
. = ..()
if(.)
return
var/current = setting
if(current == 1)
current = light_setting_list.len
else
current--
change_setting(current, user)
..()
/obj/machinery/power/floodlight/atom_break(damage_flag)
. = ..()
if(!.)
return
playsound(loc, 'sound/effects/glassbr3.ogg', 100, TRUE)
var/obj/structure/floodlight_frame/F = new(loc)
F.state = FLOODLIGHT_NEEDS_LIGHTS
new /obj/item/light/tube/broken(loc)
qdel(src)
/obj/machinery/power/floodlight/play_attack_sound(damage_amount, damage_type = BRUTE, damage_flag = 0)
playsound(src, 'sound/effects/glasshit.ogg', 75, 1)