Ticket #3864: petra-fix-training.patch
File petra-fix-training.patch, 1.9 KB (added by , 8 years ago) |
---|
-
binaries/data/mods/public/simulation/ai/petra/headquarters.js
427 427 if (item.metadata && item.metadata.role && item.metadata.role == "worker" && item.metadata.plan == undefined) 428 428 { 429 429 numberOfWorkers += item.count; 430 if ( ent.hasClass("Support"))430 if (item.metadata.support) 431 431 numberOfSupports += item.count; 432 432 } 433 433 }); … … 465 465 return; 466 466 467 467 // 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); 469 471 let template; 470 if ( (numberOfSupports + numberOfQueuedSupports) > 8 && (numberOfSupports + numberOfQueuedSupports)/numberTotal > supportRatio)472 if (numberOfSupports + numberOfQueuedSupports > supportMin) 471 473 { 472 474 let requirements; 473 475 if (numberTotal < 45) … … 489 491 // If the template variable is empty, the default unit (Support unit) will be used 490 492 // base "0" means automatic choice of base 491 493 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)); 493 495 else if (template) 494 496 queues.citizenSoldier.addPlan(new m.TrainingPlan(gameState, template, { "role": "worker", "base": 0 }, size, size)); 495 497 };