/
nuclearbomb.dm
723 lines (657 loc) · 28.4 KB
/
nuclearbomb.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
#define NUKE_INTACT 0
#define NUKE_COVER_OFF 1
#define NUKE_COVER_OPEN 2
#define NUKE_SEALANT_OPEN 3
#define NUKE_UNWRENCHED 4
#define NUKE_MOBILE 5
#define NUKE_CORE_EVERYTHING_FINE 6
#define NUKE_CORE_PANEL_EXPOSED 7
#define NUKE_CORE_PANEL_UNWELDED 8
#define NUKE_CORE_FULLY_EXPOSED 9
GLOBAL_VAR(bomb_set)
/obj/machinery/nuclearbomb
name = "\improper Nuclear Fission Explosive"
desc = "Uh oh. RUN!!!!"
icon = 'icons/obj/nuclearbomb.dmi'
icon_state = "nuclearbomb0"
density = TRUE
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | UNACIDABLE | ACID_PROOF
flags_2 = NO_MALF_EFFECT_2 | CRITICAL_ATOM_2
anchored = TRUE
power_state = NO_POWER_USE
interact_offline = TRUE
/// Are our bolts *supposed* to be in the floor, may not actually cause anchoring if the bolts are cut
var/extended = TRUE
/// If true, prevents the lights on the nuke
var/lighthack = FALSE
/// Countdown to boom
var/timeleft = 120
/// Are we counting down?
var/timing = FALSE
/// Have we gone boom yet?
var/exploded = FALSE
/// Random code between 10000 and 99999
var/r_code = "ADMIN"
/// Code entered by user
var/code
/// Is the most recently inputted code correct?
var/yes_code = FALSE
var/safety = TRUE
var/obj/item/disk/nuclear/auth = null
var/obj/item/nuke_core/plutonium/core = null
var/lastentered
var/is_syndicate = FALSE
/// If this is true you cannot unbolt the NAD with tools, only the NAD
var/requires_NAD_to_unbolt = FALSE
var/previous_level = ""
var/datum/wires/nuclearbomb/wires = null
var/removal_stage = NUKE_INTACT
///The same state removal stage is, until someone opens the panel of the nuke. This way we can have someone open the front of the nuke, while keeping track of where in the world we are on the anchoring bolts.
var/anchor_stage = NUKE_INTACT
///This is so that we can check if the internal components are sealed up properly when the outer hatch is closed.
var/core_stage = NUKE_CORE_EVERYTHING_FINE
///How many sheets of various metals we need to fix it
var/sheets_to_fix = 5
/obj/machinery/nuclearbomb/syndicate
is_syndicate = TRUE
requires_NAD_to_unbolt = TRUE
/obj/machinery/nuclearbomb/undeployed
extended = FALSE
anchored = FALSE
/obj/machinery/nuclearbomb/Initialize()
. = ..()
r_code = rand(10000, 99999) // Creates a random code upon object spawn.
wires = new/datum/wires/nuclearbomb(src)
ADD_TRAIT(src, TRAIT_OBSCURED_WIRES, ROUNDSTART_TRAIT)
previous_level = SSsecurity_level.get_current_level_as_text()
GLOB.poi_list |= src
core = new /obj/item/nuke_core/plutonium(src)
STOP_PROCESSING(SSobj, core) //Let us not irradiate the vault by default.
update_icon(UPDATE_OVERLAYS)
/obj/machinery/nuclearbomb/Destroy()
SStgui.close_uis(wires)
QDEL_NULL(wires)
QDEL_NULL(core)
GLOB.poi_list.Remove(src)
return ..()
/obj/machinery/nuclearbomb/process()
if(timing)
GLOB.bomb_set = TRUE // So long as there is one nuke timing, it means one nuke is armed.
timeleft = max(timeleft - 2, 0) // 2 seconds per process()
if(timeleft <= 0)
INVOKE_ASYNC(src, PROC_REF(explode))
return
/obj/machinery/nuclearbomb/examine(mob/user)
. = ..()
if(!panel_open)
. += "<span class='notice'>The outer panel is <b>screwed shut</b>.</span>"
switch(removal_stage)
if(NUKE_INTACT)
. += "<span class='notice'>The anchoring bolt covers are <b>welded shut</b>.</span>"
if(NUKE_COVER_OFF)
. += "<span class='notice'>The cover plate is <b>pried into</b> place.</span>"
if(NUKE_COVER_OPEN)
. += "<span class='notice'>The anchoring system sealant is <b>welded shut</b>.</span>"
if(NUKE_SEALANT_OPEN)
. += "<span class='notice'>The bolts are <b>wrenched</b> in place.</span>"
if(NUKE_UNWRENCHED)
. += "<span class='notice'>The device can be <b>pried off</b> its anchors.</span>"
if(NUKE_CORE_EVERYTHING_FINE)
. += "<span class='notice'>The outer panel can be <b>pried open</b> or it can be <i>screwed</i> back on.</span>"
if(NUKE_CORE_PANEL_EXPOSED)
. += "<span class='notice'>The outer plate can be fixed by <b>[sheets_to_fix] metal sheets</b>, while the inner core plate is <i>welded shut</i>.</span>"
if(NUKE_CORE_PANEL_UNWELDED)
. += "<span class='notice'>The inner core plate can be <b>welded shut</b> or it can be <i>pried open</i>.</span>"
if(NUKE_CORE_FULLY_EXPOSED)
. += "<span class='notice'>The inner core plate can be fixed by <b>[sheets_to_fix] titanium sheets</b>, [core ? "or the plutonium core can be <i>removed</i>" : "though the plutonium core is <i>missing</i>"].</span>"
/obj/machinery/nuclearbomb/update_overlays()
. = ..()
underlays.Cut()
set_light(0)
if(!lighthack)
underlays += emissive_appearance(icon, "nuclearbomb_lightmask")
set_light(1, LIGHTING_MINIMUM_POWER)
if(panel_open)
. += "hackpanel_open"
if(anchored) // Using anchored due to removal_stage deanchoring having multiple steps
. += "nukebolts"
// Selected stage lets us show the open core, even if the front panel is closed
var/selected_stage = removal_stage
if(removal_stage < NUKE_CORE_EVERYTHING_FINE) // Because we need to show the core
selected_stage = core_stage
switch(selected_stage)
if(NUKE_CORE_PANEL_EXPOSED)
. += "nukecore1"
if(NUKE_CORE_PANEL_UNWELDED)
. += "nukecore2"
if(NUKE_CORE_FULLY_EXPOSED)
. += core ? "nukecore3" : "nukecore4"
/obj/machinery/nuclearbomb/attackby(obj/item/O as obj, mob/user as mob, params)
if(istype(O, /obj/item/disk/nuclear))
if(extended)
if(!user.drop_item())
to_chat(user, "<span class='notice'>[O] is stuck to your hand!</span>")
return
O.forceMove(src)
auth = O
add_fingerprint(user)
return attack_hand(user)
else
to_chat(user, "<span class='notice'>You need to deploy [src] first.</span>")
return
if(istype(O, /obj/item/stack/sheet/mineral/titanium) && removal_stage == NUKE_CORE_FULLY_EXPOSED)
var/obj/item/stack/S = O
if(S.get_amount() < sheets_to_fix)
to_chat(user, "<span class='warning'>You need at least [sheets_to_fix] sheets of titanium to repair [src]'s inner core plate!</span>")
return
if(do_after(user, 2 SECONDS, target = src))
if(!loc || !S || S.get_amount() < sheets_to_fix)
return
S.use(sheets_to_fix)
user.visible_message("<span class='notice'>[user] repairs [src]'s inner core plate.</span>", \
"<span class='notice'>You repair [src]'s inner core plate. The radiation is contained.</span>")
removal_stage = NUKE_CORE_PANEL_UNWELDED
if(core)
STOP_PROCESSING(SSobj, core)
update_icon(UPDATE_OVERLAYS)
return
if(istype(O, /obj/item/stack/sheet/metal) && removal_stage == NUKE_CORE_PANEL_EXPOSED)
var/obj/item/stack/S = O
if(S.get_amount() < sheets_to_fix)
to_chat(user, "<span class='warning'>You need at least [sheets_to_fix] sheets of metal to repair [src]'s outer core plate!</span>")
return
if(do_after(user, 2 SECONDS, target = src))
if(!loc || !S || S.get_amount() < sheets_to_fix)
return
S.use(sheets_to_fix)
user.visible_message("<span class='notice'>[user] repairs [src]'s outer core plate.</span>", \
"<span class='notice'>You repair [src]'s outer core plate.</span>")
removal_stage = NUKE_CORE_EVERYTHING_FINE
update_icon(UPDATE_OVERLAYS)
return
if(istype(O, /obj/item/nuke_core/plutonium) && removal_stage == NUKE_CORE_FULLY_EXPOSED)
if(do_after(user, 2 SECONDS, target = src))
if(!user.unEquip(O))
to_chat(user, "<span class='notice'>The [O] is stuck to your hand!</span>")
return
user.visible_message("<span class='notice'>[user] puts [O] back in [src].</span>", "<span class='notice'>You put [O] back in [src].</span>")
O.forceMove(src)
core = O
update_icon(UPDATE_OVERLAYS)
return
else if(istype(O, /obj/item/disk/plantgene))
to_chat(user, "<span class='warning'>You try to plant the disk, but despite rooting around, it won't fit! After you branch out to read the instructions, you find out where the problem stems from. You've been bamboo-zled, this isn't a nuclear disk at all!</span>")
return
return ..()
/obj/machinery/nuclearbomb/crowbar_act(mob/user, obj/item/I)
. = TRUE
if(!I.tool_use_check(user, 0))
return
if(removal_stage == NUKE_COVER_OFF)
user.visible_message("[user] starts forcing open the bolt covers on [src].", "You start forcing open the anchoring bolt covers with [I]...")
if(!I.use_tool(src, user, 15, volume = I.tool_volume) || removal_stage != NUKE_COVER_OFF)
return
user.visible_message("[user] forces open the bolt covers on [src].", "You force open the bolt covers.")
removal_stage = NUKE_COVER_OPEN
if(removal_stage == NUKE_CORE_EVERYTHING_FINE)
user.visible_message("<span class='notice'>[user] starts removing [src]'s outer core plate...</span>", "<span class='notice'>You start removing [src]'s outer core plate...</span>")
if(!I.use_tool(src, user, 4 SECONDS, volume = I.tool_volume) || removal_stage != NUKE_CORE_EVERYTHING_FINE)
return
user.visible_message("<span class='notice'>[user] finishes removing [src]'s outer core plate.</span>", "<span class='notice'>You finish removing [src]'s outer core plate.</span>")
new /obj/item/stack/sheet/metal(loc, 5)
removal_stage = NUKE_CORE_PANEL_EXPOSED
if(removal_stage == NUKE_CORE_PANEL_UNWELDED)
user.visible_message("<span class='notice'>[user] starts removing [src]'s inner core plate...</span>", "<span class='notice'>You start removing [src]'s inner core plate...</span>")
if(!I.use_tool(src, user, 8 SECONDS, volume = I.tool_volume) || removal_stage != NUKE_CORE_PANEL_UNWELDED)
return
user.visible_message("<span class='notice'>[user] finishes removing [src]'s inner core plate.</span>", "<span class='notice'>You remove [src]'s inner core plate. You can see the core's green glow!</span>")
removal_stage = NUKE_CORE_FULLY_EXPOSED
new /obj/item/stack/sheet/mineral/titanium(loc, 5)
if(core)
START_PROCESSING(SSobj, core)
if(removal_stage == NUKE_UNWRENCHED)
user.visible_message("[user] begins lifting [src] off of the anchors.", "You begin lifting the device off the anchors...")
if(!I.use_tool(src, user, 8 SECONDS, volume = I.tool_volume) || removal_stage != NUKE_UNWRENCHED)
return
user.visible_message("[user] crowbars [src] off of the anchors. It can now be moved.", "You jam the crowbar under the nuclear device and lift it off its anchors. You can now move it!")
anchored = FALSE
removal_stage = NUKE_MOBILE
update_icon(UPDATE_OVERLAYS)
/obj/machinery/nuclearbomb/wrench_act(mob/user, obj/item/I)
if(!anchored)
return
if(removal_stage != NUKE_SEALANT_OPEN)
return
. = TRUE
if(!I.tool_use_check(user, 0))
return
user.visible_message("[user] begins unwrenching the anchoring bolts on [src].", "You begin unwrenching the anchoring bolts...")
if(!I.use_tool(src, user, 50, volume = I.tool_volume) || removal_stage != NUKE_SEALANT_OPEN)
return
user.visible_message("[user] unwrenches the anchoring bolts on [src].", "You unwrench the anchoring bolts.")
removal_stage = NUKE_UNWRENCHED
update_icon(UPDATE_OVERLAYS)
/obj/machinery/nuclearbomb/multitool_act(mob/user, obj/item/I)
if(!panel_open)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
attack_hand(user)
/obj/machinery/nuclearbomb/screwdriver_act(mob/user, obj/item/I)
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
if(auth || (istype(I, /obj/item/screwdriver/nuke) && !is_syndicate))
if(!panel_open)
panel_open = TRUE
to_chat(user, "You unscrew the control panel of [src].")
anchor_stage = removal_stage
removal_stage = core_stage
else
panel_open = FALSE
to_chat(user, "You screw the control panel of [src] back on.")
core_stage = removal_stage
removal_stage = anchor_stage
else
if(!panel_open)
to_chat(user, "[src] emits a buzzing noise, the panel staying locked in.")
if(panel_open)
panel_open = FALSE
to_chat(user, "You screw the control panel of [src] back on.")
core_stage = removal_stage
removal_stage = anchor_stage
flick("nuclearbombc", src)
update_icon(UPDATE_OVERLAYS)
/obj/machinery/nuclearbomb/wirecutter_act(mob/user, obj/item/I)
if(!panel_open)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = I.tool_volume))
return
attack_hand(user)
/obj/machinery/nuclearbomb/welder_act(mob/user, obj/item/I)
. = TRUE
if(!I.tool_use_check(user, 0))
return
if(requires_NAD_to_unbolt)
to_chat(user, "<span class='warning'>This device seems to have additional safeguards, and cannot be forcibly moved without using the NAD!</span>")
return
if(removal_stage == NUKE_INTACT)
visible_message("<span class='notice'>[user] starts cutting loose the anchoring bolt covers on [src].</span>",\
"<span class='notice'>You start cutting loose the anchoring bolt covers with [I]...</span>",\
"<span class='warning'>You hear welding.</span>")
if(!I.use_tool(src, user, 40, 5, volume = I.tool_volume) || removal_stage != NUKE_INTACT)
return
visible_message("<span class='notice'>[user] cuts through the bolt covers on [src].</span>",\
"<span class='notice'>You cut through the bolt cover.</span>")
removal_stage = NUKE_COVER_OFF
if(removal_stage == NUKE_CORE_PANEL_UNWELDED)
user.visible_message("<span class='notice'>[user] starts welding [src]'s inner core plate...</span>", "<span class='notice'>You start welding [src]'s inner core plate...</span>")
if(!I.use_tool(src, user, 4 SECONDS, 5, volume = I.tool_volume) || removal_stage != NUKE_CORE_PANEL_UNWELDED)
return
user.visible_message("<span class='notice'>[user] finishes welding [src]'s inner core plate...</span>", "<span class='notice'>You finish welding [src]'s inner core plate...</span>")
removal_stage = NUKE_CORE_PANEL_EXPOSED
else if(removal_stage == NUKE_CORE_PANEL_EXPOSED)
user.visible_message("<span class='notice'>[user] starts unwelding [src]'s inner core plate...</span>", "<span class='notice'>You start unwelding [src]'s inner core plate...</span>")
if(!I.use_tool(src, user, 4 SECONDS, 5, volume = I.tool_volume) || removal_stage != NUKE_CORE_PANEL_EXPOSED)
return
user.visible_message("<span class='notice'>[user] finishes unwelding [src]'s inner core plate...</span>", "<span class='notice'>You finish unwelding [src]'s inner core plate...</span>")
removal_stage = NUKE_CORE_PANEL_UNWELDED
if(removal_stage == NUKE_COVER_OPEN)
visible_message("<span class='notice'>[user] starts cutting apart the anchoring system sealant on [src].</span>",\
"<span class='notice'>You start cutting apart the anchoring system's sealant with [I]...</span>",\
"<span class='warning'>You hear welding.</span>")
if(!I.use_tool(src, user, 40, 5, volume = I.tool_volume) || removal_stage != NUKE_COVER_OPEN)
return
visible_message("<span class='notice'>[user] cuts apart the anchoring system sealant on [src].</span>",\
"<span class='notice'>You cut apart the anchoring system's sealant.</span></span>")
removal_stage = NUKE_SEALANT_OPEN
update_icon(UPDATE_OVERLAYS)
/obj/machinery/nuclearbomb/attack_ghost(mob/user as mob)
if(!panel_open)
return ui_interact(user)
if(removal_stage != NUKE_CORE_FULLY_EXPOSED || !core)
return wires.Interact(user)
/obj/machinery/nuclearbomb/attack_hand(mob/user as mob)
if(!panel_open)
return ui_interact(user)
if(!Adjacent(user))
return
if(removal_stage != NUKE_CORE_FULLY_EXPOSED || !core)
return wires.Interact(user)
if(timing) //removing the core is less risk then cutting wires, and doesnt take long, so we should not let crew do it while the nuke is armed. You can however get to it, without the special screwdriver, if you put the NAD in.
to_chat(user, "<span class='warning'>[core] won't budge, metal clamps keep it in!</span>")
return
user.visible_message("<span class='notice'>[user] starts to pull [core] out of [src]!</span>", "<span class='notice'>You start to pull [core] out of [src]!</span>")
if(do_after(user, 5 SECONDS, target = src))
user.visible_message("<span class='notice'>[user] pulls [core] out of [src]!</span>", "<span class='notice'>You pull [core] out of [src]! Might want to put it somewhere safe.</span>")
core.forceMove(loc)
core = null
update_icon(UPDATE_OVERLAYS)
/obj/machinery/nuclearbomb/ui_state(mob/user)
return GLOB.physical_state
/obj/machinery/nuclearbomb/ui_interact(mob/user, datum/tgui/ui = null)
ui = SStgui.try_update_ui(user, src, ui)
if(!ui)
ui = new(user, src, "NuclearBomb", name)
ui.open()
/obj/machinery/nuclearbomb/ui_data(mob/user)
var/list/data = list()
data["extended"] = extended
data["authdisk"] = is_auth(user)
data["diskname"] = auth ? auth.name : FALSE
data["authcode"] = yes_code
data["authfull"] = data["authdisk"] && data["authcode"]
data["safe"] = safety ? "Safe" : "Engaged"
data["time"] = timeleft
data["timer"] = timing
data["safety"] = safety
data["anchored"] = anchored
if(is_auth(user))
if(yes_code)
data["codemsg"] = "CLEAR CODE"
else if(code)
data["codemsg"] = "RE-ENTER CODE"
else
data["codemsg"] = "ENTER CODE"
else
data["codemsg"] = "-----"
return data
/obj/machinery/nuclearbomb/proc/is_auth(mob/user)
if(auth)
return TRUE
else if(user.can_admin_interact())
return TRUE
else
return FALSE
/obj/machinery/nuclearbomb/ui_act(action, params)
if(..())
return
. = TRUE
if(exploded)
return
switch(action)
if("deploy")
if(removal_stage != NUKE_MOBILE)
anchored = TRUE
visible_message("<span class='warning'>With a steely snap, bolts slide out of [src] and anchor it to the flooring!</span>")
else
visible_message("<span class='warning'>[src] makes a highly unpleasant crunching noise. It looks like the anchoring bolts have been cut.</span>")
if(!lighthack)
flick("nuclearbombc", src)
icon_state = "nuclearbomb1"
update_icon(UPDATE_OVERLAYS)
extended = TRUE
return
if("auth")
if(auth)
if(!usr.get_active_hand() && Adjacent(usr))
usr.put_in_hands(auth)
else
auth.forceMove(get_turf(src))
yes_code = FALSE
auth = null
else
var/obj/item/I = usr.get_active_hand()
if(istype(I, /obj/item/disk/nuclear))
usr.drop_item()
I.forceMove(src)
auth = I
return
if(!is_auth(usr)) // All requests below here require NAD inserted.
return FALSE
switch(action)
if("code")
if(yes_code) // Clear code
code = null
yes_code = FALSE
return
// If no code set, enter new one
var/tempcode = tgui_input_number(usr, "Code", "Input Code", max_value = 999999)
if(isnull(tempcode))
return
code = tempcode
if(code == r_code)
yes_code = TRUE
code = null
else
code = "ERROR"
return
if("toggle_anchor")
if(removal_stage == NUKE_MOBILE)
anchored = FALSE
update_icon(UPDATE_OVERLAYS)
visible_message("<span class='warning'>[src] makes a highly unpleasant crunching noise. It looks like the anchoring bolts have been cut.</span>")
return
if(!anchored && isinspace())
to_chat(usr, "<span class='warning'>There is nothing to anchor to!</span>")
return FALSE
if(!yes_code && anchored && timing)
to_chat(usr, "<span class='warning'>The code is required to unanchor [src] when armed!</span>")
return
anchored = !(anchored)
update_icon(UPDATE_OVERLAYS)
if(anchored)
visible_message("<span class='warning'>With a steely snap, bolts slide out of [src] and anchor it to the flooring.</span>")
return
requires_NAD_to_unbolt = FALSE
visible_message("<span class='warning'>The anchoring bolts slide back into the depths of [src].</span>")
return
if(!yes_code) // All requests below here require both NAD inserted AND code correct
return
switch(action)
if("set_time")
var/time = tgui_input_number(usr, "Detonation time (seconds, min 120, max 600)", "Input Time", 120, 600, 120)
if(isnull(time))
return
timeleft = time
if("toggle_safety")
safety = !(safety)
if(safety)
if(!is_syndicate)
SSsecurity_level.set_level(previous_level)
timing = FALSE
GLOB.bomb_set = FALSE
if("toggle_armed")
if(safety)
to_chat(usr, "<span class='notice'>The safety is still on.</span>")
return
if(!core)
to_chat(usr, "<span class='danger'>[src]'s screen blinks red! There is no plutonium core in [src]!</span>")
return
timing = !(timing)
if(timing)
if(!lighthack)
icon_state = "nuclearbomb2"
update_icon(UPDATE_OVERLAYS)
if(!safety)
message_admins("[key_name_admin(usr)] engaged a nuclear bomb [ADMIN_JMP(src)]")
if(!is_syndicate && SSsecurity_level.get_current_level_as_number() != SEC_LEVEL_EPSILON)
SSsecurity_level.set_level(SEC_LEVEL_DELTA)
GLOB.bomb_set = TRUE // There can still be issues with this resetting when there are multiple bombs. Not a big deal though for Nuke
else
GLOB.bomb_set = TRUE
else
if(!is_syndicate)
SSsecurity_level.set_level(previous_level)
GLOB.bomb_set = FALSE
if(!lighthack)
icon_state = "nuclearbomb1"
update_icon(UPDATE_OVERLAYS)
/obj/machinery/nuclearbomb/blob_act(obj/structure/blob/B)
if(exploded)
return
if(timing) //boom
INVOKE_ASYNC(src, PROC_REF(explode))
return
//if no boom then we need to let the blob capture our nuke
var/turf/T = get_turf(src)
if(!T)
return
if(locate(/obj/structure/blob) in T)
return
var/obj/structure/blob/captured_nuke/N = new(T, src)
N.overmind = B.overmind
N.adjustcolors(B.color)
/obj/machinery/nuclearbomb/zap_act(power, zap_flags)
. = ..()
if(zap_flags & ZAP_MACHINE_EXPLOSIVE)
qdel(src)//like the singulo, tesla deletes it. stops it from exploding over and over
/// Determine the location of the nuke with respect to the station. Used for,
/// among other things, calculating win conditions for nukies and choosing which
/// round-end cinematic to play.
/obj/machinery/nuclearbomb/proc/get_nuke_site()
var/turf/bomb_turf = get_turf(src)
if(!bomb_turf)
return NUKE_SITE_INVALID
if(!is_station_level(bomb_turf.z))
return NUKE_SITE_OFF_STATION_ZLEVEL
if(get_area(src) in SSmapping.existing_station_areas)
return NUKE_SITE_ON_STATION
return NUKE_SITE_ON_STATION_ZLEVEL
/obj/machinery/nuclearbomb/proc/explode()
if(safety)
timing = FALSE
return
exploded = TRUE
yes_code = FALSE
safety = TRUE
if(!lighthack)
icon_state = "nuclearbomb3"
update_icon(UPDATE_OVERLAYS)
playsound(src,'sound/machines/alarm.ogg',100,0,5)
if(SSticker && SSticker.mode)
SSticker.mode.explosion_in_progress = TRUE
SSticker.event_blackbox(outcome = ROUND_END_NUCLEAR)
sleep(100)
GLOB.enter_allowed = 0
var/nuke_site = get_nuke_site()
if(SSticker)
if(SSticker.mode && SSticker.mode.name == "nuclear emergency")
var/obj/docking_port/mobile/syndie_shuttle = SSshuttle.getShuttle("syndicate")
if(syndie_shuttle)
SSticker.mode:syndies_didnt_escape = is_station_level(syndie_shuttle.z)
SSticker.mode:nuke_off_station = nuke_site
SSticker.station_explosion_cinematic(nuke_site, null)
if(SSticker.mode)
SSticker.mode.explosion_in_progress = FALSE
if(SSticker.mode.name == "nuclear emergency")
SSticker.mode:nukes_left --
else if(nuke_site == NUKE_SITE_ON_STATION_ZLEVEL)
to_chat(world, "<b>A nuclear device was set off, but the explosion was out of reach of the station!</b>")
else if(nuke_site == NUKE_SITE_OFF_STATION_ZLEVEL)
to_chat(world, "<b>A nuclear device was set off, but the device nowhere near the station!</b>")
else if(nuke_site == NUKE_SITE_INVALID)
to_chat(world, "<b>A nuclear device was set off in an unknown location!</b>")
log_admin("The nuclear device [src] detonated but was not located on a valid turf.")
else
to_chat(world, "<b>The station was destroyed by the nuclear blast!</b>")
// NUKE_SITE_ON_STATION_ZLEVEL still counts as nuked for the
// purposes of /datum/game_mode/nuclear/declare_completion() and its
// weird logic of specifying whether the nuke blew up "something
// that wasn't" the station.
SSticker.mode.station_was_nuked = nuke_site == NUKE_SITE_ON_STATION || nuke_site == NUKE_SITE_ON_STATION_ZLEVEL
if(!SSticker.mode.check_finished())//If the mode does not deal with the nuke going off so just reboot because everyone is stuck as is
SSticker.reboot_helper("Station destroyed by Nuclear Device.", "nuke - unhandled ending")
return
return
/obj/machinery/nuclearbomb/proc/reset_lighthack_callback()
lighthack = !lighthack
/obj/machinery/nuclearbomb/proc/reset_safety_callback()
safety = !safety
if(safety == 1)
if(!is_syndicate)
SSsecurity_level.set_level(previous_level)
visible_message("<span class='notice'>[src] quiets down.</span>")
if(!lighthack)
if(icon_state == "nuclearbomb2")
icon_state = "nuclearbomb1"
update_icon(UPDATE_OVERLAYS)
else
visible_message("<span class='notice'>[src] emits a quiet whirling noise!</span>")
//==========DAT FUKKEN DISK===============
/obj/item/disk/nuclear
name = "nuclear authentication disk"
desc = "Better keep this safe."
icon_state = "nucleardisk"
max_integrity = 250
armor = list(MELEE = 0, BULLET = 0, LASER = 0, ENERGY = 0, BOMB = 30, RAD = 0, FIRE = 100, ACID = 100)
resistance_flags = INDESTRUCTIBLE | LAVA_PROOF | FIRE_PROOF | ACID_PROOF
/// Is the disk restricted to the station? If true, also respawns the disk when deleted
var/restricted_to_station = TRUE
/obj/item/disk/nuclear/unrestricted
name = "unrestricted nuclear authentication disk"
desc = "Seems to have been stripped of its safeties, you better not lose it."
restricted_to_station = FALSE
/obj/item/disk/nuclear/New()
..()
if(restricted_to_station)
START_PROCESSING(SSobj, src)
GLOB.poi_list |= src
/obj/item/disk/nuclear/process()
if(!restricted_to_station)
stack_trace("An unrestricted NAD ([src]) was processing.")
return PROCESS_KILL
if(!check_disk_loc())
var/holder = get(src, /mob)
if(holder)
to_chat(holder, "<span class='danger'>You can't help but feel that you just lost something back there...</span>")
qdel(src)
//station disk is allowed on the station level, escape shuttle/pods, CC, and syndicate shuttles/base, reset otherwise
/obj/item/disk/nuclear/proc/check_disk_loc()
if(!restricted_to_station)
return TRUE
var/turf/T = get_turf(src)
var/area/A = get_area(src)
if(is_station_level(T.z))
return TRUE
if(A.nad_allowed)
return TRUE
return FALSE
/obj/item/disk/nuclear/Destroy(force)
var/turf/diskturf = get_turf(src)
if(force)
message_admins("[src] has been !!force deleted!! in ([diskturf ? "[diskturf.x], [diskturf.y] ,[diskturf.z] - <A href='byond://?_src_=holder;adminplayerobservecoodjump=1;X=[diskturf.x];Y=[diskturf.y];Z=[diskturf.z]'>JMP</a>":"nonexistent location"]).")
log_game("[src] has been !!force deleted!! in ([diskturf ? "[diskturf.x], [diskturf.y] ,[diskturf.z]":"nonexistent location"]).")
GLOB.poi_list.Remove(src)
STOP_PROCESSING(SSobj, src)
return ..()
if(!restricted_to_station) // Non-restricted NADs should be allowed to be deleted, otherwise it becomes a restricted NAD when teleported
message_admins("[src] (unrestricted) has been deleted in ([diskturf ? "[diskturf.x], [diskturf.y] ,[diskturf.z] - <A href='byond://?_src_=holder;adminplayerobservecoodjump=1;X=[diskturf.x];Y=[diskturf.y];Z=[diskturf.z]'>JMP</a>":"nonexistent location"]). It will not respawn.")
log_game("[src] (unrestricted) has been deleted in ([diskturf ? "[diskturf.x], [diskturf.y] ,[diskturf.z]":"nonexistent location"]). It will not respawn.")
GLOB.poi_list.Remove(src)
STOP_PROCESSING(SSobj, src)
return ..()
var/turf/new_spawn = find_respawn()
if(new_spawn)
GLOB.poi_list.Remove(src)
var/obj/item/disk/nuclear/NEWDISK = new(new_spawn)
transfer_fingerprints_to(NEWDISK)
message_admins("[src] has been destroyed at ([diskturf.x], [diskturf.y], [diskturf.z] - <A href='byond://?_src_=holder;adminplayerobservecoodjump=1;X=[diskturf.x];Y=[diskturf.y];Z=[diskturf.z]'>JMP</a>). Moving it to ([NEWDISK.x], [NEWDISK.y], [NEWDISK.z] - <A href='byond://?_src_=holder;adminplayerobservecoodjump=1;X=[NEWDISK.x];Y=[NEWDISK.y];Z=[NEWDISK.z]'>JMP</a>).")
log_game("[src] has been destroyed in ([diskturf.x], [diskturf.y], [diskturf.z]). Moving it to ([NEWDISK.x], [NEWDISK.y], [NEWDISK.z]).")
..()
return QDEL_HINT_HARDDEL_NOW // We want this to be deleted ASAP, but we want refs properly cleared too
else
error("[src] was supposed to be destroyed, but we were unable to locate a nukedisc_respawn landmark or open surroundings to spawn a new one.")
return QDEL_HINT_LETMELIVE // Cancel destruction unless forced.
/obj/item/disk/nuclear/proc/find_respawn()
var/list/possible_spawns = GLOB.nukedisc_respawn
while(length(possible_spawns))
var/turf/current_spawn = pick_n_take(possible_spawns)
if(!current_spawn.density)
return current_spawn
// Someone built a wall over it, check the surroundings
var/list/open_turfs = current_spawn.AdjacentTurfs(open_only = TRUE)
if(length(open_turfs))
return pick(open_turfs)
#undef NUKE_INTACT
#undef NUKE_COVER_OFF
#undef NUKE_COVER_OPEN
#undef NUKE_SEALANT_OPEN
#undef NUKE_UNWRENCHED
#undef NUKE_MOBILE
#undef NUKE_CORE_EVERYTHING_FINE
#undef NUKE_CORE_PANEL_EXPOSED
#undef NUKE_CORE_PANEL_UNWELDED
#undef NUKE_CORE_FULLY_EXPOSED