fixed petra map management when not circular

This was SVN commit r14901.
This commit is contained in:
mimo 2014-04-05 12:18:37 +00:00
parent c5e59d02e1
commit fd4cd56224
6 changed files with 40 additions and 11 deletions

View File

@ -55,6 +55,8 @@ m.BaseAI.prototype.Init = function(state, playerID, sharedAI)
this.timeElapsed = sharedAI.timeElapsed;
this.circularMap = sharedAI.circularMap;
this.barterPrices = sharedAI.barterPrices;
this.CustomInit(this.gameState, this.sharedScript);

View File

@ -19,6 +19,7 @@ m.GameState.prototype.init = function(SharedScript, state, player) {
this.EntCollecNames = SharedScript._entityCollectionsName;
this.EntCollec = SharedScript._entityCollections;
this.timeElapsed = SharedScript.timeElapsed;
this.circularMap = SharedScript.circularMap;
this.templates = SharedScript._templates;
this.techTemplates = SharedScript._techTemplates;
this.entities = SharedScript.entities;

View File

@ -127,6 +127,7 @@ m.SharedScript.prototype.init = function(state) {
this.playersData = state.players;
this.territoryMap = state.territoryMap;
this.timeElapsed = state.timeElapsed;
this.circularMap = state.circularMap;
this.barterPrices = state.barterPrices;
this._entities = {};

View File

@ -617,6 +617,10 @@ m.AttackPlan.prototype.rushTargetFinder = function(gameState)
}
if (target)
targets.addEnt(target);
if (targets.length == 0 && this.type === "normal")
targets = this.defaultTargetFinder(gameState);
return targets;
};

View File

@ -715,7 +715,7 @@ m.BaseManager.prototype.assignToFoundations = function(gameState, noRepair)
var assigned = gameState.getOwnEntitiesByMetadata("target-foundation", target.id()).length;
var targetNB = this.Config.Economy.targetNumBuilders; // TODO: dynamic that.
if (target.hasClass("House"))
if (target.hasClass("House") || target.hasClass("Market"))
targetNB *= 2;
else if (target.hasClass("Barracks") || target.hasClass("Tower"))
targetNB = 4;

View File

@ -197,19 +197,40 @@ m.createBorderMap = function(gameState)
{
var map = new API3.Map(gameState.sharedScript);
var width = map.width;
var ic = (width - 1) / 2;
var radmax = (ic-2)*(ic-2); // we assume two inaccessible cells all around
for (var j = 0; j < map.length; ++j)
var border = 15;
if (gameState.ai.circularMap)
{
var dx = j%width - ic;
var dy = Math.floor(j/width) - ic;
var radius = dx*dx + dy*dy;
if (radius > radmax)
map.map[j] = 2;
else if (radius > (ic - 18)*(ic - 18))
map.map[j] = 1;
var ic = (width - 1) / 2;
var radmax = (ic-3)*(ic-3); // we assume three inaccessible cells all around
for (var j = 0; j < map.length; ++j)
{
var dx = j%width - ic;
var dy = Math.floor(j/width) - ic;
var radius = dx*dx + dy*dy;
if (radius > radmax)
map.map[j] = 2;
else if (radius > (ic - border)*(ic - border))
map.map[j] = 1;
}
}
else
{
for (var j = 0; j < map.length; ++j)
{
var ix = j%width;
var iy = Math.floor(j/width);
if (ix < border || ix >= width - border)
map.map[j] = 1;
if (iy < border || iy >= width - border)
map.map[j] = 1;
if (ix < 3 || ix >= width - 3) // we assume three inaccessible cells all around
map.map[j] = 2;
if (iy < 3 || iy >= width - 3)
map.map[j] = 2;
}
}
// map.dumpIm("border.png", 5);
return map;
};