mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 02:23:47 +00:00
some fixes for Petra AI
This was SVN commit r15247.
This commit is contained in:
@@ -822,7 +822,7 @@ m.AttackPlan.prototype.StartAttack = function(gameState)
|
||||
if (this.Config.debug)
|
||||
warn("start attack " + this.name + " with type " + this.type);
|
||||
|
||||
if (!this.target) // our target was destroyed during our preparation
|
||||
if (!this.target || !gameState.getEntityById(this.target.id())) // our target was destroyed during our preparation
|
||||
{
|
||||
if (!this.targetPos) // should not happen
|
||||
return false;
|
||||
|
||||
@@ -254,7 +254,11 @@ m.HQ.prototype.getSeaIndex = function (gameState, index1, index2)
|
||||
else
|
||||
{
|
||||
if (this.Config.debug > 0)
|
||||
warn("bad path ??? " + uneval(path));
|
||||
{
|
||||
warn("bad path from " + index1 + " to " + index2 + " ??? " + uneval(path));
|
||||
warn(" regionLinks start " + uneval(gameState.ai.accessibility.regionLinks[index1]));
|
||||
warn(" regionLinks end " + uneval(gameState.ai.accessibility.regionLinks[index2]));
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
};
|
||||
@@ -1283,7 +1287,10 @@ m.HQ.prototype.checkBaseExpansion = function(gameState,queues)
|
||||
// then expand if we have lots of units
|
||||
var numUnits = gameState.getOwnUnits().length;
|
||||
var numCCs = gameState.countEntitiesByType(gameState.applyCiv(this.bBase[0]), true);
|
||||
if (Math.floor(numUnits/60) >= numCCs)
|
||||
var popForBase = this.Config.Economy.popForTown + 20;
|
||||
if (this.saveResources)
|
||||
popForBase = this.Config.Economy.popForTown + 5;
|
||||
if (Math.floor(numUnits/popForBase) >= numCCs)
|
||||
{
|
||||
if (this.Config.debug > 1)
|
||||
warn("try to build a new base because of population " + numUnits + " for " + numCCs + " CCs");
|
||||
|
||||
@@ -742,15 +742,17 @@ m.Worker.prototype.moveAway = function(baseManager, gameState){
|
||||
var pos = this.ent.position();
|
||||
var dist = Math.min();
|
||||
var destination = pos;
|
||||
for (var i = 0; i < gatherers.length; ++i)
|
||||
for (var gatherer of gatherers)
|
||||
{
|
||||
if (gatherers[i].isIdle())
|
||||
if (!gatherer.position() || gatherer.getMetadata(PlayerID, "transport") !== undefined)
|
||||
continue;
|
||||
var distance = API3.SquareVectorDistance(pos, gatherers[i].position());
|
||||
if (gatherer.isIdle())
|
||||
continue;
|
||||
var distance = API3.SquareVectorDistance(pos, gatherer.position());
|
||||
if (distance > dist)
|
||||
continue;
|
||||
dist = distance;
|
||||
destination = gatherers[i].position();
|
||||
destination = gatherer.position();
|
||||
}
|
||||
this.ent.move(destination[0], destination[1]);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user