1
0
forked from mirrors/0ad

Petra: more tunings for new ranges and fix a bug in attack preparation

This was SVN commit r16317.
This commit is contained in:
mimo
2015-02-11 18:20:30 +00:00
parent 51a37e6d0f
commit 04fa2dd4ec
3 changed files with 13 additions and 3 deletions
@@ -55,11 +55,11 @@ m.AttackManager.prototype.update = function(gameState, queues, events)
API3.warn(" upcoming attacks =================");
for (var attackType in this.upcomingAttacks)
for (let attack of this.upcomingAttacks[attackType])
API3.warn(" type " + attackType + " state " + attack.state + " units " + attack.unitCollection.length);
API3.warn(" plan " + attack.name + " type " + attackType + " state " + attack.state + " units " + attack.unitCollection.length);
API3.warn(" started attacks ==================");
for (var attackType in this.startedAttacks)
for (let attack of this.startedAttacks[attackType])
API3.warn(" type " + attackType + " state " + attack.state + " units " + attack.unitCollection.length);
API3.warn(" plan " + attack.name + " type " + attackType + " state " + attack.state + " units " + attack.unitCollection.length);
API3.warn(" ==================================");
}
@@ -475,6 +475,7 @@ m.AttackPlan.prototype.updatePreparation = function(gameState, events)
{
if (this.canStart())
{
this.removeTrainingUnitsFromPlan(gameState);
this.queue.empty();
this.queueChamp.empty();
this.queueSiege.empty();
@@ -1694,6 +1695,7 @@ m.AttackPlan.prototype.Abort = function(gameState)
for (let unitCat in this.unitStat)
this.unit[unitCat].unregister();
this.removeTrainingUnitsFromPlan(gameState);
gameState.ai.queueManager.removeQueue("plan_" + this.name);
gameState.ai.queueManager.removeQueue("plan_" + this.name + "_champ");
gameState.ai.queueManager.removeQueue("plan_" + this.name + "_siege");
@@ -1786,6 +1788,14 @@ m.AttackPlan.prototype.debugAttack = function()
API3.warn("------------------------------");
};
m.AttackPlan.prototype.removeTrainingUnitsFromPlan = function(gameState)
{
for (let trainer of gameState.getOwnTrainingFacilities().values())
for (let item of trainer.trainingQueue())
if (item.metadata && item.metadata.plan == this.name)
item.metadata.plan = undefined;
};
m.AttackPlan.prototype.Serialize = function()
{
let properties = {
@@ -246,7 +246,7 @@ m.ConstructionPlan.prototype.findGoodPosition = function(gameState)
// requires to be inside our territory, and inside our base territory if required
// and if our first market, put it on border if possible to maximize distance with next market
var favorBorder = template.hasClass("BarterMarket");
var disfavorBorder = (template.buildCategory() === "Dock" ||
var disfavorBorder = (gameState.currentPhase() > 1 &&
(!template.getDefaultArrow() && !template.getArrowMultiplier()));
var preferredBase = (this.metadata && this.metadata.preferredBase);
if (this.metadata && this.metadata.base !== undefined)