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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -292,6 +292,7 @@ Player:
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog, badr.bomber, u2
|
||||
ConstructionYardTypes: fact
|
||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
||||
AircraftTargetType: AirborneActor
|
||||
ProtectionTypes: harv, mcv, mslo, gap, spen, syrd, iron, pdox, tsla, agun, dome, pbox, hbox, gun, ftur, sam, atek, weap, fact, proc, silo, hpad, afld, afld.ukraine, powr, apwr, stek, barr, kenn, tent, fix, fpwr, tenf, syrf, spef, weaf, domf, fixf, fapw, atef, pdof, mslf, facf
|
||||
IgnoredEnemyTargetTypes: AirborneActor
|
||||
McvManagerBotModule:
|
||||
@@ -333,6 +334,7 @@ Player:
|
||||
ConstructionYardTypes: fact
|
||||
NavalProductionTypes: spen, syrd
|
||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
||||
AircraftTargetType: AirborneActor
|
||||
ProtectionTypes: harv, mcv, mslo, gap, spen, syrd, iron, pdox, tsla, agun, dome, pbox, hbox, gun, ftur, sam, atek, weap, fact, proc, silo, hpad, afld, afld.ukraine, powr, apwr, stek, barr, kenn, tent, fix, fpwr, tenf, syrf, spef, weaf, domf, fixf, fapw, atef, pdof, mslf, facf
|
||||
IgnoredEnemyTargetTypes: AirborneActor
|
||||
UnitBuilderBotModule@normal:
|
||||
@@ -378,6 +380,7 @@ Player:
|
||||
ConstructionYardTypes: fact
|
||||
NavalProductionTypes: spen, syrd
|
||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
||||
AircraftTargetType: AirborneActor
|
||||
ProtectionTypes: harv, mcv, mslo, gap, spen, syrd, iron, pdox, tsla, agun, dome, pbox, hbox, gun, ftur, sam, atek, weap, fact, proc, silo, hpad, afld, afld.ukraine, powr, apwr, stek, barr, kenn, tent, fix, fpwr, tenf, syrf, spef, weaf, domf, fixf, fapw, atef, pdof, mslf, facf
|
||||
IgnoredEnemyTargetTypes: AirborneActor
|
||||
UnitBuilderBotModule@turtle:
|
||||
@@ -431,6 +434,7 @@ Player:
|
||||
ConstructionYardTypes: fact
|
||||
NavalProductionTypes: spen, syrd
|
||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
||||
AircraftTargetType: AirborneActor
|
||||
ProtectionTypes: harv, mcv, mslo, gap, spen, syrd, iron, pdox, tsla, agun, dome, pbox, hbox, gun, ftur, sam, atek, weap, fact, proc, silo, hpad, afld, afld.ukraine, powr, apwr, stek, barr, kenn, tent, fix, fpwr, tenf, syrf, spef, weaf, domf, fixf, fapw, atef, pdof, mslf, facf
|
||||
IgnoredEnemyTargetTypes: AirborneActor
|
||||
UnitBuilderBotModule@naval:
|
||||
|
||||
Reference in New Issue
Block a user