forked from ciribob/DCS-CTLD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CTLD.lua
6427 lines (4665 loc) · 210 KB
/
CTLD.lua
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
--[[
Combat Troop and Logistics Drop
Allows Huey, Mi-8 and C130 to transport troops internally and Helicopters to transport Logistic / Vehicle units to the field via sling-loads
without requiring external mods.
Supports all of the original CTTS functionality such as AI auto troop load and unload as well as group spawning and preloading of troops into units.
Supports deployment of Auto Lasing JTAC to the field
See https://github.com/ciribob/DCS-CTLD for a user manual and the latest version
Contributors:
- Steggles - https://github.com/Bob7heBuilder
- mvee - https://github.com/mvee
- jmontleon - https://github.com/jmontleon
- emilianomolina - https://github.com/emilianomolina
- davidp57 - https://github.com/veaf
- Allow minimum distance from friendly logistics to be set
]]
ctld = {} -- DONT REMOVE!
--- Identifier. All output in DCS.log will start with this.
ctld.Id = "CTLD - "
--- Version.
ctld.Version = "20211113.01"
-- debug level, specific to this module
ctld.Debug = true
-- trace level, specific to this module
ctld.Trace = true
ctld.alreadyInitialized = false -- if true, ctld.initialize() will not run
-- ************************************************************************
-- ********************* USER CONFIGURATION ******************************
-- ************************************************************************
ctld.staticBugWorkaround = false -- DCS had a bug where destroying statics would cause a crash. If this happens again, set this to TRUE
ctld.disableAllSmoke = false -- if true, all smoke is diabled at pickup and drop off zones regardless of settings below. Leave false to respect settings below
ctld.hoverPickup = true -- if set to false you can load crates with the F10 menu instead of hovering... Only if not using real crates!
ctld.enableCrates = true -- if false, Helis will not be able to spawn or unpack crates so will be normal CTTS
ctld.slingLoad = false -- if false, crates can be used WITHOUT slingloading, by hovering above the crate, simulating slingloading but not the weight...
-- There are some bug with Sling-loading that can cause crashes, if these occur set slingLoad to false
-- to use the other method.
-- Set staticBugFix to FALSE if use set ctld.slingLoad to TRUE
ctld.enableSmokeDrop = true -- if false, helis and c-130 will not be able to drop smoke
ctld.maxExtractDistance = 125 -- max distance from vehicle to troops to allow a group extraction
ctld.maximumDistanceLogistic = 200 -- max distance from vehicle to logistics to allow a loading or spawning operation
ctld.maximumSearchDistance = 4000 -- max distance for troops to search for enemy
ctld.maximumMoveDistance = 2000 -- max distance for troops to move from drop point if no enemy is nearby
ctld.minimumDeployDistance = 1000 -- minimum distance from a friendly pickup zone where you can deploy a crate
ctld.numberOfTroops = 10 -- default number of troops to load on a transport heli or C-130
-- also works as maximum size of group that'll fit into a helicopter unless overridden
ctld.enableFastRopeInsertion = true -- allows you to drop troops by fast rope
ctld.fastRopeMaximumHeight = 18.28 -- in meters which is 60 ft max fast rope (not rappell) safe height
ctld.vehiclesForTransportRED = { "BRDM-2", "BTR_D" } -- vehicles to load onto Il-76 - Alternatives {"Strela-1 9P31","BMP-1"}
ctld.vehiclesForTransportBLUE = { "M1045 HMMWV TOW", "M1043 HMMWV Armament" } -- vehicles to load onto c130 - Alternatives {"M1128 Stryker MGS","M1097 Avenger"}
ctld.vehiclesWeight = {
["BRDM-2"] = 7000,
["BTR_D"] = 8000,
["M1045 HMMWV TOW"] = 3220,
["M1043 HMMWV Armament"] = 2500
}
ctld.aaLaunchers = 3 -- controls how many launchers to add to the kub/buk when its spawned.
ctld.hawkLaunchers = 8 -- controls how many launchers to add to the hawk when its spawned.
ctld.spawnRPGWithCoalition = true --spawns a friendly RPG unit with Coalition forces
ctld.spawnStinger = false -- spawns a stinger / igla soldier with a group of 6 or more soldiers!
ctld.enabledFOBBuilding = true -- if true, you can load a crate INTO a C-130 than when unpacked creates a Forward Operating Base (FOB) which is a new place to spawn (crates) and carry crates from
-- In future i'd like it to be a FARP but so far that seems impossible...
-- You can also enable troop Pickup at FOBS
ctld.cratesRequiredForFOB = 3 -- The amount of crates required to build a FOB. Once built, helis can spawn crates at this outpost to be carried and deployed in another area.
-- The large crates can only be loaded and dropped by large aircraft, like the C-130 and listed in ctld.vehicleTransportEnabled
-- Small FOB crates can be moved by helicopter. The FOB will require ctld.cratesRequiredForFOB larges crates and small crates are 1/3 of a large fob crate
-- To build the FOB entirely out of small crates you will need ctld.cratesRequiredForFOB * 3
ctld.troopPickupAtFOB = true -- if true, troops can also be picked up at a created FOB
ctld.buildTimeFOB = 120 --time in seconds for the FOB to be built
ctld.crateWaitTime = 120 -- time in seconds to wait before you can spawn another crate
ctld.forceCrateToBeMoved = true -- a crate must be picked up at least once and moved before it can be unpacked. Helps to reduce crate spam
ctld.radioSound = "beacon.ogg" -- the name of the sound file to use for the FOB radio beacons. If this isnt added to the mission BEACONS WONT WORK!
ctld.radioSoundFC3 = "beaconsilent.ogg" -- name of the second silent radio file, used so FC3 aircraft dont hear ALL the beacon noises... :)
ctld.deployedBeaconBattery = 30 -- the battery on deployed beacons will last for this number minutes before needing to be re-deployed
ctld.enabledRadioBeaconDrop = true -- if its set to false then beacons cannot be dropped by units
ctld.allowRandomAiTeamPickups = false -- Allows the AI to randomize the loading of infantry teams (specified below) at pickup zones
-- Simulated Sling load configuration
ctld.minimumHoverHeight = 7.5 -- Lowest allowable height for crate hover
ctld.maximumHoverHeight = 12.0 -- Highest allowable height for crate hover
ctld.maxDistanceFromCrate = 5.5 -- Maximum distance from from crate for hover
ctld.hoverTime = 10 -- Time to hold hover above a crate for loading in seconds
-- end of Simulated Sling load configuration
-- AA SYSTEM CONFIG --
-- Sets a limit on the number of active AA systems that can be built for RED.
-- A system is counted as Active if its fully functional and has all parts
-- If a system is partially destroyed, it no longer counts towards the total
-- When this limit is hit, a player will still be able to get crates for an AA system, just unable
-- to unpack them
ctld.AASystemLimitRED = 20 -- Red side limit
ctld.AASystemLimitBLUE = 20 -- Blue side limit
--END AA SYSTEM CONFIG --
-- ***************** JTAC CONFIGURATION *****************
ctld.JTAC_LIMIT_RED = 10 -- max number of JTAC Crates for the RED Side
ctld.JTAC_LIMIT_BLUE = 10 -- max number of JTAC Crates for the BLUE Side
ctld.JTAC_dropEnabled = true -- allow JTAC Crate spawn from F10 menu
ctld.JTAC_maxDistance = 10000 -- How far a JTAC can "see" in meters (with Line of Sight)
ctld.JTAC_smokeOn_RED = true -- enables marking of target with smoke for RED forces
ctld.JTAC_smokeOn_BLUE = true -- enables marking of target with smoke for BLUE forces
ctld.JTAC_smokeColour_RED = 4 -- RED side smoke colour -- Green = 0 , Red = 1, White = 2, Orange = 3, Blue = 4
ctld.JTAC_smokeColour_BLUE = 1 -- BLUE side smoke colour -- Green = 0 , Red = 1, White = 2, Orange = 3, Blue = 4
ctld.JTAC_jtacStatusF10 = true -- enables F10 JTAC Status menu
ctld.JTAC_location = true -- shows location of target in JTAC message
ctld.location_DMS = false -- shows coordinates as Degrees Minutes Seconds instead of Degrees Decimal minutes
ctld.JTAC_lock = "all" -- "vehicle" OR "troop" OR "all" forces JTAC to only lock vehicles or troops or all ground units
-- ***************** Pickup, dropoff and waypoint zones *****************
-- Available colors (anything else like "none" disables smoke): "green", "red", "white", "orange", "blue", "none",
-- Use any of the predefined names or set your own ones
-- You can add number as a third option to limit the number of soldier or vehicle groups that can be loaded from a zone.
-- Dropping back a group at a limited zone will add one more to the limit
-- If a zone isn't ACTIVE then you can't pickup from that zone until the zone is activated by ctld.activatePickupZone
-- using the Mission editor
-- You can pickup from a SHIP by adding the SHIP UNIT NAME instead of a zone name
-- Side - Controls which side can load/unload troops at the zone
-- Flag Number - Optional last field. If set the current number of groups remaining can be obtained from the flag value
--pickupZones = { "Zone name or Ship Unit Name", "smoke color", "limit (-1 unlimited)", "ACTIVE (yes/no)", "side (0 = Both sides / 1 = Red / 2 = Blue )", flag number (optional) }
ctld.pickupZones = {
{ "pickzone1", "blue", -1, "yes", 0 },
{ "pickzone2", "red", -1, "yes", 0 },
{ "pickzone3", "none", -1, "yes", 0 },
{ "pickzone4", "none", -1, "yes", 0 },
{ "pickzone5", "none", -1, "yes", 0 },
{ "pickzone6", "none", -1, "yes", 0 },
{ "pickzone7", "none", -1, "yes", 0 },
{ "pickzone8", "none", -1, "yes", 0 },
{ "pickzone9", "none", 5, "yes", 1 }, -- limits pickup zone 9 to 5 groups of soldiers or vehicles, only red can pick up
{ "pickzone10", "none", 10, "yes", 2 }, -- limits pickup zone 10 to 10 groups of soldiers or vehicles, only blue can pick up
{ "pickzone11", "blue", 20, "no", 2 }, -- limits pickup zone 11 to 20 groups of soldiers or vehicles, only blue can pick up. Zone starts inactive!
{ "pickzone12", "red", 20, "no", 1 }, -- limits pickup zone 11 to 20 groups of soldiers or vehicles, only blue can pick up. Zone starts inactive!
{ "pickzone13", "none", -1, "yes", 0 },
{ "pickzone14", "none", -1, "yes", 0 },
{ "pickzone15", "none", -1, "yes", 0 },
{ "pickzone16", "none", -1, "yes", 0 },
{ "pickzone17", "none", -1, "yes", 0 },
{ "pickzone18", "none", -1, "yes", 0 },
{ "pickzone19", "none", 5, "yes", 0 },
{ "pickzone20", "none", 10, "yes", 0, 1000 }, -- optional extra flag number to store the current number of groups available in
{ "USA Carrier", "blue", 10, "yes", 0, 1001 }, -- instead of a Zone Name you can also use the UNIT NAME of a ship
}
-- dropOffZones = {"name","smoke colour",0,side 1 = Red or 2 = Blue or 0 = Both sides}
ctld.dropOffZones = {
{ "dropzone1", "green", 2 },
{ "dropzone2", "blue", 2 },
{ "dropzone3", "orange", 2 },
{ "dropzone4", "none", 2 },
{ "dropzone5", "none", 1 },
{ "dropzone6", "none", 1 },
{ "dropzone7", "none", 1 },
{ "dropzone8", "none", 1 },
{ "dropzone9", "none", 1 },
{ "dropzone10", "none", 1 },
}
--wpZones = { "Zone name", "smoke color", "ACTIVE (yes/no)", "side (0 = Both sides / 1 = Red / 2 = Blue )", }
ctld.wpZones = {
{ "wpzone1", "green","yes", 2 },
{ "wpzone2", "blue","yes", 2 },
{ "wpzone3", "orange","yes", 2 },
{ "wpzone4", "none","yes", 2 },
{ "wpzone5", "none","yes", 2 },
{ "wpzone6", "none","yes", 1 },
{ "wpzone7", "none","yes", 1 },
{ "wpzone8", "none","yes", 1 },
{ "wpzone9", "none","yes", 1 },
{ "wpzone10", "none","no", 0 }, -- Both sides as its set to 0
}
-- ******************** Transports names **********************
-- Use any of the predefined names or set your own ones
ctld.transportPilotNames = {
"helicargo1",
"helicargo2",
"helicargo3",
"helicargo4",
"helicargo5",
"helicargo6",
"helicargo7",
"helicargo8",
"helicargo9",
"helicargo10",
"helicargo11",
"helicargo12",
"helicargo13",
"helicargo14",
"helicargo15",
"helicargo16",
"helicargo17",
"helicargo18",
"helicargo19",
"helicargo20",
"helicargo21",
"helicargo22",
"helicargo23",
"helicargo24",
"helicargo25",
"MEDEVAC #1",
"MEDEVAC #2",
"MEDEVAC #3",
"MEDEVAC #4",
"MEDEVAC #5",
"MEDEVAC #6",
"MEDEVAC #7",
"MEDEVAC #8",
"MEDEVAC #9",
"MEDEVAC #10",
"MEDEVAC #11",
"MEDEVAC #12",
"MEDEVAC #13",
"MEDEVAC #14",
"MEDEVAC #15",
"MEDEVAC #16",
"MEDEVAC RED #1",
"MEDEVAC RED #2",
"MEDEVAC RED #3",
"MEDEVAC RED #4",
"MEDEVAC RED #5",
"MEDEVAC RED #6",
"MEDEVAC RED #7",
"MEDEVAC RED #8",
"MEDEVAC RED #9",
"MEDEVAC RED #10",
"MEDEVAC RED #11",
"MEDEVAC RED #12",
"MEDEVAC RED #13",
"MEDEVAC RED #14",
"MEDEVAC RED #15",
"MEDEVAC RED #16",
"MEDEVAC RED #17",
"MEDEVAC RED #18",
"MEDEVAC RED #19",
"MEDEVAC RED #20",
"MEDEVAC RED #21",
"MEDEVAC BLUE #1",
"MEDEVAC BLUE #2",
"MEDEVAC BLUE #3",
"MEDEVAC BLUE #4",
"MEDEVAC BLUE #5",
"MEDEVAC BLUE #6",
"MEDEVAC BLUE #7",
"MEDEVAC BLUE #8",
"MEDEVAC BLUE #9",
"MEDEVAC BLUE #10",
"MEDEVAC BLUE #11",
"MEDEVAC BLUE #12",
"MEDEVAC BLUE #13",
"MEDEVAC BLUE #14",
"MEDEVAC BLUE #15",
"MEDEVAC BLUE #16",
"MEDEVAC BLUE #17",
"MEDEVAC BLUE #18",
"MEDEVAC BLUE #19",
"MEDEVAC BLUE #20",
"MEDEVAC BLUE #21",
-- *** AI transports names (different names only to ease identification in mission) ***
-- Use any of the predefined names or set your own ones
"transport1",
"transport2",
"transport3",
"transport4",
"transport5",
"transport6",
"transport7",
"transport8",
"transport9",
"transport10",
"transport11",
"transport12",
"transport13",
"transport14",
"transport15",
"transport16",
"transport17",
"transport18",
"transport19",
"transport20",
"transport21",
"transport22",
"transport23",
"transport24",
"transport25",
}
-- *************** Optional Extractable GROUPS *****************
-- Use any of the predefined names or set your own ones
ctld.extractableGroups = {
"extract1",
"extract2",
"extract3",
"extract4",
"extract5",
"extract6",
"extract7",
"extract8",
"extract9",
"extract10",
"extract11",
"extract12",
"extract13",
"extract14",
"extract15",
"extract16",
"extract17",
"extract18",
"extract19",
"extract20",
"extract21",
"extract22",
"extract23",
"extract24",
"extract25",
}
-- ************** Logistics UNITS FOR CRATE SPAWNING ******************
-- Use any of the predefined names or set your own ones
-- When a logistic unit is destroyed, you will no longer be able to spawn crates
ctld.logisticUnits = {
"logistic1",
"logistic2",
"logistic3",
"logistic4",
"logistic5",
"logistic6",
"logistic7",
"logistic8",
"logistic9",
"logistic10",
}
-- ************** UNITS ABLE TO TRANSPORT VEHICLES ******************
-- Add the model name of the unit that you want to be able to transport and deploy vehicles
-- units db has all the names or you can extract a mission.miz file by making it a zip and looking
-- in the contained mission file
ctld.vehicleTransportEnabled = {
"76MD", -- the il-76 mod doesnt use a normal - sign so il-76md wont match... !!!! GRR
"Hercules",
}
-- ************** Maximum Units SETUP for UNITS ******************
-- Put the name of the Unit you want to limit group sizes too
-- i.e
-- ["UH-1H"] = 10,
--
-- Will limit UH1 to only transport groups with a size 10 or less
-- Make sure the unit name is exactly right or it wont work
ctld.unitLoadLimits = {
-- Remove the -- below to turn on options
-- ["SA342Mistral"] = 4,
-- ["SA342L"] = 4,
-- ["SA342M"] = 4,
}
-- ************** Allowable actions for UNIT TYPES ******************
-- Put the name of the Unit you want to limit actions for
-- NOTE - the unit must've been listed in the transportPilotNames list above
-- This can be used in conjunction with the options above for group sizes
-- By default you can load both crates and troops unless overriden below
-- i.e
-- ["UH-1H"] = {crates=true, troops=false},
--
-- Will limit UH1 to only transport CRATES but NOT TROOPS
--
-- ["SA342Mistral"] = {crates=fales, troops=true},
-- Will allow Mistral Gazelle to only transport crates, not troops
ctld.unitActions = {
-- Remove the -- below to turn on options
-- ["SA342Mistral"] = {crates=true, troops=true},
-- ["SA342L"] = {crates=false, troops=true},
-- ["SA342M"] = {crates=false, troops=true},
}
-- ************** WEIGHT CALCULATIONS FOR INFANTRY GROUPS ******************
-- Infantry groups weight is calculated based on the soldiers' roles, and the weight of their kit
-- Every soldier weights between 90% and 120% of ctld.SOLDIER_WEIGHT, and they all carry a backpack and their helmet (ctld.KIT_WEIGHT)
-- Standard grunts have a rifle and ammo (ctld.RIFLE_WEIGHT)
-- AA soldiers have a MANPAD tube (ctld.MANPAD_WEIGHT)
-- Anti-tank soldiers have a RPG and a rocket (ctld.RPG_WEIGHT)
-- Machine gunners have the squad MG and 200 bullets (ctld.MG_WEIGHT)
-- JTAC have the laser sight, radio and binoculars (ctld.JTAC_WEIGHT)
-- Mortar servants carry their tube and a few rounds (ctld.MORTAR_WEIGHT)
ctld.SOLDIER_WEIGHT = 80 -- kg, will be randomized between 90% and 120%
ctld.KIT_WEIGHT = 20 -- kg
ctld.RIFLE_WEIGHT = 5 -- kg
ctld.MANPAD_WEIGHT = 18 -- kg
ctld.RPG_WEIGHT = 7.6 -- kg
ctld.MG_WEIGHT = 10 -- kg
ctld.MORTAR_WEIGHT = 26 -- kg
ctld.JTAC_WEIGHT = 15 -- kg
-- ************** INFANTRY GROUPS FOR PICKUP ******************
-- Unit Types
-- inf is normal infantry
-- mg is M249
-- at is RPG-16
-- aa is Stinger or Igla
-- mortar is a 2B11 mortar unit
-- jtac is a JTAC soldier, which will use JTACAutoLase
-- You must add a name to the group for it to work
-- You can also add an optional coalition side to limit the group to one side
-- for the side - 2 is BLUE and 1 is RED
ctld.loadableGroups = {
{name = "Standard Group", inf = 6, mg = 2, at = 2 }, -- will make a loadable group with 6 infantry, 2 MGs and 2 anti-tank for both coalitions
{name = "Anti Air", inf = 2, aa = 3 },
{name = "Anti Tank", inf = 2, at = 6 },
{name = "Mortar Squad", mortar = 6 },
{name = "JTAC Group", inf = 4, jtac = 1 }, -- will make a loadable group with 4 infantry and a JTAC soldier for both coalitions
{name = "Single JTAC", jtac = 1 }, -- will make a loadable group witha single JTAC soldier for both coalitions
-- {name = "Mortar Squad Red", inf = 2, mortar = 5, side =1 }, --would make a group loadable by RED only
}
-- ************** SPAWNABLE CRATES ******************
-- Weights must be unique as we use the weight to change the cargo to the correct unit
-- when we unpack
--
ctld.spawnableCrates = {
-- name of the sub menu on F10 for spawning crates
["Ground Forces"] = {
--crates you can spawn
-- weight in KG
-- Desc is the description on the F10 MENU
-- unit is the model name of the unit to spawn
-- cratesRequired - if set requires that many crates of the same type within 100m of each other in order build the unit
-- side is optional but 2 is BLUE and 1 is RED
-- dont use that option with the HAWK Crates
{ weight = 500, desc = "HMMWV - TOW", unit = "M1045 HMMWV TOW", side = 2 },
{ weight = 505, desc = "HMMWV - MG", unit = "M1043 HMMWV Armament", side = 2 },
{ weight = 510, desc = "BTR-D", unit = "BTR_D", side = 1 },
{ weight = 515, desc = "BRDM-2", unit = "BRDM-2", side = 1 },
{ weight = 520, desc = "HMMWV - JTAC", unit = "Hummer", side = 2, }, -- used as jtac and unarmed, not on the crate list if JTAC is disabled
{ weight = 525, desc = "SKP-11 - JTAC", unit = "SKP-11", side = 1, }, -- used as jtac and unarmed, not on the crate list if JTAC is disabled
{ weight = 100, desc = "2B11 Mortar", unit = "2B11 mortar" },
{ weight = 250, desc = "SPH 2S19 Msta", unit = "SAU Msta", side = 1, cratesRequired = 3 },
{ weight = 255, desc = "M-109", unit = "M-109", side = 2, cratesRequired = 3 },
{ weight = 252, desc = "Ural-375 Ammo Truck", unit = "Ural-375", side = 1, cratesRequired = 2 },
{ weight = 253, desc = "M-818 Ammo Truck", unit = "M 818", side = 2, cratesRequired = 2 },
{ weight = 800, desc = "FOB Crate - Small", unit = "FOB-SMALL" }, -- Builds a FOB! - requires 3 * ctld.cratesRequiredForFOB
},
["AA short range"] = {
{ weight = 50, desc = "Stinger", unit = "Soldier stinger", side = 2 },
{ weight = 55, desc = "Igla", unit = "SA-18 Igla manpad", side = 1 },
{ weight = 405, desc = "Strela-1 9P31", unit = "Strela-1 9P31", side = 1, cratesRequired = 3 },
{ weight = 400, desc = "M1097 Avenger", unit = "M1097 Avenger", side = 2, cratesRequired = 3 },
},
["AA mid range"] = {
-- HAWK System
{ weight = 540, desc = "HAWK Launcher", unit = "Hawk ln", side = 2},
{ weight = 545, desc = "HAWK Search Radar", unit = "Hawk sr", side = 2 },
{ weight = 546, desc = "HAWK Track Radar", unit = "Hawk tr", side = 2 },
{ weight = 547, desc = "HAWK PCP", unit = "Hawk pcp" , side = 2 }, -- Remove this if on 1.2
{ weight = 548, desc = "HAWK CWAR", unit = "Hawk cwar" , side = 2 }, -- Remove this if on 2.5
{ weight = 549, desc = "HAWK Repair", unit = "HAWK Repair" , side = 2 },
-- End of HAWK
-- KUB SYSTEM
{ weight = 560, desc = "KUB Launcher", unit = "Kub 2P25 ln", side = 1},
{ weight = 565, desc = "KUB Radar", unit = "Kub 1S91 str", side = 1 },
{ weight = 570, desc = "KUB Repair", unit = "KUB Repair", side = 1},
-- End of KUB
-- BUK System
-- { weight = 575, desc = "BUK Launcher", unit = "SA-11 Buk LN 9A310M1"},
-- { weight = 580, desc = "BUK Search Radar", unit = "SA-11 Buk SR 9S18M1"},
-- { weight = 585, desc = "BUK CC Radar", unit = "SA-11 Buk CC 9S470M1"},
-- { weight = 590, desc = "BUK Repair", unit = "BUK Repair"},
-- END of BUK
},
["AA long range"] = {
-- Patriot System
{ weight = 555, desc = "Patriot Launcher", unit = "Patriot ln", side = 2 },
{ weight = 556, desc = "Patriot Radar", unit = "Patriot str" , side = 2 },
{ weight = 557, desc = "Patriot ECS", unit = "Patriot ECS", side = 2 },
-- { weight = 553, desc = "Patriot ICC", unit = "Patriot cp", side = 2 },
-- { weight = 554, desc = "Patriot EPP", unit = "Patriot EPP", side = 2 },
{ weight = 558, desc = "Patriot AMG (optional)", unit = "Patriot AMG" , side = 2 },
{ weight = 559, desc = "Patriot Repair", unit = "Patriot Repair" , side = 2 },
-- End of Patriot
{ weight = 595, desc = "Early Warning Radar", unit = "1L13 EWR", side = 1 }, -- cant be used by BLUE coalition
},
}
--- 3D model that will be used to represent a loadable crate ; by default, a generator
ctld.spawnableCratesModel_load = {
["category"] = "Fortifications",
["shape_name"] = "GeneratorF",
["type"] = "GeneratorF"
}
--- 3D model that will be used to represent a slingable crate ; by default, a crate
ctld.spawnableCratesModel_sling = {
["category"] = "Cargos",
["shape_name"] = "bw_container_cargo",
["type"] = "container_cargo"
}
--[[ Placeholder for different type of cargo containers. Let's say pipes and trunks, fuel for FOB building
["shape_name"] = "ab-212_cargo",
["type"] = "uh1h_cargo" --new type for the container previously used
["shape_name"] = "ammo_box_cargo",
["type"] = "ammo_cargo",
["shape_name"] = "barrels_cargo",
["type"] = "barrels_cargo",
["shape_name"] = "bw_container_cargo",
["type"] = "container_cargo",
["shape_name"] = "f_bar_cargo",
["type"] = "f_bar_cargo",
["shape_name"] = "fueltank_cargo",
["type"] = "fueltank_cargo",
["shape_name"] = "iso_container_cargo",
["type"] = "iso_container",
["shape_name"] = "iso_container_small_cargo",
["type"] = "iso_container_small",
["shape_name"] = "oiltank_cargo",
["type"] = "oiltank_cargo",
["shape_name"] = "pipes_big_cargo",
["type"] = "pipes_big_cargo",
["shape_name"] = "pipes_small_cargo",
["type"] = "pipes_small_cargo",
["shape_name"] = "tetrapod_cargo",
["type"] = "tetrapod_cargo",
["shape_name"] = "trunks_long_cargo",
["type"] = "trunks_long_cargo",
["shape_name"] = "trunks_small_cargo",
["type"] = "trunks_small_cargo",
]]--
-- if the unit is on this list, it will be made into a JTAC when deployed
ctld.jtacUnitTypes = {
"SKP", "Hummer" -- there are some wierd encoding issues so if you write SKP-11 it wont match as the - sign is encoded differently...
}
-- ***************************************************************
-- **************** Mission Editor Functions *********************
-- ***************************************************************
-----------------------------------------------------------------
-- Spawn group at a trigger and set them as extractable. Usage:
-- ctld.spawnGroupAtTrigger("groupside", number, "triggerName", radius)
-- Variables:
-- "groupSide" = "red" for Russia "blue" for USA
-- _number = number of groups to spawn OR Group description
-- "triggerName" = trigger name in mission editor between commas
-- _searchRadius = random distance for units to move from spawn zone (0 will leave troops at the spawn position - no search for enemy)
--
-- Example: ctld.spawnGroupAtTrigger("red", 2, "spawn1", 1000)
--
-- This example will spawn 2 groups of russians at the specified point
-- and they will search for enemy or move randomly withing 1000m
-- OR
--
-- ctld.spawnGroupAtTrigger("blue", {mg=1,at=2,aa=3,inf=4,mortar=5},"spawn2", 2000)
-- Spawns 1 machine gun, 2 anti tank, 3 anti air, 4 standard soldiers and 5 mortars
--
function ctld.spawnGroupAtTrigger(_groupSide, _number, _triggerName, _searchRadius)
local _spawnTrigger = trigger.misc.getZone(_triggerName) -- trigger to use as reference position
if _spawnTrigger == nil then
trigger.action.outText("CTLD.lua ERROR: Cant find trigger called " .. _triggerName, 10)
return
end
local _country
if _groupSide == "red" then
_groupSide = 1
_country = 0
else
_groupSide = 2
_country = 2
end
if _searchRadius < 0 then
_searchRadius = 0
end
local _pos2 = { x = _spawnTrigger.point.x, y = _spawnTrigger.point.z }
local _alt = land.getHeight(_pos2)
local _pos3 = { x = _pos2.x, y = _alt, z = _pos2.y }
local _groupDetails = ctld.generateTroopTypes(_groupSide, _number, _country)
local _droppedTroops = ctld.spawnDroppedGroup(_pos3, _groupDetails, false, _searchRadius);
if _groupSide == 1 then
table.insert(ctld.droppedTroopsRED, _droppedTroops:getName())
else
table.insert(ctld.droppedTroopsBLUE, _droppedTroops:getName())
end
end
-----------------------------------------------------------------
-- Spawn group at a Vec3 Point and set them as extractable. Usage:
-- ctld.spawnGroupAtPoint("groupside", number,Vec3 Point, radius)
-- Variables:
-- "groupSide" = "red" for Russia "blue" for USA
-- _number = number of groups to spawn OR Group Description
-- Vec3 Point = A vec3 point like {x=1,y=2,z=3}. Can be obtained from a unit like so: Unit.getName("Unit1"):getPoint()
-- _searchRadius = random distance for units to move from spawn zone (0 will leave troops at the spawn position - no search for enemy)
--
-- Example: ctld.spawnGroupAtPoint("red", 2, {x=1,y=2,z=3}, 1000)
--
-- This example will spawn 2 groups of russians at the specified point
-- and they will search for enemy or move randomly withing 1000m
-- OR
--
-- ctld.spawnGroupAtPoint("blue", {mg=1,at=2,aa=3,inf=4,mortar=5}, {x=1,y=2,z=3}, 2000)
-- Spawns 1 machine gun, 2 anti tank, 3 anti air, 4 standard soldiers and 5 mortars
function ctld.spawnGroupAtPoint(_groupSide, _number, _point, _searchRadius)
local _country
if _groupSide == "red" then
_groupSide = 1
_country = 0
else
_groupSide = 2
_country = 2
end
if _searchRadius < 0 then
_searchRadius = 0
end
local _groupDetails = ctld.generateTroopTypes(_groupSide, _number, _country)
local _droppedTroops = ctld.spawnDroppedGroup(_point, _groupDetails, false, _searchRadius);
if _groupSide == 1 then
table.insert(ctld.droppedTroopsRED, _droppedTroops:getName())
else
table.insert(ctld.droppedTroopsBLUE, _droppedTroops:getName())
end
end
-- Preloads a transport with troops or vehicles
-- replaces any troops currently on board
function ctld.preLoadTransport(_unitName, _number, _troops)
local _unit = ctld.getTransportUnit(_unitName)
if _unit ~= nil then
-- will replace any units currently on board
-- if not ctld.troopsOnboard(_unit,_troops) then
ctld.loadTroops(_unit, _troops, _number)
-- end
end
end
-- Continuously counts the number of crates in a zone and sets the value of the passed in flag
-- to the count amount
-- This means you can trigger actions based on the count and also trigger messages before the count is reached
-- Just pass in the zone name and flag number like so as a single (NOT Continuous) Trigger
-- This will now work for Mission Editor and Spawned Crates
-- e.g. ctld.cratesInZone("DropZone1", 5)
function ctld.cratesInZone(_zone, _flagNumber)
local _triggerZone = trigger.misc.getZone(_zone) -- trigger to use as reference position
if _triggerZone == nil then
trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zone, 10)
return
end
local _zonePos = mist.utils.zoneToVec3(_zone)
--ignore side, if crate has been used its discounted from the count
local _crateTables = { ctld.spawnedCratesRED, ctld.spawnedCratesBLUE, ctld.missionEditorCargoCrates }
local _crateCount = 0
for _, _crates in pairs(_crateTables) do
for _crateName, _dontUse in pairs(_crates) do
--get crate
local _crate = ctld.getCrateObject(_crateName)
--in air seems buggy with crates so if in air is true, get the height above ground and the speed magnitude
if _crate ~= nil and _crate:getLife() > 0
and (ctld.inAir(_crate) == false) then
local _dist = ctld.getDistance(_crate:getPoint(), _zonePos)
if _dist <= _triggerZone.radius then
_crateCount = _crateCount + 1
end
end
end
end
--set flag stuff
trigger.action.setUserFlag(_flagNumber, _crateCount)
-- env.info("FLAG ".._flagNumber.." crates ".._crateCount)
--retrigger in 5 seconds
timer.scheduleFunction(function(_args)
ctld.cratesInZone(_args[1], _args[2])
end, { _zone, _flagNumber }, timer.getTime() + 5)
end
-- Creates an extraction zone
-- any Soldiers (not vehicles) dropped at this zone by a helicopter will disappear
-- and be added to a running total of soldiers for a set flag number
-- The idea is you can then drop say 20 troops in a zone and trigger an action using the mission editor triggers
-- and the flag value
--
-- The ctld.createExtractZone function needs to be called once in a trigger action do script.
-- if you dont want smoke, pass -1 to the function.
--Green = 0 , Red = 1, White = 2, Orange = 3, Blue = 4, NO SMOKE = -1
--
-- e.g. ctld.createExtractZone("extractzone1", 2, -1) will create an extraction zone at trigger zone "extractzone1", store the number of troops dropped at
-- the zone in flag 2 and not have smoke
--
--
--
function ctld.createExtractZone(_zone, _flagNumber, _smoke)
local _triggerZone = trigger.misc.getZone(_zone) -- trigger to use as reference position
if _triggerZone == nil then
trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zone, 10)
return
end
local _pos2 = { x = _triggerZone.point.x, y = _triggerZone.point.z }
local _alt = land.getHeight(_pos2)
local _pos3 = { x = _pos2.x, y = _alt, z = _pos2.y }
trigger.action.setUserFlag(_flagNumber, 0) --start at 0
local _details = { point = _pos3, name = _zone, smoke = _smoke, flag = _flagNumber, radius = _triggerZone.radius}
ctld.extractZones[_zone.."-".._flagNumber] = _details
if _smoke ~= nil and _smoke > -1 then
local _smokeFunction
_smokeFunction = function(_args)
local _extractDetails = ctld.extractZones[_zone.."-".._flagNumber]
-- check zone is still active
if _extractDetails == nil then
-- stop refreshing smoke, zone is done
return
end
trigger.action.smoke(_args.point, _args.smoke)
--refresh in 5 minutes
timer.scheduleFunction(_smokeFunction, _args, timer.getTime() + 300)
end
--run local function
_smokeFunction(_details)
end
end
-- Removes an extraction zone
--
-- The smoke will take up to 5 minutes to disappear depending on the last time the smoke was activated
--
-- The ctld.removeExtractZone function needs to be called once in a trigger action do script.
--
-- e.g. ctld.removeExtractZone("extractzone1", 2) will remove an extraction zone at trigger zone "extractzone1"
-- that was setup with flag 2
--
--
--
function ctld.removeExtractZone(_zone,_flagNumber)
local _extractDetails = ctld.extractZones[_zone.."-".._flagNumber]
if _extractDetails ~= nil then
--remove zone
ctld.extractZones[_zone.."-".._flagNumber] = nil
end
end
-- CONTINUOUS TRIGGER FUNCTION
-- This function will count the current number of extractable RED and BLUE
-- GROUPS in a zone and store the values in two flags
-- A group is only counted as being in a zone when the leader of that group
-- is in the zone
-- Use: ctld.countDroppedGroupsInZone("Zone Name", flagBlue, flagRed)
function ctld.countDroppedGroupsInZone(_zone, _blueFlag, _redFlag)
local _triggerZone = trigger.misc.getZone(_zone) -- trigger to use as reference position
if _triggerZone == nil then
trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zone, 10)
return
end
local _zonePos = mist.utils.zoneToVec3(_zone)
local _redCount = 0;
local _blueCount = 0;
local _allGroups = {ctld.droppedTroopsRED,ctld.droppedTroopsBLUE,ctld.droppedVehiclesRED,ctld.droppedVehiclesBLUE}
for _, _extractGroups in pairs(_allGroups) do
for _,_groupName in pairs(_extractGroups) do
local _groupUnits = ctld.getGroup(_groupName)
if #_groupUnits > 0 then
local _zonePos = mist.utils.zoneToVec3(_zone)
local _dist = ctld.getDistance(_groupUnits[1]:getPoint(), _zonePos)
if _dist <= _triggerZone.radius then
if (_groupUnits[1]:getCoalition() == 1) then
_redCount = _redCount + 1;
else
_blueCount = _blueCount + 1;
end
end
end
end
end
--set flag stuff
trigger.action.setUserFlag(_blueFlag, _blueCount)
trigger.action.setUserFlag(_redFlag, _redCount)
-- env.info("Groups in zone ".._blueCount.." ".._redCount)
end
-- CONTINUOUS TRIGGER FUNCTION
-- This function will count the current number of extractable RED and BLUE
-- UNITS in a zone and store the values in two flags
-- Use: ctld.countDroppedUnitsInZone("Zone Name", flagBlue, flagRed)
function ctld.countDroppedUnitsInZone(_zone, _blueFlag, _redFlag)
local _triggerZone = trigger.misc.getZone(_zone) -- trigger to use as reference position
if _triggerZone == nil then
trigger.action.outText("CTLD.lua ERROR: Cant find zone called " .. _zone, 10)
return
end
local _zonePos = mist.utils.zoneToVec3(_zone)
local _redCount = 0;
local _blueCount = 0;
local _allGroups = {ctld.droppedTroopsRED,ctld.droppedTroopsBLUE,ctld.droppedVehiclesRED,ctld.droppedVehiclesBLUE}
for _, _extractGroups in pairs(_allGroups) do
for _,_groupName in pairs(_extractGroups) do
local _groupUnits = ctld.getGroup(_groupName)
if #_groupUnits > 0 then
local _zonePos = mist.utils.zoneToVec3(_zone)
for _,_unit in pairs(_groupUnits) do
local _dist = ctld.getDistance(_unit:getPoint(), _zonePos)
if _dist <= _triggerZone.radius then
if (_unit:getCoalition() == 1) then
_redCount = _redCount + 1;
else
_blueCount = _blueCount + 1;
end
end
end
end
end
end
--set flag stuff
trigger.action.setUserFlag(_blueFlag, _blueCount)
trigger.action.setUserFlag(_redFlag, _redCount)
-- env.info("Units in zone ".._blueCount.." ".._redCount)
end
-- Creates a radio beacon on a random UHF - VHF and HF/FM frequency for homing
-- This WILL NOT WORK if you dont add beacon.ogg and beaconsilent.ogg to the mission!!!
-- e.g. ctld.createRadioBeaconAtZone("beaconZone","red", 1440,"Waypoint 1") will create a beacon at trigger zone "beaconZone" for the Red side
-- that will last 1440 minutes (24 hours ) and named "Waypoint 1" in the list of radio beacons
--
-- e.g. ctld.createRadioBeaconAtZone("beaconZoneBlue","blue", 20) will create a beacon at trigger zone "beaconZoneBlue" for the Blue side