module.exports = { setup: function () { StructureSpawn.prototype = _StructureSpawn.prototype; } } class _StructureSpawn extends StructureSpawn { begin(){ if (!this.memory.creepCounter) this.memory.creepCounter = 0; this.memory.init = true; } tick(){ if(!this.memory.init) this.begin(); if(this.store.getUsedCapacity(RESOURCE_ENERGY) < 300) return; const job = this.room.memory.vacancies.pop(); if(job){ const name = getJobName(job.role); const body = getBodyByJob(job.role); if(this.createCreep(job, name, body) != OK) this.room.memory.vacancies.push(job); } } createCreep(job, name, body) { const response = this.spawnCreep(body, name + ": " + this.memory.creepCounter, { memory: { job: job } }); if (response == OK) this.memory.creepCounter++; return response; } } function getJobName(role){ switch (role) { case Role.BUILDER: return "Bob"; case Role.HARVESTER: return "Harvy"; case Role.MINER: return "minny"; case Role.SUPPLIER: return "Sully"; case Role.UPGRADER: return "Uppa"; } } function getBodyByJob(role){ switch (role) { case Role.BUILDER: case Role.HARVESTER: return [WORK, CARRY, CARRY, MOVE, MOVE]; case Role.UPGRADER: return [WORK, WORK, CARRY, MOVE]; case Role.MINER: return [WORK, WORK, MOVE, MOVE]; case Role.SUPPLIER: return [CARRY, CARRY, CARRY, MOVE, MOVE, MOVE] } }