AI uses better rally point placement

- AI places rally points at pathable locations. A pathable location isn't strictly required, but avoids the AI setting rally points at seemingly dumb locations. This is an addtional check on top of the existing buildability check.
- AI now evaluates rally points every AssignRallyPointsInterval (default 100 ticks). Invalid rally points aren't that harmful, so no need to check them every tick. Additionally we do a rolling update so rally points for multiple locations are spread across multiple ticks to reduce any potential lag spikes.
This commit is contained in:
RoosterDragon
2024-07-06 12:10:55 +01:00
committed by Gustas
parent ab28e6a75a
commit d05b07a5b0
3 changed files with 111 additions and 16 deletions

View File

@@ -258,6 +258,25 @@ namespace OpenRA.Mods.Common.Traits
return hierarchicalPathFindersBlockedByNoneByLocomotor[locomotor].PathExists(source, target);
}
/// <summary>
/// Determines if a path exists between source and target.
/// Terrain and a *subset* of immovable actors are taken into account,
/// i.e. as if a subset of <see cref="BlockedByActor.Immovable"/> was given.
/// This would apply for any actor using the given <see cref="Locomotor"/>.
/// </summary>
/// <remarks>
/// It is allowed for an actor to occupy an inaccessible space and move out of it if another adjacent cell is
/// accessible, but it is not allowed to move into an inaccessible target space. Therefore it is vitally
/// important to not mix up the source and target locations. A path can exist from an inaccessible source space
/// to an accessible target space, but if those parameters as swapped then no path can exist.
/// As only a subset of immovable actors are taken into account,
/// this method can return false positives, indicating a path might exist where none is possible.
/// </remarks>
public bool PathMightExistForLocomotorBlockedByImmovable(Locomotor locomotor, CPos source, CPos target)
{
return hierarchicalPathFindersBlockedByImmovableByLocomotor[locomotor].PathExists(source, target);
}
static Locomotor GetActorLocomotor(Actor self)
{
// PERF: This PathFinder trait requires the use of Mobile, so we can be sure that is in use.