mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
Adding source miners for rooms with low access to sources.
This commit is contained in:
parent
a91ac17be1
commit
291a8e72c1
@ -25,15 +25,22 @@ let Phase1 = {
|
|||||||
console.log(creepcounts[workerrolename])
|
console.log(creepcounts[workerrolename])
|
||||||
console.log(Game.rooms[room].energyAvailable + " of " + Game.rooms[room].energyCapacityAvailable)
|
console.log(Game.rooms[room].energyAvailable + " of " + Game.rooms[room].energyCapacityAvailable)
|
||||||
}
|
}
|
||||||
if((((creepcounts[workerrolename]< (sources.length * 3) || creepcounts[workerrolename]==undefined) && Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable) ) || ((creepcounts[workerrolename]==0 || creepcounts[workerrolename]==undefined ) && Game.rooms[room].energyAvailable>100)) {
|
if(Game.rooms[room].minablepositions>=3){
|
||||||
console.log('Spawning worker in ' + room)
|
if((((creepcounts[workerrolename]< (sources.length * 3) || creepcounts[workerrolename]==undefined) && Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable) ) || ((creepcounts[workerrolename]==0 || creepcounts[workerrolename]==undefined ) && Game.rooms[room].energyAvailable>100)) {
|
||||||
require('proc.spawning').spawnworker(room)
|
console.log('Spawning worker in ' + room)
|
||||||
|
require('proc.spawning').spawnworker(room)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if((((creepcounts['sourceminer']< Game.rooms[room].memory.minablepositions) || creepcounts['sourceminer']==undefined) && Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable) || ((creepcounts['sourceminer']==0 || creepcounts['sourceminer']==undefined ) && Game.rooms[room].energyAvailable>100)) {
|
||||||
|
console.log('Spawning sourceminer in ' + room)
|
||||||
|
require('proc.spawning').spawnsourceminer(room)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if((Game.rooms[room].storage || Game.rooms[room].terminal) && (creepcounts["mover"] < 2 || creepcounts["mover"]==undefined)){
|
if((Game.rooms[room].storage || Game.rooms[room].terminal) && (creepcounts["mover"] < 2 || creepcounts["mover"]==undefined)){
|
||||||
console.log("Spawning Mover in " + room)
|
console.log("Spawning Mover in " + room)
|
||||||
require('proc.spawning').spawnmover(room)
|
require('proc.spawning').spawnmover(room)
|
||||||
}
|
}
|
||||||
if(Game.rooms[room].find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_EXTRACTOR}}) && (creepcounts["miner"] < 1 || creepcounts["miner"]==undefined) && Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable){
|
if((Game.rooms[room].find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_EXTRACTOR}}))&&(creepcounts["miner"] < 1 || creepcounts["miner"]==undefined)&&(Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable)){
|
||||||
console.log("Spawning Miner in " + room)
|
console.log("Spawning Miner in " + room)
|
||||||
require('proc.spawning').spawnminer(room)
|
require('proc.spawning').spawnminer(room)
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ let assignMiners = {
|
|||||||
tick: function(roomname) {
|
tick: function(roomname) {
|
||||||
let sources = Game.rooms[roomname].find(FIND_SOURCES );
|
let sources = Game.rooms[roomname].find(FIND_SOURCES );
|
||||||
for(let source of sources){
|
for(let source of sources){
|
||||||
let allminers = Game.rooms[roomname].find(FIND_MY_CREEPS, {filter: (creep) =>{return ( creep.memory.role=='miner'|| creep.memory.role == ("phase" + Game.rooms[roomname].memory.phase + "worker") )}});
|
let allminers = Game.rooms[roomname].find(FIND_MY_CREEPS, {filter: (creep) =>{return ( creep.memory.role=='sourceminer'|| creep.memory.role == ("phase" + Game.rooms[roomname].memory.phase + "worker") )}});
|
||||||
//let allstorage = Game.rooms[name].find(FIND_STRUCTURES, {filter: (s) => {return ( s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_STORAGE)}})
|
//let allstorage = Game.rooms[name].find(FIND_STRUCTURES, {filter: (s) => {return ( s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_STORAGE)}})
|
||||||
let unassignedminers = _.filter(allminers, (creep) => (creep.memory.destsource == undefined ));
|
let unassignedminers = _.filter(allminers, (creep) => (creep.memory.destsource == undefined ));
|
||||||
let sourcecount = sources.length
|
let sourcecount = sources.length
|
||||||
|
@ -22,6 +22,30 @@ let buildparts = {
|
|||||||
let newcreep = spawn.createCreep(tobuild,CreepName,{role:'miner'})
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:'miner'})
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
},
|
||||||
|
spawnsourceminer: function(roomname) {
|
||||||
|
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
|
||||||
|
Game.rooms[roomname].memory.CreepNum++
|
||||||
|
let CreepName = 'sourceminer_' + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
|
||||||
|
for(let spawn of myspawns){
|
||||||
|
if(!spawn.spawning){
|
||||||
|
let tobuild=[]
|
||||||
|
for(let totry of [
|
||||||
|
[WORK,WORK,WORK,WORK,WORK,MOVE],
|
||||||
|
[WORK,WORK,WORK,WORK,MOVE],
|
||||||
|
[WORK,WORK,WORK,MOVE],
|
||||||
|
[WORK,WORK,MOVE],
|
||||||
|
[WORK,MOVE]
|
||||||
|
]){
|
||||||
|
let ispossible = spawn.canCreateCreep(totry)
|
||||||
|
if(ispossible==OK){
|
||||||
|
tobuild=totry
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:'sourceminer'})
|
||||||
|
}}
|
||||||
|
|
||||||
},
|
},
|
||||||
spawnwarrior: function(roomname) {
|
spawnwarrior: function(roomname) {
|
||||||
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
|
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
|
||||||
|
12
role.sourceminer.js
Normal file
12
role.sourceminer.js
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
let rolesourceMiner = {
|
||||||
|
run: function(creep) {
|
||||||
|
//if(Game.getObjectById(creep.memory.destsource.id)==undefined){creep.memory.destsource=undefined}
|
||||||
|
let ignorecreeps=true
|
||||||
|
//console.log('running sourceminer')
|
||||||
|
let mysource=Game.getObjectById(creep.memory.destsource.id)
|
||||||
|
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE) {
|
||||||
|
creep.travelTo(mysource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
module.exports = rolesourceMiner;
|
Loading…
Reference in New Issue
Block a user