Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit 75d5dfc

Browse files
committed
Bunker breach AI fixes
1 parent 8572f7a commit 75d5dfc

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

Base.rte/Activities/BunkerBreach.lua

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -332,25 +332,25 @@ function BunkerBreach:UpdateActivity()
332332
local dist = Vector();
333333
local searchRadius = (SceneMan.SceneWidth + SceneMan.SceneHeight) * 0.2;
334334
local targetActor = MovableMan:GetClosestEnemyActor(self.CPUTeam, Vector(self.defenderBrain.Pos.X, SceneMan.SceneHeight * 0.5), searchRadius, dist);
335-
if targetActor and not SceneMan:IsUnseen(targetActor.Pos.X, targetActor.Pos.Y, self.CPUTeam) then
336-
self.attackPos = targetActor.Pos;
337-
338-
self.CPUSpawnDelay = self.CPUSpawnDelay * 0.5;--* dist.Magnitude/searchRadius;
339-
--TODO: Fix GetClosestTeamActor and use that instead
340-
local closestGuard = MovableMan:GetClosestEnemyActor(targetActor.Team, targetActor.Pos, searchRadius - dist.Magnitude, Vector());
341-
if closestGuard and math.random() > dist.Magnitude/searchRadius then
342-
--Send a nearby alerted guard after the intruder
343-
closestGuard.AIMode = Actor.AIMODE_GOTO;
344-
closestGuard:SetAIMOWayPoint(targetActor);
345-
self.attackPos = nil;
346-
--A guard has been sent, the next unit should spawn faster
347-
self.CPUSpawnDelay = self.CPUSpawnDelay * 0.8;
335+
if targetActor then
336+
if SceneMan:IsUnseen(targetActor.Pos.X, targetActor.Pos.Y, self.CPUTeam) then
337+
self.attackPos = targetActor.Pos;
348338
else
349-
self:CreateDrop(self.CPUTeam);
350-
self.CPUSpawnDelay = (40000 - self.difficultyRatio * 20000 + unitRatio * 7500) * rte.SpawnIntervalScale;
351-
if math.random() < 0.5 then
352-
--Change target for the next attack
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);
353344
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
354354
end
355355
end
356356
else
@@ -520,11 +520,12 @@ function BunkerBreach:CreateInfantry(team, loadout)
520520
if loadout == "Engineer" and self.sendGoldDiggers then
521521
actor.AIMode = Actor.AIMODE_GOLDDIG;
522522
elseif self.attackPos then
523+
actor.AIMode = Actor.AIMODE_GOTO;
523524
actor:AddAISceneWaypoint(self.attackPos);
524-
elseif team == self.attackerTeam then
525+
elseif team == self.attackerTeam or math.random() < 0.3 then
525526
actor.AIMode = Actor.AIMODE_BRAINHUNT;
526527
else
527-
actor.AIMode = Actor.AIMODE_SENTRY;
528+
actor.AIMode = math.random() < 0.3 and Actor.AIMODE_PATROL or Actor.AIMODE_SENTRY;
528529
end
529530
actor.Team = team;
530531
return actor;

0 commit comments

Comments
 (0)