From b63f8d264ac473552ca5ef88688bc33fe5cea67a Mon Sep 17 00:00:00 2001 From: quantumstate Date: Mon, 16 Jan 2012 19:33:28 +0000 Subject: [PATCH] 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. --- .../mods/public/simulation/ai/qbot/attackMoveToLocation.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/binaries/data/mods/public/simulation/ai/qbot/attackMoveToLocation.js b/binaries/data/mods/public/simulation/ai/qbot/attackMoveToLocation.js index 0759792032..7d8b2dbcca 100644 --- a/binaries/data/mods/public/simulation/ai/qbot/attackMoveToLocation.js +++ b/binaries/data/mods/public/simulation/ai/qbot/attackMoveToLocation.js @@ -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 ) {