This repository has been archived by the owner on Apr 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 248
/
door_timer.dm
313 lines (278 loc) · 7.49 KB
/
door_timer.dm
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
/obj/machinery/door_timer
name = "Door Timer"
icon = 'icons/obj/stationobjs.dmi'
icon_state = "doortimer0"
desc = "A remote control switch for a door."
req_access = list(access_security)
anchored = 1.0
var/id = null
var/time = 30.0
var/timing = 0.0
var/last_tick = 0
// Please keep synchronizied with these lists for easy map changes:
// /obj/storage/secure/closet/brig/automatic (secure_closets.dm)
// /obj/machinery/floorflusher (floorflusher.dm)
// /obj/machinery/door/window/brigdoor (window.dm)
// /obj/machinery/flasher (flasher.dm)
solitary
name = "Cell #1"
id = "solitary"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
solitary2
name = "Cell #2"
id = "solitary2"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
solitary3
name = "Cell #3"
id = "solitary3"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
solitary4
name = "Cell #4"
id = "solitary4"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
minibrig
name = "Mini-Brig"
id = "minibrig"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
minibrig2
name = "Mini-Brig #2"
id = "minibrig2"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
minibrig3
name = "Mini-Brig #3"
id = "minibrig3"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
genpop
name = "General Population"
id = "genpop"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
genpop_n
name = "General Population North"
id = "genpop_n"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
genpop_s
name = "General Population South"
id = "genpop_s"
new_walls
north
pixel_y = 24
east
pixel_x = 22
south
pixel_y = -19
west
pixel_x = -22
/obj/machinery/door_timer/examine()
set src in oview()
set category = "Local"
boutput(usr, "A remote control switch for a door.")
if(src.timing)
var/second = src.time % 60
var/minute = (src.time - second) / 60
boutput(usr, "<span style=\"color:red\">Time Remaining: <b>[(minute ? text("[minute]:") : null)][second]</b></span>")
else boutput(usr, "<span style=\"color:red\">There is no time set.</span>")
/obj/machinery/door_timer/process()
..()
if (src.timing)
if (!last_tick) last_tick = world.time
var/passed_time = round(max(round(world.time - last_tick),10) / 10)
if (src.time > 0)
src.time -= passed_time
else
alarm()
src.time = 0
src.timing = 0
last_tick = 0
src.updateDialog()
src.update_icon()
last_tick = world.time
else
last_tick = 0
return
/obj/machinery/door_timer/power_change()
update_icon()
// Why range 30? COG2 places linked fixtures much further away from the timer than originally envisioned.
/obj/machinery/door_timer/proc/alarm()
if (!src)
return
if (stat & (NOPOWER|BROKEN))
return
/*
for(var/obj/machinery/sim/chair/C in range(30, src))
if (C.id == src.id)
if(!C.active)
continue
if(C.con_user)
C.con_user.network_device = null
C.active = 0
*/
for (var/obj/machinery/door/window/brigdoor/M in range(30, src))
if (M.id == src.id)
/*
if (M.density)
if (M.id == "genpop") // opens the inner gen pop door and not the outer so that the perp (and anyone who manages to stow away with him) can be processed for release
spawn( 50 )
M.open()
spawn( 250 )
M.close()
*/
spawn (0)
if (M) M.close()
for (var/obj/machinery/floorflusher/FF in range(30, src))
if (FF.id == src.id)
if (FF.open != 1)
FF.openup()
for (var/obj/storage/secure/closet/brig/automatic/B in range(30, src))
if (B.id == src.id && B.our_timer == src)
if (B.locked)
B.locked = 0
B.update_icon()
B.visible_message("<span style=\"color:blue\">[B.name] unlocks automatically.</span>")
src.updateUsrDialog()
src.update_icon()
return
/obj/machinery/door_timer/attack_ai(var/mob/user as mob)
return src.attack_hand(user)
/obj/machinery/door_timer/attack_hand(var/mob/user as mob)
if(..())
return
var/dat = "<HTML><BODY><TT><B>[src.name] door controls</B>"
user.machine = src
var/d2 = "<A href='?src=\ref[src];time=1'>Initiate Time</A><br>"
if (src.timing)
d2 = "<A href='?src=\ref[src];time=0'>Stop Timed</A><br>"
var/second = src.time % 60
var/minute = (src.time - second) / 60
dat += "<br><HR><br>Timer System: [d2]<br>Time Left: [(minute ? text("[minute]:") : null)][second] <A href='?src=\ref[src];tp=-30'>-</A> <A href='?src=\ref[src];tp=-1'>-</A> <A href='?src=\ref[src];tp=1'>+</A> <A href='?src=\ref[src];tp=30'>+</A>"
for (var/obj/machinery/flasher/F in range(10, src))
if (F.id == src.id)
if (F.last_flash && world.time < F.last_flash + 150)
dat += "<BR><BR><A href='?src=\ref[src];fc=1'>Flash Cell (Charging)</A>"
else
dat += "<BR><BR><A href='?src=\ref[src];fc=1'>Flash Cell</A>"
dat += "<BR><BR><A href='?action=mach_close&window=computer'>Close</A></TT></BODY></HTML>"
user << browse(dat, "window=computer;size=400x500")
onclose(user, "computer")
return
/obj/machinery/door_timer/Topic(href, href_list)
if (..())
return
if ((usr.contents.Find(src) || (in_range(src, usr) && istype(src.loc, /turf))) || (istype(usr, /mob/living/silicon)))
usr.machine = src
if (href_list["time"])
if (src.allowed(usr, req_only_one_required))
if (src.timing == 0)
for (var/obj/machinery/door/window/brigdoor/M in range(10, src))
if (M.id == src.id)
M.close() //close the cell door up when the timer starts.
else
for (var/obj/machinery/door/window/brigdoor/M in range(10, src))
if (M.id == src.id)
M.open() //open the cell door if the timer is stopped.
src.timing = text2num(href_list["time"])
logTheThing("station", usr, null, "[src.timing ? "starts" : "stops"] a door timer: [src] [log_loc(src)].")
else
if (href_list["tp"])
if(src.allowed(usr, req_only_one_required))
var/tp = text2num(href_list["tp"])
src.time += tp
src.time = min(max(round(src.time), 0), 300)
logTheThing("station", usr, null, "[tp > 0 ? "added" : "removed"] [tp % 60]sec (total: [src.time % 60]sec) to a door timer: [src] [log_loc(src)].")
if (href_list["fc"])
if (src.allowed(usr, req_only_one_required))
logTheThing("station", usr, null, "sets off flashers from a door timer: [src] [log_loc(src)].")
for (var/obj/machinery/flasher/F in range(10, src))
if (F.id == src.id)
F.flash()
src.add_fingerprint(usr)
src.updateUsrDialog()
src.update_icon()
return
/obj/machinery/door_timer/proc/update_icon()
if (stat & (NOPOWER))
icon_state = "doortimer-p"
return
else if (stat & (BROKEN))
icon_state = "doortimer-b"
return
else
if (src.timing)
icon_state = "doortimer1"
else if (src.time > 0)
icon_state = "doortimer0"
else
spawn(50)
icon_state = "doortimer0"
icon_state = "doortimer2"