diff --git a/binaries/data/mods/public/simulation/ai/qbot/economy.js b/binaries/data/mods/public/simulation/ai/qbot/economy.js index de20ea9862..659ec71657 100644 --- a/binaries/data/mods/public/simulation/ai/qbot/economy.js +++ b/binaries/data/mods/public/simulation/ai/qbot/economy.js @@ -233,10 +233,9 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events){ if (e.type === "Destroy") { if (e.msg.entityObj){ var ent = e.msg.entityObj; - var pos = ent.position(); - if (ent && pos && ent.resourceSupplyType() && ent.resourceSupplyType().generic === resource){ - var x = Math.round(pos[0] / gameState.cellSize); - var z = Math.round(pos[1] / gameState.cellSize); + if (ent && ent.position() && ent.resourceSupplyType() && ent.resourceSupplyType().generic === resource){ + var x = Math.round(ent.position()[0] / gameState.cellSize); + var z = Math.round(ent.position()[1] / gameState.cellSize); var strength = Math.round(ent.resourceSupplyMax()/decreaseFactor[resource]); this.resourceMaps[resource].addInfluence(x, z, radius[resource], -strength); } @@ -244,10 +243,9 @@ EconomyManager.prototype.updateResourceMaps = function(gameState, events){ }else if (e.type === "Create") { if (e.msg.entityObj){ var ent = e.msg.entityObj; - var pos = ent.position(); - if (ent && pos && ent.resourceSupplyType() && ent.resourceSupplyType().generic === resource){ - var x = Math.round(pos[0] / gameState.cellSize); - var z = Math.round(pos[1] / gameState.cellSize); + if (ent && ent.position() && ent.resourceSupplyType() && ent.resourceSupplyType().generic === resource){ + var x = Math.round(ent.position()[0] / gameState.cellSize); + var z = Math.round(ent.position()[1] / gameState.cellSize); var strength = Math.round(ent.resourceSupplyMax()/decreaseFactor[resource]); this.resourceMaps[resource].addInfluence(x, z, radius[resource], strength); }