forked from FAForever/faf-coop-maps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCCA_Coop_E06_UEFAI.lua
368 lines (338 loc) · 13.2 KB
/
SCCA_Coop_E06_UEFAI.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
-----------------------------------------------------------------------
-- File : /maps/SCCA_Coop_E06/SCCA_Coop_E06_UEFAI.lua
-- Author(s): Dhomie42
--
-- Summary : UEF (BlackSun) army AI for UEF Mission 6 - SCCA_Coop_E06
-----------------------------------------------------------------------
local BaseManager = import('/lua/ai/opai/basemanager.lua')
local AIBuildStructures = import('/lua/ai/aibuildstructures.lua')
---------
-- Locals
---------
local BlackSun = 2
local Difficulty = ScenarioInfo.Options.Difficulty
local SPAIFileName = '/lua/scenarioplatoonai.lua'
local CustomFunctions = '/maps/scca_coop_e06/scca_coop_e06_customfunctions.lua'
local AIAttackUtils = '/maps/scca_coop_e06/scca_coop_e06_aiattackutilities.lua'
local AIBehaviors = '/maps/scca_coop_e06/scca_coop_e06_aibehaviors.lua'
----------------
-- Base Managers
----------------
local M3AikoSEBase = BaseManager.CreateBaseManager()
function M3AikoSEBaseAI()
-- -----------
-- Aiko Base
-- -----------
M3AikoSEBase:Initialize(ArmyBrains[BlackSun], 'M3_Aiko_SE_Base', 'M2_Aeon_SE_Base_Marker', 210,
{
M3_Aiko_SE_Base_FirstStructure = 150,
}
)
-- Create a T3 Air Factory first, so we can pump out Engineers
M3AikoSEBase:AddBuildGroup('M3_Aiko_SE_Base_D1' , 100)
M3AikoSEBase:SetSupportACUCount(1)
M3AikoSEBase:SetSACUUpgrades({'Shield', 'AdvancedCoolingUpgrade', 'ResourceAllocation'}, false)
M3AikoSEBase:StartEmptyBase({16, 12, 8})
M3AikoSEBase:SetMaximumConstructionEngineers(12)
M3AikoSEBase:SetActive('AirScouting', true)
ArmyBrains[BlackSun]:PBMSetCheckInterval(7)
M3AikoSEBaseNavalAttacks()
M3AikoSEBaseTransportAttacks()
M3AikoSEBaseAirAttacks()
M3AikoSEBaseAirDefense()
M3AikoSEBaseExperimentalAttacks()
M3AikoAirStagingBase()
end
-- No need to add a BaseManager instance for just some air staging platforms, create a simple building template, and an engineer platoon that will maintain it
function M3AikoAirStagingBase()
-- Create the base template
AIBuildStructures.CreateBuildingTemplate(ArmyBrains[BlackSun], 'Black_Sun', 'M3_Aiko_AirStaging_Base')
AIBuildStructures.AppendBuildingTemplate(ArmyBrains[BlackSun], 'Black_Sun', 'M3_Aiko_AirStaging_Base', 'M3_Aiko_AirStaging_Base')
-- Add the platoon to maintain the base
local Builder = {
BuilderName = 'M3_Aiko_AirStaging_Base_Engineers_Builder',
PlatoonTemplate = {
'M3_Aiko_T3_Engineer_Template',
'NoPlan',
{ 'uel0309', 1, 1, 'Attack', 'NoFormation' }, -- T3 Engineers
},
InstanceCount = 2,
Priority = 100,
PlatoonType = 'Any',
RequiresConstruction = true,
LocationType = 'M3_Aiko_SE_Base',
BuildConditions = {
{'/lua/editor/miscbuildconditions.lua', 'MissionNumberGreaterOrEqual', {2}},
},
PlatoonAIFunction = {SPAIFileName, 'StartBaseEngineerThread'},
PlatoonData = {
MaintainBaseTemplate = 'M3_Aiko_AirStaging_Base',
PatrolChain = 'BlackSun_M3_AirStaging_Island_Patrol_Chain',
},
}
ArmyBrains[BlackSun]:PBMAddPlatoon(Builder)
end
function M3AikoSEBaseNavalAttacks()
local opai = nil
local T3Quantity = {2, 1, 1}
local T2Quantity = {4, 3, 2}
local T1Quantity = {6, 5, 3}
-- M3 Main Aiko Fleet for Phase 2
local Temp = {
'M3_Aiko_SouthEastern_Naval_Fleet',
'NoPlan',
{ 'ues0302', 0, T3Quantity[Difficulty], 'Attack', 'AttackFormation' }, -- T3 Battleship
{ 'ues0201', 0, T2Quantity[Difficulty], 'Attack', 'AttackFormation' }, -- T2 Destroyer
{ 'ues0202', 0, T2Quantity[Difficulty], 'Attack', 'AttackFormation' }, -- T2 Cruiser
{ 'ues0103', 0, T1Quantity[Difficulty], 'Attack', 'AttackFormation' }, -- T1 Frigate
{ 'ues0203', 0, T1Quantity[Difficulty], 'Attack', 'AttackFormation' }, -- T1 Submarine
}
local Builder = {
BuilderName = 'M3_Aiko_SouthEastern_Naval_Fleet_Builder',
PlatoonTemplate = Temp,
InstanceCount = Difficulty,
Priority = 100,
PlatoonType = 'Sea',
RequiresConstruction = true,
LocationType = 'M3_Aiko_SE_Base',
BuildConditions = {
{'/lua/editor/miscbuildconditions.lua', 'MissionNumberGreaterOrEqual', {3}},
{'/lua/editor/unitcountbuildconditions.lua', 'HaveGreaterThanUnitsWithCategory', {0, categories.ueb0303}},
},
PlatoonAIFunction = {AIAttackUtils, 'NavalForceAI'},
PlatoonData = {
PatrolChains = {
'BlackSun_M3_Eastern_Naval_Chain',
'BlackSun_M3_Western_Naval_Chain',
},
UseFormation = 'AttackFormation',
},
BuildTimeOut = 300,
}
ArmyBrains[BlackSun]:PBMAddPlatoon(Builder)
-- M3 Aiko Fleet for probe attacks
Temp = {
'M3_Aiko_SouthEastern_Naval_Probe_Attack',
'NoPlan',
{ 'ues0201', 0, 2, 'Attack', 'AttackFormation' }, -- T2 Destroyer
{ 'ues0202', 0, 2, 'Attack', 'AttackFormation' }, -- T2 Cruiser
{ 'ues0103', 0, 3, 'Attack', 'AttackFormation' }, -- T1 Frigate
{ 'ues0203', 0, 3, 'Attack', 'AttackFormation' }, -- T1 Submarine
}
Builder = {
BuilderName = 'M3_Aiko_SouthEastern_Naval_Probe_Attack_Builder',
PlatoonTemplate = Temp,
InstanceCount = Difficulty,
Priority = 100,
PlatoonType = 'Sea',
RequiresConstruction = true,
LocationType = 'M3_Aiko_SE_Base',
BuildConditions = {
{'/lua/editor/miscbuildconditions.lua', 'MissionNumberGreaterOrEqual', {2}},
{'/lua/editor/unitcountbuildconditions.lua', 'HaveGreaterThanUnitsWithCategory', {0, categories.ueb0303}},
},
PlatoonAIFunction = {AIAttackUtils, 'NavalForceAI'},
PlatoonData = {
PatrolChains = {
'BlackSun_M3_Eastern_Naval_Chain',
'BlackSun_M3_Western_Naval_Chain',
},
UseFormation = 'AttackFormation',
},
BuildTimeOut = 150,
}
ArmyBrains[BlackSun]:PBMAddPlatoon(Builder)
-- Reclaim platoon
Builder = {
BuilderName = 'M3_Aiko_Reclaim_Engineers_Builder',
PlatoonTemplate = {
'M3_Aiko_T3_Reclaim_Engineer_Template',
'NoPlan',
{ 'uel0309', 1, 1, 'Attack', 'NoFormation' }, -- T3 Engineer
},
InstanceCount = 8,
Priority = 100,
PlatoonType = 'Any',
RequiresConstruction = true,
LocationType = 'M3_Aiko_SE_Base',
BuildConditions = {
{'/lua/editor/miscbuildconditions.lua', 'MissionNumberGreaterOrEqual', {2}},
{CustomFunctions, 'LessMassStorageCurrent', {8500}},
},
PlatoonAIFunction = {CustomFunctions, 'EngineerPlatoonReclaim'},
}
ArmyBrains[BlackSun]:PBMAddPlatoon(Builder)
end
function M3AikoSEBaseTransportAttacks()
local opai = nil
local T3Quantity = {4, 3, 2}
local T2Quantity = {5, 4, 3}
local poolName = 'M3_Aiko_SE_Base_TransportPool'
-- T2 Transport Platoon
local Temp = {
'M3_Aiko_SouthEastern_Transport_Platoon',
'NoPlan',
{ 'uea0104', 1, 6, 'Attack', 'None' }, -- T2 Transport
}
local Builder = {
BuilderName = 'M3_Aiko_SouthEastern_Transport_Platoon',
PlatoonTemplate = Temp,
InstanceCount = 1,
Priority = 300,
PlatoonType = 'Air',
RequiresConstruction = true,
LocationType = 'M3_Aiko_SE_Base',
BuildConditions = {
{CustomFunctions, 'HaveLessThanUnitsInTransportPool', {12, poolName}},
},
PlatoonAIFunction = {CustomFunctions, 'TransportPool'},
PlatoonData = {
BaseName = 'M3_Aiko_SE_Base',
},
}
ArmyBrains[BlackSun]:PBMAddPlatoon(Builder)
Builder = {
BuilderName = 'M3_Aiko_Southern_Land_Assault',
PlatoonTemplate = {
'M3_Aiko_Southern_Land_Assault_Template',
'NoPlan',
{'uel0303', 1, T3Quantity[Difficulty], 'Attack', 'AttackFormation'}, -- T3 Siege Bot
{'uel0304', 1, T3Quantity[Difficulty], 'Artillery', 'AttackFormation'}, -- T3 Artillery
{'uel0202', 1, T2Quantity[Difficulty], 'Attack', 'AttackFormation'}, -- T2 Heavy Tank
{'uel0205', 1, T2Quantity[Difficulty], 'Attack', 'AttackFormation'}, -- T2 Mobile AA
{'uel0307', 1, T2Quantity[Difficulty], 'Attack', 'AttackFormation'}, -- T2 Mobile Shield
},
InstanceCount = 8,
Priority = 100,
PlatoonType = 'Land',
RequiresConstruction = true,
LocationType = 'M3_Aiko_SE_Base',
BuildConditions = {
{CustomFunctions, 'HaveGreaterOrEqualThanUnitsInTransportPool', {6, poolName}},
},
PlatoonAIFunction = {AIAttackUtils, 'AttackForceAI'},
PlatoonData = {
AttackChain = 'BlackSun_M3_Control_Center_Defense_Chain',
LandingChain = 'Aeon_M2_Land_Assault_Landing_Chain',
TransportReturn = 'M2_Aeon_SE_Base_Marker',
BaseName = 'M3_Aiko_SE_Base',
UseFormation = 'AttackFormation',
},
}
ArmyBrains[BlackSun]:PBMAddPlatoon(Builder)
end
function M3AikoSEBaseAirAttacks()
local opai = nil
local quantity = {18, 15, 12}
local trigger = {20, 25, 30}
-- Sends [18, 12, 6] Air Superiority Fighters to enemies if they have >= 20, 25, 30 air units
opai = M3AikoSEBase:AddOpAI('AirAttacks', 'M3_AikoSouthEastern_AirSuperiority_Attack',
{
MasterPlatoonFunction = {SPAIFileName, 'PlatoonAttackClosestUnit'},
Priority = 150,
}
)
opai:SetChildQuantity('AirSuperiority', quantity[Difficulty])
opai:AddBuildCondition('/lua/editor/otherarmyunitcountbuildconditions.lua',
'BrainsCompareNumCategory', {{'Cybran', 'Aeon'}, trigger[Difficulty], categories.AIR * categories.MOBILE, '>='})
-- Sends [18, 12, 6] Torpedo Bombers to enemies if they have >= 15, 10, 5 naval units
trigger = {5, 10, 15}
opai = M3AikoSEBase:AddOpAI('AirAttacks', 'M3_AikoSouthEastern_TorpedoBombers_Attack',
{
MasterPlatoonFunction = {SPAIFileName, 'PlatoonAttackClosestUnit'},
Priority = 140,
}
)
opai:SetChildQuantity('TorpedoBombers', quantity[Difficulty])
opai:AddBuildCondition('/lua/editor/otherarmyunitcountbuildconditions.lua',
'BrainsCompareNumCategory', {{'Cybran', 'Aeon'}, trigger[Difficulty], categories.NAVAL * categories.MOBILE, '>='})
-- Sends [18, 12, 6] Strategic Bombers to enemies
opai = M3AikoSEBase:AddOpAI('AirAttacks', 'M3_AikoSouthEastern_StratBombers_Attack',
{
MasterPlatoonFunction = {SPAIFileName, 'PlatoonAttackHighestThreat'},
Priority = 140,
}
)
opai:SetChildQuantity('StratBombers', quantity[Difficulty])
opai:AddBuildCondition('/lua/editor/miscbuildconditions.lua', 'MissionNumberGreaterOrEqual', {3})
-- Sends [18, 12, 6] Gunships to enemies
opai = M3AikoSEBase:AddOpAI('AirAttacks', 'M3_AikoSouthEastern_Gunships_Attack',
{
MasterPlatoonFunction = {SPAIFileName, 'PlatoonAttackHighestThreat'},
Priority = 140,
}
)
opai:SetChildQuantity('Gunships', quantity[Difficulty])
-- Sends [18, 12, 6] Heavy Gunships to enemies
opai = M3AikoSEBase:AddOpAI('AirAttacks', 'M3_AikoSouthEastern_HeavyGunships_Attack',
{
MasterPlatoonFunction = {SPAIFileName, 'PlatoonAttackHighestThreat'},
Priority = 140,
}
)
opai:SetChildQuantity('HeavyGunships', quantity[Difficulty])
-- Aiko general air template
quantity = {6, 5, 4}
local Builder = {
BuilderName = 'M3_Aiko_Main_AirForce_Builder',
PlatoonTemplate = {
'M3_Aiko_Main_AirForce_Template',
'NoPlan',
{ 'uea0305', 1, quantity[Difficulty], 'Attack', 'AttackFormation' }, -- T3 Heavy Gunship
{ 'uea0304', 1, quantity[Difficulty], 'Attack', 'AttackFormation' }, -- T3 Strat Bomber
{ 'uea0303', 1, quantity[Difficulty], 'Attack', 'AttackFormation' }, -- T3 ASF
{ 'uea0203', 1, quantity[Difficulty] * 2, 'Attack', 'AttackFormation' }, -- T2 Gunship
},
InstanceCount = Difficulty * 2,
Priority = 100,
PlatoonType = 'Air',
RequiresConstruction = true,
LocationType = 'M3_Aiko_SE_Base',
BuildConditions = {
{'/lua/editor/miscbuildconditions.lua', 'MissionNumberGreaterOrEqual', {3}},
},
PlatoonAIFunction = {SPAIFileName, 'PlatoonAttackHighestThreat'}
}
ArmyBrains[BlackSun]:PBMAddPlatoon(Builder)
end
function M3AikoSEBaseAirDefense()
local opai = nil
local quantity = {18, 15, 12}
local ChildType = {'AirSuperiority', 'StratBombers', 'HeavyGunships', 'Gunships', 'Bombers', 'Interceptors'}
-- Maintains [18, 15, 12] units defined in ChildType
for k = 1, table.getn(ChildType) do
opai = M3AikoSEBase:AddOpAI('AirAttacks', 'M3_Aiko_SouthEastern_AirDefense' .. ChildType[k],
{
MasterPlatoonFunction = {SPAIFileName, 'RandomDefensePatrolThread'},
PlatoonData = {
PatrolChain = 'BlackSun_M3_Island_Defense_Chain',
},
Priority = 200 - k, -- ASFs are first
}
)
opai:SetChildQuantity(ChildType[k], quantity[Difficulty])
opai:SetLockingStyle('DeathRatio', {Ratio = 0.5})
end
end
function M3AikoSEBaseExperimentalAttacks()
local opai = nil
-- Atlantis patrols
opai = M3AikoSEBase:AddOpAI('M3_Aiko_SE_Atlantis',
{
Amount = 2,
KeepAlive = true,
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {
'BlackSun_M3_Eastern_Naval_Chain',
'BlackSun_M3_Western_Naval_Chain',
},
},
BuildCondition = {
{'/lua/editor/miscbuildconditions.lua', 'MissionNumberGreaterOrEqual', {3}}
},
MaxAssist = Difficulty,
Retry = true,
}
)
end