Merge pull request #11296 from reaperrr/fix-ai-aggro
Removed dead AI code
This commit is contained in:
@@ -192,8 +192,6 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
public object Create(ActorInitializer init) { return new HackyAI(this, init); }
|
public object Create(ActorInitializer init) { return new HackyAI(this, init); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Enemy { public int Aggro; }
|
|
||||||
|
|
||||||
public enum BuildingType { Building, Defense, Refinery }
|
public enum BuildingType { Building, Defense, Refinery }
|
||||||
|
|
||||||
public sealed class HackyAI : ITick, IBot, INotifyDamage
|
public sealed class HackyAI : ITick, IBot, INotifyDamage
|
||||||
@@ -232,7 +230,6 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
|
|
||||||
BitArray resourceTypeIndices;
|
BitArray resourceTypeIndices;
|
||||||
|
|
||||||
Cache<Player, Enemy> aggro = new Cache<Player, Enemy>(_ => new Enemy());
|
|
||||||
List<BaseBuilder> builders = new List<BaseBuilder>();
|
List<BaseBuilder> builders = new List<BaseBuilder>();
|
||||||
|
|
||||||
List<Actor> unitsHangingAroundTheBase = new List<Actor>();
|
List<Actor> unitsHangingAroundTheBase = new List<Actor>();
|
||||||
@@ -559,45 +556,6 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
World.IssueOrder(orders.Dequeue());
|
World.IssueOrder(orders.Dequeue());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal Actor ChooseEnemyTarget()
|
|
||||||
{
|
|
||||||
if (Player.WinState != WinState.Undefined)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var liveEnemies = World.Players
|
|
||||||
.Where(p => Player != p && Player.Stances[p] == Stance.Enemy && p.WinState == WinState.Undefined);
|
|
||||||
|
|
||||||
if (!liveEnemies.Any())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var leastLikedEnemies = liveEnemies
|
|
||||||
.GroupBy(e => aggro[e].Aggro)
|
|
||||||
.MaxByOrDefault(g => g.Key);
|
|
||||||
|
|
||||||
var enemy = (leastLikedEnemies != null) ?
|
|
||||||
leastLikedEnemies.Random(Random) : liveEnemies.FirstOrDefault();
|
|
||||||
|
|
||||||
// Pick something worth attacking owned by that player
|
|
||||||
var target = World.ActorsHavingTrait<IOccupySpace>()
|
|
||||||
.Where(a => a.Owner == enemy)
|
|
||||||
.ClosestTo(World.Map.CenterOfCell(GetRandomBaseCenter()));
|
|
||||||
|
|
||||||
if (target == null)
|
|
||||||
{
|
|
||||||
/* Assume that "enemy" has nothing. Cool off on attacks. */
|
|
||||||
aggro[enemy].Aggro = aggro[enemy].Aggro / 2 - 1;
|
|
||||||
Log.Write("debug", "Bot {0} couldn't find target for player {1}", Player.ClientIndex, enemy.ClientIndex);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bump the aggro slightly to avoid changing our mind
|
|
||||||
if (leastLikedEnemies.Count() > 1)
|
|
||||||
aggro[enemy].Aggro++;
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal Actor FindClosestEnemy(WPos pos)
|
internal Actor FindClosestEnemy(WPos pos)
|
||||||
{
|
{
|
||||||
return World.Actors.Where(isEnemyUnit).ClosestTo(pos);
|
return World.Actors.Where(isEnemyUnit).ClosestTo(pos);
|
||||||
@@ -1091,9 +1049,6 @@ namespace OpenRA.Mods.Common.AI
|
|||||||
if (!e.Attacker.Info.HasTraitInfo<ITargetableInfo>())
|
if (!e.Attacker.Info.HasTraitInfo<ITargetableInfo>())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (e.Damage > 0)
|
|
||||||
aggro[e.Attacker.Owner].Aggro += e.Damage;
|
|
||||||
|
|
||||||
// Protected harvesters or building
|
// Protected harvesters or building
|
||||||
if ((self.Info.HasTraitInfo<HarvesterInfo>() || self.Info.HasTraitInfo<BuildingInfo>()) &&
|
if ((self.Info.HasTraitInfo<HarvesterInfo>() || self.Info.HasTraitInfo<BuildingInfo>()) &&
|
||||||
Player.Stances[e.Attacker.Owner] == Stance.Enemy)
|
Player.Stances[e.Attacker.Owner] == Stance.Enemy)
|
||||||
|
|||||||
Reference in New Issue
Block a user