-
Notifications
You must be signed in to change notification settings - Fork 0
/
DePuce_Defence_M4OrderAI.lua
245 lines (226 loc) · 8.39 KB
/
DePuce_Defence_M4OrderAI.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
local BaseManager = import('/lua/ai/opai/basemanager.lua')
local SPAIFileName = '/lua/scenarioplatoonai.lua'
local ScenarioFramework = import('/lua/ScenarioFramework.lua')
local ScenarioPlatoonAI = import('/lua/ScenarioPlatoonAI.lua')
local ScenarioUtils = import('/lua/sim/ScenarioUtilities.lua')
local Buff = import('/lua/sim/Buff.lua')
local Order_M4_South_East_Base = BaseManager.CreateBaseManager()
local Difficulty = ScenarioInfo.Options.Difficulty
local WaitForAttackSecondsMultiplier = {1.2,1,0.8}
local UnitModifier = {0.5,1,2}
local Order = 2
function Order_M4_South_East_BaseAI(PlayerCount)
Order_M4_South_East_Base:Initialize(ArmyBrains[Order], 'Order_M4_South_East_Base', 'Order_M4_South_East_Base_Marker', 90, {Order_M4_South_East_Base = 600})
Order_M4_South_East_Base:StartNonZeroBase({{10,16,24}, {6,10,16}})
Order_M4_South_East_Base_Patrol(PlayerCount)
end
function Order_M4_South_East_Base_Patrol(PlayerCount)
local opai = nil
local Temp = {
'Order_M4_Patrol_Builder_1',
'NoPlan',
{ 'uaa0303', 1, (6+PlayerCount/2), 'Attack', 'GrowthFormation' }, # T3 Air Superiority Fighter
}
local Builder = {
BuilderName = 'Order_M4_Patrol_Builder_1',
PlatoonTemplate = Temp,
InstanceCount = 2,
Priority = 320,
PlatoonType = 'Air',
RequiresConstruction = true,
LocationType = 'Order_M4_South_East_Base',
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {'Order_M4_Patrol'}
},
}
ArmyBrains[Order]:PBMAddPlatoon( Builder )
local Temp = {
'Order_M4_Patrol_Template_2',
'NoPlan',
{ 'xaa0305', 1, (6+PlayerCount/2), 'Attack', 'GrowthFormation' }, # T3 AA Gunship
}
local Builder = {
BuilderName = 'Order_M4_Patrol_Builder_2',
PlatoonTemplate = Temp,
InstanceCount = 2,
Priority = 310,
PlatoonType = 'Air',
RequiresConstruction = true,
LocationType = 'Order_M4_South_East_Base',
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {'Order_M4_Patrol'}
},
}
ArmyBrains[Order]:PBMAddPlatoon( Builder )
end
function Order_M4_South_East_Base_Air_Attacks(PlayerCount)
Order_M4_South_East_Base:SetActive('AirScouting', true)
local opai = nil
local Temp = {
'Order_M4_Air_Attack_Template_1',
'NoPlan',
{ 'uaa0203', 1, (10+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T2 Gunship
{ 'xaa0305', 1, (8+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 Gunship
}
local Builder = {
BuilderName = 'Order_M4_Air_Attack_Builder_1',
PlatoonTemplate = Temp,
InstanceCount = 2,
Priority = 140,
PlatoonType = 'Air',
RequiresConstruction = true,
LocationType = 'Order_M4_South_East_Base',
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {'Order_M4_Air_Attack_Chain_1', 'Order_M4_Air_Attack_Chain_2', 'Order_M4_Air_Attack_Chain_3'}
},
}
ArmyBrains[Order]:PBMAddPlatoon( Builder )
local Temp = {
'Order_M4_Air_Attack_Template_2',
'NoPlan',
{ 'uaa0304', 1, (8+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 Bomber
}
local Builder = {
BuilderName = 'Order_M4_Air_Attack_Builder_2',
PlatoonTemplate = Temp,
InstanceCount = 2,
Priority = 110,
PlatoonType = 'Air',
RequiresConstruction = true,
LocationType = 'Order_M4_South_East_Base',
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {'Order_M4_Air_Attack_Chain_1', 'Order_M4_Air_Attack_Chain_2', 'Order_M4_Air_Attack_Chain_3'}
},
}
ArmyBrains[Order]:PBMAddPlatoon( Builder )
local Temp = {
'Order_M4_Air_Attack_Template_3',
'NoPlan',
{ 'uaa0303', 1, (8+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 Fighter
{ 'uaa0304', 1, (6+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 Bomber
}
local Builder = {
BuilderName = 'Order_M4_Air_Attack_Builder_3',
PlatoonTemplate = Temp,
InstanceCount = 2,
Priority = 120,
PlatoonType = 'Air',
RequiresConstruction = true,
LocationType = 'Order_M4_South_East_Base',
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {'Order_M4_Air_Attack_Chain_1', 'Order_M4_Air_Attack_Chain_2', 'Order_M4_Air_Attack_Chain_3'}
},
}
ArmyBrains[Order]:PBMAddPlatoon( Builder )
end
function Order_M4_South_East_Base_Land_Attacks(PlayerCount)
local opai = nil
local Temp = {
'Order_M4_Land_Attack_Template_1',
'NoPlan',
{ 'ual0307', 1, (4+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T2 Shield Generator
{ 'ual0303', 1, (8+PlayerCount)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 Attack Bot
{ 'dalk003', 1, (6+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 AA
{ 'ual0205', 1, (2+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T2 AA
{ 'ual0202', 1, (4+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T2 Heavy Tank
}
local Builder = {
BuilderName = 'Order_M4_Land_Attack_Builder_1',
PlatoonTemplate = Temp,
InstanceCount = 2,
Priority = 120,
PlatoonType = 'Land',
RequiresConstruction = true,
LocationType = 'Order_M4_South_East_Base',
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {'Order_M4_Land_Attack_Chain_1', 'Order_M4_Land_Attack_Chain_2'}
},
}
ArmyBrains[Order]:PBMAddPlatoon( Builder )
local Temp = {
'Order_M4_Land_Attack_Template_2',
'NoPlan',
{ 'ual0307', 1, (4+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T2 Shield Generator
{ 'ual0303', 1, (6+PlayerCount)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 Sniper Bot
{ 'ual0304', 1, (6+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 Shield Disrupter
{ 'dalk003', 1, (4+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T3 AA
{ 'ual0205', 1, (2+PlayerCount/2)*UnitModifier[Difficulty], 'Attack', 'GrowthFormation' }, # T2 AA
}
local Builder = {
BuilderName = 'Order_M4_Land_Attack_Builder_2',
PlatoonTemplate = Temp,
InstanceCount = 2,
Priority = 120,
PlatoonType = 'Land',
RequiresConstruction = true,
LocationType = 'Order_M4_South_East_Base',
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {'Order_M4_Land_Attack_Chain_1', 'Order_M4_Land_Attack_Chain_2'}
},
}
ArmyBrains[Order]:PBMAddPlatoon( Builder )
end
function Order_M4_Galactic_Colossus()
local opai = nil
local quantity = {}
-- Galactic Colossus Defence
opai = Order_M4_South_East_Base:AddOpAI('Order_M4_Galactic_Colossus_1',
{
Amount = 1,
KeepAlive = true,
PlatoonAIFunction = {SPAIFileName, 'RandomDefensePatrolThread'},
PlatoonData = {
PatrolChain = 'Order_M4_Galactic_Colossus_Defence_1',
},
MaxAssist = 2*UnitModifier[Difficulty],
Retry = true,
}
)
opai = Order_M4_South_East_Base:AddOpAI('Order_M4_Galactic_Colossus_1',
{
Amount = 1,
KeepAlive = true,
PlatoonAIFunction = {SPAIFileName, 'RandomDefensePatrolThread'},
PlatoonData = {
PatrolChain = 'Order_M4_Galactic_Colossus_Defence_2',
},
MaxAssist = 2*UnitModifier[Difficulty],
Retry = true,
}
)
end
function Order_M4_CZAR(PlayerCount)
local opai = nil
local quantity = {}
-- CZAR Attack
opai = Order_M4_South_East_Base:AddOpAI('Order_M4_CZAR',
{
Amount = (2+PlayerCount/2)*UnitModifier[Difficulty],
KeepAlive = true,
PlatoonAIFunction = {SPAIFileName, 'PatrolChainPickerThread'},
PlatoonData = {
PatrolChains = {'Order_M4_Air_Attack_Chain_1', 'Order_M4_Air_Attack_Chain_2', 'Order_M4_Air_Attack_Chain_3'},
},
MaxAssist = 2*UnitModifier[Difficulty],
Retry = true,
}
)
end
function DisableBase()
if(Order_M4_South_East_Base) then
Order_M4_South_East_Base:BaseActive(false)
LOG('Order_M4_South_East_Base Disabled')
end
for _, platoon in ArmyBrains[Order]:GetPlatoonsList() do
platoon:Stop()
ArmyBrains[Order]:DisbandPlatoon(platoon)
end
LOG('All Order Platoons stopped')
end