/
robot_mob.dm
1726 lines (1503 loc) · 56.4 KB
/
robot_mob.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
GLOBAL_LIST_INIT(robot_verbs_default, list(
/mob/living/silicon/robot/proc/sensor_mode,
))
/mob/living/silicon/robot
name = "Cyborg"
real_name = "Cyborg"
icon = 'icons/mob/robots.dmi'
icon_state = "robot"
maxHealth = 100
health = 100
bubble_icon = "robot"
universal_understand = TRUE
deathgasp_on_death = TRUE
blocks_emissive = EMISSIVE_BLOCK_UNIQUE
hud_type = /datum/hud/robot
var/sight_mode = 0
var/custom_name = ""
var/custom_sprite = FALSE //Due to all the sprites involved, a var for our custom borgs may be best
//Hud stuff
var/atom/movable/screen/hands = null
var/atom/movable/screen/inv1 = null
var/atom/movable/screen/inv2 = null
var/atom/movable/screen/inv3 = null
var/atom/movable/screen/lamp_button = null
var/atom/movable/screen/thruster_button = null
var/shown_robot_modules = FALSE //Used to determine whether they have the module menu shown or not
var/atom/movable/screen/robot_modules_background
//3 Modules can be activated at any one time.
var/obj/item/robot_module/module = null
var/module_active = null
var/module_state_1 = null
var/module_state_2 = null
var/module_state_3 = null
var/obj/item/radio/borg/radio = null
var/mob/living/silicon/ai/connected_ai = null
var/obj/item/stock_parts/cell/cell = null
var/obj/machinery/camera/camera = null
// Components are basically robot organs.
var/list/components = list()
var/obj/item/robot_parts/robot_suit/robot_suit = null //Used for deconstruction to remember what the borg was constructed out of..
var/obj/item/mmi/mmi = null
var/obj/item/pda/silicon/robot/rbPDA = null
var/datum/wires/robot/wires = null
var/opened = FALSE
var/custom_panel = null
var/list/custom_panel_names = list("Cricket")
var/list/custom_eye_names = list("Cricket", "Standard")
var/emagged = 0
var/is_emaggable = TRUE
var/eye_protection = 0
var/ear_protection = FALSE
var/damage_protection = 0
var/emp_protection = FALSE
/// Value incoming brute damage to borgs is mutiplied by.
var/brute_mod = 1
/// Value incoming burn damage to borgs is multiplied by.
var/burn_mod = 1
var/list/force_modules
var/allow_rename = TRUE
var/weapons_unlock = FALSE
var/static_radio_channels = FALSE
var/wiresexposed = FALSE
var/locked = TRUE
var/list/req_one_access = list(ACCESS_ROBOTICS)
var/list/req_access
var/ident = 0
//var/list/laws = list()
var/viewalerts = FALSE
var/modtype = "Default"
var/datum/effect_system/spark_spread/spark_system //So they can initialize sparks whenever/N
var/low_power_mode = FALSE //whether the robot has no charge left.
var/weapon_lock = FALSE
var/weaponlock_time = 120
var/lawupdate = TRUE //Cyborgs will sync their laws with their AI by default
var/lockcharge //Used when locking down a borg to preserve cell charge
var/speed = 0 //Cause sec borgs gotta go fast //No they dont!
var/scrambledcodes = FALSE // Used to determine if a borg shows up on the robotics console. Setting to TRUE hides them.
var/can_lock_cover = FALSE //Used to set if a borg can re-lock its cover.
var/has_camera = TRUE
var/pdahide = FALSE //Used to hide the borg from the messenger list
var/tracking_entities = 0 //The number of known entities currently accessing the internal camera
var/braintype = "Cyborg"
var/base_icon = ""
var/modules_break = TRUE
var/lamp_max = 10 //Maximum brightness of a borg lamp. Set as a var for easy adjusting.
var/lamp_intensity = 0 //Luminosity of the headlamp. 0 is off. Higher settings than the minimum require power.
var/lamp_recharging = FALSE //Flag for if the lamp is on cooldown after being forcibly disabled.
/// When the camera moved signal was send last. Avoid overdoing it
var/last_camera_update
hud_possible = list(SPECIALROLE_HUD, DIAG_STAT_HUD, DIAG_HUD, DIAG_BATT_HUD)
var/default_cell_type = /obj/item/stock_parts/cell/high
var/ionpulse = FALSE // Jetpack-like effect.
var/ionpulse_on = FALSE // Jetpack-like effect.
/// Does it clean the tile under it?
var/floorbuffer = FALSE
var/datum/action/item_action/toggle_research_scanner/scanner = null
var/list/module_actions = list()
var/see_reagents = FALSE // Determines if the cyborg can see reagents
/// Integer used to determine self-mailing location, used only by drones and saboteur borgs
var/mail_destination = 1
var/datum/ui_module/robot_self_diagnosis/self_diagnosis
var/datum/ui_module/destination_tagger/mail_setter
silicon_subsystems = list(
/mob/living/silicon/robot/proc/self_diagnosis,
/mob/living/silicon/proc/subsystem_law_manager)
/mob/living/silicon/robot/get_cell()
return cell
/mob/living/silicon/robot/New(loc, syndie = FALSE, unfinished = FALSE, alien = FALSE, connect_to_AI = TRUE, mob/living/silicon/ai/ai_to_sync_to = null)
spark_system = new /datum/effect_system/spark_spread()
spark_system.set_up(5, 0, src)
spark_system.attach(src)
add_language("Robot Talk", 1)
wires = new(src)
robot_modules_background = new()
robot_modules_background.icon_state = "block"
robot_modules_background.layer = HUD_LAYER //Objects that appear on screen are on layer 20, UI should be just below it.
robot_modules_background.plane = HUD_PLANE
ident = rand(1, 999)
rename_character(null, get_default_name())
update_icons()
update_headlamp()
radio = new /obj/item/radio/borg(src)
if(has_camera && !camera)
camera = new /obj/machinery/camera(src)
camera.c_tag = real_name
camera.network = list("SS13","Robots")
if(wires.is_cut(WIRE_BORG_CAMERA)) // 5 = BORG CAMERA
camera.status = FALSE
if(mmi == null)
mmi = new /obj/item/mmi/robotic_brain(src) //Give the borg an MMI if he spawns without for some reason. (probably not the correct way to spawn a robotic brain, but it works)
mmi.icon_state = "boris"
initialize_components()
//if(!unfinished)
// Create all the robot parts.
for(var/V in components) if(V != "power cell")
var/datum/robot_component/C = components[V]
C.install(new C.external_type, FALSE)
..()
add_robot_verbs()
// Remove inherited verbs that effectively do nothing for cyborgs, or lead to unintended behaviour.
remove_verb(src, /mob/living/verb/rest)
remove_verb(src, /mob/living/verb/mob_sleep)
// Install a default cell into the borg if none is there yet
var/datum/robot_component/cell_component = components["power cell"]
var/obj/item/stock_parts/cell/C = cell || new default_cell_type(src)
cell_component.install(C)
init(alien, connect_to_AI, ai_to_sync_to)
diag_hud_set_borgcell()
scanner = new(src)
scanner.Grant(src)
RegisterSignal(src, COMSIG_MOVABLE_MOVED, PROC_REF(create_trail))
robot_module_hat_offset(icon_state)
/mob/living/silicon/robot/get_radio()
return radio
/mob/living/silicon/robot/proc/create_trail(datum/source, atom/oldloc, _dir, forced)
if(ionpulse_on)
var/turf/T = get_turf(oldloc)
if(!has_gravity(T))
new /obj/effect/particle_effect/ion_trails(T, _dir)
/mob/living/silicon/robot/proc/init(alien, connect_to_AI = TRUE, mob/living/silicon/ai/ai_to_sync_to = null)
aiCamera = new/obj/item/camera/siliconcam/robot_camera(src)
make_laws()
additional_law_channels["Binary"] = ":b "
if(!connect_to_AI)
return
var/found_ai = ai_to_sync_to
if(!found_ai)
found_ai = select_active_ai_with_fewest_borgs()
if(found_ai)
lawupdate = TRUE
connect_to_ai(found_ai)
else
lawupdate = FALSE
playsound(loc, 'sound/voice/liveagain.ogg', 75, 1)
/mob/living/silicon/robot/rename_character(oldname, newname)
if(!..(oldname, newname))
return FALSE
if(oldname != real_name)
notify_ai(3, oldname, newname)
custom_name = (newname != get_default_name()) ? newname : null
setup_PDA()
//We also need to update name of internal camera.
if(camera)
camera.c_tag = newname
//Check for custom sprite
check_custom_sprite()
if(mmi && mmi.brainmob)
mmi.brainmob.name = newname
return TRUE
/mob/living/silicon/robot/proc/check_custom_sprite()
if(!custom_sprite && (ckey in GLOB.configuration.custom_sprites.cyborg_ckeys))
custom_sprite = TRUE
/mob/living/silicon/robot/proc/get_default_name(prefix as text)
if(prefix)
modtype = prefix
if(mmi)
if(istype(mmi, /obj/item/mmi/robotic_brain))
braintype = "Android"
else
braintype = "Cyborg"
else
braintype = "Robot"
if(custom_name)
return custom_name
else
return "[modtype] [braintype]-[num2text(ident)]"
/mob/living/silicon/robot/verb/Namepick()
set category = "Robot Commands"
if(custom_name)
return 0
if(!allow_rename)
to_chat(src, "<span class='warning'>Rename functionality is not enabled on this unit.</span>")
return 0
rename_self(braintype, 1)
/mob/living/silicon/robot/proc/sync()
if(lawupdate && connected_ai)
lawsync()
photosync()
// setup the PDA and its name
/mob/living/silicon/robot/proc/setup_PDA()
if(!rbPDA)
rbPDA = new(src)
rbPDA.set_name_and_job(real_name, braintype)
var/datum/data/pda/app/messenger/M = rbPDA.find_program(/datum/data/pda/app/messenger)
if(M)
if(scrambledcodes)
M.hidden = 1
if(pdahide)
M.toff = 1
/mob/living/silicon/robot/binarycheck()
if(is_component_functioning("comms"))
return 1
return 0
//If there's an MMI in the robot, have it ejected when the mob goes away. --NEO
//Improved /N
/mob/living/silicon/robot/Destroy()
SStgui.close_uis(wires)
if(mmi && mind)//Safety for when a cyborg gets dust()ed. Or there is no MMI inside.
var/turf/T = get_turf(loc)//To hopefully prevent run time errors.
if(T)
mmi.forceMove(T)
if(mmi.brainmob)
mind.transfer_to(mmi.brainmob)
mmi.update_icon()
else
to_chat(src, "<span class='boldannounceooc'>Oops! Something went very wrong, your MMI was unable to receive your mind. You have been ghosted. Please make a bug report so we can fix this bug.</span>")
ghostize()
stack_trace("A borg has been destroyed, but its MMI lacked a brainmob, so the mind could not be transferred. Player: [ckey].")
mmi = null
if(connected_ai)
connected_ai.connected_robots -= src
QDEL_NULL(wires)
QDEL_NULL(module)
QDEL_NULL(camera)
QDEL_NULL(robot_suit)
QDEL_NULL(spark_system)
QDEL_NULL(self_diagnosis)
QDEL_NULL(mail_setter)
QDEL_LIST_ASSOC_VAL(components)
QDEL_NULL(rbPDA)
QDEL_NULL(radio)
scanner = null
module_actions.Cut()
return ..()
/mob/living/silicon/robot/proc/pick_module()
if(module)
return
// Pick a module type
var/selected_module = show_radial_menu(src, src, get_module_types(), radius = 42)
if(!selected_module || module)
return
// Pick a sprite
var/module_sprites = get_module_sprites(selected_module)
var/selected_sprite = show_radial_menu(src, src, module_sprites, radius = 42)
if(!selected_sprite)
return
// Now actually set the module and sprites
initialize_module(selected_module, selected_sprite, module_sprites)
/**
* Returns a list of choosable module types, associated with the module icon for the radial menu.
*
* Key: Module name | Value: Module 'icon'
*
* By default this returns the Engineering, Janitor, Medical, Mining, and Service modules.
* If there are any [/mob/living/silicon/robot/var/force_modules] set, then they are returned instead.
* If the MMI has a xenomorph brain in it ([/obj/item/mmi/var/alien]), then only the "Hunter" and standard modules is returned.
*/
/mob/living/silicon/robot/proc/get_module_types()
var/static/list/standard_modules = list(
"Engineering" = image('icons/mob/robots.dmi', "engi-radial"),
"Janitor" = image('icons/mob/robots.dmi', "jan-radial"),
"Medical" = image('icons/mob/robots.dmi', "med-radial"),
"Mining" = image('icons/mob/robots.dmi', "mining-radial"),
"Service" = image('icons/mob/robots.dmi', "serv-radial"))
var/static/list/special_modules = list(
"Combat" = image('icons/mob/robots.dmi', "security-radial"),
"Security" = image('icons/mob/robots.dmi', "security-radial"),
"Destroyer" = image('icons/mob/robots.dmi', "droidcombat"),
"Hunter" = image('icons/mob/robots.dmi', "xeno-radial"))
if(mmi?.alien)
if(!length(force_modules))
force_modules = list("Hunter") + standard_modules.Copy() // standard PLUS hunter
// Return a list of `force_modules`, with the associated images from the other lists.
if(length(force_modules))
return (standard_modules + special_modules) & force_modules
return standard_modules
/**
* Returns an associative list of possible borg sprites based on the `selected_module`.
*
* Key: Sprite name | Value: Sprite icon
*
* Arguments:
* * selected_module - The chosen cyborg module to get the sprites for.
*/
/mob/living/silicon/robot/proc/get_module_sprites(selected_module)
var/list/module_sprites
switch(selected_module)
if("Engineering")
module_sprites = list(
"Basic" = image('icons/mob/robots.dmi', "Engineering"),
"Antique" = image('icons/mob/robots.dmi', "engineerrobot"),
"Landmate" = image('icons/mob/robots.dmi', "landmate"),
"Standard" = image('icons/mob/robots.dmi', "Standard-Engi"),
"Noble-ENG" = image('icons/mob/robots.dmi', "Noble-ENG"),
"Cricket" = image('icons/mob/robots.dmi', "Cricket-ENGI")
)
if("Janitor")
module_sprites = list(
"Basic" = image('icons/mob/robots.dmi', "JanBot2"),
"Mopbot" = image('icons/mob/robots.dmi', "janitorrobot"),
"Mop Gear Rex" = image('icons/mob/robots.dmi', "mopgearrex"),
"Standard" = image('icons/mob/robots.dmi', "Standard-Jani"),
"Noble-CLN" = image('icons/mob/robots.dmi', "Noble-CLN"),
"Cricket" = image('icons/mob/robots.dmi', "Cricket-JANI"),
"Custodiborg" = image('icons/mob/robots.dmi', "custodiborg")
)
if("Medical")
module_sprites = list(
"Basic" = image('icons/mob/robots.dmi', "Medbot"),
"Surgeon" = image('icons/mob/robots.dmi', "surgeon"),
"Advanced Droid" = image('icons/mob/robots.dmi', "droid-medical"),
"Needles" = image('icons/mob/robots.dmi', "medicalrobot"),
"Standard" = image('icons/mob/robots.dmi', "Standard-Medi"),
"Noble-MED" = image('icons/mob/robots.dmi', "Noble-MED"),
"Cricket" = image('icons/mob/robots.dmi', "Cricket-MEDI"),
"Qualified Doctor" = image('icons/mob/robots.dmi', "qualified_doctor")
)
if("Mining")
module_sprites = list(
"Basic" = image('icons/mob/robots.dmi', "Miner_old"),
"Advanced Droid" = image('icons/mob/robots.dmi', "droid-miner"),
"Treadhead" = image('icons/mob/robots.dmi', "Miner"),
"Standard" = image('icons/mob/robots.dmi', "Standard-Mine"),
"Noble-DIG" = image('icons/mob/robots.dmi', "Noble-DIG"),
"Cricket" = image('icons/mob/robots.dmi', "Cricket-MINE"),
"Lavaland" = image('icons/mob/robots.dmi', "lavaland"),
"Squat" = image('icons/mob/robots.dmi', "squatminer"),
"Coffin Drill" = image('icons/mob/robots.dmi', "coffinMiner")
)
if("Service")
module_sprites = list(
"Waitress" = image('icons/mob/robots.dmi', "Service"),
"Kent" = image('icons/mob/robots.dmi', "toiletbot"),
"Bro" = image('icons/mob/robots.dmi', "Brobot"),
"Rich" = image('icons/mob/robots.dmi', "maximillion"),
"Default" = image('icons/mob/robots.dmi', "Service2"),
"Standard" = image('icons/mob/robots.dmi', "Standard-Serv"),
"Noble-SRV" = image('icons/mob/robots.dmi', "Noble-SRV"),
"Cricket" = image('icons/mob/robots.dmi', "Cricket-SERV")
)
if("Combat")
module_sprites = list(
"Combat" = image('icons/mob/robots.dmi', "ertgamma")
)
if("Security")
module_sprites = list(
"Basic" = image('icons/mob/robots.dmi', "secborg"),
"Red Knight" = image('icons/mob/robots.dmi', "Security"),
"Black Knight" = image('icons/mob/robots.dmi', "securityrobot"),
"Bloodhound" = image('icons/mob/robots.dmi', "bloodhound"),
"Standard" = image('icons/mob/robots.dmi', "Standard-Secy"),
"Noble-SEC" = image('icons/mob/robots.dmi', "Noble-SEC"),
"Cricket" = image('icons/mob/robots.dmi', "Cricket-SEC"),
"Heavy" = image('icons/mob/robots.dmi', "heavySec")
)
if("Destroyer") //for Adminbus presumably
module_sprites = list(
"Destroyer" = image('icons/mob/robots.dmi', "droidcombat")
)
if("Hunter")
module_sprites = list(
"Xeno-Hu" = image('icons/mob/robots.dmi', "xenoborg-state-a")
)
if(custom_sprite && check_sprite("[ckey]-[selected_module]"))
module_sprites["Custom"] = image('icons/mob/custom_synthetic/custom-synthetic.dmi', "[ckey]-[selected_module]")
return module_sprites
/**
* Sets the offset for a cyborg's hats based on their module icon.
* Borgs are grouped by similar sprites (Eg. all the Noble borgs are all the same sprite but recoloured.)
*
* Arguments:
* * module - An `icon_state` for which the offset needs to be calculated.
*/
/mob/living/silicon/robot/proc/robot_module_hat_offset(module)
switch(module)
if("Engineering", "Miner_old", "JanBot2", "Medbot", "engineerrobot", "maximillion", "secborg", "Hydrobot")
can_be_hatted = FALSE // Their base sprite already comes with a hat
hat_offset_y = -1
if("Noble-CLN", "Noble-SRV", "Noble-DIG", "Noble-MED", "Noble-SEC", "Noble-ENG", "Noble-STD")
can_be_hatted = TRUE
can_wear_restricted_hats = TRUE
hat_offset_y = 4
if("droid-medical")
can_be_hatted = TRUE
can_wear_restricted_hats = TRUE
hat_offset_y = 4
if("droid-miner", "mk2", "mk3")
can_be_hatted = TRUE
is_centered = TRUE
hat_offset_y = 3
if("bloodhound", "nano_bloodhound", "syndie_bloodhound", "ertgamma")
can_be_hatted = TRUE
hat_offset_y = 1
if("Cricket-SEC", "Cricket-MEDI", "Cricket-JANI", "Cricket-ENGI", "Cricket-MINE", "Cricket-SERV")
can_be_hatted = TRUE
hat_offset_y = 2
if("droidcombat-shield", "droidcombat")
can_be_hatted = TRUE
hat_alpha = 255
hat_offset_y = 2
if("droidcombat-roll")
can_be_hatted = TRUE
hat_alpha = 0
hat_offset_y = 2
if("syndi-medi", "surgeon", "toiletbot", "custodiborg")
can_be_hatted = TRUE
is_centered = TRUE
hat_offset_y = 1
if("Security", "janitorrobot", "medicalrobot")
can_be_hatted = TRUE
is_centered = TRUE
can_wear_restricted_hats = TRUE
hat_offset_y = -1
if("Brobot", "Service", "Service2", "robot_old", "securityrobot")
can_be_hatted = TRUE
is_centered = TRUE
can_wear_restricted_hats = TRUE
hat_offset_y = -1
if("Miner", "lavaland")
can_be_hatted = TRUE
hat_offset_y = -1
if("robot", "Standard", "Standard-Secy", "Standard-Medi", "Standard-Engi",
"Standard-Jani", "Standard-Serv", "Standard-Mine", "xenoborg-state-a")
can_be_hatted = TRUE
hat_offset_y = -3
if("droid")
can_be_hatted = TRUE
is_centered = TRUE
can_wear_restricted_hats = TRUE
hat_offset_y = -4
if("landmate", "syndi-engi")
can_be_hatted = TRUE
hat_offset_y = -7
if("mopgearrex")
can_be_hatted = TRUE
hat_offset_y = -6
if("qualified_doctor")
can_be_hatted = TRUE
hat_offset_y = 3
if("squatminer")
can_be_hatted = TRUE
if("coffinMiner")
can_be_hatted = TRUE
hat_offset_y = 3
if("heavySec")
can_be_hatted = TRUE
can_wear_restricted_hats = TRUE
if(silicon_hat)
if(!can_be_hatted)
remove_from_head(usr)
return
if(!can_wear_restricted_hats && is_type_in_list(silicon_hat, restricted_hats))
remove_from_head(usr)
return
/**
* Sets up the module items and sprites for the cyborg module chosen in `pick_module()`.
*
* Arguments:
* * selected_module - The name of the module chosen by the player in the previous procs.
* * selected_sprite - The name of the sprite chosen by the player in the previous procs.
* * module_sprites - The list of sprites possible for the given module. Used to transfer the `icon` and `icon_state` variables to the player.
*/
/mob/living/silicon/robot/proc/initialize_module(selected_module, selected_sprite, list/module_sprites)
switch(selected_module)
if("Engineering")
module = new /obj/item/robot_module/engineering(src)
module.channels = list("Engineering" = 1)
if(camera && ("Robots" in camera.network))
camera.network += "Engineering"
if("Janitor")
module = new /obj/item/robot_module/janitor(src)
module.channels = list("Service" = 1)
if("Medical")
module = new /obj/item/robot_module/medical(src)
module.channels = list("Medical" = 1)
if(camera && ("Robots" in camera.network))
camera.network += "Medical"
status_flags &= ~CANPUSH
see_reagents = TRUE
if("Mining")
module = new /obj/item/robot_module/miner(src)
module.channels = list("Supply" = 1)
if(camera && ("Robots" in camera.network))
camera.network += "Mining Outpost"
if("Service")
module = new /obj/item/robot_module/butler(src)
module.channels = list("Service" = 1)
see_reagents = TRUE
if(selected_sprite == "Bro")
module.module_type = "Brobot"
if("Combat")
module = new /obj/item/robot_module/combat(src)
status_flags &= ~CANPUSH
if("Security")
module = new /obj/item/robot_module/security(src)
status_flags &= ~CANPUSH
if("Hunter")
module = new /obj/item/robot_module/alien/hunter(src)
if(!module)
return FALSE
modtype = selected_module
designation = selected_module
module.add_languages(src)
module.add_armor(src)
module.add_subsystems_and_actions(src)
if(!static_radio_channels)
radio.config(module.channels)
rename_character(real_name, get_default_name())
var/image/sprite_image = module_sprites[selected_sprite]
var/list/names = splittext(selected_sprite, "-")
icon = sprite_image.icon
icon_state = sprite_image.icon_state
custom_panel = trim(names[1])
update_module_icon()
robot_module_hat_offset(icon_state)
update_icons()
if(client.stat_tab == "Status")
SSstatpanels.set_status_tab(client)
SSblackbox.record_feedback("tally", "cyborg_modtype", 1, "[lowertext(selected_module)]")
notify_ai(2)
/// Take the borg's upgrades and spill them on the floor
/mob/living/silicon/robot/proc/spill_upgrades()
for(var/obj/item/borg/upgrade/U in contents)
if(istype(U, /obj/item/borg/upgrade/reset)) // The reset module is supposed to be consumed on use, this stops it from dropping on the floor if used
QDEL_NULL(U)
U.forceMove(get_turf(src))
/mob/living/silicon/robot/proc/reset_module()
notify_ai(2)
shown_robot_modules = 0
client?.screen -= robot_modules_background
client?.screen -= hud_used.module_store_icon
uneq_all()
SStgui.close_user_uis(src)
sight_mode = null
update_sight()
hands.icon_state = "nomod"
icon_state = "robot"
module.remove_subsystems_and_actions(src)
QDEL_NULL(module)
camera.network.Remove(list("Engineering", "Medical", "Mining Outpost"))
rename_character(real_name, get_default_name("Default"))
languages = list()
speech_synthesizer_langs = list()
radio.recalculateChannels()
custom_panel = null
robot_module_hat_offset(icon_state)
update_icons()
update_headlamp()
spill_upgrades()
speed = 0 // Strip lingering upgrade effects.
ionpulse = FALSE
weapons_unlock = FALSE
add_language("Robot Talk", TRUE)
if("lava" in weather_immunities) // Remove the lava-immunity effect given by a printable upgrade
weather_immunities -= "lava"
armor = getArmor(arglist(initial(armor)))
status_flags |= CANPUSH
//for borg hotkeys, here module refers to borg inv slot, not core module
/mob/living/silicon/robot/verb/cmd_toggle_module(module as num)
set name = "Toggle Module"
set hidden = 1
toggle_module(module)
/mob/living/silicon/robot/verb/cmd_unequip_module()
set name = "Unequip Module"
set hidden = 1
uneq_active()
// this verb lets cyborgs see the stations manifest
/mob/living/silicon/robot/verb/cmd_station_manifest()
set category = "Robot Commands"
set name = "Show Station Manifest"
show_station_manifest()
/mob/living/silicon/robot/verb/toggle_component()
set category = "Robot Commands"
set name = "Toggle Component"
set desc = "Toggle a component, conserving power."
var/list/installed_components = list()
for(var/V in components)
if(V == "power cell") continue
var/datum/robot_component/C = components[V]
if(!C.is_missing())
installed_components += V
var/toggle = tgui_input_list(src, "Which component do you want to toggle?", "Toggle Component", installed_components)
if(!toggle)
return
var/datum/robot_component/C = components[toggle]
C.toggle()
to_chat(src, "<span class='warning'>You [C.toggled ? "enable" : "disable"] [C.name].</span>")
/mob/living/silicon/robot/proc/sensor_mode()
set name = "Set Sensor Augmentation"
set desc = "Augment visual feed with internal sensor overlays."
set category = "Robot Commands"
toggle_sensor_mode()
/mob/living/silicon/robot/proc/add_robot_verbs()
add_verb(src, GLOB.robot_verbs_default)
add_verb(src, silicon_subsystems)
/mob/living/silicon/robot/proc/remove_robot_verbs()
remove_verb(src, GLOB.robot_verbs_default)
remove_verb(src, silicon_subsystems)
/mob/living/silicon/robot/verb/cmd_robot_alerts()
set category = "Robot Commands"
set name = "Show Alerts"
if(usr.stat == DEAD)
to_chat(src, "<span class='userdanger'>Alert: You are dead.</span>")
return //won't work if dead
robot_alerts()
/mob/living/silicon/robot/proc/robot_alerts()
var/list/dat = list()
var/list/list/temp_alarm_list = GLOB.alarm_manager.alarms.Copy()
for(var/cat in temp_alarm_list)
if(!(cat in alarms_listend_for))
continue
dat += "<B>[cat]</B><BR>\n"
var/list/list/L = temp_alarm_list[cat].Copy()
for(var/alarm in L)
var/list/list/alm = L[alarm].Copy()
var/list/list/sources = alm[3].Copy()
var/area_name = alm[1]
for(var/thing in sources)
var/atom/A = locateUID(thing)
if(A && A.z != z)
L -= alarm
continue
dat += "<NOBR>"
dat += "-- [area_name]"
dat += "</NOBR><BR>\n"
if(!L.len)
dat += "-- All Systems Nominal<BR>\n"
dat += "<BR>\n"
var/datum/browser/alerts = new(usr, "robotalerts", "Current Station Alerts", 400, 410)
var/dat_text = dat.Join("")
alerts.set_content(dat_text)
alerts.open()
/mob/living/silicon/robot/proc/ionpulse()
if(!ionpulse_on)
return
if(cell.charge <= 50)
toggle_ionpulse()
return
cell.charge -= 25 // 500 steps on a default cell.
return 1
/mob/living/silicon/robot/proc/toggle_ionpulse()
if(!ionpulse)
to_chat(src, "<span class='notice'>No thrusters are installed!</span>")
return
ionpulse_on = !ionpulse_on
to_chat(src, "<span class='notice'>You [ionpulse_on ? null :"de"]activate your ion thrusters.</span>")
if(thruster_button)
thruster_button.icon_state = "ionpulse[ionpulse_on]"
/mob/living/silicon/robot/blob_act(obj/structure/blob/B)
if(stat != DEAD)
adjustBruteLoss(30)
else
gib()
return TRUE
// this function displays the cyborgs current cell charge in the stat panel
/mob/living/silicon/robot/proc/show_cell_power()
return list("Charge Left:", cell ? "[cell.charge]/[cell.maxcharge]" : "No Cell Inserted!")
/mob/living/silicon/robot/proc/show_gps_coords()
var/turf/turf = get_turf(src)
return list("GPS:", "[COORD(turf)]")
/mob/living/silicon/robot/proc/show_stack_energy(datum/robot_storage/robot_storage)
return list("[robot_storage.statpanel_name]:", "[robot_storage.amount] / [robot_storage.max_amount]")
// update the status screen display
/mob/living/silicon/robot/get_status_tab_items()
var/list/status_tab_data = ..()
. = status_tab_data
status_tab_data[++status_tab_data.len] = show_cell_power()
if(!module)
return
if(locate(/obj/item/gps/cyborg) in module.modules)
status_tab_data[++status_tab_data.len] = show_gps_coords()
for(var/datum/robot_storage/robot_storage in module.storages)
status_tab_data[++status_tab_data.len] = show_stack_energy(robot_storage)
/mob/living/silicon/robot/restrained()
return 0
/mob/living/silicon/robot/InCritical()
return low_power_mode
/mob/living/silicon/robot/alarm_triggered(src, class, area/A, list/O, obj/alarmsource)
if(!(class in alarms_listend_for))
return
if(alarmsource.z != z)
return
if(stat == DEAD)
return
queueAlarm(text("--- [class] alarm detected in [A.name]!"), class)
/mob/living/silicon/robot/alarm_cancelled(src, class, area/A, obj/origin, cleared)
if(cleared)
if(!(class in alarms_listend_for))
return
if(origin.z != z)
return
queueAlarm("--- [class] alarm in [A.name] has been cleared.", class, 0)
/mob/living/silicon/robot/ex_act(severity)
switch(severity)
if(1.0)
gib()
return
if(2.0)
if(stat != 2)
adjustBruteLoss(60)
adjustFireLoss(60)
if(3.0)
if(stat != 2)
adjustBruteLoss(30)
return
/mob/living/silicon/robot/bullet_act(obj/item/projectile/Proj)
..(Proj)
if(prob(75) && Proj.damage > 0) spark_system.start()
return 2
/mob/living/silicon/robot/attackby(obj/item/W, mob/user, params)
// Check if the user is trying to insert another component like a radio, actuator, armor etc.
if(istype(W, /obj/item/robot_parts/robot_component) && opened)
for(var/V in components)
var/datum/robot_component/C = components[V]
if(C.is_missing() && istype(W, C.external_type))
if(!user.drop_item())
to_chat(user, "<span class='warning'>[W] seems to be stuck in your hand!</span>")
return
C.install(W)
W.loc = null
var/obj/item/robot_parts/robot_component/WC = W
if(istype(WC))
C.brute_damage = WC.brute
C.electronics_damage = WC.burn
to_chat(usr, "<span class='notice'>You install [W].</span>")
return
if(istype(W, /obj/item/stack/cable_coil) && user.a_intent == INTENT_HELP && (wiresexposed || isdrone(src)))
user.changeNext_move(CLICK_CD_MELEE)
if(!getFireLoss())
to_chat(user, "<span class='notice'>Nothing to fix!</span>")
return
else if(!getFireLoss(TRUE))
to_chat(user, "<span class='warning'>The damaged components are beyond saving!</span>")
return
var/obj/item/stack/cable_coil/coil = W
adjustFireLoss(-30)
updatehealth()
add_fingerprint(user)
coil.use(1)
user.visible_message("<span class='alert'>\The [user] fixes some of the burnt wires on \the [src] with \the [coil].</span>")
else if(istype(W, /obj/item/stock_parts/cell) && opened) // trying to put a cell inside
var/datum/robot_component/cell/C = components["power cell"]
if(wiresexposed)
to_chat(user, "Close the panel first.")
else if(cell)
to_chat(user, "There is a power cell already installed.")
else
user.drop_item()
W.loc = src
to_chat(user, "You insert the power cell.")
C.install(W)
//This will mean that removing and replacing a power cell will repair the mount, but I don't care at this point. ~Z
C.brute_damage = 0
C.electronics_damage = 0
var/been_hijacked = FALSE
for(var/mob/living/simple_animal/demon/pulse_demon/demon in cell)
if(!been_hijacked)
demon.do_hijack_robot(src)
been_hijacked = TRUE
else
demon.exit_to_turf()
if(been_hijacked)
cell.rigged = FALSE
module?.update_cells()
diag_hud_set_borgcell()
else if(istype(W, /obj/item/encryptionkey/) && opened)
if(radio)//sanityyyyyy
radio.attackby(W,user)//GTFO, you have your own procs
else
to_chat(user, "Unable to locate a radio.")
else if(istype(W, /obj/item/card/id) || istype(W, /obj/item/pda)) // trying to unlock the interface with an ID card
if(emagged)//still allow them to open the cover
to_chat(user, "The interface seems slightly damaged.")
if(opened)
to_chat(user, "You must close the cover to swipe an ID card.")
else
if(allowed(W))
locked = !locked
to_chat(user, "You [ locked ? "lock" : "unlock"] [src]'s interface.")
to_chat(src, "<span class='notice'>[user] [ locked ? "locked" : "unlocked"] your interface.</span>")
update_icons()
else
to_chat(user, "<span class='warning'>Access denied.</span>")
else if(istype(W, /obj/item/borg/upgrade/))
var/obj/item/borg/upgrade/U = W
if(!opened)
to_chat(user, "<span class='warning'>You must access the borg's internals!</span>")
else if(!src.module && U.require_module)
to_chat(user, "<span class='warning'>The borg must choose a module before it can be upgraded!</span>")
else
if(!user.drop_item())
return
if(U.action(src))
user.visible_message("<span class='notice'>[user] applied [U] to [src].</span>", "<span class='notice'>You apply [U] to [src].</span>")
U.forceMove(src)
else if(istype(W, /obj/item/mmi_radio_upgrade))
if(!opened)
to_chat(user, "<span class='warning'>You must access the borg's internals!</span>")
return
else if(!mmi)
to_chat(user, "<span class='warning'>This cyborg does not have an MMI to augment!</span>")
return
else if(mmi.radio)
to_chat(user, "<span class='warning'>A radio upgrade is already installed in the MMI!</span>")
return
else if(user.drop_item())
to_chat(user, "<span class='notice'>You apply the upgrade to [src].</span>")
to_chat(src, "<span class='notice'>MMI radio capability installed.</span>")
mmi.install_radio()
qdel(W)
else
return ..()
/mob/living/silicon/robot/wirecutter_act(mob/user, obj/item/I)
if(!opened)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = 0))
return
if(wiresexposed)
wires.Interact(user)
/mob/living/silicon/robot/multitool_act(mob/user, obj/item/I)
if(!opened)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = 0))
return
if(wiresexposed)
wires.Interact(user)
/mob/living/silicon/robot/screwdriver_act(mob/user, obj/item/I)
if(!opened)
return
. = TRUE
if(!I.use_tool(src, user, 0, volume = 0))
return
if(!cell) // haxing
wiresexposed = !wiresexposed
to_chat(user, "<span class='notice'>The wires have been [wiresexposed ? "exposed" : "unexposed"]</span>")
update_icons()
I.play_tool_sound(user, I.tool_volume)
else //radio check
if(radio)
radio.screwdriver_act(user, I)//Push it to the radio to let it handle everything
else