mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 19:06:35 +00:00
petra: allows stables and siege workshops build orders for all civs
This was SVN commit r20389.
This commit is contained in:
@@ -55,10 +55,9 @@ m.Config = function(difficulty)
|
||||
"structures/{civ}_embassy_italiote" ],
|
||||
"gaul": [ "structures/{civ}_rotarymill", "structures/{civ}_tavern" ],
|
||||
"iber": [ "structures/{civ}_monument" ],
|
||||
"mace": [ "structures/{civ}_siege_workshop", "structures/{civ}_library",
|
||||
"structures/{civ}_theatron" ],
|
||||
"mace": [ "structures/{civ}_library", "structures/{civ}_theatron" ],
|
||||
"maur": [ "structures/{civ}_elephant_stables", "structures/{civ}_pillar_ashoka" ],
|
||||
"pers": [ "structures/{civ}_stables", "structures/{civ}_apadana", "structures/{civ}_hall"],
|
||||
"pers": [ "structures/{civ}_apadana", "structures/{civ}_hall"],
|
||||
"ptol": [ "structures/{civ}_library" ],
|
||||
"rome": [ "structures/{civ}_army_camp" ],
|
||||
"sele": [ "structures/{civ}_library" ],
|
||||
|
||||
@@ -1746,41 +1746,56 @@ m.HQ.prototype.constructTrainingBuildings = function(gameState, queues)
|
||||
if (this.saveResources && !this.canBarter || queues.militaryBuilding.hasQueuedUnits())
|
||||
return;
|
||||
|
||||
if (this.canBuild(gameState, "structures/{civ}_barracks"))
|
||||
{
|
||||
let barrackNb = gameState.getOwnEntitiesByClass("Barracks", true).length;
|
||||
if (this.saveResources && barrackNb > 0)
|
||||
return;
|
||||
let numBarracks = this.canBuild(gameState, "structures/{civ}_barracks") ? gameState.getOwnEntitiesByClass("Barracks", true).length : -1;
|
||||
let numStables = this.canBuild(gameState, "structures/{civ}_stables") ? gameState.getOwnEntitiesByClass("Stables", true).length : -1;
|
||||
if (this.saveResources && numBarracks != 0)
|
||||
return;
|
||||
|
||||
// first barracks.
|
||||
if (!barrackNb && (gameState.getPopulation() > this.Config.Military.popForBarracks1 ||
|
||||
this.phasing == 2 && gameState.getOwnStructures().filter(API3.Filters.byClass("Village")).length < 5))
|
||||
if (gameState.getPopulation() > this.Config.Military.popForBarracks1 ||
|
||||
this.phasing == 2 && gameState.getOwnStructures().filter(API3.Filters.byClass("Village")).length < 5)
|
||||
{
|
||||
// first barracks and stables.
|
||||
if (numBarracks == 0)
|
||||
{
|
||||
gameState.ai.queueManager.changePriority("militaryBuilding", 2*this.Config.priorities.militaryBuilding);
|
||||
let preferredBase = this.findBestBaseForMilitary(gameState);
|
||||
let plan = new m.ConstructionPlan(gameState, "structures/{civ}_barracks", { "preferredBase": preferredBase });
|
||||
let metadata = { "preferredBase": this.findBestBaseForMilitary(gameState) };
|
||||
let plan = new m.ConstructionPlan(gameState, "structures/{civ}_barracks", metadata);
|
||||
plan.queueToReset = "militaryBuilding";
|
||||
queues.militaryBuilding.addPlan(plan);
|
||||
return;
|
||||
}
|
||||
// second barracks, then 3rd barrack, and optional 4th for some civs as they rely on barracks more.
|
||||
if (barrackNb == 1 && gameState.getPopulation() > this.Config.Military.popForBarracks2)
|
||||
if (numStables == 0)
|
||||
{
|
||||
let preferredBase = this.findBestBaseForMilitary(gameState);
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_barracks", { "preferredBase": preferredBase }));
|
||||
let metadata = { "preferredBase": this.findBestBaseForMilitary(gameState) };
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_stables", metadata));
|
||||
return;
|
||||
}
|
||||
if (barrackNb == 2 && gameState.getPopulation() > this.Config.Military.popForBarracks2 + 20)
|
||||
|
||||
// Second barracks and stables, then 3rd barrack, and optional 4th for some civs as they rely on barracks more.
|
||||
if (numBarracks == 1 && gameState.getPopulation() > this.Config.Military.popForBarracks2)
|
||||
{
|
||||
let preferredBase = this.findBestBaseForMilitary(gameState);
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_barracks", { "preferredBase": preferredBase }));
|
||||
let metadata = { "preferredBase": this.findBestBaseForMilitary(gameState) };
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_barracks", metadata));
|
||||
return;
|
||||
}
|
||||
if (barrackNb == 3 && gameState.getPopulation() > this.Config.Military.popForBarracks2 + 50 &&
|
||||
(gameState.getPlayerCiv() === "gaul" || gameState.getPlayerCiv() === "brit" || gameState.getPlayerCiv() === "iber"))
|
||||
if (numStables == 1 && gameState.getPopulation() > this.Config.Military.popForBarracks2)
|
||||
{
|
||||
let preferredBase = this.findBestBaseForMilitary(gameState);
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_barracks", { "preferredBase": preferredBase }));
|
||||
let metadata = { "preferredBase": this.findBestBaseForMilitary(gameState) };
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_stables", metadata));
|
||||
return;
|
||||
}
|
||||
|
||||
// Then 3rd barracks/stables if needed
|
||||
if (numBarracks == 2 && numStables == -1 && gameState.getPopulation() > this.Config.Military.popForBarracks2 + 30)
|
||||
{
|
||||
let metadata = { "preferredBase": this.findBestBaseForMilitary(gameState) };
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_barracks", metadata));
|
||||
return;
|
||||
}
|
||||
if (numBarracks == -1 && numStables == 2 && gameState.getPopulation() > this.Config.Military.popForBarracks2 + 30)
|
||||
{
|
||||
let metadata = { "preferredBase": this.findBestBaseForMilitary(gameState) };
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_stables", metadata));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -1788,7 +1803,18 @@ m.HQ.prototype.constructTrainingBuildings = function(gameState, queues)
|
||||
if (this.saveResources)
|
||||
return;
|
||||
|
||||
if (this.currentPhase < 3 || gameState.getPopulation() < 80 || !this.bAdvanced.length)
|
||||
if (this.currentPhase < 3)
|
||||
return;
|
||||
|
||||
let numWorkshop = this.canBuild(gameState, "structures/{civ}_siege_workshop") ? gameState.getOwnEntitiesByClass("Workshop", true).length : -1;
|
||||
if (numWorkshop == 0)
|
||||
{
|
||||
let metadata = { "preferredBase": this.findBestBaseForMilitary(gameState) };
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, "structures/{civ}_siege_workshop", metadata));
|
||||
return;
|
||||
}
|
||||
|
||||
if (gameState.getPopulation() < 80 || !this.bAdvanced.length)
|
||||
return;
|
||||
|
||||
//build advanced military buildings
|
||||
@@ -1807,8 +1833,8 @@ m.HQ.prototype.constructTrainingBuildings = function(gameState, queues)
|
||||
continue;
|
||||
if (template.hasDefensiveFire() || template.trainableEntities())
|
||||
{
|
||||
let preferredBase = this.findBestBaseForMilitary(gameState);
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, advanced, { "preferredBase": preferredBase }));
|
||||
let metadata = { "preferredBase": this.findBestBaseForMilitary(gameState) };
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, advanced, metadata));
|
||||
}
|
||||
else // not a military building, but still use this queue
|
||||
queues.militaryBuilding.addPlan(new m.ConstructionPlan(gameState, advanced));
|
||||
|
||||
@@ -144,12 +144,9 @@ m.ConstructionPlan.prototype.findGoodPosition = function(gameState)
|
||||
let pos = gameState.ai.HQ.findDefensiveLocation(gameState, template);
|
||||
if (pos)
|
||||
return { "x": pos[0], "z": pos[1], "angle": 3*Math.PI/4, "base": pos[2] };
|
||||
|
||||
if (template.hasClass("DefenseTower") || gameState.getPlayerCiv() === "mace" || gameState.getPlayerCiv() === "maur" ||
|
||||
gameState.countEntitiesByType(gameState.applyCiv("structures/{civ}_fortress"), true) > 0 ||
|
||||
gameState.countEntitiesByType(gameState.applyCiv("structures/{civ}_army_camp"), true) > 0)
|
||||
// if this fortress is our first one, just try the standard placement
|
||||
if (!template.hasClass("Fortress") || gameState.getOwnEntitiesByClass("Fortress", true).hasEntities())
|
||||
return false;
|
||||
// if this fortress is our first siege unit builder, just try the standard placement as we want siege units
|
||||
}
|
||||
else if (template.hasClass("Market")) // Docks (i.e. NavalMarket) are done before
|
||||
{
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<Tooltip>Build siege engines. Research siege technologies.</Tooltip>
|
||||
<Icon>structures/siege_workshop.png</Icon>
|
||||
<RequiredTechnology>phase_city</RequiredTechnology>
|
||||
<VisibleClasses datatype="tokens">Workshop</VisibleClasses>
|
||||
</Identity>
|
||||
<Loot>
|
||||
<wood>75</wood>
|
||||
|
||||
Reference in New Issue
Block a user