mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
Add logic to use factories for mineral storage. fix spawning extra miners.
This commit is contained in:
parent
f2ed90049b
commit
1ff4251f03
@ -25,7 +25,7 @@ let Phase1 = {
|
||||
console.log(Game.rooms[room].energyAvailable + " of " + Game.rooms[room].energyCapacityAvailable)
|
||||
}
|
||||
if(Game.rooms[room].memory.minablepositions >= 3 ||Game.rooms[room].memory.minablepositions==undefined ){
|
||||
if((((creepcounts[workerrolename]< (Game.rooms[room].memory.minablepositions) || creepcounts[workerrolename]==undefined) && Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable) ) || ((creepcounts[workerrolename]==0 || creepcounts[workerrolename]==undefined ) && Game.rooms[room].energyAvailable>100)) {
|
||||
if((((creepcounts[workerrolename]< (Game.rooms[room].memory.minablepositions + 1) || creepcounts[workerrolename]==undefined) && Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable) ) || ((creepcounts[workerrolename]==0 || creepcounts[workerrolename]==undefined ) && Game.rooms[room].energyAvailable>100)) {
|
||||
console.log('Spawning worker in ' + room)
|
||||
require('proc.spawning').spawnworker(room)
|
||||
}
|
||||
@ -43,7 +43,7 @@ let Phase1 = {
|
||||
console.log("Spawning Mover in " + 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}}).length > 0)&&(creepcounts["miner"] < 1 || creepcounts["miner"]==undefined)&&(Game.rooms[room].energyAvailable >= Game.rooms[room].energyCapacityAvailable)){
|
||||
console.log("Spawning Miner in " + room)
|
||||
require('proc.spawning').spawnminer(room)
|
||||
}
|
||||
|
@ -17,6 +17,7 @@ let initroom = {
|
||||
minablepositions = minablepositions + this.computeSourceAccessPoints(Game.rooms[name],srcs[i])
|
||||
//minablepositions = minablepositions + this.checkminablepositions(srcs[i])
|
||||
}
|
||||
//todo - create array of minable positions in the room and assign a screep to them, rather than having them constantly try to find the nearest one.
|
||||
Game.rooms[name].memory.minablepositions = minablepositions
|
||||
},
|
||||
computeSourceAccessPoints: function(room, source){
|
||||
|
@ -17,7 +17,7 @@ let roleMiner = {
|
||||
creep.travelTo(mysource);
|
||||
}
|
||||
} else {
|
||||
let storagetargets = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE || s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_TERMINAL ) && _.sum(s.store) < s.storeCapacity) ;}});
|
||||
let storagetargets = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE || s.structureType == STRUCTURE_CONTAINER || s.structureType == STRUCTURE_TERMINAL || s.structureType == STRUCTURE_FACTORY ) && _.sum(s.store) < s.storeCapacity) ;}});
|
||||
if(storagetargets){
|
||||
if(this.transferAll(creep,storagetargets) == ERR_NOT_IN_RANGE) {
|
||||
creep.moveTo(storagetargets,{ignoreCreeps:ignorecreeps})
|
||||
|
Loading…
Reference in New Issue
Block a user