forked from yogstation13/Yogstation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecontamination.dm
More file actions
492 lines (440 loc) · 16.3 KB
/
Copy pathdecontamination.dm
File metadata and controls
492 lines (440 loc) · 16.3 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
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
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
// DECONTAMINATION STORAGE UNIT!! /////////////////
/obj/machinery/decontamination_unit
name = "advanced decontamination storage unit"
desc = "This is a more advanced version of the industrial suit storage unit developed by the NT science and engineering team. It is capable of removing organic radiation as well as contaminated equipment."
icon = 'icons/obj/machines/decontamination_unit.dmi'
icon_state = "tube"
density = TRUE
max_integrity = 300
circuit = /obj/item/circuitboard/machine/decontamination_unit
layer = ABOVE_WINDOW_LAYER
// if you add more storage slots, update cook() to clear their radiation too.
var/max_n_of_items = 53
state_open = FALSE
var/locked = FALSE
panel_open = FALSE
var/uv = FALSE
var/uv_emagged = FALSE
var/uv_cycles = 3
var/message_cooldown
var/breakout_time = 300
var/datum/looping_sound/decontamination_unit/decon
var/datum/looping_sound/decontamination_unit/emagged/decon_emagged
var/flick_waitTime = 9.5 //Waits for flick animation to complete before opening the door or it will be weird..
/obj/machinery/decontamination_unit/open
state_open = TRUE
density = FALSE
/obj/machinery/decontamination_unit/Initialize(mapload)
. = ..()
decon = new(list(src), FALSE)
decon_emagged = new(list(src), FALSE)
update_appearance(UPDATE_ICON)
/obj/machinery/decontamination_unit/update_icon_state()
. = ..()
icon_state = uv? "tube_on" : (state_open? "tube_open" : "tube")
/obj/machinery/decontamination_unit/proc/store_items()
var/atom/pickup_zone = drop_location()
for(var/obj/item/to_pickup in pickup_zone)
to_pickup.forceMove(src)
/obj/machinery/decontamination_unit/power_change()
if(!is_operational() && state_open)
open_machine()
dump_mob()
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
return ..()
/obj/machinery/decontamination_unit/proc/dump_mob()
var/turf/T = get_turf(src)
for(var/atom/movable/A in contents)
if(isliving(A))
var/mob/living/L = A
L.forceMove(T)
L.update_mobility()
occupant = null
/obj/machinery/decontamination_unit/MouseDrop_T(atom/A, mob/living/user)
if(!istype(user) || user.stat || !Adjacent(user) || !Adjacent(A) || !isliving(A))
return
if(isliving(user))
var/mob/living/L = user
if(!(L.mobility_flags & MOBILITY_STAND))
return
var/mob/living/target = A
if(!state_open)
to_chat(user, span_warning("The unit's doors are shut!"))
return
if(!is_operational())
to_chat(user, span_warning("The unit is not operational!"))
return
if(target == user)
user.visible_message(span_warning("[user] starts squeezing into [src]!"), span_notice("You start working your way into [src]..."))
else
target.visible_message(span_warning("[user] starts shoving [target] into [src]!"), span_userdanger("[user] starts shoving you into [src]!"))
if(do_after(user, 3 SECONDS, target))
if(target == user)
user.visible_message(span_warning("[user] slips into [src] and closes the door behind [user.p_them()]!"), "<span class=notice'>You slip into [src]'s cramped space and shut its door.</span>")
else
target.visible_message("<span class='warning'>[user] pushes [target] into [src] and shuts its door!<span>", span_userdanger("[user] shoves you into [src] and shuts the door!"))
close_machine(target)
add_fingerprint(user)
/obj/machinery/decontamination_unit/proc/cook()
var/mob/living/mob_occupant = occupant
if(uv_cycles)
uv_cycles--
uv = TRUE
locked = TRUE
update_appearance(UPDATE_ICON)
if(uv_emagged)
radiation_pulse(src, 500, 5)
decon_emagged.start()
if(mob_occupant)
mob_occupant.adjustFireLoss(rand(15, 26))
mob_occupant.radiation += 500
mob_occupant.adjust_fire_stacks(2)
mob_occupant.ignite_mob()
if(iscarbon(mob_occupant) && mob_occupant.stat < UNCONSCIOUS)
//Awake, organic and screaming
mob_occupant.emote("scream")
else
decon.start()
addtimer(CALLBACK(src, PROC_REF(cook)), 50)
else
uv_cycles = initial(uv_cycles)
uv = FALSE
locked = FALSE
if(uv_emagged)
flick("tube_up", src)
decon_emagged.stop()
playsound(src, 'sound/machines/decon/decon-up.ogg', 100, TRUE)
addtimer(CALLBACK(src, PROC_REF(decon_eject_emagged)), flick_waitTime)
else
flick("tube_up", src)
decon.stop()
playsound(src, 'sound/machines/decon/decon-up.ogg', 100, TRUE)
addtimer(CALLBACK(src, PROC_REF(decon_eject)), flick_waitTime)
/obj/machinery/decontamination_unit/proc/decon_eject_emagged()
var/mob/living/mob_occupant = occupant
say("ERROR: PLEASE CONTACT SUPPORT!!")
if(mob_occupant)
visible_message(span_warning("[src]'s gate creaks open with a loud whining noise, barraging you with the nauseating smell of charred flesh. A cloud of foul smoke escapes from its chamber."))
mob_occupant.electrocute_act(50, src)
else
visible_message(span_warning("[src]'s gate creaks open with a loud whining noise."))
playsound(src, 'sound/machines/airlock_alien_prying.ogg', 50, TRUE)
for(var/obj/item/item in contents)
QDEL_NULL(item)
shock()
open_machine(0)
if(occupant)
dump_mob()
/obj/machinery/decontamination_unit/proc/decon_eject()
var/mob/living/mob_occupant = occupant
say("The decontamination process is completed, thank you for your patient.")
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
if(mob_occupant)
visible_message(span_notice("[src]'s gate slides open, ejecting you out."))
mob_occupant.radiation = 0
else
visible_message(span_notice("[src]'s gate slides open. The glowing yellow lights dim to a gentle green."))
var/list/things_to_clear = list() //Done this way since using get_all_contents on the SSU itself would include circuitry and such.
if(occupant)
things_to_clear += occupant
things_to_clear += occupant.get_all_contents()
dump_mob()
if(contents.len)
things_to_clear += contents
for(var/am in things_to_clear) //Scorches away blood and forensic evidence, although the SSU itself is unaffected
var/atom/movable/dirty_movable = am
dirty_movable.wash(CLEAN_ALL)
open_machine(0)
/obj/machinery/decontamination_unit/proc/shock(mob/user)
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(5, 1, src)
s.start()
electrocute_mob(user, src, src, 1, TRUE)
/obj/machinery/decontamination_unit/emag_act(mob/user, obj/item/card/emag/emag_card)
if(obj_flags & EMAGGED)
to_chat(user, span_warning("[src] has no functional safeties to emag."))
return FALSE
if(!state_open)
if(!panel_open)
to_chat(user, span_warning("Open the panel first."))
return FALSE
else
return FALSE
to_chat(user, span_warning("You short out [src]'s safeties."))
uv_emagged = TRUE
obj_flags |= EMAGGED
return TRUE
/obj/machinery/decontamination_unit/relaymove(mob/user)
if(locked)
if(message_cooldown <= world.time)
message_cooldown = world.time + 50
to_chat(user, span_warning("[src]'s door won't budge!"))
return
open_machine()
dump_mob()
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
/obj/machinery/decontamination_unit/proc/reset_emag(mob/user)
if(panel_open)
if(obj_flags & EMAGGED)
to_chat(user, span_warning("Resetting circuitry..."))
if(do_after(user, 6 SECONDS, src))
to_chat(user, span_caution("You reset the [src]'s safeties."))
uv_emagged = FALSE
obj_flags -= EMAGGED
else
to_chat(user, span_notice("The [src] is in normal state."))
return
else
to_chat(user, span_warning("Open the panel first."))
return
/obj/machinery/decontamination_unit/container_resist(mob/living/user)
if(!locked)
open_machine()
dump_mob()
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
return
if(uv)
visible_message(span_notice("You hear someone kicking against the doors of [src]!"), \
span_notice("You cannot escape while it's active!"))
return
user.changeNext_move(CLICK_CD_BREAKOUT)
user.last_special = world.time + CLICK_CD_BREAKOUT
user.visible_message(span_notice("You hear someone kicking against the doors of [src]!"), \
span_notice("You start kicking against the doors... (this will take about [DisplayTimeText(breakout_time)].)"), \
span_italics("You hear a thump from [src]."))
if(do_after(user, breakout_time, src))
if(!user || user.stat != CONSCIOUS || user.loc != src )
return
user.visible_message(span_warning("[user] successfully broke out of [src]!"), \
span_notice("You successfully break out of [src]!"))
open_machine()
dump_mob()
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
add_fingerprint(user)
if(locked)
visible_message(span_notice("You hear someone kicking against the doors of [src]!"), \
span_notice("You start kicking against the doors..."))
addtimer(CALLBACK(src, PROC_REF(resist_open), user), 300)
else
open_machine()
dump_mob()
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
/obj/machinery/decontamination_unit/RefreshParts()
for(var/obj/item/stock_parts/matter_bin/B in component_parts)
max_n_of_items = initial(max_n_of_items) * B.rating
/obj/machinery/decontamination_unit/examine(mob/user)
. = ..()
if(obj_flags & EMAGGED)
. += span_warning("The maintenance panel is smoking slightly.")
if(in_range(user, src) || isobserver(user))
if (contents.len >= max_n_of_items)
. += span_notice("The status display reads: <b>Inventory full!</b> Please remove items or upgrade the parts of this storage unit.")
else
. += span_notice("The status display reads: Inventory quantity is currently <b>[contents.len] out of [max_n_of_items]</b> items.")
/obj/machinery/decontamination_unit/proc/resist_open(mob/user)
if(!state_open && !uv && occupant && (user in src) && user.stat == 0) // Check they're still here.
visible_message(span_notice("You see [user] burst out of [src]!"), \
span_notice("You escape the cramped confines of [src]!"))
open_machine()
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
/obj/machinery/decontamination_unit/is_operational()
return ..() && anchored
/obj/machinery/decontamination_unit/attackby(obj/item/I, mob/user, params)
if(default_unfasten_wrench(user, I))
return
if(I.tool_behaviour == TOOL_MULTITOOL)
reset_emag(user)
return
if(state_open && is_operational())
//Unable to add an item, it's already full.
if(contents.len >= max_n_of_items)
to_chat(user, span_warning("\The [src] is full!"))
return FALSE
if(!(istype(I, /obj/item/storage/bag)))
load(I)
updateUsrDialog()
//Adding items from a bag
else
var/loaded = 0
for(var/obj/G in I.contents)
if(contents.len >= max_n_of_items)
break
load(G)
loaded++
updateUsrDialog()
if(loaded)
if(contents.len >= max_n_of_items)
user.visible_message("[user] loads \the [src] with \the [I].", \
span_notice("You fill \the [src] with \the [I]."))
else
user.visible_message("[user] loads \the [src] with \the [I].", \
span_notice("You load \the [src] with \the [I]."))
if(I.contents.len > 0)
to_chat(user, span_warning("Some items are refused."))
return TRUE
else
to_chat(user, span_warning("There is nothing in [I] to put in [src]!"))
return FALSE
visible_message(span_notice("[user] inserts [I] into [src]."), span_notice("You load [I] into [src]."))
update_appearance(UPDATE_ICON)
return
if(!state_open && !uv)
if(I.tool_behaviour == TOOL_SCREWDRIVER)
panel_open = !panel_open
user.visible_message(span_notice("\The [user] [panel_open ? "opens" : "closes"] the hatch on \the [src]."), span_notice("You [panel_open ? "open" : "close"] the hatch on \the [src]."))
I.play_tool_sound(src, 50)
return
if(default_deconstruction_crowbar(I))
return
if(default_pry_open(I))
dump_mob()
return
return ..()
/obj/machinery/decontamination_unit/default_pry_open(obj/item/I)//needs to check if the storage is locked.
. = !(state_open || panel_open || is_operational() || locked) && I.tool_behaviour == TOOL_CROWBAR
if(.)
I.play_tool_sound(src, 50)
visible_message(span_notice("[usr] pries open \the [src]."), span_notice("You pry open \the [src]."))
open_machine()
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
/obj/machinery/decontamination_unit/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "Decon", name)
ui.set_autoupdate(FALSE)
ui.open()
/obj/machinery/decontamination_unit/ui_data()
var/list/data = list()
data["locked"] = locked
data["open"] = state_open
data["uv_active"] = uv
var/listofitems = list()
for (var/I in src)
var/atom/movable/O = I
if (!QDELETED(O))
var/md5name = md5(O.name)
if (listofitems[md5name])
listofitems[md5name]["amount"]++
else
listofitems[md5name] = list("name" = O.name, "type" = O.type, "amount" = 1)
sortList(listofitems)
data["contents"] = listofitems
data["name"] = name
if(occupant)
data["occupied"] = TRUE
else
data["occupied"] = FALSE
return data
/obj/machinery/decontamination_unit/ui_act(action, params)
if(..() || uv)
return
if (!anchored)
return
switch(action)
if("door")
if(state_open)
close_machine()
store_items()
playsound(src, 'sound/machines/decon/decon-close.ogg', 50, TRUE)
else
open_machine(0)
playsound(src, 'sound/machines/decon/decon-open.ogg', 50, TRUE)
if(occupant)
dump_mob()
. = TRUE
if("lock")
if(state_open)
return
locked = !locked
. = TRUE
if("uv")
var/mob/living/mob_occupant = occupant
if(!occupant && !contents.len)
return
else
if(uv_emagged)
say("ERROR: Decontamination process is going over safety limit!!")
uv_cycles = 7
else
say("Please wait untill the decontamination process is completed.")
uv_cycles = initial(uv_cycles)
if(mob_occupant && uv_emagged)
to_chat(mob_occupant, span_userdanger("[src]'s confines grow warm, then hot, then scorching. You're being burned [!mob_occupant.stat ? "alive" : "away"]!"))
else
to_chat(mob_occupant, span_warning("[src]'s confines grow warm. You're being decontaminated."))
flick("tube_down", src)
cook()
. = TRUE
if("Release")
var/desired = 0
if (params["amount"])
desired = text2num(params["amount"])
else
desired = input("How many items?", "How many items would you like to take out?", 1) as null|num
if(desired <= 0)
return FALSE
if(QDELETED(src) || QDELETED(usr) || !usr.Adjacent(src)) // Sanity checkin' in case stupid stuff happens while we wait for input()
return FALSE
//Retrieving a single item into your hand
if(desired == 1 && Adjacent(usr) && !issilicon(usr))
for(var/obj/item/O in src)
var/check_name1 = replacetext(O.name,"\improper","")
var/check_name2 = replacetext(O.name,"\proper","")
if((check_name1 == params["name"]) || (check_name2 == params["name"]))
dispense(O, usr)
break
return TRUE
//Retrieving many items
for(var/obj/item/O in src)
if(desired <= 0)
break
var/check_name1 = replacetext(O.name,"\improper","")
var/check_name2 = replacetext(O.name,"\proper","")
if((check_name1 == params["name"]) || (check_name2 == params["name"]))
dispense(O, usr)
desired--
return TRUE
update_appearance(UPDATE_ICON)
/obj/machinery/decontamination_unit/proc/load(obj/item/O)
if(ismob(O.loc))
var/mob/M = O.loc
if(!M.transferItemToLoc(O, src))
to_chat(usr, span_warning("\The [O] is stuck to your hand, you cannot put it in \the [src]!"))
return FALSE
else
return TRUE
else
if(SEND_SIGNAL(O.loc, COMSIG_CONTAINS_STORAGE))
return SEND_SIGNAL(O.loc, COMSIG_TRY_STORAGE_TAKE, O, src)
else
O.forceMove(src)
return TRUE
/obj/machinery/decontamination_unit/proc/dispense(obj/item/O, mob/M)
if(!M.put_in_hands(O))
O.forceMove(get_turf(M))
adjust_item_drop_location(O)
/obj/machinery/decontamination_unit/handle_atom_del(atom/A) // Update the UIs in case something inside gets deleted
SStgui.update_uis(src)
/obj/machinery/decontamination_unit/AltClick(mob/user)
if(!user.canUseTopic(src, !issilicon(user)))
return
if(panel_open)
to_chat(user, span_warning("Close the panel first!"))
return
if(uv)
to_chat(user, span_warning("You cannot open the gate while the cycle is running!"))
return
if(state_open)
close_machine()
store_items()
playsound(src, 'sound/machines/decon/decon-close.ogg', 75, TRUE)
else
open_machine(0)
playsound(src, 'sound/machines/decon/decon-open.ogg', 75, TRUE)
if(occupant)
dump_mob()
/obj/machinery/decontamination_unit/CtrlShiftClick(mob/user)
if(!user.canUseTopic(src, !issilicon(user)) || state_open)
return
locked = !locked
update_appearance(UPDATE_ICON)