Fix Air Squad danger detection broken in RA
This commit is contained in:
@@ -47,6 +47,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Own actor types that are prioritized when defending.")]
|
||||
public readonly HashSet<string> ProtectionTypes = new();
|
||||
|
||||
[Desc("Target types are used for identifying aircraft.")]
|
||||
public readonly BitSet<TargetableType> AircraftTargetType = new("Air");
|
||||
|
||||
[Desc("Minimum number of units AI must have before attacking.")]
|
||||
public readonly int SquadSize = 8;
|
||||
|
||||
|
||||
@@ -11,18 +11,15 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Primitives;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
{
|
||||
abstract class AirStateBase : StateBase
|
||||
{
|
||||
static readonly BitSet<TargetableType> AirTargetTypes = new("Air");
|
||||
|
||||
protected const int MissileUnitMultiplier = 3;
|
||||
|
||||
protected static int CountAntiAirUnits(IReadOnlyCollection<Actor> units)
|
||||
protected static int CountAntiAirUnits(Squad owner, IReadOnlyCollection<Actor> units)
|
||||
{
|
||||
if (units.Count == 0)
|
||||
return 0;
|
||||
@@ -40,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
|
||||
foreach (var a in ab.Armaments)
|
||||
{
|
||||
if (a.Weapon.IsValidTarget(AirTargetTypes))
|
||||
if (a.Weapon.IsValidTarget(owner.SquadManager.Info.AircraftTargetType))
|
||||
{
|
||||
missileUnitsCount++;
|
||||
break;
|
||||
@@ -99,7 +96,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
if (unitsAroundPos.Count == 0)
|
||||
return true;
|
||||
|
||||
if (CountAntiAirUnits(unitsAroundPos) * MissileUnitMultiplier < owner.Units.Count)
|
||||
if (CountAntiAirUnits(owner, unitsAroundPos) * MissileUnitMultiplier < owner.Units.Count)
|
||||
{
|
||||
detectedEnemyTarget = unitsAroundPos.Random(owner.Random);
|
||||
return true;
|
||||
@@ -111,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||
// Checks the number of anti air enemies around units
|
||||
protected virtual bool ShouldFlee(Squad owner)
|
||||
{
|
||||
return ShouldFlee(owner, enemies => CountAntiAirUnits(enemies) * MissileUnitMultiplier > owner.Units.Count);
|
||||
return ShouldFlee(owner, enemies => CountAntiAirUnits(owner, enemies) * MissileUnitMultiplier > owner.Units.Count);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user