@@ -51,6 +51,7 @@ function BunkerBreach:StartActivity()
51
51
self .checkTimer :SetRealTimeLimitMS (1000 );
52
52
self .CPUSpawnTimer = Timer ();
53
53
self .CPUSpawnDelay = (40000 - self .difficultyRatio * 20000 ) * rte .SpawnIntervalScale ;
54
+ self .CPUSearchRadius = math.sqrt (SceneMan .SceneWidth ^ 2 + SceneMan .SceneHeight ^ 2 ) * 0.5 * self .difficultyRatio ;
54
55
55
56
-- Set all actors in the scene to the defending team
56
57
for actor in MovableMan .AddedActors do
@@ -68,8 +69,8 @@ function BunkerBreach:StartActivity()
68
69
end
69
70
70
71
-- CPU team setup
71
- if self .CPUTeam ~= - 1 then
72
- self :SetTeamFunds (5000 * ( 0.5 + math.floor (self .difficultyRatio * 10 ) / 10 ) , self .CPUTeam );
72
+ if self .CPUTeam ~= Activity . NOTEAM then
73
+ self :SetTeamFunds (4000 + 8000 * math.floor (self .difficultyRatio * 5 ) / 5 , self .CPUTeam );
73
74
if (self .CPUTeam ~= self .defenderTeam ) then
74
75
self .CPUSpawnDelay = self .CPUSpawnDelay * 0.5 ;
75
76
end
@@ -195,8 +196,6 @@ function BunkerBreach:StartActivity()
195
196
end
196
197
end
197
198
end
198
- self .enemyForcesCount = 0 ;
199
- self .enemyDiggersCount = 0 ;
200
199
end
201
200
202
201
@@ -314,62 +313,54 @@ function BunkerBreach:UpdateActivity()
314
313
if self .CPUSpawnTimer :IsPastSimMS (self .CPUSpawnDelay ) then
315
314
self .CPUSpawnTimer :Reset ();
316
315
317
- local unitRatio = enemyCount / math.max (allyCount , 1 );
316
+ local enemyUnitRatio = enemyCount / math.max (allyCount , 1 );
318
317
-- Send CPU to dig for gold if funds are low and a digger hasn't recently been sent
319
318
self .sendGoldDiggers = not self .sendGoldDiggers and diggerCount < 3 and (funds < 500 or math.random () < 0.1 );
320
319
321
320
if self .CPUTeam == self .attackerTeam then
322
321
if self .sendGoldDiggers then
323
- self :CreateDrop (self .CPUTeam , " Engineer" );
324
- elseif unitRatio < 1.75 then
325
- self :CreateDrop (self .CPUTeam );
326
- self .CPUSpawnDelay = (30000 - self .difficultyRatio * 15000 + unitRatio * 5000 ) * rte .SpawnIntervalScale ;
322
+ self :CreateDrop (self .CPUTeam , " Engineer" , Actor . AIMODE_GOLDDIG );
323
+ elseif enemyUnitRatio < 1.75 then
324
+ self :CreateDrop (self .CPUTeam , " Any " , Actor . AIMODE_BRAINHUNT );
325
+ self .CPUSpawnDelay = (30000 - self .difficultyRatio * 15000 + enemyUnitRatio * 5000 ) * rte .SpawnIntervalScale ;
327
326
else
328
327
self .CPUSpawnDelay = self .CPUSpawnDelay * 0.9 ;
329
328
end
330
329
elseif self .CPUTeam == self .defenderTeam then
331
330
332
331
local dist = Vector ();
333
- local searchRadius = (SceneMan .SceneWidth + SceneMan .SceneHeight ) * 0.2 ;
334
- local targetActor = MovableMan :GetClosestEnemyActor (self .CPUTeam , Vector (self .defenderBrain .Pos .X , SceneMan .SceneHeight * 0.5 ), searchRadius , dist );
332
+ local targetActor = MovableMan :GetClosestEnemyActor (self .CPUTeam , Vector (self .defenderBrain .Pos .X , SceneMan .SceneHeight * 0.5 ), self .CPUSearchRadius , dist );
335
333
if targetActor then
336
- if SceneMan :IsUnseen (targetActor .Pos .X , targetActor .Pos .Y , self .CPUTeam ) then
337
- self .attackPos = targetActor .Pos ;
334
+ self .chokePoint = targetActor .Pos ;
335
+ local closestGuard = MovableMan :GetClosestTeamActor (self .CPUTeam , Activity .PLAYER_NONE , targetActor .Pos , self .CPUSearchRadius - dist .Magnitude , Vector (), self .defenderBrain );
336
+ if closestGuard and closestGuard .AIMODE == Actor .AIMODE_PATROL then
337
+ -- Send a nearby alerted guard after the intruder
338
+ closestGuard .AIMode = Actor .AIMODE_GOTO ;
339
+ closestGuard :AddAIMOWaypoint (targetActor );
340
+ self .chokePoint = nil ;
341
+ -- A guard has been sent, the next unit should spawn faster
342
+ self .CPUSpawnDelay = self .CPUSpawnDelay * 0.8 ;
338
343
else
339
- local closestGuard = MovableMan :GetClosestTeamActor (self .CPUTeam , Activity .PLAYER_NONE , targetActor .Pos , searchRadius - dist .Magnitude , Vector (), self .defenderBrain );
340
- if closestGuard and closestGuard .AIMODE ~= Actor .AIMODE_GOTO then
341
- -- Send a nearby alerted guard after the intruder
342
- closestGuard .AIMode = Actor .AIMODE_GOTO ;
343
- closestGuard :AddAIMOWaypoint (targetActor );
344
- self .attackPos = nil ;
345
- -- A guard has been sent, the next unit should spawn faster
346
- self .CPUSpawnDelay = self .CPUSpawnDelay * 0.8 ;
347
- else
348
- self :CreateDrop (self .CPUTeam );
349
- self .CPUSpawnDelay = (30000 - self .difficultyRatio * 15000 + unitRatio * 5000 ) * rte .SpawnIntervalScale ;
350
- if math.random () < 0.5 then
351
- -- Change target for the next attack
352
- self .attackPos = nil ;
353
- end
344
+ self :CreateDrop (self .CPUTeam , " Any" , Actor .AIMODE_GOTO );
345
+ self .CPUSpawnDelay = (30000 - self .difficultyRatio * 15000 + enemyUnitRatio * 5000 ) * rte .SpawnIntervalScale ;
346
+ if math.random () < 0.5 then
347
+ -- Change target for the next attack
348
+ self .chokePoint = nil ;
354
349
end
355
350
end
356
351
else
357
- self .attackPos = nil ;
358
-
359
- if unitRatio < 1.25 then
360
- if self .sendGoldDiggers then
361
- self :CreateDrop (self .CPUTeam , " Engineer" );
362
- else
363
- self :CreateDrop (self .CPUTeam );
364
- end
365
- self .CPUSpawnDelay = (40000 - self .difficultyRatio * 20000 + unitRatio * 7500 ) * rte .SpawnIntervalScale ;
352
+ self .chokePoint = nil ;
353
+
354
+ if self .sendGoldDiggers then
355
+ self :CreateDrop (self .CPUTeam , " Engineer" , Actor .AIMODE_GOLDDIG );
366
356
else
367
- self . CPUSpawnDelay = self . CPUSpawnDelay * 0.9 ;
357
+ self : CreateDrop ( self . CPUTeam , " Any " , enemyUnitRatio < RangeRand ( 1.5 , 0.5 ) and Actor . AIMODE_BRAINHUNT or Actor . AIMODE_PATROL ) ;
368
358
end
359
+ self .CPUSpawnDelay = (40000 - self .difficultyRatio * 20000 + enemyUnitRatio * 7500 ) * rte .SpawnIntervalScale ;
369
360
end
370
361
end
371
362
end
372
- elseif enemyCount < 1 then
363
+ elseif enemyCount < 0.5 then
373
364
for actor in MovableMan .Actors do
374
365
if actor .Team ~= self .playerTeam then
375
366
actor .Status = Actor .INACTIVE ;
@@ -384,10 +375,13 @@ function BunkerBreach:UpdateActivity()
384
375
end
385
376
386
377
387
- function BunkerBreach :CreateDrop (team , loadout )
378
+ function BunkerBreach :CreateDrop (team , loadout , aiMode )
388
379
local tech = self :GetTeamTech (team );
389
380
local crabRatio = self :GetCrabToHumanSpawnRatio (PresetMan :GetModuleID (tech ));
390
381
382
+ if loadout == " Any" then
383
+ loadout = nil ;
384
+ end
391
385
local craft = RandomACDropShip (" Craft" , tech );
392
386
if not craft or craft .MaxInventoryMass <= 0 then
393
387
-- MaxMass not defined, spawn a default craft
@@ -420,6 +414,16 @@ function BunkerBreach:CreateDrop(team, loadout)
420
414
end
421
415
422
416
if passenger then
417
+ if aiMode then
418
+ passenger .AIMode = aiMode ;
419
+ if aiMode == Actor .AIMODE_GOTO then
420
+ if self .chokePoint then
421
+ passenger :AddAISceneWaypoint (self .chokePoint );
422
+ else
423
+ passenger .AIMode = Actor .AIMODE_BRAINHUNT ;
424
+ end
425
+ end
426
+ end
423
427
craft :AddInventoryItem (passenger );
424
428
end
425
429
end
@@ -517,18 +521,7 @@ function BunkerBreach:CreateInfantry(team, loadout)
517
521
end
518
522
end
519
523
end
520
- if loadout == " Engineer" and self .sendGoldDiggers then
521
- actor .AIMode = Actor .AIMODE_GOLDDIG ;
522
- elseif self .attackPos then
523
- actor .AIMode = Actor .AIMODE_GOTO ;
524
- actor :AddAISceneWaypoint (self .attackPos );
525
- elseif team == self .attackerTeam then
526
- actor .AIMode = Actor .AIMODE_BRAINHUNT ;
527
- elseif loadout == " CQB" then
528
- actor .AIMode = Actor .AIMODE_PATROL ;
529
- else
530
- actor .AIMode = Actor .AIMODE_SENTRY ;
531
- end
524
+ actor .AIMode = Actor .AIMODE_SENTRY ;
532
525
actor .Team = team ;
533
526
return actor ;
534
527
end
0 commit comments