From 92e6570f505dfe395cbb75b9a7671087f9390157 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Tue, 21 Dec 2010 18:33:11 +1300 Subject: [PATCH] fix a crash, add a normal bot (harder) --- OpenRA.Mods.RA/HackyAI.cs | 13 ++++++------- mods/ra/rules/system.yaml | 29 ++++++++++++++++++++++++++--- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/OpenRA.Mods.RA/HackyAI.cs b/OpenRA.Mods.RA/HackyAI.cs index de375ce120..4ff23b58fa 100644 --- a/OpenRA.Mods.RA/HackyAI.cs +++ b/OpenRA.Mods.RA/HackyAI.cs @@ -38,6 +38,9 @@ namespace OpenRA.Mods.RA [FieldLoader.Load] public readonly string Name; + [FieldLoader.Load] + public readonly int SquadSize = 8; + string IBotInfo.Name { get { return this.Name; } } [FieldLoader.LoadUsing("LoadUnits")] @@ -256,17 +259,13 @@ namespace OpenRA.Mods.RA //This is purely to identify production buildings that don't have a rally point set. List activeProductionBuildings = new List(); - bool IsHumanPlayer(Player p) - { - /* hack hack: this actually detects 'is not HackyAI' -- possibly actually a good thing. */ - var hackyAI = p.PlayerActor.Trait(); - return !hackyAI.enabled; - } + bool IsHumanPlayer(Player p) { return !p.IsBot && !p.NonCombatant; } bool HasHumanPlayers() { return p.World.players.Any(a => !a.Value.IsBot && !a.Value.NonCombatant); } + int2? ChooseEnemyTarget() { // Criteria for picking an enemy: @@ -305,7 +304,7 @@ namespace OpenRA.Mods.RA /* Create an attack force when we have enough units around our base. */ // (don't bother leaving any behind for defense.) - if (unitsHangingAroundTheBase.Count > 8) + if (unitsHangingAroundTheBase.Count >= Info.SquadSize) { BotDebug("Launch an attack."); diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index 9073e004e9..8086f4a8de 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -32,7 +32,7 @@ Player: InitialCash: 5000 ActorGroupProxy: DeveloperMode: - HackyAI@Default: + HackyAI@EasyAI: Name:Easy AI BuildingFractions: proc: 20% @@ -40,7 +40,6 @@ Player: tent: 5% weap: 5% pbox: 5% - hbox: 5% gun: 5% tsla: 5% ftur: 5% @@ -48,9 +47,9 @@ Player: sam: 1% atek: 1% stek: 1% - silo: 5% fix: 1% dome: 1% + hbox: 5% UnitsToBuild: e1: 0% e2: 0% @@ -58,6 +57,30 @@ Player: 1tnk: 0% 2tnk: 0% 3tnk: 0% + HackyAI@NormalAI: + Name:Normal AI + BuildingFractions: + proc: 30% + tent: 1% + weap: 1% + pbox: 5% + gun: 15% + ftur: 10% + tsla: 15% + dome: 1% + agun: 5% + sam: 1% + atek: 1% + stek: 1% + fix: 0.1% + UnitsToBuild: + 1tnk: 0% + 2tnk: 0% + 3tnk: 0% + 4tnk: 0% + arty: 0% + v2rl: 0% + SquadSize: 15 PlayerColorPalette: BasePalette: terrain SurrenderOnDisconnect: