mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 03:43:44 +00:00
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:
@@ -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 ) {
|
||||
|
||||
Reference in New Issue
Block a user