@@ -5,7 +5,10 @@ function MetaFight:BrainCheck()
5
5
-- Clear all objective markers, they get re-added each frame
6
6
self :ClearObjectivePoints ();
7
7
-- Keep track of which teams we have set objective points for already, since multiple players can be on the same team
8
- local setTeam = { [Activity .TEAM_1 ] = false , [Activity .TEAM_2 ] = false , [Activity .TEAM_3 ] = false , [Activity .TEAM_4 ] = false };
8
+ local setTeam = {};
9
+ for team = Activity .TEAM_1 , Activity .MAXTEAMCOUNT - 1 do
10
+ setTeam [team ] = false ;
11
+ end
9
12
10
13
---- -------------------------------------------------------------
11
14
-- Brain integrity check logic for every player, Human or AI
@@ -166,36 +169,33 @@ function MetaFight:StartActivity()
166
169
-- self.CurrentScanStage = { [Activity.TEAM_1] = self.ScanStage.PRESCAN, [Activity.TEAM_2] = self.ScanStage.PRESCAN, [Activity.TEAM_3] = self.ScanStage.PRESCAN, [Activity.TEAM_4] = self.ScanStage.PRESCAN };
167
170
-- Start by assming no teams have scanning scheduled
168
171
self .CurrentScanStage = self .ScanStage .DONESCAN ;
169
- self .ScanPosX = { [ Activity . TEAM_1 ] = - 1 , [ Activity . TEAM_2 ] = - 1 , [ Activity . TEAM_3 ] = - 1 , [ Activity . TEAM_4 ] = - 1 };
170
- self .ScanTimer = { [ Activity . TEAM_1 ] = Timer (), [ Activity . TEAM_2 ] = Timer (), [ Activity . TEAM_3 ] = Timer (), [ Activity . TEAM_4 ] = Timer () };
171
- self .StartFunds = { [ Activity . TEAM_1 ] = 0 , [ Activity . TEAM_2 ] = 0 , [ Activity . TEAM_3 ] = 0 , [ Activity . TEAM_4 ] = 0 };
172
+ self .ScanPosX = {};
173
+ self .ScanTimer = {};
174
+ self .StartFunds = {};
172
175
self .ScanEndPos = Vector ();
173
176
174
- -- Reset scan timers and check that there's any teams with a scheduled scan at all
175
- for team = Activity .TEAM_1 , Activity .MAXTEAMCOUNT - 1 do
176
- if self :TeamActive (team ) then
177
- self .ScanTimer [team ]:Reset ();
178
- -- Yes there is at least one active team that has scanning scheduled
179
- if SceneMan .Scene :IsScanScheduled (team ) then
180
- self .CurrentScanStage = self .ScanStage .PRESCAN ;
181
- end
182
- end
183
- end
184
-
185
177
-- Which are the invading teams
186
- self .InvadingTeam = { [ Activity . TEAM_1 ] = false , [ Activity . TEAM_2 ] = false , [ Activity . TEAM_3 ] = false , [ Activity . TEAM_4 ] = false };
178
+ self .InvadingTeam = {};
187
179
-- Which Teams are managed tactically by the AI? Only teams with NO human players on them
188
- self .TeamAIActive = { [ Activity . TEAM_1 ] = false , [ Activity . TEAM_2 ] = false , [ Activity . TEAM_3 ] = false , [ Activity . TEAM_4 ] = false };
180
+ self .TeamAIActive = {};
189
181
-- Team has given up and is evacuating their brain
190
- self .TeamEvacuating = { [ Activity . TEAM_1 ] = false , [ Activity . TEAM_2 ] = false , [ Activity . TEAM_3 ] = false , [ Activity . TEAM_4 ] = false };
182
+ self .TeamEvacuating = {};
191
183
192
184
-- A list of AI controlled team numbers
193
185
local CPUTeams = {};
194
186
-- Timers for controlling the AI modes of team members
195
187
self .AIModeTimer = {};
196
188
197
189
for team = Activity .TEAM_1 , Activity .MAXTEAMCOUNT - 1 do
190
+ self .ScanPosX [team ] = - 1 ;
191
+ self .ScanTimer [team ] = Timer ();
192
+ self .StartFunds [team ] = 0 ;
193
+
198
194
if self :TeamActive (team ) then
195
+ if SceneMan .Scene :IsScanScheduled (team ) then
196
+ -- Yes there is at least one active team that has scanning scheduled
197
+ self .CurrentScanStage = self .ScanStage .PRESCAN ;
198
+ end
199
199
-- Start out assuming all teams are all AI invaders, then disprove it
200
200
self .InvadingTeam [team ] = true ;
201
201
self .TeamAIActive [team ] = true ;
@@ -220,34 +220,32 @@ function MetaFight:StartActivity()
220
220
self .AIModeTimer [team ] = Timer ();
221
221
table.insert (CPUTeams , team );
222
222
end
223
+ else
224
+ self .InvadingTeam [team ] = false ;
225
+ self .TeamAIActive [team ] = false ;
226
+ self .TeamEvacuating [team ] = false ;
223
227
end
224
228
end
225
229
226
230
-- MetaFight-specific player parameters
227
- self .InvadingPlayer = { [ Activity . PLAYER_1 ] = false , [ Activity . PLAYER_2 ] = false , [ Activity . PLAYER_3 ] = false , [ Activity . PLAYER_4 ] = false };
228
- self .Ready = { [ Activity . PLAYER_1 ] = false , [ Activity . PLAYER_2 ] = false , [ Activity . PLAYER_3 ] = false , [ Activity . PLAYER_4 ] = false };
231
+ self .InvadingPlayer = {};
232
+ self .Ready = {};
229
233
self .InvadingPlayerCount = 0 ;
230
234
-- At what funds level the AI starts thinking about going into brain evacuation mode
231
- self .EvacThreshold = { [ Activity . PLAYER_1 ] = 100 , [ Activity . PLAYER_2 ] = 100 , [ Activity . PLAYER_3 ] = 100 , [ Activity . PLAYER_4 ] = 100 };
235
+ self .EvacThreshold = {};
232
236
-- The last known position of all players' active brains
233
- self .LastBrainPos = { [ Activity . PLAYER_1 ] = Vector (), [ Activity . PLAYER_2 ] = Vector (), [ Activity . PLAYER_3 ] = Vector (), [ Activity . PLAYER_4 ] = Vector () };
237
+ self .LastBrainPos = {};
234
238
-- The position of the last brain that died
235
239
self .LastBrainDeathPos = Vector ();
236
240
237
- -- Count how many invading players there are
238
- for player = Activity .PLAYER_1 , Activity .MAXPLAYERCOUNT - 1 do
239
- if self :PlayerActive (player ) then -- and self:PlayerHuman(player) then
240
- if not SceneMan .Scene :GetResidentBrain (player ) then
241
- self .InvadingPlayerCount = self .InvadingPlayerCount + 1 ;
242
- end
243
- end
244
- end
245
-
246
241
local defenderTeam ;
247
242
local defenderTeamNativeCostMultiplier = 1.0 ;
248
243
249
244
-- Now init all players
250
245
for player = Activity .PLAYER_1 , Activity .MAXPLAYERCOUNT - 1 do
246
+ self .Ready [player ] = false ;
247
+ self .EvacThreshold [player ] = 100 ;
248
+ self .LastBrainPos [player ] = Vector ();
251
249
if self :PlayerActive (player ) then
252
250
-- Reset the timer that will measure the delay between ordering of reinforcements
253
251
-- Determine whether this player is invading or already has a brain to defend here
@@ -273,10 +271,7 @@ function MetaFight:StartActivity()
273
271
-- Invading player
274
272
if not residentBrain then
275
273
self .InvadingPlayer [player ] = true ;
276
- -- Sanity check
277
- if self .InvadingPlayerCount < 1 then
278
- self .InvadingPlayerCount = 1 ;
279
- end
274
+ self .InvadingPlayerCount = self .InvadingPlayerCount + 1 ;
280
275
281
276
-- Human player; init as appropriate for invaders
282
277
if self :PlayerHuman (player ) then
@@ -324,7 +319,7 @@ function MetaFight:StartActivity()
324
319
if residentBrain .Pos .X == - 1 and residentBrain .Pos .Y == - 1 then
325
320
-- Find some random spot to put our brain
326
321
local pos ;
327
- local sucess = false ;
322
+ local success = false ;
328
323
-- Make few attempts to find a suitable spot
329
324
for i = 1 , 10 do
330
325
local rangeWidth ;
@@ -351,16 +346,16 @@ function MetaFight:StartActivity()
351
346
352
347
pos = Vector (math.random (rangeStart , rangeEnd ), 0 );
353
348
354
- sucess = true ;
349
+ success = true ;
355
350
356
351
-- Measure heights 5 times and verify that we can put brain there
357
352
for j = - 2 , 2 do
358
353
if SceneMan :FindAltitude (pos + Vector (j * 10 , 0 ), 0 , 19 ) < 25 then
359
- sucess = false ;
354
+ success = false ;
360
355
end
361
356
end
362
357
363
- if sucess then
358
+ if success then
364
359
break ;
365
360
end
366
361
end
@@ -417,7 +412,7 @@ function MetaFight:StartActivity()
417
412
if residentBrain .Pos .X == - 1 and residentBrain .Pos .Y == - 1 then
418
413
-- Find some random spot to put our brain
419
414
local pos ;
420
- local sucess = false ;
415
+ local success = false ;
421
416
-- Make few attempts to find a suitable spot
422
417
for i = 1 , 20 do
423
418
local rangeWidth ;
@@ -444,16 +439,16 @@ function MetaFight:StartActivity()
444
439
445
440
pos = Vector (math.random (rangeStart , rangeEnd ), 0 );
446
441
447
- sucess = true ;
442
+ success = true ;
448
443
449
444
-- Measure heights 5 times and verify that we can put brain there
450
445
for j = - 2 , 2 do
451
446
if SceneMan :FindAltitude (pos + Vector (j * 10 , 0 ), 0 , 19 ) < 25 then
452
- sucess = false ;
447
+ success = false ;
453
448
end
454
449
end
455
450
456
- if sucess then
451
+ if success then
457
452
break ;
458
453
end
459
454
end
@@ -1435,13 +1430,13 @@ function MetaFight:OrderHeavyLoadout(player, team)
1435
1430
if actorsInCargo >= passengerLimit or totalMass > craftMaxMass then
1436
1431
break ;
1437
1432
end
1438
-
1439
- return true ;
1440
1433
end
1441
1434
1442
1435
if diggers < 1 then
1443
1436
self :AddOverridePurchase (CreateHDFirearm (" Light Digger" , " Base.rte" ), player );
1444
1437
end
1438
+
1439
+ return true ;
1445
1440
end
1446
1441
end
1447
1442
0 commit comments