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:
parent
19c828f050
commit
a4c9fd193a
@ -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)
|
||||
|
@ -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]);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user