forked from 0ad/0ad
fixed petra map management when not circular
This was SVN commit r14901.
This commit is contained in:
parent
c5e59d02e1
commit
fd4cd56224
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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 = {};
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user