Mining/Storage tweaks

This commit is contained in:
Dan Hamik 2022-05-04 08:30:12 -05:00
parent a68447d386
commit faeef7ee03
4 changed files with 33 additions and 9 deletions

View File

@ -45,7 +45,7 @@ let Phase1 = {
console.log("Spawning Mover in " + room) console.log("Spawning Mover in " + room)
require('proc.spawning').spawnmover(room) require('proc.spawning').spawnmover(room)
} }
if((myroom.storage || myroom.terminal) && (creepcounts["mineralmover"] < 1 || creepcounts["mineralmover"]==undefined)){ if(((myroom.storage || myroom.terminal) && myroom.StructureExtractor) && (creepcounts["mineralmover"] < 1 || creepcounts["mineralmover"]==undefined)){
console.log("Spawning MineralMover in " + room) console.log("Spawning MineralMover in " + room)
require('proc.spawning').spawnmineralmover(room) require('proc.spawning').spawnmineralmover(room)
} }
@ -66,7 +66,7 @@ let Phase1 = {
if(myroom.terminal.store.getUsedCapacity() == 0) { if(myroom.terminal.store.getUsedCapacity() == 0) {
//console.log("terminal is empty") //console.log("terminal is empty")
}else{ }else{
if(myroom.terminal.store.getUsedCapacity('energy') > 10000){ if(myroom.terminal.store.getUsedCapacity('energy') > 100000){
console.log("Starting market loop for "+ myroom) console.log("Starting market loop for "+ myroom)
for(mat in myroom.terminal.store){ for(mat in myroom.terminal.store){
let availtosell=0 let availtosell=0

View File

@ -5,6 +5,7 @@ global.verbosity=0
module.exports.loop = function () { module.exports.loop = function () {
console.log("----Start loop for "+ Game.time + '----') console.log("----Start loop for "+ Game.time + '----')
let decrementcounter = Game.time % 30 let decrementcounter = Game.time % 30
///for (let key of require('Empire')) global[key] = require('Empire')[key]
try{ try{
for(let name in Game.rooms){ for(let name in Game.rooms){
let myroom=Game.rooms[name] let myroom=Game.rooms[name]

View File

@ -99,10 +99,12 @@ let mover={
storagetarget=storage storagetarget=storage
} }
}*/ }*/
let storagetarget = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_CONTAINER) && s.store.getUsedCapacity('energy') >= 10) ;}}); let storagetarget = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_CONTAINER) && s.store.getUsedCapacity('energy') >= 10) ;}});
if(storagetarget===undefined){ if(storagetarget===undefined||storagetarget==null){
creep.say('finding storage')
storagetarget=creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE) && s.store.getUsedCapacity('energy') >= 10) ;}}); storagetarget=creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE) && s.store.getUsedCapacity('energy') >= 10) ;}});
if(storagetarget==undefined && creep.room.terminal){ if((storagetarget==undefined ||storagetarget==null) && creep.room.terminal){
storagetarget=creep.room.terminal storagetarget=creep.room.terminal
} }
} }
@ -119,11 +121,13 @@ let mover={
} catch(e) { } catch(e) {
console.log("oops" + e) console.log("oops" + e)
}*/ }*/
// creep.say('2')
//creep.say(storagetarget)
if(creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) { if(creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) {
creep.say('Getting Energy') creep.say('Getting Energy')
creep.travelTo(storagetarget); creep.travelTo(storagetarget);
} }
creep.memory.pulledenergyfrom=storagetarget //creep.memory.pulledenergyfrom=storagetarget
} else { } else {
if(droppedenergy){ if(droppedenergy){
if(creep.pickup(droppedenergy) == ERR_NOT_IN_RANGE) { if(creep.pickup(droppedenergy) == ERR_NOT_IN_RANGE) {

View File

@ -33,7 +33,7 @@ let Phase1Worker = {
if(creep.memory.working){ if(creep.memory.working){
let look=creep.pos.lookFor(LOOK_STRUCTURES) let look=creep.pos.lookFor(LOOK_STRUCTURES)
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 ) && _.sum(s.store) < s.store.getCapacity()) ;}});
if(creep.room.memory.NeedsRecharge==1){ if(creep.room.memory.NeedsRecharge==1){
if(creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) { if(creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) {
creep.say(creep.room.controller.ticksToDowngrade + " of " + CONTROLLER_DOWNGRADE[creep.room.controller.level] * .2) creep.say(creep.room.controller.ticksToDowngrade + " of " + CONTROLLER_DOWNGRADE[creep.room.controller.level] * .2)
@ -55,7 +55,7 @@ let Phase1Worker = {
if (road.length > 0) {creep.repair(road);} if (road.length > 0) {creep.repair(road);}
creep.moveTo(target,{ignoreCreeps:ignorecreeps}) creep.moveTo(target,{ignoreCreeps:ignorecreeps})
} }
} else if(storagetargets){ } else if(storagetargets){// && creep.room.controller.level*.02 < creep.room.storage.store.getUsedCapacity('energy')/creep.room.storage.store.getCapacity()){
if(creep.transfer(storagetargets, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { if(creep.transfer(storagetargets, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
if (road.length > 0) {creep.repair(road);} if (road.length > 0) {creep.repair(road);}
creep.moveTo(storagetargets,{ignoreCreeps:ignorecreeps}) creep.moveTo(storagetargets,{ignoreCreeps:ignorecreeps})
@ -95,8 +95,27 @@ let Phase1Worker = {
if((droppedenergy == undefined) && (tombstone==undefined)){ if((droppedenergy == undefined) && (tombstone==undefined)){
if(Game.getObjectById(creep.memory.destsource.id)==undefined){creep.memory.destsource=undefined} if(Game.getObjectById(creep.memory.destsource.id)==undefined){creep.memory.destsource=undefined}
let mysource=Game.getObjectById(creep.memory.destsource.id) let mysource=Game.getObjectById(creep.memory.destsource.id)
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE){ try{
creep.moveTo(mysource,{ignoreCreeps:ignorecreeps}) if(mysource.energy==0){
//creep.say("No Energy Left to get")
let storagetarget = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_CONTAINER) && s.store.getUsedCapacity('energy') >= 1000) ;}});
if(storagetarget===undefined){
storagetarget=creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE) && s.store.getUsedCapacity('energy') >= 100000) ;}});
if(storagetarget==undefined && creep.room.terminal && creep.room.terminal.store.getUsedCapacity('energy') > 100000){
storagetarget=creep.room.terminal
}
}
if(storagetarget != undefined && creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) {
//creep.say('Getting Energy')
creep.travelTo(storagetarget);
}
}else {
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE){
creep.moveTo(mysource,{ignoreCreeps:ignorecreeps})
}
}
} catch(e){
console.log(e)
} }
} else { } else {
if(droppedenergy){ if(droppedenergy){