Ticket #3864: petra-fix-training.patch

File petra-fix-training.patch, 1.9 KB (added by mimo, 8 years ago)
  • binaries/data/mods/public/simulation/ai/petra/headquarters.js

     
    427427            if (item.metadata && item.metadata.role && item.metadata.role == "worker" && item.metadata.plan == undefined)
    428428            {
    429429                numberOfWorkers += item.count;
    430                 if (ent.hasClass("Support"))
     430                if (item.metadata.support)
    431431                    numberOfSupports += item.count;
    432432            }
    433433        });
     
    465465        return;
    466466
    467467    // Choose whether we want soldiers instead.
    468     let supportRatio = (gameState.isDisabledTemplates(gameState.applyCiv("structures/{civ}_field")) ? Math.min(this.supportRatio, 0.2) : this.supportRatio);
     468    let supportRatio = gameState.isDisabledTemplates(gameState.applyCiv("structures/{civ}_field")) ? Math.min(this.supportRatio, 0.2) : this.supportRatio;
     469    let supportMin = gameState.isDisabledTemplates(gameState.applyCiv("structures/{civ}_field")) ? 4 : 8;
     470    supportMin = Math.max(supportMin, supportRatio * numberTotal);
    469471    let template;
    470     if ((numberOfSupports + numberOfQueuedSupports) > 8 && (numberOfSupports + numberOfQueuedSupports)/numberTotal > supportRatio)
     472    if (numberOfSupports + numberOfQueuedSupports > supportMin)
    471473    {
    472474        let requirements;
    473475        if (numberTotal < 45)
     
    489491    // If the template variable is empty, the default unit (Support unit) will be used
    490492    // base "0" means automatic choice of base
    491493    if (!template && templateDef)
    492         queues.villager.addPlan(new m.TrainingPlan(gameState, templateDef, { "role": "worker", "base": 0 }, size, size));
     494        queues.villager.addPlan(new m.TrainingPlan(gameState, templateDef, { "role": "worker", "base": 0, "support": true }, size, size));
    493495    else if (template)
    494496        queues.citizenSoldier.addPlan(new m.TrainingPlan(gameState, template, { "role": "worker", "base": 0 }, size, size));
    495497};