Fix bug #1271
This commit is contained in:
committed by
Chris Forbes
parent
0ea9e06c22
commit
bf222425fc
@@ -76,7 +76,7 @@ namespace OpenRA.Mods.RA.AI
|
||||
XRandom random = new XRandom(); //we do not use the synced random number generator.
|
||||
BaseBuilder[] builders;
|
||||
|
||||
const int MaxBaseDistance = 15;
|
||||
const int MaxBaseDistance = 20;
|
||||
public const int feedbackTime = 30; // ticks; = a bit over 1s. must be >= netlag.
|
||||
|
||||
public World world { get { return p.PlayerActor.World; } }
|
||||
@@ -221,18 +221,27 @@ namespace OpenRA.Mods.RA.AI
|
||||
|
||||
var enemy = leastLikedEnemies != null ? leastLikedEnemies.Random(random) : null;
|
||||
|
||||
/* pick something worth attacking owned by that player */
|
||||
var targets = world.Actors
|
||||
.Where(a => a.Owner == enemy && a.HasTrait<IOccupySpace>());
|
||||
Actor target=null;
|
||||
|
||||
if (targets.Count()>0)
|
||||
target = targets.Random(random);
|
||||
|
||||
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}", this.p.ClientIndex, enemy.ClientIndex);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/* bump the aggro slightly to avoid changing our mind */
|
||||
if (leastLikedEnemies.Count() > 1)
|
||||
aggro[enemy].Aggro++;
|
||||
|
||||
/* pick something worth attacking owned by that player */
|
||||
var target = world.Actors
|
||||
.Where(a => a.Owner == enemy && a.HasTrait<IOccupySpace>())
|
||||
.Random(random);
|
||||
|
||||
if (target == null)
|
||||
return null;
|
||||
|
||||
return target.Location;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user