mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 10:25:09 +00:00
Petra: the AI now destroy captured buildings it can't keep
This was SVN commit r16746.
This commit is contained in:
@@ -227,15 +227,16 @@ m.GarrisonManager.prototype.registerHolder = function(gameState, holder)
|
||||
m.GarrisonManager.prototype.addDecayingStructure = function(gameState, entId)
|
||||
{
|
||||
if (this.decayingStructures.has(entId))
|
||||
return;
|
||||
return true;
|
||||
let ent = gameState.getEntityById(entId);
|
||||
// keep only useful buildings for defense
|
||||
if (!ent || (!ent.hasClass("Barracks") && !ent.hasDefensiveFire()))
|
||||
return;
|
||||
return false;
|
||||
if (!ent.territoryDecayRate() || !ent.garrisonRegenRate())
|
||||
return;
|
||||
return false;
|
||||
let gmin = Math.ceil((ent.territoryDecayRate() - ent.defaultRegenRate()) / ent.garrisonRegenRate());
|
||||
this.decayingStructures.set(entId, gmin);
|
||||
return true;
|
||||
};
|
||||
|
||||
m.GarrisonManager.prototype.removeDecayingStructure = function(entId)
|
||||
|
||||
@@ -246,8 +246,15 @@ m.HQ.prototype.checkEvents = function (gameState, events, queues)
|
||||
m.getBestBase(gameState, ent).assignEntity(gameState, ent);
|
||||
if (ent.hasTerritoryInfluence())
|
||||
this.updateTerritories(gameState);
|
||||
if (ent.decaying() && ent.isGarrisonHolder())
|
||||
this.garrisonManager.addDecayingStructure(gameState, evt.entity);
|
||||
if (ent.decaying())
|
||||
{
|
||||
if (ent.isGarrisonHolder())
|
||||
if (this.garrisonManager.addDecayingStructure(gameState, evt.entity))
|
||||
continue
|
||||
let capture = ent.capturePoints();
|
||||
if (capture[PlayerID] > 0.5 * capture.reduce((a, b) => a + b))
|
||||
ent.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user