1
0
forked from 0ad/0ad

let petra use wooden towers in village phase

This was SVN commit r16841.
This commit is contained in:
mimo 2015-07-09 20:46:09 +00:00
parent 1b88eaf1cd
commit c4389abceb
5 changed files with 33 additions and 9 deletions

View File

@ -201,9 +201,9 @@ m.Accessibility.prototype.getTrajectToIndex = function(istart, iend)
if (istart === iend)
return [istart];
let trajects = new Set();
let trajects = new Set();
let explored = new Set();
trajects.add([istart]);
trajects.add([istart]);
explored.add(istart);
while (trajects.size)
{

View File

@ -783,7 +783,7 @@ m.BaseManager.prototype.assignToFoundations = function(gameState, noRepair)
var targetNB = 2;
if (target.hasClass("House") || target.hasClass("DropsiteWood"))
targetNB = 3;
else if (target.hasClass("Barracks") || target.hasClass("Tower") || target.hasClass("Market"))
else if (target.hasClass("Barracks") || target.hasClass("DefenseTower") || target.hasClass("Market"))
targetNB = 4;
else if (target.hasClass("Fortress"))
targetNB = 7;

View File

@ -18,7 +18,8 @@ m.Config = function(difficulty)
"fortressLapseTime" : 390, // Time to wait between building 2 fortresses
"popForBarracks1" : 25,
"popForBarracks2" : 95,
"popForBlacksmith" : 65
"popForBlacksmith" : 65,
"numWoodenTowers" : 1
};
this.Economy = {
"popForTown" : 40, // How many units we want before aging to town.
@ -123,17 +124,27 @@ m.Config.prototype.setConfig = function(gameState)
this.Economy.cityPhase = 240000;
this.Economy.femaleRatio = 0.7;
this.Economy.provisionFields = 1;
this.Military.numWoodenTowers = (this.personality.defensive > 0.66) ? 1 : 0;
}
else if (this.difficulty < 3)
{
this.Economy.cityPhase = 1800;
this.Economy.femaleRatio = 0.6;
this.Economy.provisionFields = 1;
this.Military.numWoodenTowers = (this.personality.defensive > 0.66) ? 1 : 0;
}
else
{
this.Military.towerLapseTime += Math.round(20*(this.personality.defensive - 0.5));
this.Military.fortressLapseTime += Math.round(60*(this.personality.defensive - 0.5));
if (this.difficulty == 3)
this.Military.numWoodenTowers = 1;
else
this.Military.numWoodenTowers = 2;
if (this.personality.defensive > 0.66)
++this.Military.numWoodenTowers;
else if (this.personality.defensive < 0.33)
--this.Military.numWoodenTowers;
if (this.personality.aggressive > 0.7)
{

View File

@ -34,9 +34,10 @@ m.HQ = function(Config)
this.lastTerritoryUpdate = -1;
this.stopBuilding = new Map(); // list of buildings to stop (temporarily) production because no room
this.towerStartTime = 0;
this.fortStartTime = 180; // wooden defense towers, will start at fortStartTime + towerLapseTime
this.towerStartTime = 0; // stone defense towers, will start as soon as available
this.towerLapseTime = this.Config.Military.towerLapseTime;
this.fortressStartTime = 0;
this.fortressStartTime = 0; // will start as soon as available
this.fortressLapseTime = this.Config.Military.fortressLapseTime;
this.baseManagers = [];
@ -1413,10 +1414,21 @@ m.HQ.prototype.buildDefenses = function(gameState, queues)
}
}
if (this.Config.Military.numWoodenTowers && gameState.currentPhase() < 2 && this.canBuild(gameState, "other/palisades_rocks_fort"))
{
let numTowers = gameState.getOwnEntitiesByClass("Tower", true).length; // we count all towers, including wall towers
if (numTowers < this.Config.Military.numWoodenTowers && gameState.ai.elapsedTime > this.towerLapseTime + this.fortStartTime)
{
this.fortStartTime = gameState.ai.elapsedTime;
queues.defenseBuilding.addItem(new m.ConstructionPlan(gameState, "other/palisades_rocks_fort"));
}
return;
}
if (gameState.currentPhase() < 2 || !this.canBuild(gameState, "structures/{civ}_defense_tower"))
return;
let numTowers = gameState.getOwnEntitiesByClass("DefenseTower", true).length;
let numTowers = gameState.getOwnEntitiesByClass("DefenseTower", true).filter(API3.Filters.byClass("Town")).length;
if ((numTowers == 0 || gameState.ai.elapsedTime > (1 + 0.10*numTowers)*this.towerLapseTime + this.towerStartTime)
&& gameState.getOwnFoundationsByClass("DefenseTower").length < 3)
{
@ -2026,6 +2038,7 @@ m.HQ.prototype.Serialize = function()
"targetNumWorkers": this.targetNumWorkers,
"lastTerritoryUpdate": this.lastTerritoryUpdate,
"stopBuilding": this.stopBuilding,
"fortStartTime": this.fortStartTime,
"towerStartTime": this.towerStartTime,
"towerLapseTime": this.towerLapseTime,
"fortressStartTime": this.fortressStartTime,

View File

@ -144,13 +144,13 @@ m.ConstructionPlan.prototype.findGoodPosition = function(gameState)
else
return false;
}
else if (template.hasClass("Tower") || template.hasClass("Fortress") || template.hasClass("ArmyCamp"))
else if (template.hasClass("DefenseTower") || template.hasClass("Fortress") || template.hasClass("ArmyCamp"))
{
var pos = gameState.ai.HQ.findDefensiveLocation(gameState, template);
if (pos)
return { "x": pos[0], "z": pos[1], "angle": 3*Math.PI/4, "base": pos[2] };
else if (template.hasClass("Tower") || gameState.civ() === "mace" || gameState.civ() === "maur" ||
else if (template.hasClass("DefenseTower") || gameState.civ() === "mace" || gameState.civ() === "maur" ||
gameState.countEntitiesByType(gameState.applyCiv("structures/{civ}_fortress"), true)
+ gameState.countEntitiesByType(gameState.applyCiv("structures/{civ}_army_camp"), true) > 0)
return false;