This repository has been archived by the owner on Sep 12, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 66
/
suit_storage_unit.dm
495 lines (445 loc) · 16.8 KB
/
suit_storage_unit.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
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
493
494
495
// SUIT STORAGE UNIT /////////////////
/obj/machinery/suit_storage_unit
name = "suit storage unit"
desc = "An industrial unit made to hold and decontaminate irradiated equipment. It comes with a built-in UV cauterization mechanism. A small warning label advises that organic matter should not be placed into the unit."
icon = 'icons/obj/machines/suit_storage.dmi'
icon_state = "close"
density = TRUE
max_integrity = 250
var/obj/item/clothing/suit/space/suit = null
var/obj/item/clothing/head/helmet/space/helmet = null
var/obj/item/clothing/mask/mask = null
var/obj/item/storage = null
// if you add more storage slots, update cook() to clear their radiation too.
/// What type of spacesuit the unit starts with when spawned.
var/suit_type = null
/// What type of space helmet the unit starts with when spawned.
var/helmet_type = null
/// What type of breathmask the unit starts with when spawned.
var/mask_type = null
/// What type of additional item the unit starts with when spawned.
var/storage_type = null
state_open = FALSE
/// If the SSU's doors are locked closed. Can be toggled manually via the UI, but is also locked automatically when the UV decontamination sequence is running.
var/locked = FALSE
panel_open = FALSE
/// If the safety wire is cut/pulsed, the SSU can run the decontamination sequence while occupied by a mob. The mob will be burned during every cycle of cook().
var/safeties = TRUE
/// If UV decontamination sequence is running. See cook()
var/uv = FALSE
/**
* If the hack wire is cut/pulsed.
* Modifies effects of cook()
* * If FALSE, decontamination sequence will clear radiation for all atoms (and their contents) contained inside the unit, and burn any mobs inside.
* * If TRUE, decontamination sequence will delete all items contained within, and if occupied by a mob, intensifies burn damage delt. All wires will be cut at the end.
*/
var/uv_super = FALSE
/// How many cycles remain for the decontamination sequence.
var/uv_cycles = 6
/// Cooldown for occupant breakout messages via relaymove()
var/message_cooldown
/// How long it takes to break out of the SSU.
var/breakout_time = 300
/obj/machinery/suit_storage_unit/standard_unit
suit_type = /obj/item/clothing/suit/space/eva
helmet_type = /obj/item/clothing/head/helmet/space/eva
mask_type = /obj/item/clothing/mask/breath
/obj/machinery/suit_storage_unit/captain
suit_type = /obj/item/clothing/suit/space/hardsuit/swat/captain
mask_type = /obj/item/clothing/mask/gas/atmos/captain
storage_type = /obj/item/tank/jetpack/oxygen/captain
/obj/machinery/suit_storage_unit/engine
suit_type = /obj/item/clothing/suit/space/hardsuit/engine
mask_type = /obj/item/clothing/mask/breath
storage_type= /obj/item/clothing/shoes/magboots
/obj/machinery/suit_storage_unit/atmos
suit_type = /obj/item/clothing/suit/space/hardsuit/engine/atmos
mask_type = /obj/item/clothing/mask/gas/atmos
storage_type = /obj/item/watertank/atmos
/obj/machinery/suit_storage_unit/ce
suit_type = /obj/item/clothing/suit/space/hardsuit/engine/elite
mask_type = /obj/item/clothing/mask/breath
storage_type= /obj/item/clothing/shoes/magboots/advance
/obj/machinery/suit_storage_unit/security
suit_type = /obj/item/clothing/suit/space/hardsuit/security
mask_type = /obj/item/clothing/mask/gas/sechailer
/obj/machinery/suit_storage_unit/hos
suit_type = /obj/item/clothing/suit/space/hardsuit/security/hos
mask_type = /obj/item/clothing/mask/gas/sechailer
storage_type = /obj/item/tank/internals/oxygen
/obj/machinery/suit_storage_unit/mining
suit_type = /obj/item/clothing/suit/hooded/explorer
mask_type = /obj/item/clothing/mask/gas/explorer
/obj/machinery/suit_storage_unit/mining/eva
suit_type = /obj/item/clothing/suit/space/hardsuit/mining
mask_type = /obj/item/clothing/mask/breath
/obj/machinery/suit_storage_unit/cmo
suit_type = /obj/item/clothing/suit/space/hardsuit/medical/cmo
mask_type = /obj/item/clothing/mask/breath/medical
storage_type = /obj/item/tank/internals/oxygen
/obj/machinery/suit_storage_unit/rd
suit_type = /obj/item/clothing/suit/space/hardsuit/rd
mask_type = /obj/item/clothing/mask/breath
/obj/machinery/suit_storage_unit/syndicate
suit_type = /obj/item/clothing/suit/space/hardsuit/syndi
mask_type = /obj/item/clothing/mask/gas/syndicate
storage_type = /obj/item/tank/jetpack/oxygen/harness
/obj/machinery/suit_storage_unit/ert/command
suit_type = /obj/item/clothing/suit/space/hardsuit/ert
mask_type = /obj/item/clothing/mask/breath
storage_type = /obj/item/tank/internals/emergency_oxygen/double
/obj/machinery/suit_storage_unit/ert/security
suit_type = /obj/item/clothing/suit/space/hardsuit/ert/sec
mask_type = /obj/item/clothing/mask/breath
storage_type = /obj/item/tank/internals/emergency_oxygen/double
/obj/machinery/suit_storage_unit/ert/engineer
suit_type = /obj/item/clothing/suit/space/hardsuit/ert/engi
mask_type = /obj/item/clothing/mask/breath
storage_type = /obj/item/tank/internals/emergency_oxygen/double
/obj/machinery/suit_storage_unit/ert/medical
suit_type = /obj/item/clothing/suit/space/hardsuit/ert/med
mask_type = /obj/item/clothing/mask/breath
storage_type = /obj/item/tank/internals/emergency_oxygen/double
/obj/machinery/suit_storage_unit/radsuit
name = "radiation suit storage unit"
suit_type = /obj/item/clothing/suit/radiation
helmet_type = /obj/item/clothing/head/radiation
storage_type = /obj/item/geiger_counter
/obj/machinery/suit_storage_unit/open
state_open = TRUE
density = FALSE
/obj/machinery/suit_storage_unit/Initialize()
. = ..()
wires = new /datum/wires/suit_storage_unit(src)
if(suit_type)
suit = new suit_type(src)
if(helmet_type)
helmet = new helmet_type(src)
if(mask_type)
mask = new mask_type(src)
if(storage_type)
storage = new storage_type(src)
update_icon()
/obj/machinery/suit_storage_unit/Destroy()
QDEL_NULL(suit)
QDEL_NULL(helmet)
QDEL_NULL(mask)
QDEL_NULL(storage)
return ..()
/obj/machinery/suit_storage_unit/update_overlays()
. = ..()
if(uv)
if(uv_super)
. += "super"
else if(occupant)
. += "uvhuman"
else
. += "uv"
else if(state_open)
if(machine_stat & BROKEN)
. += "broken"
else
. += "open"
if(suit)
. += "suit"
if(helmet)
. += "helm"
if(storage)
. += "storage"
else if(occupant)
. += "human"
/obj/machinery/suit_storage_unit/power_change()
. = ..()
if(!is_operational() && state_open)
open_machine()
dump_contents()
update_icon()
/obj/machinery/suit_storage_unit/dump_contents()
dropContents()
helmet = null
suit = null
mask = null
storage = null
occupant = null
/obj/machinery/suit_storage_unit/deconstruct(disassembled = TRUE)
if(!(flags_1 & NODECONSTRUCT_1))
open_machine()
dump_contents()
new /obj/item/stack/sheet/metal (loc, 2)
qdel(src)
/obj/machinery/suit_storage_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.body_position == LYING_DOWN)
return
var/mob/living/target = A
if(!state_open)
to_chat(user, "<span class='warning'>The unit's doors are shut!</span>")
return
if(!is_operational())
to_chat(user, "<span class='warning'>The unit is not operational!</span>")
return
if(occupant || helmet || suit || storage)
to_chat(user, "<span class='warning'>It's too cluttered inside to fit in!</span>")
return
if(target == user)
user.visible_message("<span class='warning'>[user] starts squeezing into [src]!</span>", "<span class='notice'>You start working your way into [src]...</span>")
else
target.visible_message("<span class='warning'>[user] starts shoving [target] into [src]!</span>", "<span class='userdanger'>[user] starts shoving you into [src]!</span>")
if(do_mob(user, target, 30))
if(occupant || helmet || suit || storage)
return
if(target == user)
user.visible_message("<span class='warning'>[user] slips into [src] and closes the door behind [user.p_them()]!</span>", "<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 class='userdanger'>[user] shoves you into [src] and shuts the door!</span>")
close_machine(target)
add_fingerprint(user)
/**
* UV decontamination sequence.
* Duration is determined by the uv_cycles var.
* Effects determined by the uv_super var.
* * If FALSE, all atoms (and their contents) contained are cleared of radiation. If a mob is inside, they are burned every cycle.
* * If TRUE, all items contained are destroyed, and burn damage applied to the mob is increased. All wires will be cut at the end.
* All atoms still inside at the end of all cycles are ejected from the unit.
*/
/obj/machinery/suit_storage_unit/proc/cook()
var/mob/living/mob_occupant = occupant
if(uv_cycles)
uv_cycles--
uv = TRUE
locked = TRUE
update_icon()
if(occupant)
if(uv_super)
mob_occupant.adjustFireLoss(rand(20, 36))
else
mob_occupant.adjustFireLoss(rand(10, 16))
mob_occupant.emote("scream")
addtimer(CALLBACK(src, .proc/cook), 50)
else
uv_cycles = initial(uv_cycles)
uv = FALSE
locked = FALSE
if(uv_super)
visible_message("<span class='warning'>[src]'s door creaks open with a loud whining noise. A cloud of foul black smoke escapes from its chamber.</span>")
playsound(src, 'sound/machines/airlock_alien_prying.ogg', 50, TRUE)
helmet = null
qdel(helmet)
suit = null
qdel(suit) // Delete everything but the occupant.
mask = null
qdel(mask)
storage = null
qdel(storage)
// The wires get damaged too.
wires.cut_all()
else
if(!occupant)
visible_message("<span class='notice'>[src]'s door slides open. The glowing yellow lights dim to a gentle green.</span>")
else
visible_message("<span class='warning'>[src]'s door slides open, barraging you with the nauseating smell of charred flesh.</span>")
mob_occupant.radiation = 0
playsound(src, 'sound/machines/airlockclose.ogg', 25, TRUE)
var/list/things_to_clear = list() //Done this way since using GetAllContents on the SSU itself would include circuitry and such.
if(suit)
things_to_clear += suit
things_to_clear += suit.GetAllContents()
if(helmet)
things_to_clear += helmet
things_to_clear += helmet.GetAllContents()
if(mask)
things_to_clear += mask
things_to_clear += mask.GetAllContents()
if(storage)
things_to_clear += storage
things_to_clear += storage.GetAllContents()
if(occupant)
things_to_clear += occupant
things_to_clear += occupant.GetAllContents()
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(FALSE)
if(occupant)
dump_contents()
/obj/machinery/suit_storage_unit/proc/shock(mob/user, prb)
if(!prob(prb))
var/datum/effect_system/spark_spread/s = new /datum/effect_system/spark_spread
s.set_up(5, 1, src)
s.start()
if(electrocute_mob(user, src, src, 1, TRUE))
return 1
/obj/machinery/suit_storage_unit/relaymove(mob/living/user, direction)
if(locked)
if(message_cooldown <= world.time)
message_cooldown = world.time + 50
to_chat(user, "<span class='warning'>[src]'s door won't budge!</span>")
return
open_machine()
dump_contents()
/obj/machinery/suit_storage_unit/container_resist_act(mob/living/user)
if(!locked)
open_machine()
dump_contents()
return
user.changeNext_move(CLICK_CD_BREAKOUT)
user.last_special = world.time + CLICK_CD_BREAKOUT
user.visible_message("<span class='notice'>You see [user] kicking against the doors of [src]!</span>", \
"<span class='notice'>You start kicking against the doors... (this will take about [DisplayTimeText(breakout_time)].)</span>", \
"<span class='hear'>You hear a thump from [src].</span>")
if(do_after(user,(breakout_time), target = src))
if(!user || user.stat != CONSCIOUS || user.loc != src )
return
user.visible_message("<span class='warning'>[user] successfully broke out of [src]!</span>", \
"<span class='notice'>You successfully break out of [src]!</span>")
open_machine()
dump_contents()
add_fingerprint(user)
if(locked)
visible_message("<span class='notice'>You see [user] kicking against the doors of [src]!</span>", \
"<span class='notice'>You start kicking against the doors...</span>")
addtimer(CALLBACK(src, .proc/resist_open, user), 300)
else
open_machine()
dump_contents()
/obj/machinery/suit_storage_unit/proc/resist_open(mob/user)
if(!state_open && occupant && (user in src) && user.stat == 0) // Check they're still here.
visible_message("<span class='notice'>You see [user] burst out of [src]!</span>", \
"<span class='notice'>You escape the cramped confines of [src]!</span>")
open_machine()
/obj/machinery/suit_storage_unit/attackby(obj/item/I, mob/user, params)
if(state_open && is_operational())
if(istype(I, /obj/item/clothing/suit))
if(suit)
to_chat(user, "<span class='warning'>The unit already contains a suit!.</span>")
return
if(!user.transferItemToLoc(I, src))
return
suit = I
else if(istype(I, /obj/item/clothing/head))
if(helmet)
to_chat(user, "<span class='warning'>The unit already contains a helmet!</span>")
return
if(!user.transferItemToLoc(I, src))
return
helmet = I
else if(istype(I, /obj/item/clothing/mask))
if(mask)
to_chat(user, "<span class='warning'>The unit already contains a mask!</span>")
return
if(!user.transferItemToLoc(I, src))
return
mask = I
else
if(storage)
to_chat(user, "<span class='warning'>The auxiliary storage compartment is full!</span>")
return
if(!user.transferItemToLoc(I, src))
return
storage = I
visible_message("<span class='notice'>[user] inserts [I] into [src]</span>", "<span class='notice'>You load [I] into [src].</span>")
update_icon()
return
if(panel_open && is_wire_tool(I))
wires.interact(user)
return
if(!state_open)
if(default_deconstruction_screwdriver(user, "panel", "close", I))
return
if(default_pry_open(I))
dump_contents()
return
return ..()
/* ref tg-git issue #45036
screwdriving it open while it's running a decontamination sequence without closing the panel prior to finish
causes the SSU to break due to state_open being set to TRUE at the end, and the panel becoming inaccessible.
*/
/obj/machinery/suit_storage_unit/default_deconstruction_screwdriver(mob/user, icon_state_open, icon_state_closed, obj/item/I)
if(!(flags_1 & NODECONSTRUCT_1) && I.tool_behaviour == TOOL_SCREWDRIVER && uv)
to_chat(user, "<span class='warning'>It might not be wise to fiddle with [src] while it's running...</span>")
return TRUE
return ..()
/obj/machinery/suit_storage_unit/default_pry_open(obj/item/I)//needs to check if the storage is locked.
. = !(state_open || panel_open || is_operational() || locked || (flags_1 & NODECONSTRUCT_1)) && I.tool_behaviour == TOOL_CROWBAR
if(.)
I.play_tool_sound(src, 50)
visible_message("<span class='notice'>[usr] pries open \the [src].</span>", "<span class='notice'>You pry open \the [src].</span>")
open_machine()
/obj/machinery/suit_storage_unit/ui_state(mob/user)
return GLOB.notcontained_state
/obj/machinery/suit_storage_unit/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "SuitStorageUnit", name)
ui.open()
/obj/machinery/suit_storage_unit/ui_data()
var/list/data = list()
data["locked"] = locked
data["open"] = state_open
data["safeties"] = safeties
data["uv_active"] = uv
data["uv_super"] = uv_super
if(helmet)
data["helmet"] = helmet.name
else
data["helmet"] = null
if(suit)
data["suit"] = suit.name
else
data["suit"] = null
if(mask)
data["mask"] = mask.name
else
data["mask"] = null
if(storage)
data["storage"] = storage.name
else
data["storage"] = null
if(occupant)
data["occupied"] = TRUE
else
data["occupied"] = FALSE
return data
/obj/machinery/suit_storage_unit/ui_act(action, params)
if(..() || uv)
return
switch(action)
if("door")
if(state_open)
close_machine()
else
open_machine(0)
if(occupant)
dump_contents() // Dump out contents if someone is in there.
. = TRUE
if("lock")
if(state_open)
return
locked = !locked
. = TRUE
if("uv")
if(occupant && safeties)
return
else if(!helmet && !mask && !suit && !storage && !occupant)
return
else
if(occupant)
var/mob/living/mob_occupant = occupant
to_chat(mob_occupant, "<span class='userdanger'>[src]'s confines grow warm, then hot, then scorching. You're being burned [!mob_occupant.stat ? "alive" : "away"]!</span>")
cook()
. = TRUE
if("dispense")
if(!state_open)
return
var/static/list/valid_items = list("helmet", "suit", "mask", "storage")
var/item_name = params["item"]
if(item_name in valid_items)
var/obj/item/I = vars[item_name]
vars[item_name] = null
if(I)
I.forceMove(loc)
. = TRUE
update_icon()