Unhardcode AI air units and exclude scripted aircraft.
This commit is contained in:
committed by
reaperrr
parent
00ece1ba55
commit
e82aa9977e
@@ -24,6 +24,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Actor types that are valid for naval squads.")]
|
||||
public readonly HashSet<string> NavalUnitsTypes = new HashSet<string>();
|
||||
|
||||
[Desc("Actor types that are excluded from ground attacks.")]
|
||||
public readonly HashSet<string> AirUnitsTypes = new HashSet<string>();
|
||||
|
||||
[Desc("Actor types that should generally be excluded from attack squads.")]
|
||||
public readonly HashSet<string> ExcludeFromSquadsTypes = new HashSet<string>();
|
||||
|
||||
@@ -257,7 +260,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
foreach (var a in newUnits)
|
||||
{
|
||||
if (a.Info.HasTraitInfo<AircraftInfo>() && a.Info.HasTraitInfo<AttackBaseInfo>())
|
||||
if (Info.AirUnitsTypes.Contains(a.Info.Name))
|
||||
{
|
||||
var air = GetSquadOfType(SquadType.Air);
|
||||
if (air == null)
|
||||
@@ -307,10 +310,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
var allEnemyBaseBuilder = AIUtils.FindEnemiesByCommonName(Info.ConstructionYardTypes, Player);
|
||||
|
||||
// TODO: This should use common names & ExcludeFromSquads instead of hardcoding TraitInfo checks
|
||||
var ownUnits = activeUnits
|
||||
.Where(unit => unit.IsIdle && unit.Info.HasTraitInfo<AttackBaseInfo>()
|
||||
&& !unit.Info.HasTraitInfo<AircraftInfo>() && !Info.NavalUnitsTypes.Contains(unit.Info.Name) && !unit.Info.HasTraitInfo<HarvesterInfo>()).ToList();
|
||||
&& !Info.AirUnitsTypes.Contains(unit.Info.Name) && !Info.NavalUnitsTypes.Contains(unit.Info.Name) && !Info.ExcludeFromSquadsTypes.Contains(unit.Info.Name)).ToList();
|
||||
|
||||
if (!allEnemyBaseBuilder.Any() || ownUnits.Count < Info.SquadSize)
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2021 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using OpenRA.Mods.Common.Traits;
|
||||
|
||||
namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public class UnhardcodeSquadManager : UpdateRule
|
||||
{
|
||||
public override string Name => "SquadManagerBotModule got new fields to configure ground attacks and defensive actions.";
|
||||
|
||||
public override string Description => "AirUnitsTypes and ProtectionTypes were added.";
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
|
||||
{
|
||||
var addNodes = new List<MiniYamlNode>();
|
||||
|
||||
var aircraft = modData.DefaultRules.Actors.Values.Where(a => a.HasTraitInfo<AircraftInfo>() && a.HasTraitInfo<AttackBaseInfo>()).Select(a => a.Name);
|
||||
var airUnits = new MiniYamlNode("AirUnitsTypes", FieldSaver.FormatValue(aircraft.ToList()));
|
||||
addNodes.Add(airUnits);
|
||||
|
||||
var vips = modData.DefaultRules.Actors.Values.Where(a => a.HasTraitInfo<HarvesterInfo>() || a.HasTraitInfo<BaseBuildingInfo>() || (a.HasTraitInfo<BuildingInfo>() && a.HasTraitInfo<BuildableInfo>() && !a.HasTraitInfo<LineBuildInfo>() && !a.HasTraitInfo<PlugInfo>())).Select(a => a.Name);
|
||||
var protection = new MiniYamlNode("ProtectionTypes", FieldSaver.FormatValue(vips.ToList()));
|
||||
addNodes.Add(protection);
|
||||
|
||||
foreach (var squadManager in actorNode.ChildrenMatching("SquadManagerBotModule"))
|
||||
foreach (var addNode in addNodes)
|
||||
squadManager.AddNode(addNode);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,8 +216,9 @@ Player:
|
||||
SquadManagerBotModule@cabal:
|
||||
RequiresCondition: enable-cabal-ai
|
||||
SquadSize: 15
|
||||
ExcludeFromSquadsTypes: harv, mcv
|
||||
ExcludeFromSquadsTypes: harv, mcv, a10
|
||||
ConstructionYardTypes: fact
|
||||
AirUnitsTypes: heli, orca
|
||||
UnitBuilderBotModule@cabal:
|
||||
RequiresCondition: enable-cabal-ai
|
||||
UnitQueues: Vehicle.Nod, Vehicle.GDI, Infantry.Nod, Infantry.GDI, Aircraft.Nod, Aircraft.GDI
|
||||
@@ -250,8 +251,9 @@ Player:
|
||||
SquadManagerBotModule@watson:
|
||||
RequiresCondition: enable-watson-ai
|
||||
SquadSize: 15
|
||||
ExcludeFromSquadsTypes: harv, mcv
|
||||
ExcludeFromSquadsTypes: harv, mcv, a10
|
||||
ConstructionYardTypes: fact
|
||||
AirUnitsTypes: heli, orca
|
||||
UnitBuilderBotModule@watson:
|
||||
RequiresCondition: enable-watson-ai
|
||||
UnitQueues: Vehicle.Nod, Vehicle.GDI, Infantry.Nod, Infantry.GDI, Aircraft.Nod, Aircraft.GDI
|
||||
@@ -279,8 +281,9 @@ Player:
|
||||
SquadManagerBotModule@hal9001:
|
||||
RequiresCondition: enable-hal9001-ai
|
||||
SquadSize: 8
|
||||
ExcludeFromSquadsTypes: harv, mcv
|
||||
ExcludeFromSquadsTypes: harv, mcv, a10
|
||||
ConstructionYardTypes: fact
|
||||
AirUnitsTypes: heli, orca
|
||||
UnitBuilderBotModule@hal9001:
|
||||
RequiresCondition: enable-hal9001-ai
|
||||
UnitQueues: Vehicle.Nod, Vehicle.GDI, Infantry.Nod, Infantry.GDI, Aircraft.Nod, Aircraft.GDI
|
||||
|
||||
@@ -219,7 +219,7 @@ Player:
|
||||
RequiresCondition: enable-omnius-ai
|
||||
SquadSize: 8
|
||||
MaxBaseRadius: 40
|
||||
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
|
||||
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce, ornithopter
|
||||
ConstructionYardTypes: construction_yard
|
||||
IgnoredEnemyTargetTypes: Creep
|
||||
UnitBuilderBotModule@omnius:
|
||||
@@ -263,7 +263,7 @@ Player:
|
||||
RequiresCondition: enable-vidious-ai
|
||||
SquadSize: 6
|
||||
MaxBaseRadius: 40
|
||||
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
|
||||
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce, ornithopter
|
||||
ConstructionYardTypes: construction_yard
|
||||
IgnoredEnemyTargetTypes: Creep
|
||||
UnitBuilderBotModule@vidious:
|
||||
@@ -302,7 +302,7 @@ Player:
|
||||
RequiresCondition: enable-gladius-ai
|
||||
SquadSize: 10
|
||||
MaxBaseRadius: 40
|
||||
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce
|
||||
ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce, ornithopter
|
||||
ConstructionYardTypes: construction_yard
|
||||
IgnoredEnemyTargetTypes: Creep
|
||||
UnitBuilderBotModule@gladius:
|
||||
|
||||
@@ -274,9 +274,10 @@ Player:
|
||||
SquadManagerBotModule@rush:
|
||||
RequiresCondition: enable-rush-ai
|
||||
SquadSize: 20
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog
|
||||
NavalUnitsTypes: ss,msub,dd,ca,lst,pt
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog, badr.bomber, u2
|
||||
ConstructionYardTypes: fact
|
||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
||||
McvManagerBotModule:
|
||||
RequiresCondition: enable-rush-ai || enable-normal-ai || enable-turtle-ai || enable-naval-ai
|
||||
McvTypes: mcv
|
||||
@@ -311,10 +312,11 @@ Player:
|
||||
SquadManagerBotModule@normal:
|
||||
RequiresCondition: enable-normal-ai
|
||||
SquadSize: 40
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog
|
||||
NavalUnitsTypes: ss,msub,dd,ca,lst,pt
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog, badr.bomber, u2
|
||||
ConstructionYardTypes: fact
|
||||
NavalProductionTypes: spen,syrd
|
||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
||||
UnitBuilderBotModule@normal:
|
||||
RequiresCondition: enable-normal-ai
|
||||
UnitsToBuild:
|
||||
@@ -353,10 +355,11 @@ Player:
|
||||
SquadManagerBotModule@turtle:
|
||||
RequiresCondition: enable-turtle-ai
|
||||
SquadSize: 10
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog
|
||||
NavalUnitsTypes: ss,msub,dd,ca,lst,pt
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog, badr.bomber, u2
|
||||
ConstructionYardTypes: fact
|
||||
NavalProductionTypes: spen,syrd
|
||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
||||
UnitBuilderBotModule@turtle:
|
||||
RequiresCondition: enable-turtle-ai
|
||||
UnitsToBuild:
|
||||
@@ -395,10 +398,11 @@ Player:
|
||||
SquadManagerBotModule@naval:
|
||||
RequiresCondition: enable-naval-ai
|
||||
SquadSize: 1
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog
|
||||
ExcludeFromSquadsTypes: harv, mcv, dog, badr.bomber, u2
|
||||
NavalUnitsTypes: ss,msub,dd,ca,lst,pt
|
||||
ConstructionYardTypes: fact
|
||||
NavalProductionTypes: spen,syrd
|
||||
AirUnitsTypes: mig, yak, heli, hind, mh60
|
||||
UnitBuilderBotModule@naval:
|
||||
RequiresCondition: enable-naval-ai
|
||||
UnitsToBuild:
|
||||
|
||||
@@ -70,8 +70,9 @@ Player:
|
||||
SquadManagerBotModule@test:
|
||||
RequiresCondition: enable-test-ai
|
||||
SquadSize: 20
|
||||
ExcludeFromSquadsTypes: harv, mcv
|
||||
ExcludeFromSquadsTypes: harv, mcv, dpod, hunter
|
||||
ConstructionYardTypes: gacnst
|
||||
AirUnitsTypes: orca, orcab, scrin, apache, jumpjet
|
||||
UnitBuilderBotModule@test:
|
||||
RequiresCondition: enable-test-ai
|
||||
UnitQueues: Vehicle, Infantry, Air
|
||||
|
||||
Reference in New Issue
Block a user