/
airlock.dm
1723 lines (1556 loc) · 60.2 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.
hasPower - 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
/// How much extra health airlocks get when braced with a seal
#define AIRLOCK_SEAL_MULTIPLIER 2
#define AIRLOCK_DAMAGE_DEFLECTION_N 21 // Normal airlock damage deflection
#define AIRLOCK_DAMAGE_DEFLECTION_R 30 // Reinforced airlock damage deflection
/obj/machinery/door/airlock
name = "airlock"
icon = 'icons/obj/doors/airlocks/station/public.dmi'
icon_state = "closed"
max_integrity = 300
var/normal_integrity = AIRLOCK_INTEGRITY_N
integrity_failure = 0.25
damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_N
autoclose = TRUE
secondsElectrified = MACHINE_NOT_ELECTRIFIED //How many seconds remain until the door is no longer electrified. -1/MACHINE_ELECTRIFIED_PERMANENT = permanently electrified until someone fixes it.
assemblytype = /obj/structure/door_assembly
normalspeed = 1
explosion_block = 1
hud_possible = list(DIAG_AIRLOCK_HUD)
req_ship_access = TRUE
smoothing_groups = list(SMOOTH_GROUP_AIRLOCK)
FASTDMM_PROP(\
pinned_vars = list("req_access_txt", "req_one_access_txt", "name")\
)
interaction_flags_machine = INTERACT_MACHINE_WIRES_IF_OPEN | INTERACT_MACHINE_ALLOW_SILICON | INTERACT_MACHINE_OPEN_SILICON | INTERACT_MACHINE_REQUIRES_SILICON | INTERACT_MACHINE_OPEN
var/security_level = 0 //How much are wires secured
var/aiControlDisabled = AI_WIRE_NORMAL //If 1, 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/secondsMainPowerLost = 0 //The number of seconds until power is restored.
var/secondsBackupPowerLost = 0 //The number of seconds until power is restored.
var/spawnPowerRestoreRunning = FALSE
var/lights = TRUE // bolt lights show by default
var/aiDisabledIdScanner = FALSE
var/aiHacking = FALSE
var/closeOtherId //Cyclelinking for airlocks that aren't on the same x or y coord as the target.
var/obj/machinery/door/airlock/closeOther
var/justzap = FALSE
var/obj/item/electronics/airlock/electronics
var/shockCooldown = FALSE //Prevents multiple shocks from happening
var/obj/item/note //Any papers pinned to the airlock
/// The seal on the airlock
var/obj/item/seal
var/detonated = FALSE
var/abandoned = FALSE
var/doorOpen = 'sound/machines/airlocks/standard/open.ogg'
var/doorClose = 'sound/machines/airlocks/standard/close.ogg'
var/doorDeni = 'sound/machines/airlocks/access_denied.ogg' // i'm thinkin' Deni's
var/boltUp = 'sound/machines/airlocks/bolts_up.ogg'
var/boltDown = 'sound/machines/airlocks/bolts_down.ogg'
var/pry_sound = 'sound/machines/creaking.ogg'
var/pry_open_sound = 'sound/machines/airlocks/open_force.ogg'
var/pry_close_sound = 'sound/machines/airlocks/close_force.ogg'
var/noPower = 'sound/machines/doorclick.ogg'
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/cyclelinkeddir = 0
var/cyclelinkedx = 0 //WS start negative is left positive is right
var/cyclelinkedy = 0 //WS end negative is down positive is up
var/obj/machinery/door/airlock/cyclelinkedairlock
var/shuttledocked = 0
var/delayed_close_requested = FALSE // TRUE means the door will automatically close the next time it's opened.
var/prying_so_hard = FALSE
flags_1 = RAD_PROTECT_CONTENTS_1 | RAD_NO_CONTAMINATE_1 | HTML_USE_INITAL_ICON_1
rad_insulation = RAD_MEDIUM_INSULATION
var/static/list/airlock_overlays = list()
var/has_hatch = TRUE //If TRUE, this door has hatches, and certain small creatures can move through them without opening the door
var/hatchstate = 0 //0: closed, 1: open
var/hatch_offset_x = 0
var/hatch_offset_y = 0
var/hatch_colour = "#7d7d7d"
var/hatch_open_sound = 'sound/machines/airlocks/hatch/hatch_open.ogg'
var/hatch_close_sound = 'sound/machines/airlocks/hatch/hatch_close.ogg'
/obj/machinery/door/airlock/Initialize()
. = ..()
wires = new /datum/wires/airlock(src)
if(frequency)
set_frequency(frequency)
if(closeOtherId != null)
addtimer(CALLBACK(PROC_REF(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
prepare_huds()
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
diag_hud.add_to_hud(src)
diag_hud_set_electrified()
RegisterSignal(src, COMSIG_MACHINERY_BROKEN, PROC_REF(on_break))
update_appearance()
var/static/list/connections = list(
COMSIG_ATOM_ENTERED = PROC_REF(on_entered),
COMSIG_ATOM_EXITED = PROC_REF(on_exited)
)
AddElement(/datum/element/connect_loc, connections)
return INITIALIZE_HINT_LATELOAD
/obj/machinery/door/airlock/LateInitialize()
. = ..()
if(cyclelinkedx || cyclelinkedy) //WS start
cyclelinkairlock_target()
else
if(cyclelinkeddir)
cyclelinkairlock() //WS end
if(abandoned)
var/outcome = rand(1,100)
switch(outcome)
if(1 to 9)
var/turf/here = get_turf(src)
for(var/turf/closed/T in range(2, src))
here.PlaceOnTop(T.type)
qdel(src)
return
here.PlaceOnTop(/turf/closed/wall)
qdel(src)
return
if(9 to 11)
lights = FALSE
locked = TRUE
if(12 to 15)
locked = TRUE
if(16 to 23)
welded = TRUE
if(24 to 30)
panel_open = TRUE
update_appearance()
/obj/machinery/door/airlock/ComponentInitialize()
. = ..()
AddComponent(/datum/component/ntnet_interface)
/obj/machinery/door/airlock/connect_to_shuttle(obj/docking_port/mobile/port, obj/docking_port/stationary/dock)
if(id_tag)
id_tag = "[REF(port)][id_tag]"
/obj/machinery/door/airlock/CanPass(atom/movable/mover, turf/target)
. = ..()
if(density && has_hatch && (mover.pass_flags & PASSDOORHATCH))
return TRUE //If this airlock is closed, has hatches, and this creature can go through hatches, then we let it through without opening the airlock
/obj/machinery/door/airlock/proc/on_entered(datum/source, atom/movable/mover)
SIGNAL_HANDLER
if(density && has_hatch && (mover.pass_flags & PASSDOORHATCH) && !hatchstate)
hatchstate = 1
update_appearance()
playsound(loc, hatch_open_sound, 40, 1, -1, mono_adj = TRUE)
if(mover.layer != initial(mover.layer))
return
mover.layer = UNDERDOOR
/obj/machinery/door/airlock/proc/on_exited(datum/source, atom/movable/mover)
SIGNAL_HANDLER
if(density && has_hatch && (mover.pass_flags & PASSDOORHATCH))
mover.layer = initial(mover.layer)
close_hatch()
/obj/machinery/door/airlock/proc/close_hatch()
hatchstate = 0
update_appearance()
playsound(loc, hatch_close_sound, 30, 1, -1, mono_adj = TRUE)
/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/proc/cyclelinkairlock_target() //WS start
if (cyclelinkedairlock)
cyclelinkedairlock.cyclelinkedairlock = null
cyclelinkedairlock = null
if(!cyclelinkedx && !cyclelinkedy)
return
var/turf/T = get_turf(src)
var/obj/machinery/door/airlock/FoundDoor
var/dirlook
var/targ
if(cyclelinkedx)
if(cyclelinkedx > 0)
targ = cyclelinkedx
dirlook = 4
else
targ = cyclelinkedx * -1
dirlook = 8
for(var/i = 0; i < targ; i++)
T = get_step(T, dirlook)
if(cyclelinkedy)
if(cyclelinkedy > 0)
targ = cyclelinkedy
dirlook = 1
else
targ = cyclelinkedy * -1
dirlook = 2
for(var/i = 0; i < targ; i++)
T = get_step(T, dirlook)
FoundDoor = locate() in T
if (FoundDoor && (FoundDoor.cyclelinkedy != -1 * cyclelinkedy || FoundDoor.cyclelinkedx != -1 * cyclelinkedx))
FoundDoor = null
if (!FoundDoor)
log_mapping("[src] at [AREACOORD(src)] failed to find a valid airlock to cyclelink_target with! Was targeting [T.x], [T.y], [T.z].")
return
FoundDoor.cyclelinkedairlock = src
cyclelinkedairlock = FoundDoor //WS end
/obj/machinery/door/airlock/proc/cyclelinkairlock()
if (cyclelinkedairlock)
cyclelinkedairlock.cyclelinkedairlock = null
cyclelinkedairlock = null
if (!cyclelinkeddir)
return
var/limit = world.view
var/turf/T = get_turf(src)
var/obj/machinery/door/airlock/FoundDoor
do
T = get_step(T, cyclelinkeddir)
FoundDoor = locate() in T
if (FoundDoor && FoundDoor.cyclelinkeddir != get_dir(FoundDoor, src))
FoundDoor = null
limit--
while(!FoundDoor && limit)
if (!FoundDoor)
log_mapping("[src] at [AREACOORD(src)] failed to find a valid airlock to cyclelink with!")
return
FoundDoor.cyclelinkedairlock = src
cyclelinkedairlock = FoundDoor
/obj/machinery/door/airlock/vv_edit_var(var_name)
. = ..()
switch (var_name)
if (NAMEOF(src, cyclelinkedx)) //WS start
cyclelinkairlock_target()
if (NAMEOF(src, cyclelinkedy))
cyclelinkairlock_target() //WS end
if (NAMEOF(src, cyclelinkeddir))
cyclelinkairlock()
/obj/machinery/door/airlock/check_access_ntnet(datum/netdata/data)
return !requiresID() || ..()
/obj/machinery/door/airlock/ntnet_receive(datum/netdata/data)
// Check if the airlock is powered and can accept control packets.
if(!hasPower() || !canAIControl())
return
// Check packet access level.
if(!check_access_ntnet(data))
return
// Handle received packet.
var/command = lowertext(data.data["data"])
var/command_value = lowertext(data.data["data_secondary"])
switch(command)
if("open")
if(command_value == "on" && !density)
return
if(command_value == "off" && density)
return
if(density)
INVOKE_ASYNC(src, PROC_REF(open))
else
INVOKE_ASYNC(src, PROC_REF(close))
if("bolt")
if(command_value == "on" && locked)
return
if(command_value == "off" && !locked)
return
if(locked)
unbolt()
else
bolt()
if("emergency")
if(command_value == "on" && emergency)
return
if(command_value == "off" && !emergency)
return
emergency = !emergency
update_appearance()
/obj/machinery/door/airlock/lock()
bolt()
/obj/machinery/door/airlock/proc/bolt()
if(locked)
return
locked = TRUE
playsound(src, boltDown, 30, FALSE, 3, mono_adj = TRUE)
audible_message("<span class='hear'>You hear a click from the bottom of the door.</span>", null, 1)
update_appearance()
/obj/machinery/door/airlock/unlock()
unbolt()
/obj/machinery/door/airlock/proc/unbolt()
if(!locked)
return
locked = FALSE
playsound(src, boltUp, 30, FALSE, 3, mono_adj = TRUE)
audible_message("<span class='hear'>You hear a click from the bottom of the door.</span>", null, 1)
update_appearance()
/obj/machinery/door/airlock/narsie_act()
var/turf/T = get_turf(src)
var/obj/machinery/door/airlock/cult/A
if(GLOB.cult_narsie)
var/runed = prob(20)
if(glass)
if(runed)
A = new/obj/machinery/door/airlock/cult/glass(T)
else
A = new/obj/machinery/door/airlock/cult/unruned/glass(T)
else
if(runed)
A = new/obj/machinery/door/airlock/cult(T)
else
A = new/obj/machinery/door/airlock/cult/unruned(T)
A.name = name
else
A = new /obj/machinery/door/airlock/cult/weak(T)
qdel(src)
/obj/machinery/door/airlock/Destroy()
QDEL_NULL(wires)
QDEL_NULL(electronics)
if(closeOther)
closeOther.closeOther = null
closeOther = null
if (cyclelinkedairlock)
if (cyclelinkedairlock.cyclelinkedairlock == src)
cyclelinkedairlock.cyclelinkedairlock = null
cyclelinkedairlock = null
if(id_tag)
for(var/obj/machinery/doorButtons/D in GLOB.machines)
D.removeMe(src)
QDEL_NULL(note)
QDEL_NULL(seal)
for(var/datum/atom_hud/data/diagnostic/diag_hud in GLOB.huds)
diag_hud.remove_from_hud(src)
return ..()
/obj/machinery/door/airlock/handle_atom_del(atom/A)
if(A == note)
note = null
update_appearance()
if(A == seal)
seal = null
update_appearance()
/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 = TRUE
addtimer(VARSET_CALLBACK(src, justzap, FALSE) , 10)
return
else
return
else if(user.hallucinating() && ishuman(user) && prob(1) && !operating)
var/mob/living/carbon/human/H = user
if(H.gloves)
var/obj/item/clothing/gloves/G = H.gloves
if(G.siemens_coefficient)//not insulated
new /datum/hallucination/shock(H)
return
if (cyclelinkedairlock)
if (!shuttledocked && !emergency && !cyclelinkedairlock.shuttledocked && !cyclelinkedairlock.emergency && allowed(user))
if(cyclelinkedairlock.operating)
cyclelinkedairlock.delayed_close_requested = TRUE
else
addtimer(CALLBACK(cyclelinkedairlock, PROC_REF(close)), 2)
if(locked && allowed(user) && aac)
aac.request_from_door(src)
return
..()
/obj/machinery/door/airlock/proc/isElectrified()
if(secondsElectrified != MACHINE_NOT_ELECTRIFIED)
return TRUE
return FALSE
/obj/machinery/door/airlock/proc/canAIControl(mob/user)
return ((aiControlDisabled != AI_WIRE_DISABLED) && !isAllPowerCut() && check_ship_ai_access(user))
/obj/machinery/door/airlock/proc/canAIHack()
return ((aiControlDisabled==AI_WIRE_DISABLED) && (!hackProof) && (!isAllPowerCut()));
/obj/machinery/door/airlock/hasPower()
return ((!secondsMainPowerLost || !secondsBackupPowerLost) && !(machine_stat & NOPOWER))
/obj/machinery/door/airlock/requiresID()
return !(wires.is_cut(WIRE_IDSCAN) || aiDisabledIdScanner)
/obj/machinery/door/airlock/proc/isAllPowerCut()
if((wires.is_cut(WIRE_POWER1) || wires.is_cut(WIRE_POWER2)) && (wires.is_cut(WIRE_BACKUP1) || wires.is_cut(WIRE_BACKUP2)))
return TRUE
/obj/machinery/door/airlock/proc/regainMainPower()
if(secondsMainPowerLost > 0)
secondsMainPowerLost = 0
update_appearance()
/obj/machinery/door/airlock/proc/handlePowerRestore()
var/cont = TRUE
while (cont)
sleep(10)
if(QDELETED(src))
return
cont = FALSE
if(secondsMainPowerLost>0)
if(!wires.is_cut(WIRE_POWER1) && !wires.is_cut(WIRE_POWER2))
secondsMainPowerLost -= 1
updateDialog()
cont = TRUE
if(secondsBackupPowerLost>0)
if(!wires.is_cut(WIRE_BACKUP1) && !wires.is_cut(WIRE_BACKUP2))
secondsBackupPowerLost -= 1
updateDialog()
cont = TRUE
spawnPowerRestoreRunning = FALSE
updateDialog()
update_appearance()
/obj/machinery/door/airlock/proc/loseMainPower()
if(secondsMainPowerLost <= 0)
secondsMainPowerLost = 60
if(secondsBackupPowerLost < 10)
secondsBackupPowerLost = 10
if(!spawnPowerRestoreRunning)
spawnPowerRestoreRunning = TRUE
INVOKE_ASYNC(src, PROC_REF(handlePowerRestore))
update_appearance()
/obj/machinery/door/airlock/proc/loseBackupPower()
if(secondsBackupPowerLost < 60)
secondsBackupPowerLost = 60
if(!spawnPowerRestoreRunning)
spawnPowerRestoreRunning = TRUE
INVOKE_ASYNC(src, PROC_REF(handlePowerRestore))
update_appearance()
/obj/machinery/door/airlock/proc/regainBackupPower()
if(secondsBackupPowerLost > 0)
secondsBackupPowerLost = 0
update_appearance()
// shock user with probability prb (if all connections & power are working)
// returns TRUE if shocked, FALSE otherwise
// The preceding comment was borrowed from the grille's shock script
/obj/machinery/door/airlock/proc/shock(mob/living/user, prb)
if(!istype(user) || !hasPower()) // unpowered, no shock
return FALSE
if(shockCooldown > world.time)
return FALSE //Already shocked someone recently?
if(!prob(prb))
return FALSE //you lucked out, no shock for you
do_sparks(5, TRUE, src)
var/check_range = TRUE
if(electrocute_mob(user, get_area(src), src, 1, check_range))
shockCooldown = world.time + 10
return TRUE
else
return FALSE
/obj/machinery/door/airlock/update_icon(updates=ALL, state=0, override=FALSE)
if(operating && !override)
return
if(!state)
state = density ? AIRLOCK_CLOSED : AIRLOCK_OPEN
airlock_state = state
. = ..()
if(hasPower() && unres_sides)
set_light(2, 1)
else
set_light(0)
/obj/machinery/door/airlock/update_icon_state()
. = ..()
switch(airlock_state)
if(AIRLOCK_OPEN, AIRLOCK_CLOSED)
icon_state = ""
if(AIRLOCK_DENY, AIRLOCK_OPENING, AIRLOCK_CLOSING, AIRLOCK_EMAG)
icon_state = "nonexistenticonstate" //MADNESS
/obj/machinery/door/airlock/update_overlays()
. = ..()
var/mutable_appearance/frame_overlay
var/mutable_appearance/filling_overlay
var/mutable_appearance/lights_overlay
var/mutable_appearance/panel_overlay
var/mutable_appearance/weld_overlay
var/mutable_appearance/damag_overlay
var/mutable_appearance/sparks_overlay
var/mutable_appearance/note_overlay
var/mutable_appearance/seal_overlay
var/notetype = note_type()
var/mutable_appearance/hatch_overlay
switch(airlock_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(seal)
seal_overlay = get_airlock_overlay("sealed", overlays_file)
if(obj_integrity < integrity_failure * max_integrity)
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 && hasPower())
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(has_hatch)
if(hatchstate)
hatch_overlay = get_airlock_overlay("hatch_open", icon)
else
hatch_overlay = get_airlock_overlay("hatch_closed", icon)
if(AIRLOCK_DENY)
if(!hasPower())
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 * max_integrity)
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(seal)
seal_overlay = get_airlock_overlay("sealed", overlays_file)
lights_overlay = get_airlock_overlay("lights_denied", overlays_file)
if(note)
note_overlay = get_airlock_overlay(notetype, note_overlay_file)
if(has_hatch)
if(hatchstate)
hatch_overlay = get_airlock_overlay("hatch_open", icon)
else
hatch_overlay = get_airlock_overlay("hatch_closed", icon)
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 * max_integrity)
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(seal)
seal_overlay = get_airlock_overlay("sealed", 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 && hasPower())
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(has_hatch)
hatch_overlay = get_airlock_overlay("hatch_closing", icon)
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 && hasPower())
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)
if(has_hatch)
hatch_overlay = get_airlock_overlay("hatch_opening", icon)
. += frame_overlay
. += filling_overlay
. += lights_overlay
. += panel_overlay
. += weld_overlay
. += sparks_overlay
. += damag_overlay
. += note_overlay
. += seal_overlay
. += hatch_overlay
if(hasPower() && unres_sides)
if(unres_sides & NORTH)
var/image/I = image(icon='icons/obj/doors/airlocks/station/overlays.dmi', icon_state="unres_n")
I.pixel_y = 32
. += I
if(unres_sides & SOUTH)
var/image/I = image(icon='icons/obj/doors/airlocks/station/overlays.dmi', icon_state="unres_s")
I.pixel_y = -32
. += I
if(unres_sides & EAST)
var/image/I = image(icon='icons/obj/doors/airlocks/station/overlays.dmi', icon_state="unres_e")
I.pixel_x = 32
. += I
if(unres_sides & WEST)
var/image/I = image(icon='icons/obj/doors/airlocks/station/overlays.dmi', icon_state="unres_w")
I.pixel_x = -32
. += I
else
set_light(0)
/proc/get_airlock_overlay(icon_state, icon_file)
var/obj/machinery/door/airlock/A
pass(A) //suppress unused warning
var/list/airlock_overlays = A.airlock_overlays
var/iconkey = "[icon_state][icon_file]"
if((!(. = airlock_overlays[iconkey])))
. = airlock_overlays[iconkey] = mutable_appearance(icon_file, icon_state)
/obj/machinery/door/airlock/do_animate(animation)
switch(animation)
if("opening")
update_icon(ALL, AIRLOCK_OPENING)
if("closing")
update_icon(ALL, AIRLOCK_CLOSING)
if("deny")
if(!machine_stat)
update_icon(ALL, AIRLOCK_DENY)
playsound(src, doorDeni, 50, FALSE, 3, mono_adj = TRUE)
sleep(6)
update_icon(ALL, AIRLOCK_CLOSED)
/obj/machinery/door/airlock/examine(mob/user)
. = ..()
if(obj_flags & EMAGGED)
. += "<span class='warning'>Its access panel is smoking slightly.</span>"
if(note)
if(!in_range(user, src))
. += "There's a [note.name] pinned to the front. You can't read it from here."
else
. += "There's a [note.name] pinned to the front..."
. += note.examine(user)
if(seal)
. += "It's been braced with a pneumatic seal."
if(panel_open)
switch(security_level)
if(AIRLOCK_SECURITY_NONE)
. += "Its wires are exposed!"
if(AIRLOCK_SECURITY_METAL)
. += "Its wires are hidden behind a welded metal cover."
if(AIRLOCK_SECURITY_PLASTEEL_I_S)
. += "There is some shredded plasteel inside."
if(AIRLOCK_SECURITY_PLASTEEL_I)
. += "Its wires are behind an inner layer of plasteel."
if(AIRLOCK_SECURITY_PLASTEEL_O_S)
. += "There is some shredded plasteel inside."
if(AIRLOCK_SECURITY_PLASTEEL_O)
. += "There is a welded plasteel cover hiding its wires."
if(AIRLOCK_SECURITY_PLASTEEL)
. += "There is a protective grille over its panel."
else if(security_level)
if(security_level == AIRLOCK_SECURITY_METAL)
. += "It looks a bit stronger."
else
. += "It looks very robust."
if(issilicon(user) && !(machine_stat & BROKEN))
. += "<span class='notice'>Shift-click [src] to [ density ? "open" : "close"] it.</span>"
. += "<span class='notice'>Ctrl-click [src] to [ locked ? "raise" : "drop"] its bolts.</span>"
. += "<span class='notice'>Alt-click [src] to [ secondsElectrified ? "un-electrify" : "permanently electrify"] it.</span>"
. += "<span class='notice'>Ctrl-Shift-click [src] to [ emergency ? "disable" : "enable"] emergency access.</span>"
/obj/machinery/door/airlock/attack_ai(mob/user)
if(!canAIControl(user))
if(canAIHack())
hack(user)
return
else
to_chat(user, "<span class='warning'>Airlock AI control has been blocked with a firewall. Unable to hack.</span>")
if(obj_flags & EMAGGED)
to_chat(user, "<span class='warning'>Unable to interface: Airlock is unresponsive.</span>")
return
if(detonated)
to_chat(user, "<span class='warning'>Unable to interface. Airlock control panel damaged.</span>")
return
ui_interact(user)
/obj/machinery/door/airlock/proc/hack(mob/user)
set waitfor = 0
if(!aiHacking)
aiHacking = TRUE
to_chat(user, "<span class='warning'>Airlock AI control has been blocked. Beginning fault-detection.</span>")
sleep(50)
if(canAIControl(user))
to_chat(user, "<span class='notice'>Alert cancelled. Airlock control has been restored without our assistance.</span>")
aiHacking = FALSE
return
else if(!canAIHack())
to_chat(user, "<span class='warning'>Connection lost! Unable to hack airlock.</span>")
aiHacking = FALSE
return
to_chat(user, "<span class='notice'>Fault confirmed: airlock control wire disabled or cut.</span>")
sleep(20)
to_chat(user, "<span class='notice'>Attempting to hack into airlock. This may take some time.</span>")
sleep(200)
if(canAIControl(user))
to_chat(user, "<span class='notice'>Alert cancelled. Airlock control has been restored without our assistance.</span>")
aiHacking = FALSE
return
else if(!canAIHack())
to_chat(user, "<span class='warning'>Connection lost! Unable to hack airlock.</span>")
aiHacking = FALSE
return
to_chat(user, "<span class='notice'>Upload access confirmed. Loading control program into airlock software.</span>")
sleep(170)
if(canAIControl(user))
to_chat(user, "<span class='notice'>Alert cancelled. Airlock control has been restored without our assistance.</span>")
aiHacking = FALSE
return
else if(!canAIHack())
to_chat(user, "<span class='warning'>Connection lost! Unable to hack airlock.</span>")
aiHacking = FALSE
return
to_chat(user, "<span class='notice'>Transfer complete. Forcing airlock to execute program.</span>")
sleep(50)
//disable blocked control
aiControlDisabled = AI_WIRE_HACKED
to_chat(user, "<span class='notice'>Receiving control information from airlock.</span>")
sleep(10)
//bring up airlock dialog
aiHacking = FALSE
if(user)
attack_ai(user)
/obj/machinery/door/airlock/attack_animal(mob/user)
. = ..()
if(isElectrified())
shock(user, 100)
/obj/machinery/door/airlock/attack_paw(mob/user)
return attack_hand(user)
/obj/machinery/door/airlock/attack_hand(mob/user)
if(user.a_intent == INTENT_GRAB && note) //WS edit - Grabbing notes off doors
user.visible_message("<span class='notice'>[user] grabs [note] from [src].</span>", "<span class='notice'>You remove [note] from [src].</span>")
user.put_in_hands(note)
note = null
update_appearance() //WS end
return TRUE
if(locked && allowed(user) && aac)
aac.request_from_door(src)
. = TRUE
else
. = ..()
if(.)
return
if(!(issilicon(user) || isAdminGhostAI(user)))
if(isElectrified())
if(shock(user, 100))
return
if(ishuman(user) && prob(40) && density)
var/mob/living/carbon/human/H = user
if((HAS_TRAIT(H, TRAIT_DUMB)) && Adjacent(user))
playsound(src, 'sound/effects/bang.ogg', 25, TRUE)
if(!istype(H.head, /obj/item/clothing/head/helmet))
H.visible_message("<span class='danger'>[user] headbutts the airlock.</span>", \
"<span class='userdanger'>You headbutt the airlock!</span>")
H.Paralyze(100)
H.apply_damage(10, BRUTE, BODY_ZONE_HEAD)
else
visible_message("<span class='danger'>[user] headbutts the airlock. Good thing [user.p_theyre()] wearing a helmet.</span>")
/obj/machinery/door/airlock/attempt_wire_interaction(mob/user)
if(security_level)
to_chat(user, "<span class='warning'>Wires are protected!</span>")
return WIRE_INTERACTION_FAIL
return ..()
/obj/machinery/door/airlock/proc/electrified_loop()
while (secondsElectrified > MACHINE_NOT_ELECTRIFIED)
sleep(10)
if(QDELETED(src))
return
secondsElectrified--
updateDialog()
// This is to protect against changing to permanent, mid loop.
if(secondsElectrified == MACHINE_NOT_ELECTRIFIED)
set_electrified(MACHINE_NOT_ELECTRIFIED)
else
set_electrified(MACHINE_ELECTRIFIED_PERMANENT)
updateDialog()
/obj/machinery/door/airlock/Topic(href, href_list, nowindow = 0)
// If you add an if(..()) check you must first remove the var/nowindow parameter.
// Otherwise it will runtime with this kind of error: null.Topic()
if(!nowindow)
..()
if(!usr.canUseTopic(src) && !isAdminGhostAI(usr))
return
add_fingerprint(usr)
if((in_range(src, usr) && isturf(loc)) && panel_open)
usr.set_machine(src)
add_fingerprint(usr)
if(!nowindow)
updateUsrDialog()
else
updateDialog()
/obj/machinery/door/airlock/attackby(obj/item/C, mob/user, params)
if(!issilicon(user) && !isAdminGhostAI(user))
if(isElectrified())
if(shock(user, 75))
return
add_fingerprint(user)
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, TRUE, 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_appearance()
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, TRUE, 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(max_integrity * AIRLOCK_INTEGRITY_MULTIPLIER)
damage_deflection = AIRLOCK_DAMAGE_DEFLECTION_R
update_appearance()
return
if(AIRLOCK_SECURITY_METAL)
if(C.tool_behaviour == TOOL_WELDER)
if(!C.tool_start_check(user, amount=2))
return
to_chat(user, "<span class='notice'>You begin cutting the panel's shielding...</span>")
if(C.use_tool(src, user, 40, volume=50, amount = 2))
if(!panel_open)
return
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='hear'>You hear welding.</span>")
security_level = AIRLOCK_SECURITY_NONE
spawn_atom_to_turf(/obj/item/stack/sheet/metal, user.loc, 2)
update_appearance()
return
if(AIRLOCK_SECURITY_PLASTEEL_I_S)