petra: additional bugfixes and tweaks

This was SVN commit r16649.
This commit is contained in:
mimo 2015-05-10 20:21:00 +00:00
parent 20877632ce
commit d41671044a
5 changed files with 28 additions and 19 deletions

View File

@ -27,19 +27,19 @@ m.AttackManager.prototype.init = function(gameState)
this.outOfPlan.registerUpdates();
};
m.AttackManager.prototype.setRushes = function()
m.AttackManager.prototype.setRushes = function(allowed)
{
if (this.Config.personality.aggressive > 0.8)
if (this.Config.personality.aggressive > 0.8 && allowed > 2)
{
this.maxRushes = 3
this.rushSize = [ 16, 22, 28 ];
}
else if (this.Config.personality.aggressive > 0.6)
else if (this.Config.personality.aggressive > 0.6 && allowed > 1)
{
this.maxRushes = 2;
this.rushSize = [ 18, 28 ];
}
else if (this.Config.personality.aggressive > 0.3)
else if (this.Config.personality.aggressive > 0.3 && allowed > 0)
{
this.maxRushes = 1;
this.rushSize = [ 24 ];
@ -83,6 +83,7 @@ m.AttackManager.prototype.checkEvents = function(gameState, events)
continue;
}
attack.targetPos = attack.target.position();
attack.resetPath(gameState);
}
if (attack.targetPlayer && attack.targetPlayer === targetPlayer)
available += attack.unitCollection.length;

View File

@ -402,13 +402,7 @@ m.AttackPlan.prototype.updatePreparation = function(gameState)
}
}
// reset the path so that we recompute it for this new target
this.path = undefined;
if (!this.pathFinder)
{
this.pathFinder = new API3.aStarPath(gameState, false, false, this.targetPlayer);
this.pathWidth = 6;
this.pathSampling = 2;
}
this.resetPath(gameState);
}
// when we have a target, we path to it.
@ -1703,6 +1697,18 @@ m.AttackPlan.prototype.removeUnit = function(ent, update)
this.unitCollection.updateEnt(ent);
};
// Reset the path so that it can be recomputed for a new target
m.AttackPlan.prototype.resetPath = function(gameState)
{
this.path = undefined;
if (!this.pathFinder)
{
this.pathFinder = new API3.aStarPath(gameState, false, false, this.targetPlayer);
this.pathWidth = 6;
this.pathSampling = 2;
}
};
m.AttackPlan.prototype.checkEvents = function(gameState, events)
{
let renameEvents = events["EntityRenamed"];

View File

@ -312,11 +312,10 @@ m.DefenseManager.prototype.assignDefenders = function(gameState)
aMin = a;
distMin = dist;
}
if (aMin === undefined)
{
for (var a = 0; a < armiesNeeding.length; ++a)
API3.warn(" defense/armiesNeeding " + uneval(armiesNeeding[a]["need"]));
}
// if outside our territory (helping an ally or attacking a cc foundation), keep some troops in backup
if (i < 12 && this.territoryMap.getOwner(armiesNeeding[aMin]["army"].foePosition) !== PlayerID)
continue;
var str = m.getMaxStrength(ent);
armiesNeeding[aMin]["need"] -= str;

View File

@ -248,7 +248,7 @@ m.HQ.prototype.checkEvents = function (gameState, events, queues)
m.getBestBase(ent, gameState).assignEntity(gameState, ent);
if (ent.hasTerritoryInfluence())
this.updateTerritories(gameState);
if (ent.decaying && ent.isGarrisonHolder())
if (ent.decaying() && ent.isGarrisonHolder())
this.garrisonManager.addDecayingStructure(gameState, evt.entity);
}
}

View File

@ -439,11 +439,14 @@ m.HQ.prototype.configFirstBase = function(gameState)
}
}
if (this.Config.debug > 1)
API3.warn("startingWood: " + startingWood + "(cut at 8500 for no rush and 6000 for saveResources)");
API3.warn("startingWood: " + startingWood + " (cut at 8500 for no rush and 6000 for saveResources)");
if (startingWood < 6000)
this.saveResources = true;
if (startingWood > 8500 && this.canBuildUnits)
this.attackManager.setRushes();
{
let allowed = Math.ceil((startingWood - 8500) / 3000);
this.attackManager.setRushes(allowed);
}
// immediatly build a wood dropsite if possible.
var template = gameState.applyCiv("structures/{civ}_storehouse");