forked from 0ad/0ad
petra: additional bugfixes and tweaks
This was SVN commit r16649.
This commit is contained in:
parent
20877632ce
commit
d41671044a
@ -27,19 +27,19 @@ m.AttackManager.prototype.init = function(gameState)
|
|||||||
this.outOfPlan.registerUpdates();
|
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.maxRushes = 3
|
||||||
this.rushSize = [ 16, 22, 28 ];
|
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.maxRushes = 2;
|
||||||
this.rushSize = [ 18, 28 ];
|
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.maxRushes = 1;
|
||||||
this.rushSize = [ 24 ];
|
this.rushSize = [ 24 ];
|
||||||
@ -83,6 +83,7 @@ m.AttackManager.prototype.checkEvents = function(gameState, events)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
attack.targetPos = attack.target.position();
|
attack.targetPos = attack.target.position();
|
||||||
|
attack.resetPath(gameState);
|
||||||
}
|
}
|
||||||
if (attack.targetPlayer && attack.targetPlayer === targetPlayer)
|
if (attack.targetPlayer && attack.targetPlayer === targetPlayer)
|
||||||
available += attack.unitCollection.length;
|
available += attack.unitCollection.length;
|
||||||
|
@ -402,13 +402,7 @@ m.AttackPlan.prototype.updatePreparation = function(gameState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// reset the path so that we recompute it for this new target
|
// reset the path so that we recompute it for this new target
|
||||||
this.path = undefined;
|
this.resetPath(gameState);
|
||||||
if (!this.pathFinder)
|
|
||||||
{
|
|
||||||
this.pathFinder = new API3.aStarPath(gameState, false, false, this.targetPlayer);
|
|
||||||
this.pathWidth = 6;
|
|
||||||
this.pathSampling = 2;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// when we have a target, we path to it.
|
// when we have a target, we path to it.
|
||||||
@ -1703,6 +1697,18 @@ m.AttackPlan.prototype.removeUnit = function(ent, update)
|
|||||||
this.unitCollection.updateEnt(ent);
|
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)
|
m.AttackPlan.prototype.checkEvents = function(gameState, events)
|
||||||
{
|
{
|
||||||
let renameEvents = events["EntityRenamed"];
|
let renameEvents = events["EntityRenamed"];
|
||||||
|
@ -312,11 +312,10 @@ m.DefenseManager.prototype.assignDefenders = function(gameState)
|
|||||||
aMin = a;
|
aMin = a;
|
||||||
distMin = dist;
|
distMin = dist;
|
||||||
}
|
}
|
||||||
if (aMin === undefined)
|
|
||||||
{
|
// if outside our territory (helping an ally or attacking a cc foundation), keep some troops in backup
|
||||||
for (var a = 0; a < armiesNeeding.length; ++a)
|
if (i < 12 && this.territoryMap.getOwner(armiesNeeding[aMin]["army"].foePosition) !== PlayerID)
|
||||||
API3.warn(" defense/armiesNeeding " + uneval(armiesNeeding[a]["need"]));
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
var str = m.getMaxStrength(ent);
|
var str = m.getMaxStrength(ent);
|
||||||
armiesNeeding[aMin]["need"] -= str;
|
armiesNeeding[aMin]["need"] -= str;
|
||||||
|
@ -248,7 +248,7 @@ m.HQ.prototype.checkEvents = function (gameState, events, queues)
|
|||||||
m.getBestBase(ent, gameState).assignEntity(gameState, ent);
|
m.getBestBase(ent, gameState).assignEntity(gameState, ent);
|
||||||
if (ent.hasTerritoryInfluence())
|
if (ent.hasTerritoryInfluence())
|
||||||
this.updateTerritories(gameState);
|
this.updateTerritories(gameState);
|
||||||
if (ent.decaying && ent.isGarrisonHolder())
|
if (ent.decaying() && ent.isGarrisonHolder())
|
||||||
this.garrisonManager.addDecayingStructure(gameState, evt.entity);
|
this.garrisonManager.addDecayingStructure(gameState, evt.entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -439,11 +439,14 @@ m.HQ.prototype.configFirstBase = function(gameState)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (this.Config.debug > 1)
|
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)
|
if (startingWood < 6000)
|
||||||
this.saveResources = true;
|
this.saveResources = true;
|
||||||
if (startingWood > 8500 && this.canBuildUnits)
|
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.
|
// immediatly build a wood dropsite if possible.
|
||||||
var template = gameState.applyCiv("structures/{civ}_storehouse");
|
var template = gameState.applyCiv("structures/{civ}_storehouse");
|
||||||
|
Loading…
Reference in New Issue
Block a user