diff --git a/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs b/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs index de93e9334d..69ae8ffbbb 100644 --- a/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs +++ b/OpenRA.Mods.Common/Traits/BotModules/SquadManagerBotModule.cs @@ -36,6 +36,9 @@ namespace OpenRA.Mods.Common.Traits [Desc("Enemy building types around which to scan for targets for naval squads.")] public readonly HashSet NavalProductionTypes = new HashSet(); + [Desc("Own actor types that are prioritized when defending.")] + public readonly HashSet ProtectionTypes = new HashSet(); + [Desc("Minimum number of units AI must have before attacking.")] public readonly int SquadSize = 8; @@ -321,7 +324,7 @@ namespace OpenRA.Mods.Common.Traits { // Don't rush enemy aircraft! var enemies = World.FindActorsInCircle(b.CenterPosition, WDist.FromCells(Info.RushAttackScanRadius)) - .Where(unit => IsPreferredEnemyUnit(unit) && unit.Info.HasTraitInfo() && !unit.Info.HasTraitInfo() && !Info.NavalUnitsTypes.Contains(unit.Info.Name)).ToList(); + .Where(unit => IsPreferredEnemyUnit(unit) && unit.Info.HasTraitInfo() && !Info.AirUnitsTypes.Contains(unit.Info.Name) && !Info.NavalUnitsTypes.Contains(unit.Info.Name)).ToList(); if (AttackOrFleeFuzzy.Rush.CanAttack(ownUnits, enemies)) { @@ -350,8 +353,7 @@ namespace OpenRA.Mods.Common.Traits if (!protectSq.IsValid) { var ownUnits = World.FindActorsInCircle(World.Map.CenterOfCell(GetRandomBaseCenter()), WDist.FromCells(Info.ProtectUnitScanRadius)) - .Where(unit => unit.Owner == Player && !unit.Info.HasTraitInfo() && !unit.Info.HasTraitInfo() - && unit.Info.HasTraitInfo()); + .Where(unit => unit.Owner == Player && !Info.ProtectionTypes.Contains(unit.Info.Name) && unit.Info.HasTraitInfo()); foreach (var a in ownUnits) protectSq.Units.Add(a); @@ -370,9 +372,7 @@ namespace OpenRA.Mods.Common.Traits if (!IsPreferredEnemyUnit(e.Attacker)) return; - // Protected priority assets, MCVs, harvesters and buildings - // TODO: Use *CommonNames, instead of hard-coding trait(info)s. - if (self.Info.HasTraitInfo() || self.Info.HasTraitInfo() || self.Info.HasTraitInfo()) + if (Info.ProtectionTypes.Contains(self.Info.Name)) { foreach (var n in notifyPositionsUpdated) n.UpdatedDefenseCenter(e.Attacker.Location); diff --git a/mods/cnc/rules/ai.yaml b/mods/cnc/rules/ai.yaml index 7a4471f224..28f4dc592c 100644 --- a/mods/cnc/rules/ai.yaml +++ b/mods/cnc/rules/ai.yaml @@ -219,6 +219,7 @@ Player: ExcludeFromSquadsTypes: harv, mcv, a10 ConstructionYardTypes: fact AirUnitsTypes: heli, orca + ProtectionTypes: fact, fact.gdi, fact.nod, nuke, nuk2, proc, silo, pyle, hand, afld, weap, hpad, hq, fix, eye, tmpl, gun, sam, obli, gtwr, atwr, mcv, harv, miss UnitBuilderBotModule@cabal: RequiresCondition: enable-cabal-ai UnitQueues: Vehicle.Nod, Vehicle.GDI, Infantry.Nod, Infantry.GDI, Aircraft.Nod, Aircraft.GDI @@ -254,6 +255,7 @@ Player: ExcludeFromSquadsTypes: harv, mcv, a10 ConstructionYardTypes: fact AirUnitsTypes: heli, orca + ProtectionTypes: fact, fact.gdi, fact.nod, nuke, nuk2, proc, silo, pyle, hand, afld, weap, hpad, hq, fix, eye, tmpl, gun, sam, obli, gtwr, atwr, mcv, harv, miss UnitBuilderBotModule@watson: RequiresCondition: enable-watson-ai UnitQueues: Vehicle.Nod, Vehicle.GDI, Infantry.Nod, Infantry.GDI, Aircraft.Nod, Aircraft.GDI @@ -284,6 +286,7 @@ Player: ExcludeFromSquadsTypes: harv, mcv, a10 ConstructionYardTypes: fact AirUnitsTypes: heli, orca + ProtectionTypes: fact, fact.gdi, fact.nod, nuke, nuk2, proc, silo, pyle, hand, afld, weap, hpad, hq, fix, eye, tmpl, gun, sam, obli, gtwr, atwr, mcv, harv, miss UnitBuilderBotModule@hal9001: RequiresCondition: enable-hal9001-ai UnitQueues: Vehicle.Nod, Vehicle.GDI, Infantry.Nod, Infantry.GDI, Aircraft.Nod, Aircraft.GDI diff --git a/mods/cnc/rules/misc.yaml b/mods/cnc/rules/misc.yaml index c2b1d76a35..b8760d1139 100644 --- a/mods/cnc/rules/misc.yaml +++ b/mods/cnc/rules/misc.yaml @@ -81,6 +81,7 @@ fact.colorpicker: Inherits: FACT -Buildable: -MapEditorData: + -BaseBuilding: RenderSprites: Image: fact Palette: colorpicker diff --git a/mods/d2k/rules/ai.yaml b/mods/d2k/rules/ai.yaml index 6fad5988a7..273a78be93 100644 --- a/mods/d2k/rules/ai.yaml +++ b/mods/d2k/rules/ai.yaml @@ -222,6 +222,7 @@ Player: ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce, ornithopter ConstructionYardTypes: construction_yard IgnoredEnemyTargetTypes: Creep + ProtectionTypes: mcv, harvester, construction_yard, conyard.atreides, conyard.harkonnen, conyard.ordos, wind_trap, barracks, refinery, silo, light_factory, heavy_factory, outpost, starport, medium_gun_turret, large_gun_turret, repair_pad, high_tech_factory, research_centre, palace, mcv.starport, harvester.starport UnitBuilderBotModule@omnius: RequiresCondition: enable-omnius-ai UnitQueues: Infantry, Vehicle, Armor, Starport, Aircraft @@ -266,6 +267,7 @@ Player: ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce, ornithopter ConstructionYardTypes: construction_yard IgnoredEnemyTargetTypes: Creep + ProtectionTypes: mcv, harvester, construction_yard, conyard.atreides, conyard.harkonnen, conyard.ordos, wind_trap, barracks, refinery, silo, light_factory, heavy_factory, outpost, starport, medium_gun_turret, large_gun_turret, repair_pad, high_tech_factory, research_centre, palace, mcv.starport, harvester.starport UnitBuilderBotModule@vidious: RequiresCondition: enable-vidious-ai UnitQueues: Infantry, Vehicle, Armor, Starport, Aircraft @@ -305,6 +307,7 @@ Player: ExcludeFromSquadsTypes: harvester, mcv, carryall, carryall.reinforce, ornithopter ConstructionYardTypes: construction_yard IgnoredEnemyTargetTypes: Creep + ProtectionTypes: mcv, harvester, construction_yard, conyard.atreides, conyard.harkonnen, conyard.ordos, wind_trap, barracks, refinery, silo, light_factory, heavy_factory, outpost, starport, medium_gun_turret, large_gun_turret, repair_pad, high_tech_factory, research_centre, palace, mcv.starport, harvester.starport UnitBuilderBotModule@gladius: RequiresCondition: enable-gladius-ai UnitQueues: Infantry, Vehicle, Armor, Starport, Aircraft diff --git a/mods/ra/rules/ai.yaml b/mods/ra/rules/ai.yaml index b118fdd32d..d73975c9e2 100644 --- a/mods/ra/rules/ai.yaml +++ b/mods/ra/rules/ai.yaml @@ -278,6 +278,7 @@ Player: ExcludeFromSquadsTypes: harv, mcv, dog, badr.bomber, u2 ConstructionYardTypes: fact AirUnitsTypes: mig, yak, heli, hind, mh60 + 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 McvManagerBotModule: RequiresCondition: enable-rush-ai || enable-normal-ai || enable-turtle-ai || enable-naval-ai McvTypes: mcv @@ -317,6 +318,7 @@ Player: ConstructionYardTypes: fact NavalProductionTypes: spen,syrd AirUnitsTypes: mig, yak, heli, hind, mh60 + 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 UnitBuilderBotModule@normal: RequiresCondition: enable-normal-ai UnitsToBuild: @@ -360,6 +362,7 @@ Player: ConstructionYardTypes: fact NavalProductionTypes: spen,syrd AirUnitsTypes: mig, yak, heli, hind, mh60 + 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 UnitBuilderBotModule@turtle: RequiresCondition: enable-turtle-ai UnitsToBuild: @@ -403,6 +406,7 @@ Player: ConstructionYardTypes: fact NavalProductionTypes: spen,syrd AirUnitsTypes: mig, yak, heli, hind, mh60 + 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 UnitBuilderBotModule@naval: RequiresCondition: enable-naval-ai UnitsToBuild: diff --git a/mods/ra/rules/misc.yaml b/mods/ra/rules/misc.yaml index 8def47ff66..f1c485095b 100644 --- a/mods/ra/rules/misc.yaml +++ b/mods/ra/rules/misc.yaml @@ -442,6 +442,7 @@ fact.colorpicker: Inherits: FACT -Buildable: -MapEditorData: + -BaseBuilding: RenderSprites: Image: fact Palette: colorpicker diff --git a/mods/ts/rules/ai.yaml b/mods/ts/rules/ai.yaml index 8431b88e2a..4a0e1b91f9 100644 --- a/mods/ts/rules/ai.yaml +++ b/mods/ts/rules/ai.yaml @@ -73,6 +73,7 @@ Player: ExcludeFromSquadsTypes: harv, mcv, dpod, hunter ConstructionYardTypes: gacnst AirUnitsTypes: orca, orcab, scrin, apache, jumpjet + ProtectionTypes: gapowr, gapowrup, gapile, gaweap, gahpad, gadept, garadr, gatech, gaplug, gagate_a, gagate_b, gactwr, gavulc, garock, gacsam, napowr, naapwr, nahand, naweap, nahpad, naradr, natech, nastlh, natmpl, namisl, nawast, nagate_a, nagate_b, nalasr, naobel, nasam, weed, gacnst, proc, gasilo, napuls, mcv, harv UnitBuilderBotModule@test: RequiresCondition: enable-test-ai UnitQueues: Vehicle, Infantry, Air