-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
airlock.dm
1369 lines (1254 loc) · 53.1 KB
/
airlock.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
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
New methods:
pulse - sends a pulse into a wire for hacking purposes
cut - cuts a wire and makes any necessary state changes
mend - mends a wire and makes any necessary state changes
canAIControl - 1 if the AI can control the airlock, 0 if not (then check canAIHack to see if it can hack in)
canAIHack - 1 if the AI can hack into the airlock to recover control, 0 if not. Also returns 0 if the AI does not *need* to hack it.
arePowerSystemsOn - 1 if the main or backup power are functioning, 0 if not.
requiresIDs - 1 if the airlock is requiring IDs, 0 if not
isAllPowerCut - 1 if the main and backup power both have cut wires.
regainMainPower - handles the effect of main power coming back on.
loseMainPower - handles the effect of main power going offline. Usually (if one isn't already running) spawn a thread to count down how long it will be offline - counting down won't happen if main power was completely cut along with backup power, though, the thread will just sleep.
loseBackupPower - handles the effect of backup power going offline.
regainBackupPower - handles the effect of main power coming back on.
shock - has a chance of electrocuting its target.
*/
// Wires for the airlock are located in the datum folder, inside the wires datum folder.
#define AIRLOCK_CLOSED 1
#define AIRLOCK_CLOSING 2
#define AIRLOCK_OPEN 3
#define AIRLOCK_OPENING 4
#define AIRLOCK_DENY 5
#define AIRLOCK_EMAG 6
#define AIRLOCK_SECURITY_NONE 0 //Normal airlock //Wires are not secured
#define AIRLOCK_SECURITY_METAL 1 //Medium security airlock //There is a simple metal over wires (use welder)
#define AIRLOCK_SECURITY_PLASTEEL_I_S 2 //Sliced inner plating (use crowbar), jumps to 0
#define AIRLOCK_SECURITY_PLASTEEL_I 3 //Removed outer plating, second layer here (use welder)
#define AIRLOCK_SECURITY_PLASTEEL_O_S 4 //Sliced outer plating (use crowbar)
#define AIRLOCK_SECURITY_PLASTEEL_O 5 //There is first layer of plasteel (use welder)
#define AIRLOCK_SECURITY_PLASTEEL 6 //Max security airlock //Fully secured wires (use wirecutters to remove grille, that is electrified)
#define AIRLOCK_INTEGRITY_N 300 // Normal airlock integrity
#define AIRLOCK_INTEGRITY_MULTIPLIER 1.5 // How much reinforced doors health increases
#define AIRLOCK_DAMAGE_DEFLECTION_N 21 // Normal airlock damage deflection
#define AIRLOCK_DAMAGE_DEFLECTION_R 30 // Reinforced airlock damage deflection
var/list/airlock_overlays = list()
/obj/machinery/door/airlock
name = "airlock"
icon = 'icons/obj/doors/airlocks/station/public.dmi'
icon_state = "closed"
max_integrity = 300
integrity_failure = 70
damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_N
autoclose = TRUE
explosion_block = 1
assemblytype = /obj/structure/door_assembly
normalspeed = 1
var/security_level = 0 //How much are wires secured
var/aiControlDisabled = FALSE //If TRUE, AI control is disabled until the AI hacks back in and disables the lock. If 2, the AI has bypassed the lock. If -1, the control is enabled but the AI had bypassed it earlier, so if it is disabled again the AI would have no trouble getting back in.
var/hackProof = FALSE // if TRUE, this door can't be hacked by the AI
var/electrified_until = 0 // World time when the door is no longer electrified. -1 if it is permanently electrified until someone fixes it.
var/main_power_lost_until = 0 //World time when main power is restored.
var/backup_power_lost_until = -1 //World time when backup power is restored.
var/electrified_timer
var/main_power_timer
var/backup_power_timer
var/spawnPowerRestoreRunning = 0
var/lights = TRUE // bolt lights show by default
var/datum/wires/airlock/wires
var/aiDisabledIdScanner = 0
var/aiHacking = 0
var/obj/machinery/door/airlock/closeOther
var/closeOtherId
var/lockdownbyai = 0
var/justzap = 0
var/obj/item/airlock_electronics/electronics
var/hasShocked = 0 //Prevents multiple shocks from happening
var/obj/item/note //Any papers pinned to the airlock
var/previous_airlock = /obj/structure/door_assembly //what airlock assembly mineral plating was applied to
var/airlock_material //material of inner filling; if its an airlock with glass, this should be set to "glass"
var/overlays_file = 'icons/obj/doors/airlocks/station/overlays.dmi'
var/note_overlay_file = 'icons/obj/doors/airlocks/station/overlays.dmi' //Used for papers and photos pinned to the airlock
var/normal_integrity = AIRLOCK_INTEGRITY_N
var/prying_so_hard = FALSE
var/image/old_frame_overlay //keep those in order to prevent unnecessary updating
var/image/old_filling_overlay
var/image/old_lights_overlay
var/image/old_panel_overlay
var/image/old_weld_overlay
var/image/old_sparks_overlay
var/image/old_dam_overlay
var/image/old_note_overlay
var/doorOpen = 'sound/machines/airlock_open.ogg'
var/doorClose = 'sound/machines/airlock_close.ogg'
var/doorDeni = 'sound/machines/DeniedBeep.ogg' // i'm thinkin' Deni's
var/boltUp = 'sound/machines/BoltsUp.ogg'
var/boltDown = 'sound/machines/BoltsDown.ogg'
var/is_special = 0
/obj/machinery/door/airlock/welded
welded = TRUE
/*
About the new airlock wires panel:
* An airlock wire dialog can be accessed by the normal way or by using wirecutters or a multitool on the door while the wire-panel is open. This would show the following wires, which you can either wirecut/mend or send a multitool pulse through. There are 9 wires.
* one wire from the ID scanner. Sending a pulse through this flashes the red light on the door (if the door has power). If you cut this wire, the door will stop recognizing valid IDs. (If the door has 0000 access, it still opens and closes, though)
* two wires for power. Sending a pulse through either one causes a breaker to trip, disabling the door for 10 seconds if backup power is connected, or 1 minute if not (or until backup power comes back on, whichever is shorter). Cutting either one disables the main door power, but unless backup power is also cut, the backup power re-powers the door in 10 seconds. While unpowered, the door may be open, but bolts-raising will not work. Cutting these wires may electrocute the user.
* one wire for door bolts. Sending a pulse through this drops door bolts (whether the door is powered or not) or raises them (if it is). Cutting this wire also drops the door bolts, and mending it does not raise them. If the wire is cut, trying to raise the door bolts will not work.
* two wires for backup power. Sending a pulse through either one causes a breaker to trip, but this does not disable it unless main power is down too (in which case it is disabled for 1 minute or however long it takes main power to come back, whichever is shorter). Cutting either one disables the backup door power (allowing it to be crowbarred open, but disabling bolts-raising), but may electocute the user.
* one wire for opening the door. Sending a pulse through this while the door has power makes it open the door if no access is required.
* one wire for AI control. Sending a pulse through this blocks AI control for a second or so (which is enough to see the AI control light on the panel dialog go off and back on again). Cutting this prevents the AI from controlling the door unless it has hacked the door through the power connection (which takes about a minute). If both main and backup power are cut, as well as this wire, then the AI cannot operate or hack the door at all.
* one wire for electrifying the door. Sending a pulse through this electrifies the door for 30 seconds. Cutting this wire electrifies the door, so that the next person to touch the door without insulated gloves gets electrocuted. (Currently it is also STAYING electrified until someone mends the wire)
* one wire for controling door safetys. When active, door does not close on someone. When cut, door will ruin someone's shit. When pulsed, door will immedately ruin someone's shit.
* one wire for controlling door speed. When active, dor closes at normal rate. When cut, door does not close manually. When pulsed, door attempts to close every tick.
*/
// You can find code for the airlock wires in the wire datum folder.
/obj/machinery/door/airlock/New()
..()
wires = new(src)
/obj/machinery/door/airlock/Initialize()
. = ..()
if(closeOtherId != null)
addtimer(CALLBACK(src, .proc/update_other_id), 5)
if(glass)
airlock_material = "glass"
if(security_level > AIRLOCK_SECURITY_METAL)
obj_integrity = normal_integrity * AIRLOCK_INTEGRITY_MULTIPLIER
max_integrity = normal_integrity * AIRLOCK_INTEGRITY_MULTIPLIER
else
obj_integrity = normal_integrity
max_integrity = normal_integrity
if(damage_deflection == AIRLOCK_DAMAGE_DEFLECTION_N && security_level > AIRLOCK_SECURITY_METAL)
damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_R
update_icon()
/obj/machinery/door/airlock/proc/update_other_id()
for(var/obj/machinery/door/airlock/A in GLOB.airlocks)
if(A.closeOtherId == closeOtherId && A != src)
closeOther = A
break
/obj/machinery/door/airlock/Destroy()
QDEL_NULL(electronics)
QDEL_NULL(wires)
QDEL_NULL(note)
if(main_power_timer)
deltimer(main_power_timer)
main_power_timer = null
if(backup_power_timer)
deltimer(backup_power_timer)
backup_power_timer = null
if(electrified_timer)
deltimer(electrified_timer)
electrified_timer = null
if(radio_controller)
radio_controller.remove_object(src, frequency)
radio_connection = null
return ..()
/obj/machinery/door/airlock/handle_atom_del(atom/A)
if(A == note)
note = null
update_icon()
/obj/machinery/door/airlock/bumpopen(mob/living/user) //Airlocks now zap you when you 'bump' them open when they're electrified. --NeoFite
if(!issilicon(usr))
if(isElectrified())
if(!justzap)
if(shock(user, 100))
justzap = 1
spawn (10)
justzap = 0
return
else /*if(justzap)*/
return
else if(user.hallucination > 50 && prob(10) && !operating)
to_chat(user, "<span class='danger'>You feel a powerful shock course through your body!</span>")
user.adjustStaminaLoss(50)
user.AdjustStunned(5)
return
..(user)
/obj/machinery/door/airlock/bumpopen(mob/living/simple_animal/user)
..(user)
/obj/machinery/door/airlock/autoclose()
autoclose_timer = 0
if(!QDELETED(src) && !density && !operating && !locked && !welded && autoclose)
close()
return
/obj/machinery/door/airlock/proc/isElectrified()
if(electrified_until != 0)
return 1
return 0
/obj/machinery/door/airlock/proc/isWireCut(wireIndex)
// You can find the wires in the datum folder.
return wires.IsIndexCut(wireIndex)
/obj/machinery/door/airlock/proc/canAIControl()
return ((aiControlDisabled!=1) && (!isAllPowerLoss()));
/obj/machinery/door/airlock/proc/canAIHack()
return ((aiControlDisabled==1) && (!hackProof) && (!isAllPowerLoss()));
/obj/machinery/door/airlock/proc/arePowerSystemsOn()
if(stat & (NOPOWER|BROKEN))
return 0
return (main_power_lost_until==0 || backup_power_lost_until==0)
/obj/machinery/door/airlock/requiresID()
return !(isWireCut(AIRLOCK_WIRE_IDSCAN) || aiDisabledIdScanner)
/obj/machinery/door/airlock/proc/isAllPowerLoss()
if(stat & (NOPOWER|BROKEN))
return 1
if(mainPowerCablesCut() && backupPowerCablesCut())
return 1
return 0
/obj/machinery/door/airlock/proc/mainPowerCablesCut()
return isWireCut(AIRLOCK_WIRE_MAIN_POWER1)
/obj/machinery/door/airlock/proc/backupPowerCablesCut()
return isWireCut(AIRLOCK_WIRE_BACKUP_POWER1)
/obj/machinery/door/airlock/proc/loseMainPower()
main_power_lost_until = mainPowerCablesCut() ? -1 : world.time + SecondsToTicks(60)
if(main_power_lost_until > 0)
main_power_timer = addtimer(CALLBACK(src, .proc/regainMainPower), SecondsToTicks(60), TIMER_UNIQUE | TIMER_STOPPABLE)
// If backup power is permanently disabled then activate in 10 seconds if possible, otherwise it's already enabled or a timer is already running
if(backup_power_lost_until == -1 && !backupPowerCablesCut())
backup_power_lost_until = world.time + SecondsToTicks(10)
backup_power_timer = addtimer(CALLBACK(src, .proc/regainBackupPower), SecondsToTicks(10), TIMER_UNIQUE | TIMER_STOPPABLE)
// Disable electricity if required
if(electrified_until && isAllPowerLoss())
electrify(0)
/obj/machinery/door/airlock/proc/loseBackupPower()
backup_power_lost_until = backupPowerCablesCut() ? -1 : world.time + SecondsToTicks(60)
if(backup_power_lost_until > 0)
backup_power_timer = addtimer(CALLBACK(src, .proc/regainBackupPower), SecondsToTicks(60), TIMER_UNIQUE | TIMER_STOPPABLE)
// Disable electricity if required
if(electrified_until && isAllPowerLoss())
electrify(0)
/obj/machinery/door/airlock/proc/regainMainPower()
main_power_timer = null
if(!mainPowerCablesCut())
main_power_lost_until = 0
// If backup power is currently active then disable, otherwise let it count down and disable itself later
if(!backup_power_lost_until)
backup_power_lost_until = -1
update_icon()
/obj/machinery/door/airlock/proc/regainBackupPower()
backup_power_timer = null
if(!backupPowerCablesCut())
// Restore backup power only if main power is offline, otherwise permanently disable
backup_power_lost_until = main_power_lost_until == 0 ? -1 : 0
update_icon()
/obj/machinery/door/airlock/proc/electrify(duration, feedback = 0)
if(electrified_timer)
deltimer(electrified_timer)
electrified_timer = null
var/message = ""
if(isWireCut(AIRLOCK_WIRE_ELECTRIFY) && arePowerSystemsOn())
message = text("The electrification wire is cut - Door permanently electrified.")
electrified_until = -1
else if(duration && !arePowerSystemsOn())
message = text("The door is unpowered - Cannot electrify the door.")
electrified_until = 0
else if(!duration && electrified_until != 0)
message = "The door is now un-electrified."
electrified_until = 0
else if(duration) //electrify door for the given duration seconds
if(usr)
shockedby += text("\[[time_stamp()]\] - [usr](ckey:[usr.ckey])")
usr.create_attack_log("<font color='red'>Electrified the [name] at [x] [y] [z]</font>")
else
shockedby += text("\[[time_stamp()]\] - EMP)")
message = "The door is now electrified [duration == -1 ? "permanently" : "for [duration] second\s"]."
electrified_until = duration == -1 ? -1 : world.time + SecondsToTicks(duration)
if(duration != -1)
electrified_timer = addtimer(CALLBACK(src, .proc/electrify, 0), SecondsToTicks(duration), TIMER_UNIQUE | TIMER_STOPPABLE)
if(feedback && message)
to_chat(usr, message)
// shock user with probability prb (if all connections & power are working)
// returns 1 if shocked, 0 otherwise
// The preceding comment was borrowed from the grille's shock script
/obj/machinery/door/airlock/shock(mob/user, prb)
if(!arePowerSystemsOn())
return 0
if(hasShocked)
return 0 //Already shocked someone recently?
if(..())
hasShocked = 1
sleep(10)
hasShocked = 0
return 1
else
return 0
//Checks if the user can get shocked and shocks him if it can. Returns TRUE if it happened
/obj/machinery/door/airlock/proc/shock_user(mob/user, prob)
return (!issilicon(user) && isElectrified() && shock(user, prob))
/obj/machinery/door/airlock/update_icon(state=0, override=0)
if(operating && !override)
return
icon_state = density ? "closed" : "open"
switch(state)
if(0)
if(density)
state = AIRLOCK_CLOSED
else
state = AIRLOCK_OPEN
if(AIRLOCK_OPEN, AIRLOCK_CLOSED)
if(AIRLOCK_DENY, AIRLOCK_OPENING, AIRLOCK_CLOSING, AIRLOCK_EMAG)
icon_state = "nonexistenticonstate" //MADNESS
set_airlock_overlays(state)
/obj/machinery/door/airlock/proc/set_airlock_overlays(state)
var/image/frame_overlay
var/image/filling_overlay
var/image/lights_overlay
var/image/panel_overlay
var/image/weld_overlay
var/image/damag_overlay
var/image/sparks_overlay
var/image/note_overlay
var/notetype = note_type()
switch(state)
if(AIRLOCK_CLOSED)
frame_overlay = get_airlock_overlay("closed", icon)
if(airlock_material)
filling_overlay = get_airlock_overlay("[airlock_material]_closed", overlays_file)
else
filling_overlay = get_airlock_overlay("fill_closed", icon)
if(panel_open)
if(security_level)
panel_overlay = get_airlock_overlay("panel_closed_protected", overlays_file)
else
panel_overlay = get_airlock_overlay("panel_closed", overlays_file)
if(welded)
weld_overlay = get_airlock_overlay("welded", overlays_file)
if(obj_integrity <integrity_failure)
damag_overlay = get_airlock_overlay("sparks_broken", overlays_file)
else if(obj_integrity < (0.75 * max_integrity))
damag_overlay = get_airlock_overlay("sparks_damaged", overlays_file)
if(lights && arePowerSystemsOn())
if(locked)
lights_overlay = get_airlock_overlay("lights_bolts", overlays_file)
else if(emergency)
lights_overlay = get_airlock_overlay("lights_emergency", overlays_file)
if(note)
note_overlay = get_airlock_overlay(notetype, note_overlay_file)
if(AIRLOCK_DENY)
if(!arePowerSystemsOn())
return
frame_overlay = get_airlock_overlay("closed", icon)
if(airlock_material)
filling_overlay = get_airlock_overlay("[airlock_material]_closed", overlays_file)
else
filling_overlay = get_airlock_overlay("fill_closed", icon)
if(panel_open)
if(security_level)
panel_overlay = get_airlock_overlay("panel_closed_protected", overlays_file)
else
panel_overlay = get_airlock_overlay("panel_closed", overlays_file)
if(obj_integrity <integrity_failure)
damag_overlay = get_airlock_overlay("sparks_broken", overlays_file)
else if(obj_integrity < (0.75 * max_integrity))
damag_overlay = get_airlock_overlay("sparks_damaged", overlays_file)
if(welded)
weld_overlay = get_airlock_overlay("welded", overlays_file)
lights_overlay = get_airlock_overlay("lights_denied", overlays_file)
if(note)
note_overlay = get_airlock_overlay(notetype, note_overlay_file)
if(AIRLOCK_EMAG)
frame_overlay = get_airlock_overlay("closed", icon)
sparks_overlay = get_airlock_overlay("sparks", overlays_file)
if(airlock_material)
filling_overlay = get_airlock_overlay("[airlock_material]_closed", overlays_file)
else
filling_overlay = get_airlock_overlay("fill_closed", icon)
if(panel_open)
if(security_level)
panel_overlay = get_airlock_overlay("panel_closed_protected", overlays_file)
else
panel_overlay = get_airlock_overlay("panel_closed", overlays_file)
if(obj_integrity <integrity_failure)
damag_overlay = get_airlock_overlay("sparks_broken", overlays_file)
else if(obj_integrity < (0.75 * max_integrity))
damag_overlay = get_airlock_overlay("sparks_damaged", overlays_file)
if(welded)
weld_overlay = get_airlock_overlay("welded", overlays_file)
if(note)
note_overlay = get_airlock_overlay(notetype, note_overlay_file)
if(AIRLOCK_CLOSING)
frame_overlay = get_airlock_overlay("closing", icon)
if(airlock_material)
filling_overlay = get_airlock_overlay("[airlock_material]_closing", overlays_file)
else
filling_overlay = get_airlock_overlay("fill_closing", icon)
if(lights && arePowerSystemsOn())
lights_overlay = get_airlock_overlay("lights_closing", overlays_file)
if(panel_open)
if(security_level)
panel_overlay = get_airlock_overlay("panel_closing_protected", overlays_file)
else
panel_overlay = get_airlock_overlay("panel_closing", overlays_file)
if(note)
note_overlay = get_airlock_overlay("[notetype]_closing", note_overlay_file)
if(AIRLOCK_OPEN)
frame_overlay = get_airlock_overlay("open", icon)
if(airlock_material)
filling_overlay = get_airlock_overlay("[airlock_material]_open", overlays_file)
else
filling_overlay = get_airlock_overlay("fill_open", icon)
if(panel_open)
if(security_level)
panel_overlay = get_airlock_overlay("panel_open_protected", overlays_file)
else
panel_overlay = get_airlock_overlay("panel_open", overlays_file)
if(obj_integrity < (0.75 * max_integrity))
damag_overlay = get_airlock_overlay("sparks_open", overlays_file)
if(note)
note_overlay = get_airlock_overlay("[notetype]_open", note_overlay_file)
if(AIRLOCK_OPENING)
frame_overlay = get_airlock_overlay("opening", icon)
if(airlock_material)
filling_overlay = get_airlock_overlay("[airlock_material]_opening", overlays_file)
else
filling_overlay = get_airlock_overlay("fill_opening", icon)
if(lights && arePowerSystemsOn())
lights_overlay = get_airlock_overlay("lights_opening", overlays_file)
if(panel_open)
if(security_level)
panel_overlay = get_airlock_overlay("panel_opening_protected", overlays_file)
else
panel_overlay = get_airlock_overlay("panel_opening", overlays_file)
if(note)
note_overlay = get_airlock_overlay("[notetype]_opening", note_overlay_file)
//doesn't use overlays.Cut() for performance reasons
if(frame_overlay != old_frame_overlay)
overlays -= old_frame_overlay
overlays += frame_overlay
old_frame_overlay = frame_overlay
if(filling_overlay != old_filling_overlay)
overlays -= old_filling_overlay
overlays += filling_overlay
old_filling_overlay = filling_overlay
if(lights_overlay != old_lights_overlay)
overlays -= old_lights_overlay
overlays += lights_overlay
old_lights_overlay = lights_overlay
if(panel_overlay != old_panel_overlay)
overlays -= old_panel_overlay
overlays += panel_overlay
old_panel_overlay = panel_overlay
if(weld_overlay != old_weld_overlay)
overlays -= old_weld_overlay
overlays += weld_overlay
old_weld_overlay = weld_overlay
if(sparks_overlay != old_sparks_overlay)
overlays -= old_sparks_overlay
overlays += sparks_overlay
old_sparks_overlay = sparks_overlay
if(damag_overlay != old_dam_overlay)
overlays -= old_dam_overlay
overlays += damag_overlay
old_dam_overlay = damag_overlay
if(note_overlay != old_note_overlay)
overlays -= old_note_overlay
overlays += note_overlay
old_note_overlay = note_overlay
/proc/get_airlock_overlay(icon_state, icon_file)
var/iconkey = "[icon_state][icon_file]"
if(airlock_overlays[iconkey])
return airlock_overlays[iconkey]
airlock_overlays[iconkey] = image(icon_file, icon_state)
return airlock_overlays[iconkey]
/obj/machinery/door/airlock/do_animate(animation)
switch(animation)
if("opening")
update_icon(AIRLOCK_OPENING)
if("closing")
update_icon(AIRLOCK_CLOSING)
if("deny")
if(!stat)
update_icon(AIRLOCK_DENY)
playsound(src,doorDeni,50,0,3)
sleep(6)
update_icon(AIRLOCK_CLOSED)
/obj/machinery/door/airlock/examine(mob/user)
..()
if(emagged)
to_chat(user, "<span class='warning'>Its access panel is smoking slightly.</span>")
if(note)
if(!in_range(user, src))
to_chat(user, "There's a [note.name] pinned to the front. You can't [note_type() == "note" ? "read" : "see"] it from here.")
else
to_chat(user, "There's a [note.name] pinned to the front...")
note.examine(user)
if(panel_open)
switch(security_level)
if(AIRLOCK_SECURITY_NONE)
to_chat(user, "Its wires are exposed!")
if(AIRLOCK_SECURITY_METAL)
to_chat(user, "Its wires are hidden behind a welded metal cover.")
if(AIRLOCK_SECURITY_PLASTEEL_I_S)
to_chat(user, "There is some shredded plasteel inside.")
if(AIRLOCK_SECURITY_PLASTEEL_I)
to_chat(user, "Its wires are behind an inner layer of plasteel.")
if(AIRLOCK_SECURITY_PLASTEEL_O_S)
to_chat(user, "There is some shredded plasteel inside.")
if(AIRLOCK_SECURITY_PLASTEEL_O)
to_chat(user, "There is a welded plasteel cover hiding its wires.")
if(AIRLOCK_SECURITY_PLASTEEL)
to_chat(user, "There is a protective grille over its panel.")
else if(security_level)
if(security_level == AIRLOCK_SECURITY_METAL)
to_chat(user, "It looks a bit stronger.")
else
to_chat(user, "It looks very robust.")
/obj/machinery/door/airlock/attack_ghost(mob/user)
if(panel_open)
wires.Interact(user)
ui_interact(user)
/obj/machinery/door/airlock/attack_ai(mob/user)
ui_interact(user)
/obj/machinery/door/airlock/ui_interact(mob/user, ui_key = "main", datum/nanoui/ui = null, force_open = 1)
ui = SSnanoui.try_update_ui(user, src, ui_key, ui, force_open)
if(!ui)
ui = new(user, src, ui_key, "door_control.tmpl", "Door Controls - [src]", 600, 375)
ui.open()
ui.set_auto_update(1)
/obj/machinery/door/airlock/ui_data(mob/user, datum/topic_state/state = default_state)
var/data[0]
data["main_power_loss"] = round(main_power_lost_until > 0 ? max(main_power_lost_until - world.time, 0) / 10 : main_power_lost_until, 1)
data["backup_power_loss"] = round(backup_power_lost_until > 0 ? max(backup_power_lost_until - world.time, 0) / 10 : backup_power_lost_until, 1)
data["electrified"] = round(electrified_until > 0 ? max(electrified_until - world.time, 0) / 10 : electrified_until, 1)
data["open"] = !density
var/commands[0]
commands[++commands.len] = list("name" = "IdScan", "command"= "idscan", "active" = !aiDisabledIdScanner,"enabled" = "Enabled", "disabled" = "Disable", "danger" = 0, "act" = 1)
commands[++commands.len] = list("name" = "Bolts", "command"= "bolts", "active" = !locked, "enabled" = "Raised", "disabled" = "Dropped", "danger" = 0, "act" = 0)
commands[++commands.len] = list("name" = "Bolt Lights", "command"= "lights", "active" = lights, "enabled" = "Enabled", "disabled" = "Disable", "danger" = 0, "act" = 1)
commands[++commands.len] = list("name" = "Safeties", "command"= "safeties", "active" = safe, "enabled" = "Nominal", "disabled" = "Overridden", "danger" = 1, "act" = 0)
commands[++commands.len] = list("name" = "Timing", "command"= "timing", "active" = normalspeed, "enabled" = "Nominal", "disabled" = "Overridden", "danger" = 1, "act" = 0)
commands[++commands.len] = list("name" = "Door State", "command"= "open", "active" = density, "enabled" = "Closed", "disabled" = "Opened", "danger" = 0, "act" = 0)
commands[++commands.len] = list("name" = "Emergency Access","command"= "emergency", "active" = !emergency, "enabled" = "Disabled", "disabled" = "Enabled", "danger" = 0, "act" = 0)
data["commands"] = commands
return data
/obj/machinery/door/airlock/proc/hack(mob/user)
set waitfor = 0
if(!aiHacking)
aiHacking = TRUE
to_chat(user, "Airlock AI control has been blocked. Beginning fault-detection.")
sleep(50)
if(canAIControl())
to_chat(user, "Alert cancelled. Airlock control has been restored without our assistance.")
aiHacking = FALSE
return
else if(!canAIHack(user))
to_chat(user, "Connection lost! Unable to hack airlock.")
aiHacking=0
return
to_chat(user, "Fault confirmed: airlock control wire disabled or cut.")
sleep(20)
to_chat(user, "Attempting to hack into airlock. This may take some time.")
sleep(200)
if(canAIControl())
to_chat(user, "Alert cancelled. Airlock control has been restored without our assistance.")
aiHacking = FALSE
return
else if(!canAIHack(user))
to_chat(user, "Connection lost! Unable to hack airlock.")
aiHacking = FALSE
return
to_chat(user, "Upload access confirmed. Loading control program into airlock software.")
sleep(170)
if(canAIControl())
to_chat(user, "Alert cancelled. Airlock control has been restored without our assistance.")
aiHacking = FALSE
return
else if(!canAIHack(user))
to_chat(user, "Connection lost! Unable to hack airlock.")
aiHacking = FALSE
return
to_chat(user, "Transfer complete. Forcing airlock to execute program.")
sleep(50)
//disable blocked control
aiControlDisabled = 2
to_chat(user, "Receiving control information from airlock.")
sleep(10)
//bring up airlock dialog
aiHacking = FALSE
if(user)
attack_ai(user)
/obj/machinery/door/airlock/CanPass(atom/movable/mover, turf/target, height=0)
if(isElectrified() && density && istype(mover, /obj/item))
var/obj/item/I = mover
if(I.flags & CONDUCT)
do_sparks(5, 1, src)
return ..()
/obj/machinery/door/airlock/attack_hand(mob/user)
if(shock_user(user, 100))
return
if(headbutt_airlock(user))
return//Smack that head against that airlock
if(remove_airlock_note(user, FALSE))
return
if(panel_open)
if(security_level)
to_chat(user, "<span class='warning'>Wires are protected!</span>")
return
wires.Interact(user)
else
..()
//Checks if the user can headbutt the airlock and does it if it can. Returns TRUE if it happened
/obj/machinery/door/airlock/proc/headbutt_airlock(mob/user)
if(ishuman(user) && prob(40) && density)
var/mob/living/carbon/human/H = user
if(H.getBrainLoss() >= 60 && Adjacent(user))
playsound(loc, 'sound/effects/bang.ogg', 25, 1)
if(!istype(H.head, /obj/item/clothing/head/helmet))
visible_message("<span class='warning'>[user] headbutts the airlock.</span>")
var/obj/item/organ/external/affecting = H.get_organ("head")
H.Stun(5)
H.Weaken(5)
if(affecting.receive_damage(10, 0))
H.UpdateDamageIcon()
else
visible_message("<span class='warning'>[user] headbutts the airlock. Good thing [user.p_theyre()] wearing a helmet.</span>")
return TRUE
return FALSE
//For the tools being used on the door. Since you don't want to call the attack_hand method if you're using hands. That would be silly
//Also it's a bit inconsistent that when you access the panel you headbutt it. But not while crowbarring
//Try to interact with the panel. If the user can't it'll try activating the door
/obj/machinery/door/airlock/proc/interact_with_panel(mob/user)
if(shock_user(user, 100))
return
if(panel_open)
if(security_level)
to_chat(user, "<span class='warning'>Wires are protected!</span>")
return
wires.Interact(user)
else
try_to_activate_door(user)
/obj/machinery/door/airlock/CanUseTopic(mob/user)
if(!issilicon(user) && !isobserver(user))
return STATUS_CLOSE
if(emagged)
to_chat(user, "<span class='warning'>Unable to interface: Internal error.</span>")
return STATUS_CLOSE
if(!canAIControl() && !isobserver(user))
if(canAIHack(user))
hack(user)
else
if(isAllPowerLoss()) //don't really like how this gets checked a second time, but not sure how else to do it.
to_chat(user, "<span class='warning'>Unable to interface: Connection timed out.</span>")
else
to_chat(user, "<span class='warning'>Unable to interface: Connection refused.</span>")
return STATUS_CLOSE
return ..()
/obj/machinery/door/airlock/Topic(href, href_list, nowindow = 0)
if(..())
return 1
var/activate = text2num(href_list["activate"])
switch(href_list["command"])
if("idscan")
if(isWireCut(AIRLOCK_WIRE_IDSCAN))
to_chat(usr, "The IdScan wire has been cut - IdScan feature permanently disabled.")
else if(activate && aiDisabledIdScanner)
aiDisabledIdScanner = 0
to_chat(usr, "IdScan feature has been enabled.")
else if(!activate && !aiDisabledIdScanner)
aiDisabledIdScanner = 1
to_chat(usr, "IdScan feature has been disabled.")
if("main_power")
if(!main_power_lost_until)
loseMainPower()
update_icon()
if("backup_power")
if(!backup_power_lost_until)
loseBackupPower()
update_icon()
if("bolts")
if(isWireCut(AIRLOCK_WIRE_DOOR_BOLTS))
to_chat(usr, "The door bolt control wire has been cut - Door bolts permanently dropped.")
else if(activate && lock())
to_chat(usr, "The door bolts have been dropped.")
else if(!activate && unlock())
to_chat(usr, "The door bolts have been raised.")
if("electrify_temporary")
if(activate && isWireCut(AIRLOCK_WIRE_ELECTRIFY))
to_chat(usr, text("The electrification wire is cut - Door permanently electrified."))
else if(!activate && electrified_until != 0)
to_chat(usr, "The door is now un-electrified.")
electrify(0)
else if(activate) //electrify door for 30 seconds
shockedby += text("\[[time_stamp()]\][usr](ckey:[usr.ckey])")
usr.create_attack_log("<font color='red'>Electrified the [name] at [x] [y] [z]</font>")
to_chat(usr, "The door is now electrified for thirty seconds.")
electrify(30)
if("electrify_permanently")
if(isWireCut(AIRLOCK_WIRE_ELECTRIFY))
to_chat(usr, text("The electrification wire is cut - Cannot electrify the door."))
else if(!activate && electrified_until != 0)
to_chat(usr, "The door is now un-electrified.")
electrify(0)
else if(activate)
shockedby += text("\[[time_stamp()]\][usr](ckey:[usr.ckey])")
usr.create_attack_log("<font color='red'>Electrified the [name] at [x] [y] [z]</font>")
to_chat(usr, "The door is now electrified.")
electrify(-1)
if("open")
if(welded)
to_chat(usr, text("The airlock has been welded shut!"))
else if(locked)
to_chat(usr, text("The door bolts are down!"))
else if(activate && density)
open()
else if(!activate && !density)
close()
if("safeties")
// Safeties! We don't need no stinking safeties!
if(isWireCut(AIRLOCK_WIRE_SAFETY))
to_chat(usr, text("The safety wire is cut - Cannot secure the door."))
else if(activate && safe)
safe = 0
else if(!activate && !safe)
safe = 1
if("timing")
// Door speed control
if(isWireCut(AIRLOCK_WIRE_SPEED))
to_chat(usr, text("The timing wire is cut - Cannot alter timing."))
else if(activate && normalspeed)
normalspeed = 0
else if(!activate && !normalspeed)
normalspeed = 1
if("lights")
// Bolt lights
if(isWireCut(AIRLOCK_WIRE_LIGHT))
to_chat(usr, "The bolt lights wire has been cut - The door bolt lights are permanently disabled.")
else if(!activate && lights)
lights = 0
to_chat(usr, "The door bolt lights have been disabled.")
else if(activate && !lights)
lights = 1
to_chat(usr, "The door bolt lights have been enabled.")
update_icon()
if("emergency")
// Emergency access
if(emergency)
emergency = 0
to_chat(usr, "Emergency access has been disabled.")
else
emergency = 1
to_chat(usr, "Emergency access has been enabled.")
update_icon()
return 1
/obj/machinery/door/airlock/attackby(obj/item/C, mob/user, params)
if(shock_user(user, 75))
return
add_fingerprint(user)
if(headbutt_airlock(user))//See if the user headbutts the airlock
return
if(panel_open)
switch(security_level)
if(AIRLOCK_SECURITY_NONE)
if(istype(C, /obj/item/stack/sheet/metal))
var/obj/item/stack/sheet/metal/S = C
if(S.get_amount() < 2)
to_chat(user, "<span class='warning'>You need at least 2 metal sheets to reinforce [src].</span>")
return
to_chat(user, "<span class='notice'>You start reinforcing [src]...</span>")
if(do_after(user, 20, 1, target = src))
if(!panel_open || !S.use(2))
return
user.visible_message("<span class='notice'>[user] reinforces \the [src] with metal.</span>",
"<span class='notice'>You reinforce \the [src] with metal.</span>")
security_level = AIRLOCK_SECURITY_METAL
update_icon()
return
else if(istype(C, /obj/item/stack/sheet/plasteel))
var/obj/item/stack/sheet/plasteel/S = C
if(S.get_amount() < 2)
to_chat(user, "<span class='warning'>You need at least 2 plasteel sheets to reinforce [src].</span>")
return
to_chat(user, "<span class='notice'>You start reinforcing [src]...</span>")
if(do_after(user, 20, 1, target = src))
if(!panel_open || !S.use(2))
return
user.visible_message("<span class='notice'>[user] reinforces \the [src] with plasteel.</span>",
"<span class='notice'>You reinforce \the [src] with plasteel.</span>")
security_level = AIRLOCK_SECURITY_PLASTEEL
modify_max_integrity(normal_integrity * AIRLOCK_INTEGRITY_MULTIPLIER)
damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_R
update_icon()
return
if(AIRLOCK_SECURITY_METAL)
if(iswelder(C))
var/obj/item/weldingtool/WT = C
if(!WT.remove_fuel(2, user))
return
to_chat(user, "<span class='notice'>You begin cutting the panel's shielding...</span>")
playsound(loc, WT.usesound, 40, 1)
if(do_after(user, 40 * WT.toolspeed, 1, target = src))
if(!panel_open || !WT.isOn())
return
playsound(loc, WT.usesound, 50, 1)
user.visible_message("<span class='notice'>[user] cuts through \the [src]'s shielding.</span>",
"<span class='notice'>You cut through \the [src]'s shielding.</span>",
"<span class='italics'>You hear welding.</span>")
security_level = AIRLOCK_SECURITY_NONE
spawn_atom_to_turf(/obj/item/stack/sheet/metal, user.loc, 2)
update_icon()
return
if(AIRLOCK_SECURITY_PLASTEEL_I_S)
if(iscrowbar(C))
var/obj/item/crowbar/W = C
to_chat(user, "<span class='notice'>You start removing the inner layer of shielding...</span>")
playsound(src, W.usesound, 100, 1)
if(do_after(user, 40 * W.toolspeed, 1, target = src))
if(!panel_open)
return
if(security_level != AIRLOCK_SECURITY_PLASTEEL_I_S)
return
user.visible_message("<span class='notice'>[user] remove \the [src]'s shielding.</span>",
"<span class='notice'>You remove \the [src]'s inner shielding.</span>")
security_level = AIRLOCK_SECURITY_NONE
modify_max_integrity(normal_integrity)
damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_N
spawn_atom_to_turf(/obj/item/stack/sheet/plasteel, user.loc, 1)
update_icon()
return
if(AIRLOCK_SECURITY_PLASTEEL_I)
if(iswelder(C))
var/obj/item/weldingtool/WT = C
if(!WT.remove_fuel(2, user))
return
to_chat(user, "<span class='notice'>You begin cutting the inner layer of shielding...</span>")
playsound(loc, WT.usesound, 40, 1)
if(do_after(user, 40 * WT.toolspeed, 1, target = src))
if(!panel_open || !WT.isOn())
return
playsound(loc, WT.usesound, 50, 1)
user.visible_message("<span class='notice'>[user] cuts through \the [src]'s shielding.</span>",
"<span class='notice'>You cut through \the [src]'s shielding.</span>",
"<span class='italics'>You hear welding.</span>")
security_level = AIRLOCK_SECURITY_PLASTEEL_I_S
return
if(AIRLOCK_SECURITY_PLASTEEL_O_S)
if(iscrowbar(C))
var/obj/item/crowbar/W = C
to_chat(user, "<span class='notice'>You start removing outer layer of shielding...</span>")
playsound(src, W.usesound, 100, 1)
if(do_after(user, 40 * W.toolspeed, 1, target = src))
if(!panel_open)
return
if(security_level != AIRLOCK_SECURITY_PLASTEEL_O_S)
return
user.visible_message("<span class='notice'>[user] remove \the [src]'s shielding.</span>",
"<span class='notice'>You remove \the [src]'s shielding.</span>")
security_level = AIRLOCK_SECURITY_PLASTEEL_I
spawn_atom_to_turf(/obj/item/stack/sheet/plasteel, user.loc, 1)
return
if(AIRLOCK_SECURITY_PLASTEEL_O)
if(iswelder(C))
var/obj/item/weldingtool/WT = C
if(!WT.remove_fuel(2, user))
return
to_chat(user, "<span class='notice'>You begin cutting the outer layer of shielding...</span>")
playsound(loc, WT.usesound, 40, 1)
if(do_after(user, 40 * WT.toolspeed, 1, target = src))
if(!panel_open || !WT.isOn())
return
playsound(loc, WT.usesound, 50, 1)
user.visible_message("<span class='notice'>[user] cuts through \the [src]'s shielding.</span>",
"<span class='notice'>You cut through \the [src]'s shielding.</span>",
"<span class='italics'>You hear welding.</span>")
security_level = AIRLOCK_SECURITY_PLASTEEL_O_S
return
if(AIRLOCK_SECURITY_PLASTEEL)
if(iswirecutter(C))
var/obj/item/wirecutters/W = C
if(arePowerSystemsOn() && shock(user, 60)) // Protective grille of wiring is electrified
return
to_chat(user, "<span class='notice'>You start cutting through the outer grille.</span>")
playsound(src, W.usesound, 100, 1)
if(do_after(user, 10 * W.toolspeed, 1, target = src))
if(!panel_open)
return
user.visible_message("<span class='notice'>[user] cut through \the [src]'s outer grille.</span>",
"<span class='notice'>You cut through \the [src]'s outer grille.</span>")
security_level = AIRLOCK_SECURITY_PLASTEEL_O
return
if(isscrewdriver(C))
panel_open = !panel_open
to_chat(user, "<span class='notice'>You [panel_open ? "open":"close"] the maintenance panel of the airlock.</span>")
playsound(loc, C.usesound, 50, 1)
update_icon()
else if(iswirecutter(C))
if(note)
remove_airlock_note(user, TRUE)
else
return interact_with_panel(user)
else if(ismultitool(C))
return interact_with_panel(user)
else if(istype(C, /obj/item/assembly/signaler))
return interact_with_panel(user)
else if(istype(C, /obj/item/pai_cable)) // -- TLE
var/obj/item/pai_cable/cable = C
cable.plugin(src, user)
else if(istype(C, /obj/item/paper) || istype(C, /obj/item/photo))
if(note)
to_chat(user, "<span class='warning'>There's already something pinned to this airlock! Use wirecutters or your hands to remove it.</span>")
return
if(!user.unEquip(C))
to_chat(user, "<span class='warning'>For some reason, you can't attach [C]!</span>")
return
C.forceMove(src)
user.visible_message("<span class='notice'>[user] pins [C] to [src].</span>", "<span class='notice'>You pin [C] to [src].</span>")
note = C
update_icon()
else
return ..()
/obj/machinery/door/airlock/try_to_weld(obj/item/weldingtool/W, mob/user)
if(!operating && density)
if(user.a_intent != INTENT_HELP)
if(W.remove_fuel(0, user))
user.visible_message("[user] is [welded ? "unwelding":"welding"] the airlock.", \
"<span class='notice'>You begin [welded ? "unwelding":"welding"] the airlock...</span>", \
"<span class='italics'>You hear welding.</span>")
playsound(loc, W.usesound, 40, 1)
if(do_after(user, 40 * W.toolspeed, 1, target = src, extra_checks = CALLBACK(src, .proc/weld_checks, W, user)))
playsound(loc, 'sound/items/welder2.ogg', 50, 1)
welded = !welded
user.visible_message("[user.name] has [welded? "welded shut":"unwelded"] [src].", \
"<span class='notice'>You [welded ? "weld the airlock shut":"unweld the airlock"].</span>")
update_icon()
else
if(obj_integrity < max_integrity)
if(W.remove_fuel(0, user))
user.visible_message("[user] is welding the airlock.", \
"<span class='notice'>You begin repairing the airlock...</span>", \
"<span class='italics'>You hear welding.</span>")
playsound(loc, W.usesound, 40, 1)
if(do_after(user, 40 * W.toolspeed, 1, target = src, extra_checks = CALLBACK(src, .proc/weld_checks, W, user)))
playsound(loc, 'sound/items/welder2.ogg', 50, 1)
obj_integrity = max_integrity
stat &= ~BROKEN
user.visible_message("[user.name] has repaired [src].", \
"<span class='notice'>You finish repairing the airlock.</span>")
update_icon()