Teach PetraAI the new garrisonRegenRate.

Improves behaviour after 856e876148 by counting in the capture strength
of garrisoned entities.

Differential revision: https://code.wildfiregames.com/D4799
Comment by: @Silier
This was SVN commit r27322.
This commit is contained in:
Freagarach 2022-12-30 07:28:02 +00:00
parent 89c78ee1f3
commit 5044850f93
2 changed files with 8 additions and 3 deletions

View File

@ -168,8 +168,13 @@ PETRA.allowCapture = function(gameState, ent, target)
return !target.decaying();
let antiCapture = target.defaultRegenRate();
if (target.isGarrisonHolder() && target.garrisoned())
antiCapture += target.garrisonRegenRate() * target.garrisoned().length;
if (target.isGarrisonHolder())
{
const garrisonRegenRate = target.garrisonRegenRate();
for (const garrisonedEntity of target.garrisoned())
antiCapture += garrisonRegenRate * (gameState.getEntityById(garrisonedEntity)?.captureStrength() || 0);
}
if (target.decaying())
antiCapture -= target.territoryDecayRate();

View File

@ -316,7 +316,7 @@ PETRA.GarrisonManager.prototype.keepGarrisoned = function(ent, holder, around)
return around.meleeSiege;
return holder.buffHeal() && ent.needsHeal();
case PETRA.GarrisonManager.TYPE_DECAY:
return this.decayingStructures.has(holder.id());
return ent.captureStrength() && this.decayingStructures.has(holder.id());
case PETRA.GarrisonManager.TYPE_EMERGENCY: // f.e. hero in regicide mode
if (holder.buffHeal() && ent.isHealable() && ent.healthLevel() < this.Config.garrisonHealthLevel.high)
return true;