1
0
forked from 0ad/0ad

Petra: Let getBestBase optionally check for fully-constructed bases

Patch by Sandarac
Reviewed By: mimo
Differential Revision: https://code.wildfiregames.com/D237
This was SVN commit r19313.
This commit is contained in:
mimo 2017-03-19 10:35:22 +00:00
parent 19c828f050
commit a4c9fd193a
2 changed files with 3 additions and 3 deletions

View File

@ -235,7 +235,7 @@ m.IsSupplyFull = function(gameState, ent)
/**
* get the best base (in terms of distance and accessIndex) for an entity
*/
m.getBestBase = function(gameState, ent)
m.getBestBase = function(gameState, ent, onlyConstructedBase = false)
{
let pos = ent.position();
if (!pos)
@ -254,7 +254,7 @@ m.getBestBase = function(gameState, ent)
let accessIndex = gameState.ai.accessibility.getAccessValue(pos);
for (let base of gameState.ai.HQ.baseManagers)
{
if (!base.anchor)
if (!base.anchor || onlyConstructedBase && base.anchor.foundationProgress() !== undefined)
continue;
let dist = API3.SquareVectorDistance(base.anchor.position(), pos);
if (base.accessIndex !== accessIndex)

View File

@ -376,7 +376,7 @@ m.GameTypeManager.prototype.pickCriticalEntRetreatLocation = function(gameState,
// Couldn't find a place to garrison, so the ent will flee from attacks
criticalEnt.setStance("passive");
let accessIndex = gameState.ai.accessibility.getAccessValue(criticalEnt.position());
let basePos = m.getBestBase(gameState, criticalEnt);
let basePos = m.getBestBase(gameState, criticalEnt, true);
if (basePos && basePos.accessIndex == accessIndex)
criticalEnt.move(basePos.anchor.position()[0], basePos.anchor.position()[1]);
};