-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSeraNukeMission_script.lua
1477 lines (1302 loc) · 54.4 KB
/
SeraNukeMission_script.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
-- ****************************************************************************
-- **
-- ** File : /maps/SeraNukeMission/SeraNukeMission_script.lua
-- ** Author(s): FunkOff
-- **
-- ** Summary : Main mission flow script for SeraNukeMission
-- **
-- ****************************************************************************
local Cinematics = import('/lua/cinematics.lua')
#local CustomFunctions = import('/maps/SeraNukeMission/SeraNukeMission_CustomFunctions.lua') --> make
local M1AeonAI = import('/maps/SeraNukeMission/SeraNukeMission_m1AeonAI.lua')
local M1SeraAI = import('/maps/SeraNukeMission/SeraNukeMission_m1SeraAI.lua')
local M2OrderAI = import('/maps/SeraNukeMission/SeraNukeMission_m2OrderAI.lua')
local M2CybranAI = import('/maps/SeraNukeMission/SeraNukeMission_m2CybranAI.lua')
local M2UEFAI = import('/maps/SeraNukeMission/SeraNukeMission_m2UEFAI.lua')
local M3AeonAI = import('/maps/SeraNukeMission/SeraNukeMission_m3AeonAI.lua')
local M3CybranAI = import('/maps/SeraNukeMission/SeraNukeMission_m3CybranAI.lua')
local M3UEFAI = import('/maps/SeraNukeMission/SeraNukeMission_m3UEFAI.lua')
--local M4AeonAI = import('/maps/SeraNukeMission/SeraNukeMission_m4AeonAI.lua')
--local M4CybranAI = import('/maps/SeraNukeMission/SeraNukeMission_m4CybranAI.lua')
--local M4UEFAI = import('/maps/SeraNukeMission/SeraNukeMission_m4UEFAI.lua')
local Objectives = import('/lua/ScenarioFramework.lua').Objectives
#local OpStrings = import('/maps/SeraNukeMission/SeraNukeMission_strings.lua') --> make
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
local ScenarioPlatoonAI = import('/lua/ScenarioPlatoonAI.lua')
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local Utilities = import('/lua/Utilities.lua')
---------
-- Globals
---------
ScenarioInfo.Player1 = 1
ScenarioInfo.Seraphim = 2
ScenarioInfo.Order = 3
ScenarioInfo.UEF = 4
ScenarioInfo.Aeon = 5
ScenarioInfo.Cybran = 6
ScenarioInfo.Civilians = 7
ScenarioInfo.Player2 = 8
ScenarioInfo.Player3 = 9
ScenarioInfo.Player4 = 10
ScenarioInfo.HumanPlayers = {} --Is this needed????
ScenarioInfo.Player1Exists = false
ScenarioInfo.Player2Exists = false
ScenarioInfo.Player3Exists = false
ScenarioInfo.Player4Exists = false
--------
-- Locals
--------
local Player1 = ScenarioInfo.Player1
local Player2 = ScenarioInfo.Player2
local Player3 = ScenarioInfo.Player3
local Player4 = ScenarioInfo.Player4
local Aeon = ScenarioInfo.Aeon
local Cybran = ScenarioInfo.Cybran
local Order = ScenarioInfo.Order
local Seraphim = ScenarioInfo.Seraphim
local UEF = ScenarioInfo.UEF
local Civilians = ScenarioInfo.Civilians
local AssignedObjectives = {}
local Difficulty = ScenarioInfo.Options.Difficulty
-- How long should we wait at the beginning of the NIS to allow slower machines to catch up?
local NIS1InitialDelay = 3
--------------
-- Debug only!
--------------
local Debug = false
local SkipNIS1 = false
local SkipNIS2 = false
local SkipNIS3 = false
local SkipNIS4 = false
function Player1CommanderKilled()
ArmyBrains[Player1]:OnDefeat()
if(not ScenarioInfo.OpEnded) then
ScenarioFramework.CDRDeathNISCamera(ScenarioInfo.Player1Commander)
end
return
end
function OrderCommanderKilled()
ArmyBrains[Order]:OnDefeat()
end
function SeraphimCommanderKilled()
ArmyBrains[Seraphim]:OnDefeat()
end
function M1CoalitionAttacks()
--Stop recurring attacks from previous phase
if ScenarioInfo.M1RecurringAttacks then
for k,v in ScenarioInfo.M1RecurringAttacks do
KillThread(v)
end
end
local platoon
ScenarioInfo.M1RecurringAttacks = {}
-- Aeon Air Raid, lasts 4 minutes
ScenarioInfo.M1RecurringAttacks.AeonAirRaid = ForkThread(function()
for i = 1, (Difficulty * 2) do
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Aeon', 'M1_AirRaid_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M1_AirRaid_Aeon')
WaitSeconds(4*60/Difficulty)
end
end)
--Aeon GC Attack
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Aeon', 'M1_GC_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_GC_Move')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_SeraphimBase')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_CybranAmphibiousAttack')
-- UEF Fleet Attack
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M1_AttackFleet_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_AttackFleet_UEF1')
-- UEF Riptide Attack vs Player1 and vs Seraphim, lasts 3 minutes
ScenarioInfo.M1RecurringAttacks.UEFRipTides = ForkThread(
function()
for i = 1, Difficulty do
for i = 1, Difficulty do
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M1_AttackPlayer1_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_YolonaOss')
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M1_AttackSera_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_SeraphimBase')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_YolonaOss')
WaitSeconds(15)
end
WaitSeconds(60*3/Difficulty)
end
end)
--Cybran Spider Attack
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Cybran', 'M1_Experimentals_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_CybranAmphibiousMove')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_SeraphimBase')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_CybranAmphibiousAttack')
--Cybran Wagners
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Cybran', 'M1_WagnerAttack_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M3_CybranAmphibiousMove')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_SeraphimBase')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_CybranAmphibiousAttack')
end
----------
-- Startup
----------
function OnPopulate(scenario)
ScenarioUtils.InitializeScenarioArmies()
-- Sets Army Colors
--ScenarioFramework.SetSeraphimColor(Player1)
ScenarioFramework.SetSeraphimColor(Seraphim)
ScenarioFramework.SetArmyColor(Player1, 220, 200, 20)
ScenarioFramework.SetAeonEvilColor(Order)
ScenarioFramework.SetUEFPlayerColor(UEF)
ScenarioFramework.SetAeonPlayerColor(Aeon)
ScenarioFramework.SetCybranPlayerColor(Cybran)
ScenarioFramework.SetUEFAlly2Color(Civilians)
local colors = {
['Player2'] = {255, 200, 0},
['Player3'] = {189, 116, 16},
['Player4'] = {89, 133, 39}
}
local ArmyTable = ListArmies()
for army, color in colors do
if ArmyTable[ScenarioInfo[army]] then
ScenarioFramework.SetArmyColor(ScenarioInfo[army], unpack(color))
end
end
if ArmyTable[ScenarioInfo.Player1].Human then
ScenarioInfo.Player1Exists = true
end
if ArmyTable[ScenarioInfo.Player2].Human then
ScenarioInfo.Player2Exists = true
end
if ArmyTable[ScenarioInfo.Player3].Human then
ScenarioInfo.Player3Exists = true
end
if ArmyTable[ScenarioInfo.Player4].Human then
ScenarioInfo.Player4Exists = true
ScenarioInfo.Player4Base = ScenarioUtils.CreateArmyGroup('Player4','Base')
----create mex positions for this base that are not normally there
for k, unit in EntityCategoryFilterDown(categories.uab1302, ScenarioInfo.Player4Base) do
posx = unit:GetPosition()[1]
posy = unit:GetPosition()[3]
GenerateResourcesMarker(posx, posy)
end
end
-- Unit Cap
--ScenarioFramework.SetSharedUnitCap(1000)
-- Disable friendly AI sharing resources to Player1s
GetArmyBrain(Seraphim):SetResourceSharing(false)
GetArmyBrain(Order):SetResourceSharing(false)
--UEF Support base in M3 location to provide power for M1 fleet
ScenarioUtils.CreateArmyGroup('UEF','M1_SupportBase')
------------
-- Aeon Air and Land Bases
------------
M1AeonAI.AeonM1AirBaseAI()
M1AeonAI.AeonM1LandBaseAI()
ArmyBrains[Aeon]:PBMSetCheckInterval(5)
local AeonM1SMD = ScenarioUtils.CreateArmyGroup('Aeon','M1_SMD')
for i,SMD in AeonM1SMD do
SMD:GiveTacticalSiloAmmo(Difficulty - 1)
end
------------
-- Seraphim Base, run by AI if Player2 not present, else given to Player1
------------
if not ScenarioInfo.Player2Exists then
M1SeraAI.SeraphimBaseAI()
ArmyBrains[Seraphim]:PBMSetCheckInterval(6)
else
local Player2Base = {}
Player2Base.Core = ScenarioUtils.CreateArmyGroup('Seraphim', 'CoreBase')
Player2Base.InnerDefenseRing = ScenarioUtils.CreateArmyGroup('Seraphim', 'InnerDefenseRing' )
Player2Base.SupportFactories = ScenarioUtils.CreateArmyGroup('Seraphim', 'SeraphimSupportFactories')
if Difficulty<3 then
Player2Base.OuterDefenseRing = ScenarioUtils.CreateArmyGroup('Seraphim', 'OuterDefenseRing' )
end
for index, group in Player2Base do
for i, unit in group do
ScenarioFramework.GiveUnitToArmy(unit, ArmyTable[ScenarioInfo.Player2])
end
end
end
------------
-- Seraphim Defense Patrols
------------
local DefenseForceSouth = ScenarioUtils.CreateArmyGroupAsPlatoon('Seraphim', 'M1_DefenseForceSouth_D' .. Difficulty, 'GrowthFormation')
local DefenseForceEast = ScenarioUtils.CreateArmyGroupAsPlatoon('Seraphim', 'M1_DefenseForceEast_D' .. Difficulty, 'GrowthFormation')
local DefenseFleet1 = ScenarioUtils.CreateArmyGroupAsPlatoon('Seraphim', 'DefenseFleet1_D' .. Difficulty, 'GrowthFormation')
local DefenseFleet2 = ScenarioUtils.CreateArmyGroupAsPlatoon('Seraphim', 'DefenseFleet2_D' .. Difficulty, 'GrowthFormation')
local DefenseAirPatrol = ScenarioUtils.CreateArmyGroupAsPlatoon('Seraphim', 'M1_DefenseAirPatrol_D' .. Difficulty, 'GrowthFormation')
--If there's no Player2, set patrols
if not ScenarioInfo.Player2Exists then
ScenarioFramework.PlatoonPatrolChain(DefenseForceSouth, 'M1_SeraLandPatrolSouth')
ScenarioFramework.PlatoonPatrolChain(DefenseForceEast, 'M1_SeraLandPatrolEast')
ScenarioFramework.PlatoonPatrolChain(DefenseFleet1, 'M1_SeraSeaPatrolSouth')
ScenarioFramework.PlatoonPatrolChain(DefenseFleet2, 'M1_SeraSeaPatrolWest')
ScenarioFramework.PlatoonPatrolChain(DefenseAirPatrol, 'M1_SeraLandPatrolSouth')
else --else, just give them to Player2
for index, unit in DefenseForceSouth:GetPlatoonUnits() do
ScenarioFramework.GiveUnitToArmy(unit, ArmyTable[ScenarioInfo.Player2])
end
for index, unit in DefenseForceEast:GetPlatoonUnits() do
ScenarioFramework.GiveUnitToArmy(unit, ArmyTable[ScenarioInfo.Player2])
end
for index, unit in DefenseFleet1:GetPlatoonUnits() do
ScenarioFramework.GiveUnitToArmy(unit, ArmyTable[ScenarioInfo.Player2])
end
for index, unit in DefenseFleet2:GetPlatoonUnits() do
ScenarioFramework.GiveUnitToArmy(unit, ArmyTable[ScenarioInfo.Player2])
end
for index, unit in DefenseAirPatrol:GetPlatoonUnits() do
ScenarioFramework.GiveUnitToArmy(unit, ArmyTable[ScenarioInfo.Player2])
end
end
--If there is no Player2, spawn the Commander
if not ScenarioInfo.Player2Exists then
ScenarioInfo.SeraphimCommander = ScenarioFramework.SpawnCommander('Seraphim', 'Commander', false, 'Ithanyis', false, SeraphimCommanderKilled,
{'BlastAttack','DamageStabilization','RateOfFire'})
---So it doesnt wander away from the main base and get killed building T1 PD
ScenarioInfo.SeraphimCommander:AddBuildRestriction( categories.SERAPHIM * ( categories.DEFENSE + categories.SHIELD) )
end
-- Resources for Coalition AI, slightly delayed cause army didn't recieve it for some reason
ForkThread(function()
WaitSeconds(2)
ArmyBrains[Aeon]:GiveStorage('ENERGY', 100000)
ArmyBrains[Aeon]:GiveStorage('MASS', 20000)
ArmyBrains[Aeon]:GiveResource('MASS', 20000)
ArmyBrains[Aeon]:GiveResource('ENERGY', 100000)
ArmyBrains[Cybran]:GiveStorage('ENERGY', 100000)
ArmyBrains[Cybran]:GiveStorage('MASS', 20000)
ArmyBrains[Cybran]:GiveResource('MASS', 20000)
ArmyBrains[Cybran]:GiveResource('ENERGY', 100000)
ArmyBrains[UEF]:GiveStorage('ENERGY', 100000)
ArmyBrains[UEF]:GiveStorage('MASS', 20000)
ArmyBrains[UEF]:GiveResource('MASS', 20000)
ArmyBrains[UEF]:GiveResource('ENERGY', 100000)
end)
------------
-- Player1 Base and Fleet
------------
local Player1Base = ScenarioUtils.CreateArmyGroup('Player1', 'Base')
local DefenseFleet = ScenarioUtils.CreateArmyGroupAsPlatoon('Player1', 'DefenseFleet','GrowthFormation')
for k, v in EntityCategoryFilterDown(categories.xss0201, DefenseFleet:GetPlatoonUnits()) do
IssueDive({v})
end
for k, v in EntityCategoryFilterDown(categories.xsb2401, Player1Base) do
ScenarioInfo.YolonaOss = v
end
------------------
-- Initial Attacks
------------------
M1CoalitionAttacks()
#ScenarioFramework.CreatePlatoonDeathTrigger(M1SendTitans2, platoon)
-- First objective area
ScenarioFramework.SetPlayableArea('AREA_1', false)
end
function OnStart(self)
--------------------
-- Build Restrictions
--------------------
for _, Player in ScenarioInfo.HumanPlayers do
ScenarioFramework.AddRestriction(Player,
categories.xal0305 + -- Aeon Sniper Bot
categories.xaa0202 + -- Aeon Mid Range fighter (Swift Wind)
categories.xal0203 + -- Aeon Assault Tank (Blaze)
categories.xab1401 + -- Aeon Quantum Resource Generator
categories.xas0204 + -- Aeon Submarine Hunter
categories.xaa0306 + -- Aeon Torpedo Bomber
categories.xas0306 + -- Aeon Missile Ship
categories.xab3301 + -- Aeon Quantum Optics Device
categories.xab2307 + -- Aeon Rapid Fire Artillery
categories.xaa0305 + -- Aeon AA Gunship
categories.xrl0302 + -- Cybran Mobile Bomb
categories.xra0105 + -- Cybran Light Gunship
categories.xrs0204 + -- Cybran Sub Killer
categories.xrs0205 + -- Cybran Counter-Intelligence Boat
categories.xrb2308 + -- Cybran Torpedo Ambushing System
categories.xrb0104 + -- Cybran Engineering Station 1
categories.xrb0204 + -- Cybran Engineering Station 2
categories.xrb0304 + -- Cybran Engineering Station 3
categories.xrb3301 + -- Cybran Perimeter Monitoring System
categories.xra0305 + -- Cybran Heavy Gunship
categories.xrl0305 + -- Cybran Brick
categories.xrl0403 + -- Cybran Amphibious Mega Bot
categories.url0402 + -- Cybran Monkeylord
categories.url0401 + -- Cybran Scathis
categories.ura0401 + -- Cybran Soul Ripper
categories.xeb2306 + -- UEF Heavy Point Defense
categories.xel0305 + -- UEF Percival
categories.xel0306 + -- UEF Mobile Missile Platform
categories.xes0102 + -- UEF Torpedo Boat
categories.xes0205 + -- UEF Shield Boat
categories.xes0307 + -- UEF Battlecruiser
categories.xeb0104 + -- UEF Engineering Station 1
categories.xeb0204 + -- UEF Engineering Station 2
categories.xea0306 + -- UEF Heavy Air Transport
categories.xeb2402 + -- UEF Sub-Orbital Defense System
categories.ueb2401 + -- UEF Mavor
categories.ues0401 + -- UEF Atlantis
categories.xeb2402 + -- UEF Sub-Orbital Defense System
--categories.xsl0305 + -- Seraph Sniper Bot
--categories.xsa0402 + -- Seraph Exp Bomber
categories.xss0304 + -- Seraph Sub Hunter
categories.xsb0304 -- Seraph Gate
--categories.xsl0301 -- Seraph sACU
--categories.xsb2401 -- Seraph exp Nuke (need this)
)
end
-- Initialize camera
#if not SkipNIS1 then
# Cinematics.CameraMoveToMarker(ScenarioUtils.GetMarker('Cam_1_1'))
#end
ForkThread(IntroMission1NIS)
end
------------
-- Mission 1
------------
function IntroMission1NIS()
if not SkipNIS1 then
Cinematics.EnterNISMode()
ForkThread(function()
-- Vision for NIS location
local VisMarkerPlayer1 = ScenarioFramework.CreateVisibleAreaLocation(150, 'M1_CybranAmphibiousAttack3', 20, ArmyBrains[Player1])
ScenarioInfo.NISGatePlayer1 = ScenarioUtils.CreateArmyGroup('Player1', 'M1_NISGate')[1]
ScenarioInfo.NISGroupPlayer1 = ScenarioUtils.CreateArmyGroup('UEF', 'M1_NISAirRaid')
IssueAttack(ScenarioInfo.NISGroupPlayer1 ,ScenarioInfo.NISGatePlayer1)
WaitSeconds(8)
ScenarioInfo.Player1Commander = ScenarioFramework.SpawnCommander('Player1', 'Commander', 'Gate', true, true, Player1CommanderKilled)
--WaitSeconds(1)
IssueGuard({ScenarioInfo.Player1Commander}, ScenarioInfo.YolonaOss)
end)
Cinematics.CameraMoveToMarker(ScenarioUtils.GetMarker('M1_CybranAmphibiousAttack3'), 4)
-- spawn coop Player1s too
if ScenarioInfo.Player2Exists or ScenarioInfo.Player3Exists or ScenarioInfo.Player4Exists then
WaitSeconds(10)
ForkThread(M1CoopNIS)
WaitSeconds(20)
else
WaitSeconds(16)
end
--VisMarker:Destroy()
for k, v in ScenarioInfo.NISGroupPlayer1 do
if not v:IsDead() then
v:Kill()
end
end
ScenarioInfo.NISGatePlayer1:Kill()
Cinematics.ExitNISMode()
else
ScenarioInfo.Player1Commander = ScenarioFramework.SpawnCommander('Player1', 'Commander', 'Warp', true, true, Player1CommanderKilled)
end
IntroMission1()
end
function M1CoopNIS()
local VisMarkerPlayer1 = ScenarioFramework.CreateVisibleAreaLocation(100, 'M1NISCoop', 20, ArmyBrains[Player1])
ScenarioInfo.NISGroupCoop = ScenarioUtils.CreateArmyGroup('UEF', 'M1_NISAirRaidCoop')
ScenarioInfo.NISGateCoop = ScenarioUtils.CreateArmyGroup('Seraphim', 'M1_CoopGate')[1]
IssueAttack(ScenarioInfo.NISGroupCoop ,ScenarioInfo.NISGateCoop)
Cinematics.CameraMoveToMarker(ScenarioUtils.GetMarker('M1NISCoop'), 4)
if ScenarioInfo.Player2Exists then
ScenarioInfo.Player2Commander = ScenarioFramework.SpawnCommander('Player2', 'Commander', 'Gate', true, true, Player2CommanderKilled)
ScenarioInfo.SeraphimCommander = ScenarioInfo.Player2Commander
IssueMove({ScenarioInfo.Player2Commander},ScenarioUtils.MarkerToPosition('Player2Move'))
WaitSeconds(2)
else
WaitSeconds(2)
end
if ScenarioInfo.Player3Exists then
ScenarioInfo.Player3Commander = ScenarioFramework.SpawnCommander('Player3', 'Commander', 'Gate', true, true, Player3CommanderKilled)
WaitSeconds(1)
IssueMove({ScenarioInfo.Player3Commander},ScenarioUtils.MarkerToPosition('Player3Move'))
WaitSeconds(2)
else
WaitSeconds(3)
end
if ScenarioInfo.Player4Exists then
ScenarioInfo.Player4Commander = ScenarioFramework.SpawnCommander('Player4', 'Commander', 'Gate', true, true, Player4CommanderKilled)
WaitSeconds(1)
IssueMove({ScenarioInfo.Player4Commander},ScenarioUtils.MarkerToPosition('Player4Move'))
WaitSeconds(3)
else
WaitSeconds(3)
end
for k, v in ScenarioInfo.NISGroupCoop do
if not v:IsDead() then
IssueAggressiveMove({v},ScenarioUtils.MarkerToPosition('Player2Move'))
end
end
---]]
--WaitSeconds(2)
ScenarioInfo.NISGateCoop:Kill()
end
function Player2CommanderKilled()
ArmyBrains[Player2]:OnDefeat()
end
function Player3CommanderKilled()
ArmyBrains[Player3]:OnDefeat()
end
function Player4CommanderKilled()
ArmyBrains[Player4]:OnDefeat()
end
function IntroMission1()
ScenarioInfo.MissionNumber = 1
if Debug then
Utilities.UserConRequest('SallyShears')
-- Utilities.UserConRequest('ren_IgnoreDecalLOD')
-- Utilities.UserConRequest('ren_ShadowLOD' 500) -- 250
end
StartMission1()
end
function StartMission1()
----------------------------------------
--Primary Objective 1 - Protect the Yolona Oss
----------------------------------------
ScenarioInfo.M1P1 = Objectives.Protect(
'primary',
'incomplete',
'Defend the Yolona Oss',
'Use the Yolona Oss to crush the coalition.',
{
Units = {ScenarioInfo.YolonaOss},
}
)
ScenarioInfo.M1P1:AddResultCallback(
function(result)
if(result == false) then
Player1LoseYolonaOss()
end
end
)
table.insert(AssignedObjectives, ScenarioInfo.M1P1)
------------------------------------------
-- Secondary Objective 1 - Protect the Seraphim Ally
------------------------------------------
ScenarioInfo.M1S1 = Objectives.Protect(
'secondary',
'incomplete',
'Protect the Seraphim Commander',
'Protect the Seraphim Commander against coalition retaliation.',
{
Units = {ScenarioInfo.SeraphimCommander},
}
)
ScenarioInfo.M1S1:AddResultCallback()
table.insert(AssignedObjectives, ScenarioInfo.M1S1)
------------------------------------------
-- Primary Objective 2 - Destroy Aeon Base
------------------------------------------
ScenarioInfo.M1P2 = Objectives.CategoriesInArea(
'primary', -- type
'incomplete', -- complete
'Destroy Aeon Forward Bases', -- title
'Disrupt Coalition counter attacks.', -- description
'kill', -- action
{ -- target
MarkUnits = true,
Requirements = {
{
Area = 'M1_Aeon_AirBase',
Category = categories.FACTORY,
CompareOp = '<=',
Value = 0,
ArmyIndex = Aeon,
},
{
Area = 'M1_Aeon_LandBase',
Category = categories.FACTORY,
CompareOp = '<=',
Value = 0,
ArmyIndex = Aeon,
},
},
}
)
ScenarioInfo.M1P2:AddResultCallback(
function(result)
if(result) then
if ScenarioInfo.MissionNumber == 1 then
-- ScenarioFramework.Dialogue(OpStrings.M1_Bases_Destroyed, IntroMission2, true)
IntroMission2()
else
-- ScenarioFramework.Dialogue(OpStrings.M1_Bases_Destroyed, nil, true)
end
end
end
)
table.insert(AssignedObjectives, ScenarioInfo.M1P2)
--ScenarioFramework.CreateTimerTrigger(M1P1Reminder1, 600)
-- Expand map even if objective isn't finished yet
local M1MapExpandDelay = {7*60, 6*60, 5*60}
ScenarioFramework.CreateTimerTrigger(IntroMission2, M1MapExpandDelay[Difficulty])
end
function M2CoalitionAttacks()
--Stop recurring attacks from M2 if already in progress
if ScenarioInfo.M2RecurringAttacks then
for k,v in ScenarioInfo.M2RecurringAttacks do
KillThread(v)
end
end
--Cybran Island base either gets a t3 heavy artillery now, or a scathis soon. Unless difficulty is easy, then niether
if Difficulty > 1 and not ScenarioInfo.SeraphimCommander:IsDead() then
ScenarioInfo.M2RecurringAttacks.Scathis = ForkThread(function()
WaitSeconds(10*60/Difficulty) --5 min for medium, 200 seconds for hard
local platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Cybran', 'M2_Scathis','GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M2_ScathisMoveChain')
end)
elseif Difficulty > 1 and not ScenarioInfo.M2DontMakeHeavyArtillery then
ScenarioUtils.CreateArmyGroup('Cybran','M2_HeavyArtillery')
end
ScenarioInfo.M2DontMakeHeavyArtillery = true
------------
-- UEF and Aeon Fleet Attacks
------------
--Just one attack
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Aeon', 'M2_FleetAttack_D' .. Difficulty, 'GrowthFormation')
for k, v in EntityCategoryFilterDown(categories.uas0401, platoon:GetPlatoonUnits()) do
--IssueDive({v})
end
ScenarioFramework.PlatoonPatrolChain(platoon, 'M2_AeonFleetAttack')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M1_YolonaOss')
--Just one attack
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M2_AttackFleetNorth_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M2_UEFFleetAttack')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M1_YolonaOss')
------------
-- Experimental Attacks
------------
--Aeon GC Attack --lasts 10 minutes. 1 wave for easy, 2 for med, 3 for hard
ScenarioInfo.M2RecurringAttacks.AeonGCs = ForkThread(function()
WaitSeconds(40)
for i = 1, Difficulty do
for i = 1, 2 do
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Aeon', 'M1_GC_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M2_GC_Move')
ScenarioFramework.PlatoonAttackChain(platoon, 'M2_OrderBase')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_YolonaOss')
WaitSeconds(10)
end
WaitSeconds(60*10/Difficulty)
end
end
)
--Cybran Monkey Attack --lasts 10 minutes. 1 wave for easy, 2 for med, 3 for hard
ScenarioInfo.M2RecurringAttacks.CybranSpiders = ForkThread(function()
WaitSeconds(20)
for i = 1, (Difficulty) do
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Cybran', 'M2_Experimentals_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_CybranAmphibiousMove')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_SeraphimBase')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_CybranAmphibiousAttack')
WaitSeconds(60*10/Difficulty)
end
end)
--UEF Fatboy Attack, two attacks at the same time, but happens only once this wave
ForkThread(function()
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M2_FatBoys_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M2_FatBoyMove1')
ScenarioFramework.PlatoonAttackChain(platoon, 'M2_OrderBase')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_YolonaOss')
WaitSeconds(10)
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M2_FatBoys_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M2_FatBoyMove2')
ScenarioFramework.PlatoonAttackChain(platoon, 'M2_OrderBase')
ScenarioFramework.PlatoonMoveChain(platoon, 'M1_YolonaOss')
end)
------------
-- Air Raids
------------
-- Aeon Air Raid --Lasts 10 minutes, 2 attacks easy, 4 medium, 6 hard
ScenarioInfo.M2RecurringAttacks.AeonAirRaid = ForkThread(function()
for i = 1, (2*Difficulty) do
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Aeon', 'M1_AirRaid_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_AirRaid_Aeon')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_YolonaOss')
WaitSeconds(10*60/(2*Difficulty))
end
end)
-- Cybran Air Raid --Lasts a little over 10 minutes, 2 attacks easy, 4 medium, 6 hard
ScenarioInfo.M2RecurringAttacks.CybranAirRaid = ForkThread(function()
WaitSeconds(30)
local WaveCount = 1
if Difficulty > 1 then
local WaveCount = 2
else
local WaveCount = 1
end
for i = 1, (2*Difficulty) do
for i = 1, WaveCount do
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Cybran', 'M2_AirRaid_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_CybranAmphibiousAttack')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M1_YolonaOss')
WaitSeconds(5)
end
WaitSeconds(10*60/(2*Difficulty))
end
end)
-- UEF Air Raid ----Lasts 10 minutes, 3 attacks easy, 6 medium, 9 hard
ScenarioInfo.M2RecurringAttacks.UEFAirRaid = ForkThread(function()
for i = 1, (Difficulty * 3) do
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M2_AirRaid_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonAttackChain(platoon, 'M2_OrderBase')
ScenarioFramework.PlatoonAttackChain(platoon, 'M1_YolonaOss')
WaitSeconds(10*60/(3*Difficulty))
end
end)
------------
--Cybran Stealth Battleship Attack -- Just one
------------
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Cybran', 'M2_FleetAttack_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M2_SeraFleetAttack')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M1_YolonaOss')
end
function Mission2NIS()
if not SkipNIS3 then
Cinematics.EnterNISMode()
local VisMarkerM2 = ScenarioFramework.CreateVisibleAreaLocation(200, 'M2_UEFAirBase', 0, ArmyBrains[Player1])
Cinematics.CameraMoveToMarker('M2NISTempest', 4)
WaitSeconds(10)
VisMarkerM2:Destroy()
Cinematics.ExitNISMode()
end
end
function IntroMission2()
if ScenarioInfo.MissionNumber == 2 or ScenarioInfo.MissionNumber == 3 then
return
end
ScenarioInfo.MissionNumber = 2
ScenarioFramework.SetPlayableArea('AREA_2', false)
--Stop recurring attacks from previous phase
for k,v in ScenarioInfo.M1RecurringAttacks do
KillThread(v)
end
ScenarioInfo.M2RecurringAttacks = {}
M2CoalitionAttacks()
------------
-- Order Base
------------
M2OrderAI.OrderBaseAI()
ArmyBrains[Order]:PBMSetCheckInterval(5)
ScenarioInfo.OrderCommander = ScenarioFramework.SpawnCommander('Order', 'Commander', false, 'Veronica', false, OrderCommanderKilled,
{'Shield','T3Engineering'})
--So it doesnt wander away from the main base and get killed building T1 torp defenses
ScenarioInfo.OrderCommander:AddBuildRestriction( categories.AEON * ( categories.DEFENSE) )
------------
-- Order Fleet Attacks, East and West
------------
ScenarioInfo.M2OrderEastFleet = ScenarioUtils.CreateArmyGroupAsPlatoon('Order', 'M2_DefenseFleetEast_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(ScenarioInfo.M2OrderEastFleet, 'M2_AeonFleetAttack')
--ScenarioFramework.PlatoonPatrolChain(platoon, 'M2_UEFFleetAttackChain')
--ForkThread(function()
-- ScenarioPlatoonAI.PlatoonAttackClosestUnit(platoon)
--end
--)
ScenarioInfo.M2OrderWestFleet = ScenarioUtils.CreateArmyGroupAsPlatoon('Order', 'M2_DefenseFleetWest_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(ScenarioInfo.M2OrderWestFleet, 'M2_UEFFleetAttack')
ScenarioFramework.PlatoonPatrolChain(ScenarioInfo.M2OrderWestFleet, 'M2_AeonFleetAttack')
------------
-- Order Land and Air Patrols
------------
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Order', 'M2_DefensePatrol_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M2_OrderLandPatrol1')
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Order', 'M2_AirPatrol_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M2_OrderAirPatrol')
------------
-- Cybran Island Base
------------
M2CybranAI.CybranIslandBaseAI()
ArmyBrains[Cybran]:PBMSetCheckInterval(5)
local M2CybranSMDs = ScenarioUtils.CreateArmyGroup('Cybran','M2_SMD')
for i,SMD in M2CybranSMDs do
SMD:GiveTacticalSiloAmmo(Difficulty - 1)
end
------------
-- UEF Air Base
------------
M2UEFAI.UEFM2AirBaseAI()
ArmyBrains[UEF]:PBMSetCheckInterval(5)
local UEFM2SMD = ScenarioUtils.CreateArmyGroup('UEF','M2_SMD')
for i,SMD in UEFM2SMD do
SMD:GiveTacticalSiloAmmo(Difficulty - 1)
end
------------
-- Seraphim Fleet Attacks
------------
if not ScenarioInfo.SeraphimCommander:IsDead() then
ScenarioInfo.M2SeraphimFleet = ScenarioUtils.CreateArmyGroupAsPlatoon('Seraphim', 'M2_FleetAttack_D' .. Difficulty, 'GrowthFormation')
for k, v in EntityCategoryFilterDown(categories.xss0201, ScenarioInfo.M2SeraphimFleet:GetPlatoonUnits()) do
IssueDive({v})
end
ScenarioFramework.PlatoonPatrolChain(ScenarioInfo.M2SeraphimFleet, 'M2_SeraFleetAttack')
ScenarioFramework.PlatoonPatrolChain(ScenarioInfo.M2SeraphimFleet, 'M2_CybranIslandBase')
else
end
------
-- Add Seraphim Tech 3 navy attack to base build if we have an ai there
----
if not ScenarioInfo.Player2Exists then
M1SeraAI.M2SeraphimAttacks()
end
ForkThread(Mission2NIS)
------------------------------------------
-- Secondary Objective 2 - Protect the Order Ally
------------------------------------------
ScenarioInfo.M1S2 = Objectives.Protect(
'secondary',
'incomplete',
'Protect the Order Commander',
'Protect the Order Commander against coalition retaliation.',
{
Units = {ScenarioInfo.OrderCommander},
}
)
ScenarioInfo.M1S2:AddResultCallback(
function(result)
if(result == false) then
--Player1Lose()
--ArmyBrains[Order]:OnDefeat()
end
end
)
table.insert(AssignedObjectives, ScenarioInfo.M1S1)
------------------------------------------
-- Primary Objective 3 - Destroy UEF Air Base and Cybran Island Base
------------------------------------------
ScenarioInfo.M2P3 = Objectives.CategoriesInArea(
'primary', -- type
'incomplete', -- complete
'Destroy UEF and Cybran Forward Bases', -- title
'Distrupt Coalition counter attacks.', -- description
'kill', -- action
{ -- target
MarkUnits = true,
Requirements = {
{
Area = 'M2_UEFAirBase',
Category = categories.FACTORY,
CompareOp = '<=',
Value = 0,
ArmyIndex = UEF,
},
{
Area = 'M2_Cybran_IslandBase',
Category = categories.FACTORY,
CompareOp = '<=',
Value = 0,
ArmyIndex = Cybran,
},
},
}
)
ScenarioInfo.M2P3:AddResultCallback(
function(result)
if(result) then
if ScenarioInfo.MissionNumber == 2 then
-- ScenarioFramework.Dialogue(OpStrings.M1_Bases_Destroyed, IntroMission2, true)
IntroMission3()
else
-- ScenarioFramework.Dialogue(OpStrings.M1_Bases_Destroyed, nil, true)
end
end
end
)
table.insert(AssignedObjectives, ScenarioInfo.M2P3)
-- Expand map even if objective isn't finished yet
-- Expand map even if objective isn't finished yet
local M2MapExpandDelay = {10*60, 9*60, 8*60}
ScenarioFramework.CreateTimerTrigger(IntroMission3, M2MapExpandDelay[Difficulty])
end
function M3CoalitionAttacks() --We will save time by also calling this in M4
M3CybranFleetAttack()
M3AeonFleetAttack()
M3CybranMegaliths()
M3AeonGCs()
M3CybranMonkeyAttack()
M3UEFFatboyAttack()
M3UEFAirRaid()
M3CybranAirRaid()
if ScenarioInfo.MissionNumber == 3 then --These attacks only occur on M3
M3AeonCZAR()
M3_CybranSubAttack()
M3_UEFSubAttack()
end
end
function M3CybranFleetAttack()
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Cybran', 'M3_FleetAttack_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M3_CybranFleetAttack')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M1_YolonaOss')
end
function M3AeonFleetAttack()
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Aeon', 'M3_FleetAttack_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M2_AeonFleetAttack')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M1_YolonaOss')
end
function M3_CybranSubAttack()
platoon = ScenarioUtils.CreateArmyGroupAsPlatoon('Cybran', 'M3_SubAttack_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(platoon, 'M3_CybranSubAttack')
ScenarioFramework.PlatoonPatrolChain(platoon, 'M1_YolonaOss')
end
function M3_UEFSubAttack()
ScenarioInfo.M3UEFNukeSubs = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M3_NukeSubs_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(ScenarioInfo.M3UEFNukeSubs, 'M3_UEFSubAttack')
local counter = 0
for _, submarine in EntityCategoryFilterDown(categories.ues0304, ScenarioInfo.M3UEFNukeSubs:GetPlatoonUnits()) do
counter = counter + 1
submarine.target = counter
submarine.NukeThread = submarine:ForkThread(function(self)
WaitSeconds(5)
while not self:IsDead() and self:IsUnitState('Moving') do
WaitSeconds(5)
end
for i = 1, 3 do
if self and not self:IsDead() then
self:GiveNukeSiloAmmo(1)
if not ScenarioInfo.OrderCommander:IsDead() then
IssueNuke({self}, ScenarioUtils.MarkerToPosition('M3_UEFNuke' .. i ..(self.target)))
else
IssueNuke({self}, ScenarioUtils.MarkerToPosition('M1_YolonaOss')) --If the Order is dead, shoot the Player1 instead
end
WaitSeconds(10)
end
end
end)
end
ScenarioInfo.M3UEFAtlantis = ScenarioUtils.CreateArmyGroupAsPlatoon('UEF', 'M3_AtlantisAttack_D' .. Difficulty, 'GrowthFormation')
ScenarioFramework.PlatoonMoveChain(ScenarioInfo.M3UEFAtlantis, 'M3_UEFAtlantisAttack')
for _, Atlantis in ScenarioInfo.M3UEFAtlantis:GetPlatoonUnits() do
Atlantis.AttackThread = Atlantis:ForkThread(function(self)
WaitSeconds(5)
if self:IsDead() then
return
end
while not self:IsDead() and self:IsUnitState('Moving') do
WaitSeconds(5)
end
--IssueDive({self})
WaitSeconds(10)
while self and not self:IsDead() do
local cargoUnits = ScenarioUtils.CreateArmyGroup('UEF', 'M3_AtlantisSquadron')
for _, unit in cargoUnits do
IssueStop({unit})
self:AddUnitToStorage(unit)
end
IssueClearCommands({self})
IssueTransportUnload({self}, self:GetPosition())
for _, unit in cargoUnits do
while (not unit:IsDead() and unit:IsUnitState('Attached')) do
WaitSeconds(2)
end