Improve AI squad pathing and regrouping behavior.

Ensure the target location can be pathed to by all units in the squad, so the squad won't get stuck if some units can't make it. Improve the choice of leader for the squad. We attempt to a choose a leader whose locomotor is the most restrictive in terms of passable terrain. This maximises the chance that the squad will be able to follow the leader along the path to the target. We also keep this choice of leader as the squad advances, this avoids the squad constantly switching leaders and regrouping backwards in some cases.
This commit is contained in:
RoosterDragon
2023-07-20 19:08:49 +01:00
committed by Gustas
parent 24536fa296
commit a67e85e092
6 changed files with 80 additions and 33 deletions

View File

@@ -85,9 +85,8 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
if (!squad.IsValid)
return false;
var randomSquadUnit = squad.Units.Random(squad.Random);
var dangerRadius = squad.SquadManager.Info.DangerScanRadius;
var units = squad.World.FindActorsInCircle(randomSquadUnit.CenterPosition, WDist.FromCells(dangerRadius)).ToList();
var units = squad.World.FindActorsInCircle(squad.CenterPosition(), WDist.FromCells(dangerRadius)).ToList();
// If there are any own buildings within the DangerRadius, don't flee
// PERF: Avoid LINQ