Fixed attackMoveToLocation apart from when it runs out of targets.

Thanks to iap for pointing out a stupid error I had made.

This was SVN commit r10917.
This commit is contained in:
quantumstate
2012-01-16 19:33:28 +00:00
parent 09907adae3
commit b63f8d264a
@@ -89,15 +89,12 @@ AttackMoveToLocation.prototype.execute = function(gameState, militaryManager){
// Find possible distinct paths to the enemy
var pathFinder = new PathFinder(gameState);
var pathsToEnemy = pathFinder.getPaths(curPos, this.targetPos);
if (! pathsToEnemy){
pathsToEnemy = [this.targetPos];
if (!pathsToEnemy || !pathsToEnemy[0] || pathsToEnemy[0][0] === undefined || pathsToEnemy[0][1] === undefined){
pathsToEnemy = [[this.targetPos]];
}
var rand = Math.floor(Math.random() * pathsToEnemy.length);
this.path = pathsToEnemy[rand];
if (! this.path || !this.path[0] || this.path[0][0] === undefined || this.path[0][1] === undefined){
pathsToEnemy = [this.targetPos];
}
pending.move(this.path[0][0], this.path[0][1]);
} else if (targets.length == 0 ) {