forked from 0ad/0ad
wraitii
d23b7deb98
Aegis should mostly respect tech limitations so I'll ref #1964. I'm going to go with #2364 is fixed, the AI should be more efficient in early-game, and late-game is a known problem. Fixes #2274 and fixes #2379. Refs #2372 as it should fix several of those warnings for AIs. Fixes #2256 with a new bartering system, in parts taken from mimo's patch. This was SVN commit r14582.
51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
var AEGIS = function(m)
|
|
{
|
|
|
|
m.ResearchPlan = function(gameState, type, rush) {
|
|
if (!m.QueuePlan.call(this, gameState, type, {}))
|
|
return false;
|
|
|
|
if (this.template.researchTime === undefined)
|
|
return false;
|
|
|
|
this.category = "technology";
|
|
|
|
this.rush = rush ? true : false;
|
|
|
|
return true;
|
|
};
|
|
|
|
m.ResearchPlan.prototype = Object.create(m.QueuePlan.prototype);
|
|
|
|
m.ResearchPlan.prototype.canStart = function(gameState) {
|
|
// also checks canResearch
|
|
return (gameState.findResearchers(this.type).length !== 0);
|
|
};
|
|
|
|
m.ResearchPlan.prototype.start = function(gameState) {
|
|
var self = this;
|
|
|
|
//m.debug ("Starting the research plan for " + this.type);
|
|
var trainers = gameState.findResearchers(this.type).toEntityArray();
|
|
|
|
//for (var i in trainers)
|
|
// warn (this.type + " - " +trainers[i].genericName());
|
|
|
|
// Prefer training buildings with short queues
|
|
// (TODO: this should also account for units added to the queue by
|
|
// plans that have already been executed this turn)
|
|
if (trainers.length > 0){
|
|
trainers.sort(function(a, b) {
|
|
return (a.trainingQueueTime() - b.trainingQueueTime());
|
|
});
|
|
// drop anything in the queue if we rush it.
|
|
if (this.rush)
|
|
trainers[0].stopAllProduction(0.45);
|
|
trainers[0].research(this.type);
|
|
}
|
|
this.onStart(gameState);
|
|
};
|
|
|
|
return m;
|
|
}(AEGIS);
|