forked from goonstation/goonstation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gangwar.dm
2513 lines (2176 loc) · 96.4 KB
/
gangwar.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
/datum/game_mode/gang
name = "Gang War (Beta)"
config_tag = "gang"
regular = FALSE
/// Makes it so gang members are chosen randomly at roundstart instead of being recruited.
var/random_gangs = TRUE
antag_token_support = TRUE
var/list/datum/gang/gangs = list()
var/const/setup_min_teams = 2
var/const/setup_max_teams = 6
var/const/waittime_l = 600 //lower bound on time before intercept arrives (in tenths of seconds)
var/const/waittime_h = 1800 //upper bound on time before intercept arrives (in tenths of seconds)
var/list/potential_hot_zones = null
var/area/hot_zone
#ifdef RP_MODE
var/const/kidnapping_timer = 15 MINUTES //Time to find and kidnap the victim.
var/const/delay_between_kidnappings = 12 MINUTES
#else
var/const/kidnapping_timer = 8 MINUTES //Time to find and kidnap the victim.
var/const/delay_between_kidnappings = 5 MINUTES
#endif
var/kidnapping_score = 20000
var/kidnap_success = 0 //true if the gang successfully kidnaps.
var/slow_process = 0 //number of ticks to skip the extra gang process loops
var/shuttle_called = FALSE
var/mob/kidnapping_target
/datum/game_mode/gang/announce()
boutput(world, "<B>The current game mode is - Gang War!</B>")
boutput(world, "<B>A number of gangs are competing for control of the station!</B>")
boutput(world, "<B>Gang members are antagonists and can kill or be killed!</B>")
/datum/game_mode/gang/pre_setup()
var/num_players = 0
for(var/client/C)
var/mob/new_player/player = C.mob
if (!istype(player)) continue
if(player.ready) num_players++
#ifdef RP_MODE
#define PLAYERS_PER_GANG_GENERATED 15
#else
#define PLAYERS_PER_GANG_GENERATED 12
#endif
var/num_teams = clamp(round((num_players) / PLAYERS_PER_GANG_GENERATED), setup_min_teams, setup_max_teams) //1 gang per 9 players, 15 on RP
#undef PLAYERS_PER_GANG_GENERATED
var/list/leaders_possible = get_possible_enemies(ROLE_GANG_LEADER, num_teams)
if (num_teams > length(leaders_possible))
num_teams = length(leaders_possible)
if (!length(leaders_possible))
return 0
token_players = antag_token_list()
for(var/datum/mind/tplayer in token_players)
if (!length(token_players))
break
src.traitors += tplayer
token_players.Remove(tplayer)
logTheThing(LOG_ADMIN, tplayer.current, "successfully redeems an antag token.")
message_admins("[key_name(tplayer.current)] successfully redeems an antag token.")
var/list/chosen_leader = antagWeighter.choose(pool = leaders_possible, role = ROLE_GANG_LEADER, amount = num_teams, recordChosen = 1)
src.traitors |= chosen_leader
#ifndef ME_AND_MY_40_ALT_ACCOUNTS
// check if we can actually run the mode before assigning special roles to minds
if(length(get_possible_enemies(ROLE_GANG_MEMBER, round(num_teams * GANG_MAX_MEMBERS), force_fill = FALSE) - src.traitors) < round(num_teams * GANG_MAX_MEMBERS * 0.66)) //must have at least 2/3 full gangs or there's no point
//boutput(world, SPAN_ALERT("<b>ERROR: The readied players are not collectively gangster enough for the selected mode, aborting gangwars.</b>"))
return 0
#endif
for (var/datum/mind/leader in src.traitors)
leaders_possible.Remove(leader)
leader.special_role = ROLE_GANG_LEADER
return 1
/datum/game_mode/gang/post_setup()
for(var/datum/mind/antag_mind in src.traitors)
if(antag_mind.special_role == ROLE_GANG_LEADER)
antag_mind.add_antagonist(ROLE_GANG_LEADER, silent=TRUE)
if(src.random_gangs)
fill_gangs()
// we delay announcement to make sure everyone gets information about the other members
for(var/datum/mind/antag_mind in src.traitors)
antag_mind.get_antagonist(ROLE_GANG_LEADER)?.unsilence()
antag_mind.get_antagonist(ROLE_GANG_MEMBER)?.unsilence()
find_potential_hot_zones()
SPAWN(rand(waittime_l, waittime_h))
send_intercept()
return 1
/datum/game_mode/gang/proc/fill_gangs(list/datum/mind/candidates = null, max_member_count = INFINITY)
var/num_teams = length(src.gangs)
var/num_people_needed = 0
if(num_teams == 0)
logTheThing(LOG_DEBUG, null, "Gangs gamemode attempted to fill gangs, but there were no gangs to fill.")
message_admins("It's gangs, but there are no gangs??")
return
for(var/datum/gang/gang in src.gangs)
num_people_needed += min(gang.current_max_gang_members, max_member_count) - length(gang.members)
if(isnull(candidates))
candidates = get_possible_enemies(ROLE_GANG_MEMBER, num_people_needed, allow_carbon=TRUE, filter_proc=PROC_REF(can_join_gangs), force_fill = FALSE)
var/num_people_available = min(num_people_needed, length(candidates))
var/people_added_per_gang = round(num_people_available / num_teams)
num_people_available = people_added_per_gang * num_teams
shuffle_list(candidates)
var/i = 1
for(var/datum/gang/gang in src.gangs)
for(var/j in 1 to people_added_per_gang)
var/datum/mind/candidate = candidates[i++]
candidate.add_subordinate_antagonist(ROLE_GANG_MEMBER, master = gang.leader, silent=TRUE)
traitors |= candidate
/datum/game_mode/gang/proc/can_join_gangs(mob/M)
var/datum/job/job = find_job_in_controller_by_string(M.mind.assigned_role)
. = !job || job.can_join_gangs
/datum/game_mode/gang/proc/force_shuttle()
if (!emergency_shuttle.online)
emergency_shuttle.disabled = SHUTTLE_CALL_ENABLED
emergency_shuttle.incall()
command_alert("Centcom is very disappointed in you all for this 'gang' silliness. The shuttle has been called.","Emergency Shuttle Update")
/datum/game_mode/gang/send_intercept()
..(src.traitors)
/datum/game_mode/gang/process()
..()
#ifndef RP_MODE
if (ticker.round_elapsed_ticks >= 55 MINUTES && !shuttle_called)
shuttle_called = TRUE
force_shuttle()
#endif //RP_MODE
slow_process ++
if (slow_process < 5)
return
else
slow_process = 0
for(var/datum/gang/G as anything in gangs)
if (G.leader) //leaders immune to debuffs
var/mob/living/carbon/human/H = G.leader.current
var/turf/sourceturf = get_turf(H)
if ((G in sourceturf?.controlling_gangs) && G.gear_worn(H) == 2)
H.setStatus("ganger", duration = INFINITE_STATUS)
else
H.delStatus("ganger")
if (islist(G.members))
for (var/datum/mind/M as anything in G.members)
var/mob/living/carbon/human/H = M.current
var/turf/sourceturf = get_turf(H)
var/gearworn = G.gear_worn(H)
if (G in sourceturf.controlling_gangs) //if we're in friendly territory (or contested territory)
H.delStatus("ganger_debuff")
if (gearworn == 2) //gain a buff for wearing your gang outfit
H.setStatus("ganger", duration = INFINITE_STATUS)
else
H.delStatus("ganger")
else if (length(sourceturf.controlling_gangs)) //if we're in enemy territory (and not contested territory)
H.delStatus("ganger")
if (gearworn == 2) //gain a debuff for not wearing your outfit
H.delStatus("ganger_debuff")
else
H.setStatus("ganger_debuff", duration = INFINITE_STATUS)
else //if we're in neutral ground, remove all debuffs
H.delStatus("ganger_debuff")
H.delStatus("ganger")
/datum/game_mode/gang/declare_completion()
if (!check_winner())
boutput(world, "<h2><b>The round was a draw!</b></h2>")
else
var/datum/gang/winner = check_winner()
if (istype(winner))
boutput(world, "<h2><b>[winner.gang_name], led by [winner.leader.current.real_name], won the round!</b></h2>")
var/datum/hud/gang_victory/victory_hud = new(winner)
for (var/client/C in clients)
victory_hud.add_client(C)
..()
/datum/game_mode/gang/proc/check_winner()
var/datum/gang/victorius_gang = null
// Find the highest scoring gang.
for (var/datum/gang/gang in src.gangs)
if(!victorius_gang)
victorius_gang = gang
else if(victorius_gang.gang_score() < gang.gang_score())
victorius_gang = gang
// Check if the highest score is a draw.
for (var/datum/gang/gang in src.gangs)
if((victorius_gang != gang) && (victorius_gang.gang_score() == gang.gang_score()))
return 0
if (istype(victorius_gang))
return victorius_gang
/// hot zone thing
/datum/game_mode/gang/proc/find_potential_hot_zones()
potential_hot_zones = list()
var/list/area/areas = get_accessible_station_areas()
for(var/area/area in areas)
if(istype(areas[area], /area/station/security) || areas[area].teleport_blocked || istype(areas[area], /area/station/turret_protected))
continue
potential_hot_zones += areas[area]
return
/datum/game_mode/gang/proc/process_kidnapping_event()
kidnap_success = 0
kidnapping_target = null
var/datum/gang/top_gang = null
for (var/datum/gang/G in gangs)
if (!top_gang)
top_gang = G
continue
if (G.gang_score() > top_gang.gang_score())
top_gang = G
if (!top_gang)
logTheThing(LOG_DEBUG, null, "No winning gang chosen for kidnapping event. Something's broken.")
message_admins("No winning gang chosen for kidnapping event. Something's broken.")
return 0
//get possible targets. Looks for ckey, if they are not dead, and if they are not in the top gang.
var/list/potential_targets = list()
for (var/mob/living/carbon/human/H in mobs)
if (H.ckey && !isdead(H) && H.get_gang() != top_gang && !istype(H.mutantrace, /datum/mutantrace/virtual))
potential_targets += H
if (!length(potential_targets))
logTheThing(LOG_DEBUG, null, "No players found to be kidnapping targets.")
message_admins("No kidnapping target has been chosen for kidnapping event. This should be pretty unlikely, unless there's only like 1 person on.")
return 0
kidnapping_target = pick(potential_targets)
var/target_name
if (ismob(kidnapping_target))
target_name = kidnapping_target.real_name
broadcast_to_all_gangs("The [hot_zone.name] is a high priority area. Ensure that your gang has control of it five minutes from now!")
//alert gangs, alert target which gang to be wary of.
for (var/datum/gang/G in gangs)
if (G == top_gang)
G.broadcast_to_gang("A bounty has been placed on the capture of [target_name]. Shove them into your gang locker <ALIVE>, within 8 minutes for a massive reward!")
else
G.broadcast_to_gang("[target_name] is the target of a kidnapping by [top_gang.gang_name]. Ensure that [target_name] is alive and well for the next 8 minutes for a reward!")
boutput(kidnapping_target, SPAN_ALERT("You get the feeling that [top_gang.gang_name] wants you dead! Run and hide or ask security for help!"))
SPAWN(kidnapping_timer - 1 MINUTE)
if(kidnapping_target != null) broadcast_to_all_gangs("[target_name] has still not been captured by [top_gang.gang_name] and they have 1 minute left!")
sleep(1 MINUTE)
//if they didn't kidnap em, then give points to other gangs depending on whether they are alive or not.
if(!kidnap_success)
//if the kidnapping target is null or dead, nobody gets points. (the target will be "gibbed" if successfully "kidnapped" and points awarded there)
if (kidnapping_target && !isdead(kidnapping_target))
for (var/datum/gang/G in gangs)
if (G != top_gang)
G.score_event += kidnapping_score / length(gangs) //This is less than the total points the top_gang would get, so it behooves security to help the non-top gangs keep the target safe.
broadcast_to_all_gangs("[top_gang.gang_name] has failed to kidnap [target_name] and the other gangs have been rewarded for thwarting the kidnapping attempt!")
else
broadcast_to_all_gangs("[target_name] has died in one way or another. No gangs have been rewarded for this futile exercise.")
sleep(delay_between_kidnappings)
process_kidnapping_event()
proc/broadcast_to_all_gangs(var/message)
var/datum/language/L = languages.language_cache["english"]
var/list/messages = L.get_messages(message)
for (var/datum/gang/gang in get_all_gangs())
gang.announcer_radio.set_secure_frequency("g", gang.gang_frequency)
gang.announcer_radio.talk_into(gang.announcer_source, messages, "g", gang.announcer_source.name, "english")
/// For a given tile, this contains the number of gang tags that see or influence this tile for a gang. Used to track overlays.
/datum/gangtileclaim
var/datum/gang/gang
var/sights //! whether this tile is *seen* by a nearby tag, generating points for it.
var/claims //! whether this tile is claimed by a tag, meaning it is valid for expanding a gangs'territory
var/image/image //! The overlay for this tile.
New(gang, newImage, newSight, newClaim)
image = newImage
sights = newSight
claims = newClaim
..()
/datum/gang
/// The maximum number of gang members per gang.
var/static/current_max_gang_members = GANG_MAX_MEMBERS
/// Gang tag icon states that are being used by other gangs.
var/static/list/used_tags
/// Gang names that are being used by other gangs.
var/static/list/used_names
/// Radio frequencies that are being used by other gangs.
var/static/list/used_frequencies
/// Jumpsuit items that are being used by other gangs as part of their gang uniform.
var/static/list/uniform_list
/// Mask or hat items that are being used by other gangs as part of their gang uniform.
var/static/list/headwear_list
var/static/list/color_list = list("#88CCEE","#117733","#332288","#DDCC77","#CC6677","#AA4499") //(hopefully) colorblind friendly palette
var/static/list/colors_left = null
/// The radio source for the gang's announcer, who will announce various messages of importance over the gang's frequency.
var/datum/generic_radio_source/announcer_source
/// The radio headset that the gang's announcer will use.
var/obj/item/device/radio/headset/gang/announcer_radio
/// The chosen name of this gang.
var/gang_name = "Gang Name"
/// The randomly selected tag of this gang.
var/gang_tag = 0
/// The ID of the color selected
var/color_id = 0
/// The unique radio frequency that members of this gang will communicate over.
var/gang_frequency = 0
/// The amount of spray paint cans this gang may spawn.
var/spray_paint_remaining = GANG_STARTING_SPRAYPAINT
/// The chosen jumpsuit item of this gang.
var/obj/item/clothing/uniform = null
/// The chosen mask or hat item of this gang.
var/obj/item/clothing/headwear = null
/// The location of this gang's locker.
var/area/base = null
/// The various areas that this gang currently controls.
var/list/area/controlled_areas = list()
/// The mind of this gang's leader.
var/datum/mind/leader = null
/// The minds of gang members associated with this gang. Does not include the gang leader.
var/list/members = list()
var/list/tags = list()
/// The minds of members of this gang who are currently on cooldown from redeeming their gear from the gang locker.
var/list/gear_cooldown = list()
/// The gang locker of this gang.
var/obj/ganglocker/locker = null
/// The usable number of points that this gang has to spend with.
/// The street cred this gang has - used exclusively by the leader for purchasing gang members & revives
var/street_cred = 0
/// The number of tiles this gang controls.
var/tiles_controlled = 0
/// Associative list between Gang members -> their points
var/gang_points = list()
#ifdef BONUS_POINTS
street_cred = 99999
#endif
/// An associative list of the items that this gang has purchased and the quantity in which they have been purchased.
var/list/items_purchased = list()
var/datum/client_image_group/turf_image_group = new/datum/client_image_group()
var/color = "#DDDDDD"
/// Points gained by this gang from owning areas.
var/score_turf = 0
/// The total quantity of cash that this gang has deposited.
var/score_cash = 0
/// Points gained by this gang from gun deposits.
var/score_gun = 0
/// Points gained by this gang from drug deposits.
var/score_drug = 0
/// Points gained by this gang from completing events.
var/score_event = 0
var/static/list/first_names = strings("gangwar.txt", "part1")
var/static/list/second_names = strings("gangwar.txt", "part2")
/// Whether or not the leader of this gang has claimed a recruitment briefcase
var/claimed_briefcase = FALSE
/// Price of the janktank II, for this gang (gang member revival syringe)
var/current_revival_price = GANG_REVIVE_COST
/// Price to hire a spectator gang member, for this gang
var/current_newmember_price = GANG_NEW_MEMBER_COST
/// Whether a gang member can claim to be leader. For when the leader cryos & observes (and NOT when the leader dies)
var/leader_claimable = FALSE
/// Potential loot drop zones for this gang
var/list/potential_drop_zones
/// Strings used to build PDA messages sent to civilians.
var/static/gangGreetings[] = list("yo", "hey","hiya","oi", "psst", "pssst" )
var/static/gangIntermediates[] = list("don't ask how I got your number.","heads up.", "help us out.")
var/static/gangEndings[] = list("best of luck.", "maybe help them, yeah?", "stay in line and you'll probably live.", "don't think of stealing it.")
proc/living_member_count()
var/result = 0
for (var/datum/mind/member as anything in members)
if (!isdead(member.current))
result++
return result
proc/handle_leader_cryo()
broadcast_to_gang("Your leader has entered cryogenic storage. You can claim leadership at your locker.")
leader_claimable = TRUE
proc/get_dead_memberlist()
var/list/result = list()
for (var/datum/mind/member as anything in members)
if (istype(member.current.loc, /obj/cryotron))
var/obj/cryotron/cryo = member.current.loc
var/cryoTime = cryo.stored_mobs[member.current]
if (TIME - cryoTime > GANG_CRYO_LOCKOUT)
result[(member.current?.real_name)] = member
continue
if (isdead(member.current))
result[(member.current?.real_name)] = member
return result
proc/unclaim_tiles(var/location, claimRange, minimumRange)
var/squared_claim = claimRange*claimRange
var/squared_minimum = minimumRange*minimumRange
var/datum/client_image_group/imgroup = get_image_group(CLIENT_IMAGE_GROUP_GANGS)
var/turf/sourceturf = get_turf(location)
for (var/turf/turftile in range(claimRange,sourceturf))
var/tileDistance = GET_SQUARED_EUCLIDEAN_DIST(turftile, sourceturf)
if(tileDistance > squared_claim) continue
if (!turftile.controlling_gangs)
return
if (!(src in turftile.controlling_gangs))
return
var/datum/gangtileclaim/tileClaim = turftile.controlling_gangs[src]
if (!tileClaim)
return
tileClaim.claims -= 1
if (tileDistance <= squared_minimum)
tileClaim.sights -= 1
if (tileClaim.sights == 0)
if (tileClaim.claims > 0)
imgroup.remove_image(tileClaim.image)
qdel(tileClaim.image)
tileClaim.image = image('icons/effects/gang_overlays.dmi', turftile, "owned")
tileClaim.image.color = src.color
imgroup.add_image(tileClaim.image)
tileClaim.image.alpha = 80
if (tileClaim.claims == 0)
imgroup.remove_image(tileClaim.image)
qdel(tileClaim.image)
src.tiles_controlled -= 1
turftile.controlling_gangs[src] = null
/// Claim all tiles within claimRange, making all within minimumRange unclaimable.
proc/claim_tiles(var/location, claimRange, minimumRange)
var/squared_claim = claimRange*claimRange
var/squared_minimum = minimumRange*minimumRange
var/datum/client_image_group/imgroup = get_image_group(CLIENT_IMAGE_GROUP_GANGS)
var/turf/sourceturf = get_turf(location)
if (!sourceturf.controlling_gangs)
sourceturf.controlling_gangs = new/list()
if (!sourceturf.controlling_gangs[src])
var/image/img = image('icons/effects/gang_overlays.dmi', sourceturf, "owned")
img.alpha = 230
img.color = src.color
src.tiles_controlled += 1
sourceturf.controlling_gangs[src] = new/datum/gangtileclaim(src,img,1,1)
imgroup.add_image(img)
else
var/datum/gangtileclaim/tileClaim = sourceturf.controlling_gangs[src]
tileClaim.image.alpha = 230
tileClaim.sights += 1
tileClaim.claims += 1
for (var/turf/turftile in orange(claimRange,sourceturf))
var/distance = GET_SQUARED_EUCLIDEAN_DIST(turftile, sourceturf)
if(distance > squared_claim) continue
if (!turftile.controlling_gangs)
turftile.controlling_gangs = new/list()
if (!turftile.controlling_gangs[src] || turftile.controlling_gangs[src].claims == 0)
var/image/img
//give the tiles different effects based on their distance
if(distance > squared_minimum)
img = image('icons/effects/gang_overlays.dmi', turftile, "owned")
turftile.controlling_gangs[src] = new/datum/gangtileclaim(src,img,0,1) //mark this tile as claimable
img.alpha = 80
else
img = image('icons/effects/gang_overlays.dmi', turftile, "seen")
turftile.controlling_gangs[src] = new/datum/gangtileclaim(src,img,1,1) //mark this tile as unclaimable
img.alpha = 170
img.color = src.color
src.tiles_controlled += 1
imgroup.add_image(img)
else
var/datum/gangtileclaim/tileClaim = turftile.controlling_gangs[src]
if(distance <= squared_minimum)
if (tileClaim.sights == 0)
imgroup.remove_image(tileClaim.image)
qdel(tileClaim.image)
tileClaim.image = image('icons/effects/gang_overlays.dmi', turftile, "seen")
tileClaim.image.color = src.color
imgroup.add_image(tileClaim.image)
tileClaim.image.alpha = 170
tileClaim.sights += 1
tileClaim.claims += 1
New()
. = ..()
if (colors_left == null)
colors_left = new/list(length(color_list))
for (var/color = 1 to length(color_list))
colors_left[color] = color
if (!src.used_tags)
src.used_tags = list()
if (!src.used_names)
src.used_names = list()
if (!src.used_frequencies)
src.used_frequencies = list()
if (!src.uniform_list || !src.headwear_list)
src.make_item_lists()
color_id = pick(colors_left)
colors_left -= color_id
color = color_list[color_id]
src.gang_tag = rand(0, 22)
while(src.gang_tag in src.used_tags)
src.gang_tag = rand(0, 22)
src.used_tags += src.gang_tag
src.gang_frequency = rand(1360, 1420)
while(src.gang_frequency in src.used_frequencies)
src.gang_frequency = rand(1360, 1420)
src.used_frequencies += src.gang_frequency
protected_frequencies += gang_frequency
src.announcer_source = new /datum/generic_radio_source()
src.announcer_source.set_name("The [pick("Kingpin","Cabal","Council","Boss")]")
src.announcer_radio = new /obj/item/device/radio/headset/gang()
if (istype(ticker?.mode, /datum/game_mode/gang))
var/datum/game_mode/gang/gamemode = ticker.mode
gamemode.gangs += src
proc/generate_random_name()
if (prob(70))
. = pick_string("gangwar.txt", "fullchosen")
else
. = "[pick(first_names)] [pick(second_names)]"
proc/select_gang_name()
var/temporary_name = generate_random_name()
while(src.gang_name == "Gang Name")
var/choice = "Accept"
if(src.leader?.current)
// if the leader is disconnected, this tgui_alert call will return null, breaking everything. Default to "Accept" and give them the random name
choice = tgui_alert(src.leader?.current, "Name: [temporary_name].", "Approve Your Gang's Name", list("Accept", "Reselect", "Randomise")) || "Accept"
switch(choice)
if ("Accept")
if (temporary_name in src.used_names)
boutput(src.leader.current, SPAN_ALERT("Another gang has this name."))
// to prevent the incredibly slim chance that a disconncted gang leader rolls the same name as an existing gang
temporary_name = generate_random_name()
continue
src.gang_name = temporary_name
src.used_names += temporary_name
for(var/datum/mind/member in src.members + list(src.leader))
boutput(member.current, SPAN_ALERT("<h4>Your gang name is [src.gang_name]!</h4>"))
if ("Reselect")
var/first_name = tgui_input_list(src.leader.current, "Select the first word in your gang's name:", "Gang Name Selection", first_names)
var/second_name = tgui_input_list(src.leader.current, "Select the second word in your gang's name:", "Gang Name Selection", second_names)
temporary_name = "[first_name] [second_name]"
if ("Randomise")
temporary_name = generate_random_name()
// add the gang to their displayed name for antag and round end stuff. works hopefully??
var/datum/antagonist/leader_antag = src.leader.get_antagonist(ROLE_GANG_LEADER)
leader_antag.display_name = "[src.gang_name] [leader_antag.display_name]"
for (var/datum/mind/ganger in src.members)
var/datum/antagonist/antag = ganger.get_antagonist(ROLE_GANG_MEMBER)
antag.display_name = "[src.gang_name] [antag.display_name]"
proc/select_gang_uniform()
// Jumpsuit Selection.
var/temporary_jumpsuit = tgui_input_list(src.leader.current, "Select your gang's uniform slot item:", "Gang Uniform Selection", src.uniform_list)
while (!src.uniform_list[temporary_jumpsuit])
boutput(src.leader.current , SPAN_ALERT("That uniform has been claimed by another gang."))
temporary_jumpsuit = tgui_input_list(src.leader.current, "Select your gang's uniform slot item:", "Gang Uniform Selection", src.uniform_list)
src.uniform = src.uniform_list[temporary_jumpsuit]
src.uniform_list -= temporary_jumpsuit
// Mask/Headwear Selection.
if(src.gang_name == "NICOLAS CAGE FAN CLUB")
src.headwear = /obj/item/clothing/mask/niccage
else
var/temporary_headwear = tgui_input_list(src.leader.current, "Select your gang's mask or head slot item:", "Gang Uniform Selection", src.headwear_list)
while(!src.headwear_list[temporary_headwear])
boutput(src.leader.current , SPAN_ALERT("That mask or hat has been claimed by another gang."))
temporary_headwear = tgui_input_list(src.leader.current, "Select your gang's mask or head slot item:", "Gang Uniform Selection", src.headwear_list)
src.headwear = src.headwear_list[temporary_headwear]
src.headwear_list -= temporary_headwear
proc/broadcast_to_gang(var/message)
var/datum/language/L = languages.language_cache["english"]
var/list/messages = L.get_messages(message)
src.announcer_radio.set_secure_frequency("g", src.gang_frequency)
src.announcer_radio.talk_into(src.announcer_source, messages, "g", src.announcer_source.name, "english")
proc/num_tiles_controlled()
return src.tiles_controlled
proc/gang_score()
var/score = 0
score += score_turf
score += score_cash
score += score_gun
score += score_drug
score += score_event
return round(score)
/// Shows maptext to the gang, with formatting for score increases.
proc/show_score_maptext(amount, turf/location)
var/image/chat_maptext/chat_text = null
chat_text = make_chat_maptext(location, "<span class='ol c pixel' style='color: #08be4e;'>+[amount]</span>", alpha = 180, time = 0.5 SECONDS)
chat_text.show_to(src.leader.current.client)
for (var/datum/mind/userMind as anything in src.members)
var/client/userClient = userMind.current.client
if (userClient?.preferences?.flying_chat_hidden)
chat_text.show_to(userClient)
/// add points to this gang, bonusMob optionally getting a bonus
/// if location is defined, maptext will come from that location, for all members.
proc/add_points(amount, mob/bonusMob = null, turf/location = null, showText = FALSE)
street_cred += amount
var/datum/mind/bonusMind = bonusMob?.mind
if (leader)
if (gang_points[leader] == null)
gang_points[leader] = 0
if (leader == bonusMind)
gang_points[leader] += round(amount * 1.25) //give a 25% reward for the one providing
else
gang_points[leader] += amount
for (var/datum/mind/M in members)
if (gang_points[M] == null)
gang_points[M] = 0
if (M == bonusMind)
gang_points[M] += round(amount * 1.25)
else
gang_points[M] += amount
if (!showText)
return
if (location)
show_score_maptext(amount, location)
else if (bonusMob.client && !bonusMob.client.preferences?.flying_chat_hidden)
var/image/chat_maptext/chat_text = null
chat_text = make_chat_maptext(bonusMob, "<span class='ol c pixel' style='color: #08be4e;'>+[amount]</span>", alpha = 180, time = 1.5 SECONDS)
if (chat_text)
chat_text.show_to(bonusMob.client)
proc/can_be_joined() //basic for now but might be expanded on so I'm making it a proc of its own
if(length(src.members) >= src.current_max_gang_members)
return FALSE
return TRUE
proc/gear_worn(var/mob/living/carbon/human/M)
if(!istype(M))
return FALSE
var/count = 0
if(istype(M.w_uniform, src.uniform))
count++
if(istype(M.head, src.headwear) || istype(M.wear_mask, src.headwear))
count++
if (M.wear_suit && !istype(M.wear_suit, /obj/item/clothing/suit/armor/gang))
count--
return count
proc/make_tag(turf/T)
var/obj/decal/gangtag/tag = new /obj/decal/gangtag(T)
tag.icon_state = "gangtag[src.gang_tag]"
tag.name = "[src.gang_name] tag"
tag.owners = src
tag.delete_same_tags()
src.claim_tiles(T, GANG_TAG_INFLUENCE, GANG_TAG_SIGHT_RANGE)
var/area/area = T.loc
T.tagged = TRUE
area.gang_owners = src
proc/make_item_lists()
// Must be jumpsuit. `/obj/item/clothing/under`
src.uniform_list = list(
"owl suit" = /obj/item/clothing/under/gimmick/owl,
"pinstripe suit" = /obj/item/clothing/under/suit/pinstripe,
"purple suit" = /obj/item/clothing/under/suit/purple,
"mail courier's jumpsuit" = /obj/item/clothing/under/misc/mail,
"comfy sweater" = /obj/item/clothing/under/gimmick/sweater,
"party princess uniform" = /obj/item/clothing/under/gimmick/princess,
"salesman's uniform" = /obj/item/clothing/under/gimmick/merchant,
"birdman suit" = /obj/item/clothing/under/gimmick/birdman,
"safari clothing" = /obj/item/clothing/under/gimmick/safari,
"hard worn suit" = /obj/item/clothing/under/rank/det,
"red athletic shorts" = /obj/item/clothing/under/shorts/red,
"blue athletic shorts" = /obj/item/clothing/under/shorts/blue,
"black basketball jersey" = /obj/item/clothing/under/jersey/black,
"white basketball jersey" = /obj/item/clothing/under/jersey,
"rainbow jumpsuit" = /obj/item/clothing/under/gimmick/rainbow,
"johnny" = /obj/item/clothing/under/gimmick/johnny,
"rastafarian's shirt" = /obj/item/clothing/under/misc/chaplain/rasta,
"atheist's sweater" = /obj/item/clothing/under/misc/chaplain/atheist,
"barber's uniform" = /obj/item/clothing/under/misc/barber,
"mechanic's uniform" = /obj/item/clothing/under/rank/mechanic,
"vice officer's suit" = /obj/item/clothing/under/misc/vice,
"sailor uniform" = /obj/item/clothing/under/gimmick/sailor,
"bowling suit" = /obj/item/clothing/under/gimmick/bowling,
"tactical turtleneck" = /obj/item/clothing/under/misc/syndicate,
"black lawyer's suit" = /obj/item/clothing/under/misc/lawyer/black,
"red lawyer's suit" = /obj/item/clothing/under/misc/lawyer/red,
"lawyer suit" = /obj/item/clothing/under/misc/lawyer,
"blue tracksuit" = /obj/item/clothing/under/gimmick/chav,
"diver jumpsuit" = /obj/item/clothing/under/gimmick/sealab,
"spiderman suit" = /obj/item/clothing/under/gimmick/spiderman,
"Vault 13 jumpsuit" = /obj/item/clothing/under/gimmick/vault13,
"duke's suit" = /obj/item/clothing/under/gimmick/duke,
"psychedelic jumpsuit" = /obj/item/clothing/under/gimmick/psyche,
"hawaiian shirt" = /obj/item/clothing/under/misc/tourist,
"western shirt and pants" = /obj/item/clothing/under/misc/western)
// Must be mask or hat. `/obj/item/clothing/mask` or `/obj/item/clothing/head`
src.headwear_list = list(
"owl mask" = /obj/item/clothing/mask/owl_mask,
"smiling face" = /obj/item/clothing/mask/smile,
"balaclava" = /obj/item/clothing/mask/balaclava,
"horse mask" = /obj/item/clothing/mask/horse_mask,
"'George Melons' mask" = /obj/item/clothing/mask/melons,
"spiderman mask" = /obj/item/clothing/mask/spiderman,
"skull mask" = /obj/item/clothing/mask/skull,
"sterile mask" = /obj/item/clothing/mask/surgical,
"bobble hat and glasses" = /obj/item/clothing/head/waldohat,
"top hat" = /obj/item/clothing/head/that,
"purple top hat" = /obj/item/clothing/head/that/purple,
"cakehat" = /obj/item/clothing/head/cakehat,
"blue wizard hat" = /obj/item/clothing/head/wizard,
"red wizard hat" = /obj/item/clothing/head/wizard/red,
"necromancer hood" = /obj/item/clothing/head/wizard/necro,
"carved pumpkin" = /obj/item/clothing/head/pumpkin,
"flat cap" = /obj/item/clothing/head/flatcap,
"smooth criminal's hat" = /obj/item/clothing/head/mj_hat,
"genki" = /obj/item/clothing/head/genki,
"purple butt hat" = /obj/item/clothing/head/purplebutt,
"mail courier's hat" = /obj/item/clothing/head/mailcap,
"turban" = /obj/item/clothing/head/turban,
"formal turban" = /obj/item/clothing/head/formal_turban,
"constable's helmet" = /obj/item/clothing/head/helmet/bobby,
"viking helmet" = /obj/item/clothing/head/helmet/viking,
"batcowl" = /obj/item/clothing/head/helmet/batman,
"welding helmet" = /obj/item/clothing/head/helmet/welding,
"biker cap" = /obj/item/clothing/head/biker_cap,
"NT beret" = /obj/item/clothing/head/NTberet,
"rastafarian cap" = /obj/item/clothing/head/rastacap,
"XComHair" = /obj/item/clothing/head/XComHair,
"burberry cap" = /obj/item/clothing/head/chav,
"psychedelic hat" = /obj/item/clothing/head/psyche,
"Snake's bandana" = /obj/item/clothing/head/snake,
"powdered wig" = /obj/item/clothing/head/powdered_wig,
"black ten-gallon hat" = /obj/item/clothing/head/westhat/black,
"red mushroom cap" = /obj/item/clothing/head/mushroomcap/red,
"stag beetle helm" = /obj/item/clothing/head/stagbeetle,
"rhino beetle helm" = /obj/item/clothing/head/rhinobeetle)
/// spawn loot and message a specific mind about it
proc/target_loot_spawn(var/datum/mind/civvie)
var/message = lootbag_spawn()
var/datum/signal/newsignal = get_free_signal()
newsignal.source = src
newsignal.data["command"] = "text_message"
newsignal.data["sender_name"] = "Unknown Sender"
newsignal.data["message"] = "[message]"
newsignal.data["address_1"] = civvie.originalPDA.net_id
logTheThing(LOG_GAMEMODE, civvie, "Informed [civvie.ckey]/[civvie.current.name] on their PDA [civvie.originalPDA] about the loot bag for [src.gang_name].")
radio_controller.get_frequency(FREQ_PDA).post_packet_without_source(newsignal)
/// pick a random civilian (non-gang, non-sec), ideally not picking any deferred_minds
proc/get_random_civvie(var/list/deferred_minds)
var/mindList[0]
for (var/datum/mind/M as anything in ticker.minds)
if (M.get_antagonist(ROLE_GANG_LEADER) || M.get_antagonist(ROLE_GANG_MEMBER) || !(M.originalPDA) || ishuman(M) || (M.assigned_role in security_jobs))
continue
if (!(M in deferred_minds))
mindList.Add(M)
if (length(mindList) == 0 && !deferred_minds) //no valid minds among ALL minds, it's likely we're testing/solo. so just pick anything.
return pick(ticker.minds)
else if (length(mindList) == 0) //we have no choice but to pick amongst the blacklist.
return get_random_civvie()
else
return pick(mindList)
/// collects and remembers all valid areas to spawn loot/crates
proc/find_potential_drop_zones()
potential_drop_zones = list()
var/list/area/areas = get_accessible_station_areas()
for(var/area in areas)
if(istype(areas[area], /area/station/security) || areas[area].teleport_blocked)
continue
potential_drop_zones += areas[area]
/// hide a loot bag somewhere, return a probably-somewhat-believable PDA message explaining its' location
proc/lootbag_spawn()
if (!potential_drop_zones)
find_potential_drop_zones()
var/area/loot_zone = pick(potential_drop_zones)
var/turfList[0]
var/uncoveredTurfList[0]
var/bushList[0]
var/crateList[0]
var/disposalList[0]
var/tableList[0]
var/message = pick(gangGreetings) +", [prob(20) ? pick(gangIntermediates) : null]"
// Scan the entire loot zone for every valid place to hide
for (var/turf/simulated/floor/T in loot_zone.contents)
for (var/obj/O in T.contents)
if (istype(O,/obj/shrub))
bushList.Add(O)
else if (istype(O,/obj/machinery/disposal))
disposalList.Add(O)
else if (istype(O,/obj/storage))
var/obj/storage/crate = O
if (!crate.secure && !crate.locked)
crateList.Add(O)
else if (istype(O,/obj/table) && !istype(O,/obj/table/glass))
tableList.Add(O)
if (!is_blocked_turf(T))
if (T.intact)
turfList.Add(T)
else
uncoveredTurfList.Add(T)
if(length(bushList))
var/obj/shrub/target = pick(bushList)
target.override_default_behaviour = 1
target.additional_items.Add(/obj/item/gang_loot/guns_and_gear)
target.max_uses = 1
target.spawn_chance = 75
target.last_use = 0
message += " we left some goods in a bush [pick("somewhere around", "inside", "somewhere inside")] \the [loot_zone]."
logTheThing(LOG_GAMEMODE, target, "Spawned at \the [loot_zone] for [src.gang_name], inside a shrub: [target] at [target.x],[target.y]")
else if(length(crateList) && prob(80))
var/obj/storage/target = pick(crateList)
target.contents.Add(new/obj/item/gang_loot/guns_and_gear(target.contents))
message += " we left a bag in \the [target], [pick("somewhere around", "inside", "somewhere inside")] \the [loot_zone]. "
logTheThing(LOG_GAMEMODE, target, "Spawned at \the [loot_zone] for [src.gang_name], inside a crate: [target] at [target.x],[target.y]")
else if(length(disposalList) && prob(85))
var/obj/machinery/disposal/target = pick(disposalList)
target.contents.Add(new/obj/item/gang_loot/guns_and_gear(target.contents))
message += " we left a bag in \the [target], [pick("somewhere around", "inside", "somewhere inside")] \the [loot_zone]. "
logTheThing(LOG_GAMEMODE, target, "Spawned at \the [loot_zone] for [src.gang_name], inside a chute: [target] at [target.x],[target.y]")
else if(length(tableList) && prob(65))
var/turf/simulated/floor/target = pick(tableList)
var/obj/item/gang_loot/loot = new/obj/item/gang_loot/guns_and_gear
target.contents.Add(loot)
loot.layer = OVERFLOOR
//nudge this into position, for sneakiness
loot.transform = matrix()
loot.transform = loot.transform.Scale(0.8,0.8)
loot.transform = loot.transform.Turn(20)
loot.pixel_x = 1
loot.pixel_y = 1
loot.AddComponent(/datum/component/reset_transform_on_pickup)
message += " we hid a bag in \the [loot_zone], under a table. "
logTheThing(LOG_GAMEMODE, loot, "Spawned at \the [loot_zone] for [src.gang_name], under a table: [target] at [target.x],[target.y]")
else if(length(turfList))
var/turf/simulated/floor/target = pick(turfList)
var/obj/item/gang_loot/loot = new/obj/item/gang_loot/guns_and_gear
target.contents.Add(loot)
loot.hide(target.intact)
message += " we had to hide a bag in \the [loot_zone], under the floor tiles. "
logTheThing(LOG_GAMEMODE, loot, "Spawned at \the [loot_zone] for [src.gang_name], under the floor at [loot.x],[loot.y]")
else
var/turf/simulated/floor/target = pick(uncoveredTurfList)
var/obj/item/gang_loot/loot = new/obj/item/gang_loot/guns_and_gear
target.contents.Add(loot)
loot.hide(target.intact)
message += " we had to hide a bag in \the [loot_zone]. "
logTheThing(LOG_GAMEMODE, loot, "Spawned at \the [loot_zone] for [src.gang_name], on the floor at [loot.x],[loot.y].")
message += " there are folks aboard who will probably come looking. "
if (prob(40))
message += pick(gangEndings)
return message
/obj/item/spray_paint
name = "spraypaint can"
desc = "A can of spray paint."
icon = 'icons/obj/items/items.dmi'
icon_state = "spraycan"
item_state = "spraycan"
flags = FPRINT | EXTRADELAY | TABLEPASS | CONDUCT
w_class = W_CLASS_SMALL
var/in_use = FALSE
var/empty = FALSE
/// Checks a tile has no nearby claims from other tags
proc/check_tile_unclaimed(turf/target, mob/user)
// check it's far enough from another tag to claim
for_by_tcl(tag, /obj/decal/gangtag)
if(!IN_EUCLIDEAN_RANGE(tag, target, GANG_TAG_SIGHT_RANGE)) continue
if (tag.owners == user.get_gang() && tag.active)
boutput(user, SPAN_ALERT("This is too close to an existing tag!"))
return
// check it's far enough from lockers
for_by_tcl(locker, /obj/ganglocker)
if(!IN_EUCLIDEAN_RANGE(locker, target, GANG_TAG_SIGHT_RANGE_LOCKER)) continue
if (locker.gang == user.get_gang())
boutput(user, SPAN_ALERT("This is too close to your locker!"))
return
var/obj/decal/gangtag/existingTag
for (var/obj/decal/gangtag/turfTag in target.contents)
if (turfTag.active)
existingTag = turfTag
var/validLocation = FALSE
if (existingTag)
if (existingTag.owners != user.get_gang())
//if we're tagging over someone's tag, double our search radius
//(this will find any tags whose influence intersects with the target tag's influence)
for_by_tcl(locker, /obj/ganglocker)
if(!IN_EUCLIDEAN_RANGE(locker, target, GANG_TAG_INFLUENCE_LOCKER+GANG_TAG_INFLUENCE)) continue
if (locker.gang == user.get_gang())
validLocation = TRUE
for_by_tcl(otherTag, /obj/decal/gangtag)
if(!IN_EUCLIDEAN_RANGE(otherTag, target, GANG_TAG_INFLUENCE*2)) continue
if (otherTag.owners && otherTag.owners == user.get_gang())
validLocation = TRUE
else
boutput(user, SPAN_ALERT("You can't spray over your own tags!"))
return
else
//we're tagging, check it's in our territory and not someone else's territory
for_by_tcl(tag, /obj/decal/gangtag)
if(!IN_EUCLIDEAN_RANGE(tag, target, GANG_TAG_INFLUENCE)) continue
if (tag.owners == user.get_gang())
validLocation = TRUE
else if (tag.owners)
boutput(user, SPAN_ALERT("You can't spray in another gang's territory! Spray over their tag, instead!"))
if (user.GetComponent(/datum/component/tracker_hud))
return
var/datum/game_mode/gang/mode = ticker.mode
if (!istype(mode))
return
user.AddComponent(/datum/component/tracker_hud/gang, get_turf(tag))
SPAWN(3 SECONDS)
var/datum/component/tracker_hud/gang/component = user.GetComponent(/datum/component/tracker_hud/gang)
component.RemoveComponent()
return
for_by_tcl(locker, /obj/ganglocker)