/
singularity.dm
1813 lines (1583 loc) · 51 KB
/
singularity.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
/*
Contains:
-Singularity generator
-Singularity
-Field generator & containment field
-Emitter
-Collector array & controller
-Singularity bomb
*/
// I came here with good intentions, I swear, I didn't know what this code was like until I was already waist deep in it
#define SINGULARITY_TIME 11
// I'm sorry
//////////////////////////////////////////////////// Singularity generator /////////////////////
/obj/machinery/the_singularitygen/
name = "Gravitational Singularity Generator"
desc = "An Odd Device which produces a Black Hole when set up."
icon = 'icons/obj/singularity.dmi'
icon_state = "TheSingGen"
anchored = 0 // so it can be moved around out of crates
density = 1
mats = 250
var/bhole = 0 // it is time. we can trust people to use the singularity For Good - cirr
/* no
/obj/machinery/the_singularitygen/New()
..()
*/
/obj/machinery/the_singularitygen/process()
var/checkpointC = 0
for (var/obj/X in orange(4,src))
if (istype(X, /obj/machinery/containment_field))
checkpointC ++
if (checkpointC >= 20)
// Did you know this thing still works? And wasn't logged (Convair880)?
logTheThing("bombing", src.fingerprintslast, null, "A [src.name] was activated, spawning a singularity at [log_loc(src)]. Last touched by: [src.fingerprintslast ? "[src.fingerprintslast]" : "*null*"]")
message_admins("A [src.name] was activated, spawning a singularity at [log_loc(src)]. Last touched by: [src.fingerprintslast ? "[src.fingerprintslast]" : "*null*"]")
var/turf/T = src.loc
playsound(T, 'sound/machines/satcrash.ogg', 100, 0, 3, 0.8)
if (src.bhole)
new /obj/bhole(T, 3000)
else
new /obj/machinery/the_singularity(T, 100)
qdel(src)
/obj/machinery/the_singularitygen/attackby(obj/item/W, mob/user)
src.add_fingerprint(user)
if (iswrenchingtool(W))
if (!anchored)
anchored = 1
playsound(src.loc, "sound/items/Ratchet.ogg", 75, 1)
boutput(user, "You secure the [src.name] to the floor.")
src.anchored = 1
else if (anchored)
anchored = 0
playsound(src.loc, "sound/items/Ratchet.ogg", 75, 1)
boutput(user, "You unsecure the [src.name].")
src.anchored = 0
logTheThing("station", user, null, "[src.anchored ? "bolts" : "unbolts"] a [src.name] [src.anchored ? "to" : "from"] the floor at [log_loc(src)].") // Ditto (Convair880).
return
else
return ..()
//////////////////////////////////////////////////// Singularity /////////////////////////////
/obj/machinery/the_singularity/
name = "gravitational singularity"
desc = "A Gravitational Singularity."
icon = 'icons/effects/160x160.dmi'
icon_state = "Sing2"
anchored = 1
density = 1
event_handler_flags = IMMUNE_SINGULARITY
deconstruct_flags = DECON_WELDER | DECON_MULTITOOL
bound_width = 96
bound_height = 96
bound_x = -32
bound_y = -32
var/active = 0
var/energy = 10
var/warp = 5
var/lastT = 0
var/warp_delay = 30
var/Dtime = null
var/Wtime = 0
var/dieot = 0
var/selfmove = 1
var/grav_pull = 6
#ifdef SINGULARITY_TIME
/*
hello I've lost my remaining sanity by dredging this code from the depths of hell where it was cast eons before I arrived in this place
for some reason I brought it back and tried to clean it up a bit and I regret everything but it's too late now I can't put it back please forgive me
- haine
*/
/obj/machinery/the_singularity/New(loc, var/E = 100, var/Ti = null)
src.energy = E
pixel_x = -64
pixel_y = -64
event()
if (Ti)
src.Dtime = Ti
..()
/obj/machinery/the_singularity/process()
eat()
if (src.Dtime)//If its a temp singularity IE: an event
if (Wtime != 0)
if ((src.Wtime + src.Dtime) <= world.time)
src.Wtime = 0
qdel (src)
else
src.Wtime = world.time
if (dieot)
if (energy <= 0)//slowly dies over time
qdel (src)
else
energy -= 15
if (prob(20))//Chance for it to run a special event
event()
if (active == 1)
move()
SPAWN_DBG(1.1 SECONDS) // slowing this baby down a little -drsingh
move()
else
var/checkpointC = 0
for (var/obj/machinery/containment_field/X in orange(3,src))
checkpointC ++
if (checkpointC < 18)
src.active = 1
grav_pull = 8
/obj/machinery/the_singularity/proc/eat()
for (var/X in orange(grav_pull,get_turf(src)))
LAGCHECK(LAG_LOW)
if (!X)
continue
var/atom/A = X
if (A.event_handler_flags & IMMUNE_SINGULARITY)
continue
if (!active)
if (A.event_handler_flags & IMMUNE_SINGULARITY_INACTIVE)
continue
if (!isarea(X))
if (get_dist(src, X) <= 2) // why was this a switch before ffs
src.Bumped(A)
if (A && A.qdeled)
A = null
X = null
else if (istype(X, /atom/movable))
var/atom/movable/AM = X
if (!AM.anchored)
step_towards(AM, src)
/obj/machinery/the_singularity/proc/move()
// if we're inside something (e.g posessed mob) dont move
if (!isturf(src.loc))
return
if (selfmove)
var/dir = pick(cardinal)
var/checkloc = get_step(src,dir)
for (var/dist = 0, dist < 3, dist ++)
if (locate(/obj/machinery/containment_field) in checkloc)
return
checkloc = get_step(checkloc, dir)
step(src, dir)
/obj/machinery/the_singularity/Bumped(atom/A)
var/gain = 0
if (A.event_handler_flags & IMMUNE_SINGULARITY)
return
if (!active)
if (A.event_handler_flags & IMMUNE_SINGULARITY_INACTIVE)
return
if (isliving(A) && !isintangible(A))//if its a mob
var/mob/living/L = A
gain = 20
if (ishuman(L))
var/mob/living/carbon/human/H = A
//Special halloween-time Unkillable gibspam protection!
if (H.unkillable)
H.unkillable = 0
if (H.mind && H.mind.assigned_role)
switch (H.mind.assigned_role)
if ("Clown")
// Hilarious.
gain = 500
if ("Lawyer")
// Satan.
gain = 250
if ("Tourist", "Geneticist")
// Nerds that are oblivious to dangers
gain = 200
if ("Chief Engineer")
// Hubris
gain = 150
if ("Engineer", "Mechanic")
// More hubris
gain = 100
if ("Staff Assistant", "Captain")
// Worthless
gain = 20
else
gain = 50
L.gib()
else if (isobj(A))
//if (istype(A, /obj/item/graviton_grenade))
//src.warp = 100
if (istype(A, /obj/decal/cleanable)) //MBC : this check sucks, but its far better than cleanables doing hard-delete at the whims of the singularity. replace ASAP when i figure out cleanablessssss
pool(A)
gain = 2
else
var/obj/O = A
O.ex_act(1.0)
if (O)
qdel(O)
gain = 2
else if (isturf(A))
var/turf/T = A
if (T.turf_flags & IS_TYPE_SIMULATED)
if (istype(T, /turf/simulated/floor))
T.ReplaceWithSpace()
gain = 2
else
T.ReplaceWithFloor()
src.energy += gain
/obj/machinery/the_singularity/attackby(var/obj/item/I as obj, var/mob/user as mob)
if (istype(I, /obj/item/clothing/mask/cigarette))
var/obj/item/clothing/mask/cigarette/C = I
if (!C.on)
C.light(user, "<span class='alert'><b>[user]</b> lights [C] on [src]. Holy fucking shit!</span>")
else
return ..()
else
return ..()
// totally rewrote this proc from the ground-up because it was puke but I want to keep this comment down here vvv so we can bask in the glory of What Used To Be - haine
/* uh why was lighting a cig causing the singularity to have an extra process()?
this is dumb as hell, commenting this. the cigarette will get processed very soon. -drsingh
SPAWN_DBG(0) //start fires while it's lit
src.process()
*/
/////////////////////////////////////////////Controls which "event" is called
/obj/machinery/the_singularity/proc/event()
var/numb = rand(1,4)
switch (numb)
if (1)//EMP
Zzzzap()
return
if (2)//Eats the turfs around it
BHolerip()
return
if (3)//tox damage all carbon mobs in area
Toxmob()
return
if (4)//Stun mobs who lack optic scanners
Mezzer()
return
/obj/machinery/the_singularity/proc/Toxmob()
for (var/mob/living/carbon/M in orange(7, src))
if (ishuman(M))
var/mob/living/carbon/human/H = M
if (H.wear_suit)
return
M.take_toxin_damage(3)
M.changeStatus("radiation", 100)
M.updatehealth()
M.show_text("You feel odd.", "red")
/obj/machinery/the_singularity/proc/Mezzer()
for (var/mob/living/carbon/M in oviewers(8, get_turf(src)))
if (ishuman(M))
var/mob/living/carbon/human/H = M
if (istype(H.glasses,/obj/item/clothing/glasses/meson))
M.show_text("You look directly into [src.name], good thing you had your protective eyewear on!", "green")
return
M.changeStatus("stunned", 3 SECONDS)
M.visible_message("<span class='alert'><B>[M] stares blankly at [src]!</B></span>",\
"<B>You look directly into [src]!<br><span class='alert'>You feel weak!</span></B>")
/obj/machinery/the_singularity/proc/BHolerip()
for (var/turf/T in orange(6,get_turf(src)))
LAGCHECK(LAG_LOW)
if (prob(70))
continue
if (T && !(T.turf_flags & CAN_BE_SPACE_SAMPLE) && (get_dist(src,T) == 4 || get_dist(src,T) == 5)) // I'm very tired and this is the least dumb thing I can make of what was here for now
if (T.turf_flags & IS_TYPE_SIMULATED)
if (istype(T,/turf/simulated/floor) && !istype(T,/turf/simulated/floor/plating))
var/turf/simulated/floor/F = T
if (!F.broken)
if (prob(80))
new/obj/item/tile (F)
F.break_tile_to_plating()
else
F.break_tile()
else if (istype(T, /turf/simulated/wall))
var/turf/simulated/wall/W = T
if (istype(W, /turf/simulated/wall/r_wall) || istype(W, /turf/simulated/wall/auto/reinforced))
new /obj/structure/girder/reinforced(W)
else
new /obj/structure/girder(W)
var/obj/item/sheet/S = new /obj/item/sheet(W)
if (W.material)
S.setMaterial(W.material)
else
var/datum/material/M = getMaterial("steel")
S.setMaterial(M)
W.ReplaceWithFloor()
else
T.ReplaceWithFloor()
return
/obj/machinery/the_singularity/proc/Zzzzap()///Pulled from wizard spells might edit later
var/turf/T = get_turf(src)
var/obj/overlay/pulse = new/obj/overlay(T)
pulse.icon = 'icons/effects/effects.dmi'
pulse.icon_state = "emppulse"
pulse.name = "emp pulse"
pulse.anchored = 1
SPAWN_DBG (20)
if (pulse)
qdel(pulse)
for (var/mob/M in all_viewers(world.view-1, T))
if (!isliving(M))
continue
//if (M == usr) // what
//continue // what?????
M.emp_act()
for (var/obj/machinery/M in range(world.view-1, T))
M.emp_act()
#endif
//////////////////////////////////////// Field generator /////////////////////////////////////////
/obj/machinery/field_generator
name = "Field Generator"
desc = "Projects an energy field when active"
icon = 'icons/obj/singularity.dmi'
icon_state = "Field_Gen"
anchored = 0
density = 1
req_access = list(access_engineering_engine)
object_flags = CAN_REPROGRAM_ACCESS
var/Varedit_start = 0
var/Varpower = 0
var/active = 0
var/power = 20
var/max_power = 250
var/state = 0
var/steps = 0
var/last_check = 0
var/check_delay = 10
var/recalc = 0
var/locked = 1
//Remote control stuff
var/net_id = null
var/obj/machinery/power/data_terminal/link = null
mats = 14
proc/set_active(var/act)
if (src.active != act)
src.active = act
if (src.active)
event_handler_flags |= IMMUNE_SINGULARITY
else
event_handler_flags &= ~IMMUNE_SINGULARITY
/obj/machinery/field_generator/attack_hand(mob/user as mob)
if(state == 3)
if(!src.locked)
if(src.active >= 1)
// src.active = 0
// icon_state = "Field_Gen"
boutput(user, "You are unable to turn off the field generator, wait till it powers down.")
// src.cleanup()
else
set_active(1)
icon_state = "Field_Gen +a"
boutput(user, "You turn on the field generator.")
logTheThing("station", user, null, "activated a [src.name] at [log_loc(src)].") // Hmm (Convair880).
else
boutput(user, "The controls are locked!")
else
boutput(user, "The field generator needs to be firmly secured to the floor first.")
src.add_fingerprint(user)
/obj/machinery/field_generator/attack_ai(mob/user as mob)
if(state == 3)
if(src.active >= 1)
boutput(user, "You are unable to turn off the field generator, wait till it powers down.")
else
src.set_active(1)
icon_state = "Field_Gen +a"
boutput(user, "You turn on the field generator.")
logTheThing("station", user, null, "activated a [src.name] at [log_loc(src)].") // Hmm (Convair880).
else
boutput(user, "The field generator needs to be firmly secured to the floor first.")
src.add_fingerprint(user)
/obj/machinery/field_generator/New()
..()
SPAWN_DBG(0.6 SECONDS)
if(!src.link && (state == 3))
src.get_link()
src.net_id = format_net_id("\ref[src]")
/obj/machinery/field_generator/process()
if(src.Varedit_start == 1)
if(src.active == 0)
src.set_active(1)
src.state = 3
src.power = 250
src.anchored = 1
icon_state = "Field_Gen +a"
Varedit_start = 0
if(src.active == 1)
if(!src.state == 3)
src.set_active(0)
return
setup_field(1)
setup_field(2)
setup_field(4)
setup_field(8)
src.set_active(2)
if(src.power < 0)
src.power = 0
if(src.power > src.max_power)
src.power = src.max_power
if(src.active >= 1)
src.power -= 1
if(Varpower == 0)
if(src.power <= 0)
src.visible_message("<span class='alert'>The [src.name] shuts down due to lack of power!</span>")
icon_state = "Field_Gen"
src.set_active(0)
src.cleanup(1)
src.cleanup(2)
src.cleanup(4)
src.cleanup(8)
/obj/machinery/field_generator/proc/setup_field(var/NSEW = 0)
var/turf/T = src.loc
var/turf/T2 = src.loc
var/obj/machinery/field_generator/G
var/steps = 0
var/oNSEW = 0
if(!NSEW)//Make sure its ran right
return
if(NSEW == 1)
oNSEW = 2
else if(NSEW == 2)
oNSEW = 1
else if(NSEW == 4)
oNSEW = 8
else if(NSEW == 8)
oNSEW = 4
for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for another generator
T = get_step(T2, NSEW)
T2 = T
steps += 1
if(locate(/obj/machinery/field_generator) in T)
G = (locate(/obj/machinery/field_generator) in T)
steps -= 1
if(!G.active)
return
G.cleanup(oNSEW)
break
if(isnull(G))
return
T2 = src.loc
for(var/dist = 0, dist < steps, dist += 1) // creates each field tile
var/field_dir = get_dir(T2,get_step(T2, NSEW))
T = get_step(T2, NSEW)
T2 = T
var/obj/machinery/containment_field/CF = new/obj/machinery/containment_field/(src, G) //(ref to this gen, ref to connected gen)
CF.set_loc(T)
CF.dir = field_dir
//Create a link with a data terminal on the same tile, if possible.
/obj/machinery/field_generator/proc/get_link()
if(src.link)
src.link.master = null
src.link = null
var/turf/T = get_turf(src)
var/obj/machinery/power/data_terminal/test_link = locate() in T
if(test_link && !DATA_TERMINAL_IS_VALID_MASTER(test_link, test_link.master))
src.link = test_link
src.link.master = src
return
/obj/machinery/field_generator/bullet_act(var/obj/projectile/P)
if(!P)
return
if(!P.proj_data)
return
if(P.proj_data.damage_type == D_ENERGY)
src.power += P.power
/obj/machinery/field_generator/attackby(obj/item/W, mob/user)
if (iswrenchingtool(W))
if(active)
boutput(user, "Turn off the field generator first.")
return
else if(state == 0)
state = 1
playsound(src.loc, "sound/items/Ratchet.ogg", 75, 1)
boutput(user, "You secure the external reinforcing bolts to the floor.")
src.anchored = 1
return
else if(state == 1)
state = 0
playsound(src.loc, "sound/items/Ratchet.ogg", 75, 1)
boutput(user, "You undo the external reinforcing bolts.")
src.anchored = 0
return
if(istype(W, /obj/item/weldingtool))
var/turf/T = user.loc
if(!W:try_weld(user, 1, noisy = 2))
return
if(state == 1)
boutput(user, "You start to weld the field generator to the floor.")
sleep(2 SECONDS)
if ((user.loc == T && user.equipped() == W))
state = 3
W:eyecheck(user)
boutput(user, "You weld the field generator to the floor.")
src.get_link() //Set up a link, now that we're secure!
else if((isrobot(user) && (user.loc == T)))
state = 3
boutput(user, "You weld the field generator to the floor.")
src.get_link()
return
if(state == 3)
boutput(user, "You start to cut the field generator free from the floor.")
sleep(2 SECONDS)
if ((user.loc == T && user.equipped() == W))
state = 1
if(src.link) //Clear active link.
src.link.master = null
src.link = null
W:eyecheck(user)
boutput(user, "You cut the field generator free from the floor.")
else if((isrobot(user) && (user.loc == T)))
state = 1
if(src.link) //Clear active link.
src.link.master = null
src.link = null
boutput(user, "You cut the field generator free from the floor.")
return
if (istype(W, /obj/item/device/pda2) && W:ID_card)
W = W:ID_card
if (istype(W, /obj/item/card/id))
if (src.allowed(user))
src.locked = !src.locked
boutput(user, "Controls are now [src.locked ? "locked." : "unlocked."]")
else
boutput(user, "<span class='alert'>Access denied.</span>")
else
src.add_fingerprint(user)
boutput(user, "<span class='alert'>You hit the [src.name] with your [W.name]!</span>")
for(var/mob/M in AIviewers(src))
if(M == user) continue
M.show_message("<span class='alert'>The [src.name] has been hit with the [W.name] by [user.name]!</span>")
/obj/machinery/field_generator/proc/cleanup(var/NSEW)
var/obj/machinery/containment_field/F
var/obj/machinery/field_generator/G
var/turf/T = src.loc
var/turf/T2 = src.loc
for(var/dist = 0, dist <= 9, dist += 1) // checks out to 8 tiles away for fields
T = get_step(T2, NSEW)
T2 = T
if(locate(/obj/machinery/containment_field) in T)
F = (locate(/obj/machinery/containment_field) in T)
qdel(F)
if(locate(/obj/machinery/field_generator) in T)
G = (locate(/obj/machinery/field_generator) in T)
if(!G.active)
break
//Send a signal over our link, if possible.
/obj/machinery/field_generator/proc/post_status(var/target_id, var/key, var/value, var/key2, var/value2, var/key3, var/value3)
if(!src.link || !target_id)
return
var/datum/signal/signal = get_free_signal()
signal.source = src
signal.transmission_method = TRANSMISSION_WIRE
signal.data[key] = value
if(key2)
signal.data[key2] = value2
if(key3)
signal.data[key3] = value3
signal.data["address_1"] = target_id
signal.data["sender"] = src.net_id
src.link.post_signal(src, signal)
//What do we do with an incoming command?
/obj/machinery/field_generator/receive_signal(datum/signal/signal)
if(!src.link)
return
if(!signal || !src.net_id || signal.encryption)
return
/* People might abuse this but I find it funny
if(signal.transmission_method != TRANSMISSION_WIRE) //No radio for us thanks
return
*/
var/target = signal.data["sender"]
//They don't need to target us specifically to ping us.
//Otherwise, ff they aren't addressing us, ignore them
if(signal.data["address_1"] != src.net_id)
if((signal.data["address_1"] == "ping") && signal.data["sender"])
SPAWN_DBG(0.5 SECONDS) //Send a reply for those curious jerks
src.post_status(target, "command", "ping_reply", "device", "PNET_ENG_FIELD", "netid", src.net_id)
return
var/sigcommand = lowertext(signal.data["command"])
if(!sigcommand || !signal.data["sender"])
return
//Oh okay, time to start up.
if(sigcommand == "activate" && !src.active)
src.set_active(1)
icon_state = "Field_Gen +a"
if(sigcommand == "deactivate" && src.active)
src.set_active(0)
icon_state = "Field_Gen"
return
/obj/machinery/field_generator/disposing()
src.cleanup(1)
src.cleanup(2)
src.cleanup(4)
src.cleanup(8)
if (link)
link.master = null
link = null
..()
/////////////////////////////////////////////// Containment field //////////////////////////////////
/obj/machinery/containment_field
name = "Containment Field"
desc = "An energy field."
icon = 'icons/obj/singularity.dmi'
icon_state = "Contain_F"
anchored = 1
density = 0
event_handler_flags = USE_FLUID_ENTER | IMMUNE_SINGULARITY | USE_CANPASS
var/active = 1
var/power = 10
var/delay = 5
var/last_active
var/mob/U
var/obj/machinery/field_generator/gen_primary
var/obj/machinery/field_generator/gen_secondary
var/datum/light/light
/obj/machinery/containment_field/New(var/obj/machinery/field_generator/A, var/obj/machinery/field_generator/B)
src.gen_primary = A
src.gen_secondary = B
light = new /datum/light/point
light.set_brightness(0.7)
light.set_color(0, 0.1, 0.8)
light.attach(src)
light.enable()
..()
/obj/machinery/containment_field/attack_hand(mob/user as mob)
return
/obj/machinery/containment_field/process()
if(isnull(gen_primary)||isnull(gen_secondary))
qdel(src)
return
if(!(gen_primary.active)||!(gen_secondary.active))
qdel(src)
return
/obj/machinery/containment_field/proc/shock(mob/user as mob)
if(isnull(gen_primary))
qdel(src)
return
if(isnull(gen_secondary))
qdel(src)
return
var/datum/effects/system/spark_spread/s = unpool(/datum/effects/system/spark_spread)
s.set_up(5, 1, user.loc)
s.start()
src.power = max(gen_primary.power,gen_secondary.power)
var/prot = 1
var/shock_damage = 0
if(src.power > 200)
shock_damage = min(rand(40,80),rand(40,100))*prot
else if(src.power > 120)
shock_damage = min(rand(30,60),rand(30,90))*prot
else if(src.power > 80)
shock_damage = min(rand(20,40),rand(20,40))*prot
else if(src.power > 60)
shock_damage = min(rand(20,30),rand(20,30))*prot
else
shock_damage = min(rand(10,20),rand(10,20))*prot
// Added (Convair880).
logTheThing("combat", user, null, "was shocked by a containment field at [log_loc(src)].")
if (user && user.bioHolder)
if (user.bioHolder.HasEffect("resist_electric") == 2)
var/healing = 0
if (shock_damage)
healing = shock_damage / 3
user.HealDamage("All", shock_damage, shock_damage)
user.take_toxin_damage(0 - healing)
boutput(user, "<span class='notice'>You absorb the electrical shock, healing your body!</span>")
return
else if (user.bioHolder.HasEffect("resist_electric") == 1)
boutput(user, "<span class='notice'>You feel electricity course through you harmlessly!</span>")
return
user.TakeDamage(user.hand == 1 ? "l_arm" : "r_arm", 0, shock_damage)
user.updatehealth()
boutput(user, "<span class='alert'><B>You feel a powerful shock course through your body sending you flying!</B></span>")
user.unlock_medal("HIGH VOLTAGE", 1)
if (isliving(user))
var/mob/living/L = user
L.Virus_ShockCure(100)
L.shock_cyberheart(100)
if(user.getStatusDuration("stunned") < shock_damage * 10) user.changeStatus("stunned", shock_damage * 10)
if(user.getStatusDuration("weakened") < shock_damage * 10) user.changeStatus("weakened", shock_damage * 10)
if(user.get_burn_damage() >= 500) //This person has way too much BURN, they've probably been shocked a lot! Let's destroy them!
user.visible_message("<span style=\"color:red;font-weight:bold;\">[user.name] was disintegrated by the [src.name]!</span>")
user.elecgib()
return
else
var/throwdir = get_dir(src, get_step_away(user, src))
if (prob(20))
user.set_loc(get_turf(src))
if (prob(50))
throwdir = turn(throwdir,90)
else
throwdir = turn(throwdir,-90)
var/atom/target = get_edge_target_turf(user, throwdir)
user.throw_at(target, 200, 4)
for(var/mob/M in AIviewers(src))
if(M == user) continue
M.show_message("<span class='alert'>[user.name] was shocked by the [src.name]!</span>", 3, "<span class='alert'>You hear a heavy electrical crack</span>", 2)
src.gen_primary.power -= 3
src.gen_secondary.power -= 3
return
/obj/machinery/containment_field/CanPass(atom/movable/O as mob|obj, target as turf, height=0, air_group=0)
if(iscarbon(O) && prob(80))
shock(O)
..()
/////////////////////////////////////////// Emitter ///////////////////////////////
/obj/machinery/emitter
name = "Emitter"
desc = "Shoots a high power laser when active"
icon = 'icons/obj/singularity.dmi'
icon_state = "Emitter"
anchored = 0
density = 1
req_access = list(access_engineering_engine)
object_flags = CAN_REPROGRAM_ACCESS
var/active = 0
var/power = 20
var/fire_delay = 100
var/HP = 20
var/last_shot = 0
var/shot_number = 0
var/state = 0
var/locked = 1
//Remote control stuff
var/net_id = null
var/obj/machinery/power/data_terminal/link = null
var/datum/projectile/current_projectile = new/datum/projectile/laser/heavy
mats = 10
/obj/machinery/emitter/New()
..()
SPAWN_DBG(0.6 SECONDS)
if(!src.link && (state == 3))
src.get_link()
src.net_id = format_net_id("\ref[src]")
//Create a link with a data terminal on the same tile, if possible.
/obj/machinery/emitter/proc/get_link()
if(src.link)
src.link.master = null
src.link = null
var/turf/T = get_turf(src)
var/obj/machinery/power/data_terminal/test_link = locate() in T
if(test_link && !DATA_TERMINAL_IS_VALID_MASTER(test_link, test_link.master))
src.link = test_link
src.link.master = src
return
/obj/machinery/emitter/attack_hand(mob/user as mob)
if(state == 3)
if(!src.locked)
if(src.active==1)
if(alert("Turn off the emitter?",,"Yes","No") == "Yes")
src.active = 0
icon_state = "Emitter"
boutput(user, "You turn off the emitter.")
logTheThing("station", user, null, "deactivated active emitter at [log_loc(src)].")
message_admins("[key_name(user)] deactivated active emitter at [log_loc(src)].")
else
if(alert("Turn on the emitter?",,"Yes","No") == "Yes")
src.active = 1
icon_state = "Emitter +a"
boutput(user, "You turn on the emitter.")
logTheThing("station", user, null, "activated emitter at [log_loc(src)].")
src.shot_number = 0
src.fire_delay = 100
message_admins("[key_name(user)] activated emitter at [log_loc(src)].")
else
boutput(user, "The controls are locked!")
else
boutput(user, "The emitter needs to be firmly secured to the floor first.")
src.add_fingerprint(user)
..()
/obj/machinery/emitter/attack_ai(mob/user as mob)
if(state == 3)
if(src.active==1)
if(alert("Turn off the emitter?",,"Yes","No") == "Yes")
src.active = 0
icon_state = "Emitter"
boutput(user, "You turn off the emitter.")
logTheThing("station", user, null, "deactivated active emitter at [log_loc(src)].")
message_admins("[key_name(user)] deactivated active emitter at [log_loc(src)].")
else
if(alert("Turn on the emitter?",,"Yes","No") == "Yes")
src.active = 1
icon_state = "Emitter +a"
boutput(user, "You turn on the emitter.")
logTheThing("station", user, null, "activated emitter at [log_loc(src)].")
src.shot_number = 0
src.fire_delay = 100
message_admins("[key_name(user)] activated emitter at [log_loc(src)].")
else
boutput(user, "The emitter needs to be firmly secured to the floor first.")
src.add_fingerprint(user)
return
/obj/machinery/emitter/process()
if(status & (NOPOWER|BROKEN))
return
if(!src.state == 3)
src.active = 0
return
if(((src.last_shot + src.fire_delay) <= world.time) && (src.active == 1))
src.last_shot = world.time
if(src.shot_number < 3)
src.fire_delay = 2
src.shot_number ++
else
src.fire_delay = rand(20,100)
src.shot_number = 0
if ((src.dir - 1) & src.dir) // Not cardinal (not power of 2)
src.dir &= 12 // Cardinalize
src.visible_message("<span class='alert'><b>[src]</b> fires a bolt of energy!</span>")
shoot_projectile_DIR(src, current_projectile, dir)
if(prob(35))
var/datum/effects/system/spark_spread/s = unpool(/datum/effects/system/spark_spread)
s.set_up(5, 1, src)
s.start()
..()
/obj/machinery/emitter/attackby(obj/item/W, mob/user)
if (ispryingtool(W))
if(!anchored)
src.dir = turn(src.dir, -90)
return
else
boutput(user, "The emitter is too firmly secured to be rotated!")
return
else if (iswrenchingtool(W))
if(active)
boutput(user, "Turn off the emitter first.")
return
else if(state == 0)
state = 1
playsound(src.loc, "sound/items/Ratchet.ogg", 75, 1)
boutput(user, "You secure the external reinforcing bolts to the floor.")
src.anchored = 1
desc = "Shoots a high power laser when active, it has been bolted to the floor."
return
else if(state == 1)
state = 0
playsound(src.loc, "sound/items/Ratchet.ogg", 75, 1)
boutput(user, "You undo the external reinforcing bolts.")
src.anchored = 0
desc = "Shoots a high power laser when active."
return
if(istype(W, /obj/item/weldingtool) && W:welding)
var/turf/T = user.loc
if(!W:try_weld(user, 1, noisy = 2))
return
if(state == 1)
W:eyecheck(user)
boutput(user, "You start to weld the emitter to the floor.")
sleep(2 SECONDS)
if ((user.loc == T && user.equipped() == W))
state = 3
src.get_link()
boutput(user, "You weld the emitter to the floor.")
else if((isrobot(user) && (user.loc == T)))
state = 3
src.get_link()
desc = "Shoots a high power laser when active, it has been bolted and welded to the floor."