[PetraAI] - Make easy difficulties of AI weaker
This patch decreases the popScaling so that the easy AI difficulties have lower targeted population. And it also decreases the size & priority of the attacks from the easy an very easy AI. Refs: #6149 Differential revision: D3997 Patch by: @marder Tested by: @Langbart Comments by: @wraitii, @Freagarach This was SVN commit r25600.
This commit is contained in:
parent
d08c96be43
commit
7e92f714ca
@ -173,25 +173,38 @@ PETRA.AttackPlan = function(gameState, Config, uniqueID, type, data)
|
||||
// and lower priority and smaller sizes for easier difficulty levels
|
||||
if (this.Config.difficulty < 2)
|
||||
{
|
||||
priority *= 0.6;
|
||||
variation *= 0.5;
|
||||
priority *= 0.4;
|
||||
variation *= 0.2;
|
||||
}
|
||||
else if (this.Config.difficulty < 3)
|
||||
{
|
||||
priority *= 0.8;
|
||||
variation *= 0.8;
|
||||
variation *= 0.6;
|
||||
}
|
||||
for (let cat in this.unitStat)
|
||||
|
||||
if (this.Config.difficulty < 2)
|
||||
{
|
||||
this.unitStat[cat].targetSize = Math.round(variation * this.unitStat[cat].targetSize);
|
||||
this.unitStat[cat].minSize = Math.min(this.unitStat[cat].minSize, this.unitStat[cat].targetSize);
|
||||
for (const cat in this.unitStat)
|
||||
{
|
||||
this.unitStat[cat].targetSize = Math.ceil(variation * this.unitStat[cat].targetSize);
|
||||
this.unitStat[cat].minSize = Math.min(this.unitStat[cat].targetSize, Math.min(this.unitStat[cat].minSize, 2));
|
||||
this.unitStat[cat].batchSize = this.unitStat[cat].minSize;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (const cat in this.unitStat)
|
||||
{
|
||||
this.unitStat[cat].targetSize = Math.ceil(variation * this.unitStat[cat].targetSize);
|
||||
this.unitStat[cat].minSize = Math.min(this.unitStat[cat].minSize, this.unitStat[cat].targetSize);
|
||||
}
|
||||
}
|
||||
|
||||
// change the sizes according to max population
|
||||
this.neededShips = Math.ceil(this.Config.popScaling * this.neededShips);
|
||||
for (let cat in this.unitStat)
|
||||
{
|
||||
this.unitStat[cat].targetSize = Math.round(this.Config.popScaling * this.unitStat[cat].targetSize);
|
||||
this.unitStat[cat].targetSize = Math.ceil(this.Config.popScaling * this.unitStat[cat].targetSize);
|
||||
this.unitStat[cat].minSize = Math.ceil(this.Config.popScaling * this.unitStat[cat].minSize);
|
||||
}
|
||||
|
||||
@ -706,19 +719,22 @@ PETRA.AttackPlan.prototype.assignUnits = function(gameState)
|
||||
added = true;
|
||||
}
|
||||
|
||||
// Finally add also some workers,
|
||||
// Finally add also some workers for the higher difficulties,
|
||||
// If Rush, assign all kind of workers, keeping only a minimum number of defenders
|
||||
// Otherwise, assign only some idle workers if too much of them
|
||||
if (this.Config.difficulty <= 2)
|
||||
return added;
|
||||
|
||||
let num = 0;
|
||||
let numbase = {};
|
||||
const numbase = {};
|
||||
let keep = this.type != "Rush" ?
|
||||
6 + 4 * gameState.getNumPlayerEnemies() + 8 * this.Config.personality.defensive : 8;
|
||||
keep = Math.round(this.Config.popScaling * keep);
|
||||
for (let ent of gameState.getOwnEntitiesByRole("worker", true).values())
|
||||
for (const ent of gameState.getOwnEntitiesByRole("worker", true).values())
|
||||
{
|
||||
if (!ent.hasClass("CitizenSoldier") || !this.isAvailableUnit(gameState, ent))
|
||||
continue;
|
||||
let baseID = ent.getMetadata(PlayerID, "base");
|
||||
const baseID = ent.getMetadata(PlayerID, "base");
|
||||
if (baseID)
|
||||
numbase[baseID] = numbase[baseID] ? ++numbase[baseID] : 1;
|
||||
else
|
||||
|
@ -208,12 +208,14 @@ PETRA.Config.prototype.setConfig = function(gameState)
|
||||
|
||||
if (this.difficulty < 2)
|
||||
{
|
||||
this.popScaling = 0.5;
|
||||
this.Economy.supportRatio = 0.5;
|
||||
this.Economy.provisionFields = 1;
|
||||
this.Military.numSentryTowers = this.personality.defensive > this.personalityCut.strong ? 1 : 0;
|
||||
}
|
||||
else if (this.difficulty < 3)
|
||||
{
|
||||
this.popScaling = 0.7;
|
||||
this.Economy.supportRatio = 0.4;
|
||||
this.Economy.provisionFields = 1;
|
||||
this.Military.numSentryTowers = this.personality.defensive > this.personalityCut.strong ? 1 : 0;
|
||||
@ -254,16 +256,15 @@ PETRA.Config.prototype.setConfig = function(gameState)
|
||||
}
|
||||
|
||||
if (maxPop < 300)
|
||||
{
|
||||
this.popScaling = Math.sqrt(maxPop / 300);
|
||||
this.Military.popForBarracks1 = Math.min(Math.max(Math.floor(this.Military.popForBarracks1 * this.popScaling), 12), Math.floor(maxPop/5));
|
||||
this.Military.popForBarracks2 = Math.min(Math.max(Math.floor(this.Military.popForBarracks2 * this.popScaling), 45), Math.floor(maxPop*2/3));
|
||||
this.Military.popForForge = Math.min(Math.max(Math.floor(this.Military.popForForge * this.popScaling), 30), Math.floor(maxPop/2));
|
||||
this.Economy.popPhase2 = Math.min(Math.max(Math.floor(this.Economy.popPhase2 * this.popScaling), 20), Math.floor(maxPop/2));
|
||||
this.Economy.workPhase3 = Math.min(Math.max(Math.floor(this.Economy.workPhase3 * this.popScaling), 40), Math.floor(maxPop*2/3));
|
||||
this.Economy.workPhase4 = Math.min(Math.max(Math.floor(this.Economy.workPhase4 * this.popScaling), 45), Math.floor(maxPop*2/3));
|
||||
this.Economy.targetNumTraders = Math.round(this.Economy.targetNumTraders * this.popScaling);
|
||||
}
|
||||
this.popScaling *= Math.sqrt(maxPop / 300);
|
||||
|
||||
this.Military.popForBarracks1 = Math.min(Math.max(Math.floor(this.Military.popForBarracks1 * this.popScaling), 12), Math.floor(maxPop/5));
|
||||
this.Military.popForBarracks2 = Math.min(Math.max(Math.floor(this.Military.popForBarracks2 * this.popScaling), 45), Math.floor(maxPop*2/3));
|
||||
this.Military.popForForge = Math.min(Math.max(Math.floor(this.Military.popForForge * this.popScaling), 30), Math.floor(maxPop/2));
|
||||
this.Economy.popPhase2 = Math.min(Math.max(Math.floor(this.Economy.popPhase2 * this.popScaling), 20), Math.floor(maxPop/2));
|
||||
this.Economy.workPhase3 = Math.min(Math.max(Math.floor(this.Economy.workPhase3 * this.popScaling), 40), Math.floor(maxPop*2/3));
|
||||
this.Economy.workPhase4 = Math.min(Math.max(Math.floor(this.Economy.workPhase4 * this.popScaling), 45), Math.floor(maxPop*2/3));
|
||||
this.Economy.targetNumTraders = Math.round(this.Economy.targetNumTraders * this.popScaling);
|
||||
this.Economy.targetNumWorkers = Math.max(this.Economy.targetNumWorkers, this.Economy.popPhase2);
|
||||
this.Economy.workPhase3 = Math.min(this.Economy.workPhase3, this.Economy.targetNumWorkers);
|
||||
this.Economy.workPhase4 = Math.min(this.Economy.workPhase4, this.Economy.targetNumWorkers);
|
||||
|
Loading…
Reference in New Issue
Block a user