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.")]
|
[Desc("Own actor types that are prioritized when defending.")]
|
||||||
public readonly HashSet<string> ProtectionTypes = new();
|
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.")]
|
[Desc("Minimum number of units AI must have before attacking.")]
|
||||||
public readonly int SquadSize = 8;
|
public readonly int SquadSize = 8;
|
||||||
|
|
||||||
|
|||||||
@@ -11,18 +11,15 @@
|
|||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.Primitives;
|
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
||||||
{
|
{
|
||||||
abstract class AirStateBase : StateBase
|
abstract class AirStateBase : StateBase
|
||||||
{
|
{
|
||||||
static readonly BitSet<TargetableType> AirTargetTypes = new("Air");
|
|
||||||
|
|
||||||
protected const int MissileUnitMultiplier = 3;
|
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)
|
if (units.Count == 0)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -40,7 +37,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
|||||||
|
|
||||||
foreach (var a in ab.Armaments)
|
foreach (var a in ab.Armaments)
|
||||||
{
|
{
|
||||||
if (a.Weapon.IsValidTarget(AirTargetTypes))
|
if (a.Weapon.IsValidTarget(owner.SquadManager.Info.AircraftTargetType))
|
||||||
{
|
{
|
||||||
missileUnitsCount++;
|
missileUnitsCount++;
|
||||||
break;
|
break;
|
||||||
@@ -99,7 +96,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
|||||||
if (unitsAroundPos.Count == 0)
|
if (unitsAroundPos.Count == 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (CountAntiAirUnits(unitsAroundPos) * MissileUnitMultiplier < owner.Units.Count)
|
if (CountAntiAirUnits(owner, unitsAroundPos) * MissileUnitMultiplier < owner.Units.Count)
|
||||||
{
|
{
|
||||||
detectedEnemyTarget = unitsAroundPos.Random(owner.Random);
|
detectedEnemyTarget = unitsAroundPos.Random(owner.Random);
|
||||||
return true;
|
return true;
|
||||||
@@ -111,7 +108,7 @@ namespace OpenRA.Mods.Common.Traits.BotModules.Squads
|
|||||||
// Checks the number of anti air enemies around units
|
// Checks the number of anti air enemies around units
|
||||||
protected virtual bool ShouldFlee(Squad owner)
|
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
|
ExcludeFromSquadsTypes: harv, mcv, dog, badr.bomber, u2
|
||||||
ConstructionYardTypes: fact
|
ConstructionYardTypes: fact
|
||||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
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
|
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
|
IgnoredEnemyTargetTypes: AirborneActor
|
||||||
McvManagerBotModule:
|
McvManagerBotModule:
|
||||||
@@ -333,6 +334,7 @@ Player:
|
|||||||
ConstructionYardTypes: fact
|
ConstructionYardTypes: fact
|
||||||
NavalProductionTypes: spen, syrd
|
NavalProductionTypes: spen, syrd
|
||||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
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
|
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
|
IgnoredEnemyTargetTypes: AirborneActor
|
||||||
UnitBuilderBotModule@normal:
|
UnitBuilderBotModule@normal:
|
||||||
@@ -378,6 +380,7 @@ Player:
|
|||||||
ConstructionYardTypes: fact
|
ConstructionYardTypes: fact
|
||||||
NavalProductionTypes: spen, syrd
|
NavalProductionTypes: spen, syrd
|
||||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
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
|
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
|
IgnoredEnemyTargetTypes: AirborneActor
|
||||||
UnitBuilderBotModule@turtle:
|
UnitBuilderBotModule@turtle:
|
||||||
@@ -431,6 +434,7 @@ Player:
|
|||||||
ConstructionYardTypes: fact
|
ConstructionYardTypes: fact
|
||||||
NavalProductionTypes: spen, syrd
|
NavalProductionTypes: spen, syrd
|
||||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
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
|
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
|
IgnoredEnemyTargetTypes: AirborneActor
|
||||||
UnitBuilderBotModule@naval:
|
UnitBuilderBotModule@naval:
|
||||||
|
|||||||
Reference in New Issue
Block a user