mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
spin up changes and add ruin gathering
This commit is contained in:
parent
68493b137c
commit
02a0227980
@ -56,7 +56,14 @@ module.exports = {
|
||||
spawnminer: function(){
|
||||
for(let myroom of _.filter(Game.rooms, 'controller.my')) {
|
||||
let name = myroom.name
|
||||
require('proc.spawning').spawnminer(name)
|
||||
require('proc.spawning').spawnsourceminer(name)
|
||||
}
|
||||
return 'Spawning initiated'
|
||||
},
|
||||
spawnmover: function(){
|
||||
for(let myroom of _.filter(Game.rooms, 'controller.my')) {
|
||||
let name = myroom.name
|
||||
require('proc.spawning').spawnmover(name)
|
||||
}
|
||||
return 'Spawning initiated'
|
||||
},
|
||||
|
@ -2,15 +2,18 @@ let Phase1 = {
|
||||
run: function(room) {
|
||||
let myroom=Game.rooms[room]
|
||||
require('assignsources').tick(room)
|
||||
creepcounts = _.countBy(myroom.find(FIND_MY_CREEPS), c => c.memory.role)
|
||||
myroom.memory.creepcounts=creepcounts
|
||||
myroom.memory.movercount=creepcounts["mover"]
|
||||
if(Game.time % 10 === 0){
|
||||
//console.log('processing spawn')
|
||||
|
||||
let myspawns = myroom.find(FIND_MY_SPAWNS)
|
||||
|
||||
if(myspawns.length>0){
|
||||
let myspawn = myspawns[0]
|
||||
let creepcount = myroom.find(FIND_MY_CREEPS).length
|
||||
creepcounts = _.countBy(myroom.find(FIND_MY_CREEPS), c => c.memory.role)
|
||||
myroom.memory.movercount=creepcounts["mover"]
|
||||
|
||||
let workerrolename = 'phase' + myroom.memory.phase +'worker'
|
||||
let sources = myroom.find(FIND_SOURCES )
|
||||
if(myroom.controller.ticksToDowngrade < CONTROLLER_DOWNGRADE[myroom.controller.level] * .2 ){
|
||||
@ -26,13 +29,13 @@ let Phase1 = {
|
||||
console.log(creepcounts[workerrolename])
|
||||
console.log(myroom.energyAvailable + " of " + myroom.energyCapacityAvailable)
|
||||
}
|
||||
if(myroom.memory.minablepositions >= 3 ||myroom.memory.minablepositions==undefined ){
|
||||
if((myroom.memory.minablepositions >= 3 ||myroom.memory.minablepositions==undefined) && (creepcounts["mover"] == 0 || creepcounts["mover"]==undefined) ){
|
||||
if((((creepcounts[workerrolename]< (myroom.memory.minablepositions + 1) || creepcounts[workerrolename]==undefined) && myroom.energyAvailable >= myroom.energyCapacityAvailable) ) || ((creepcounts[workerrolename]==0 || creepcounts[workerrolename]==undefined ) && myroom.energyAvailable>100)) {
|
||||
console.log('Spawning worker in ' + room)
|
||||
require('proc.spawning').spawnworker(room)
|
||||
}
|
||||
} else {
|
||||
if((((creepcounts['sourceminer']< myroom.memory.minablepositions) || creepcounts['sourceminer']==undefined) && myroom.energyAvailable >= myroom.energyCapacityAvailable) || ((creepcounts['sourceminer']==0 || creepcounts['sourceminer']==undefined ) && myroom.energyAvailable>100)) {
|
||||
if((((creepcounts['sourceminer']< myroom.find(FIND_SOURCES).length) || creepcounts['sourceminer']==undefined) ) || ((creepcounts['sourceminer']==0 || creepcounts['sourceminer']==undefined ) && myroom.energyAvailable>100)) {
|
||||
console.log('Spawning sourceminer in ' + room)
|
||||
require('proc.spawning').spawnsourceminer(room)
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ let initroom = {
|
||||
Game.rooms[name].memory.mineralminablepositions = mineralminablepositions
|
||||
let minablepositions = 0
|
||||
let srcs = Game.rooms[name].find(FIND_SOURCES);
|
||||
Game.rooms[name].memory.sourcecount=srcs.length
|
||||
for(let i = 0;i<srcs.length;i++)
|
||||
{
|
||||
minablepositions = minablepositions + this.computeSourceAccessPoints(Game.rooms[name],srcs[i])
|
||||
|
@ -100,7 +100,7 @@ let mover={
|
||||
}
|
||||
}*/
|
||||
|
||||
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') >= 1000) ;}});
|
||||
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) ;}});
|
||||
@ -110,7 +110,8 @@ let mover={
|
||||
}
|
||||
let droppedenergy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, {filter: (r) =>{return ( r.resourceType==RESOURCE_ENERGY&& r.amount>10)}});
|
||||
let tombstone = creep.pos.findClosestByRange(FIND_TOMBSTONES, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>200)}});
|
||||
if((droppedenergy == undefined) && (tombstone==undefined)){
|
||||
let ruins=creep.pos.findClosestByRange(FIND_RUINS, {filter: ruin => ruin.store.getUsedCapacity(RESOURCE_ENERGY) > 0});
|
||||
if((droppedenergy == undefined) && (tombstone==undefined) && (ruins==undefined)){
|
||||
/*try{
|
||||
// console.log(storagetarget.store.getUsedCapacity('energy')/storagetarget.store.getCapacity())
|
||||
if(storagetarget.store.getUsedCapacity('energy')< 1000 && (storagetarget.store.getUsedCapacity('energy')/storagetarget.store.getCapacity() < .5 )){
|
||||
@ -129,7 +130,14 @@ let mover={
|
||||
}
|
||||
//creep.memory.pulledenergyfrom=storagetarget
|
||||
} else {
|
||||
if(droppedenergy){
|
||||
if(ruins){
|
||||
if(creep.withdraw(ruins,RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
||||
if(global.verbosity>0){
|
||||
creep.say("MTRU");
|
||||
}
|
||||
creep.moveTo(ruins,{ignoreCreeps:ignorecreeps})
|
||||
}
|
||||
}else if(droppedenergy){
|
||||
if(creep.pickup(droppedenergy) == ERR_NOT_IN_RANGE) {
|
||||
if(global.verbosity>0){
|
||||
creep.say("MTDE");
|
||||
|
@ -67,7 +67,7 @@ let Phase1Worker = {
|
||||
creep.moveTo(Game.rooms[creep.memory.assignedroom].controller,{ignoreCreeps:ignorecreeps})
|
||||
}
|
||||
}
|
||||
} else if ((creep.ticksToLive < 300 || creep.ticksToLive <= creep.memory.renewto) && (Game.rooms[creep.room.name].find(FIND_MY_SPAWNS, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>200)}})) ) {
|
||||
} else if (creep.pos.findClosestByRange(FIND_MY_SPAWNS) && (creep.ticksToLive < 300 || creep.ticksToLive <= creep.memory.renewto) && (Game.rooms[creep.room.name].find(FIND_MY_SPAWNS, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>200)}})) ) {
|
||||
if(creep.memory.renewto == undefined){
|
||||
creep.memory.renewto = 1200
|
||||
} else {
|
||||
@ -78,36 +78,54 @@ let Phase1Worker = {
|
||||
creep.say('renewing')
|
||||
console.log(creep.name + ": " + creep.ticksToLive + " " + creep.memory.renewto)
|
||||
let spawn = creep.pos.findClosestByRange(FIND_MY_SPAWNS)
|
||||
if(creep.room.memory.NeedsRecharge==1 && creep.carry.energy>0){
|
||||
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.moveTo(creep.room.controller)
|
||||
}
|
||||
} else {
|
||||
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE){
|
||||
creep.moveTo(spawn);
|
||||
if(spawn != undefined && spawn!= null){
|
||||
if(creep.room.memory.NeedsRecharge==1 && creep.carry.energy>0){
|
||||
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.moveTo(creep.room.controller)
|
||||
}
|
||||
} else {
|
||||
|
||||
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE){
|
||||
creep.say('MVSP')
|
||||
creep.moveTo(spawn);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
creep.memory.renewto=1
|
||||
}
|
||||
} else {
|
||||
let droppedenergy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, {filter: (r) =>{return ( r.resourceType==RESOURCE_ENERGY&& r.amount>200)}});
|
||||
let tombstone = creep.pos.findClosestByRange(FIND_TOMBSTONES, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>200)}});
|
||||
//console.log(tombstones)
|
||||
if((droppedenergy == undefined) && (tombstone==undefined)){
|
||||
//console.log(tombstone)
|
||||
if((droppedenergy == undefined || droppedenergy==null) && (tombstone==undefined || tombstone==null)){
|
||||
creep.say("1")
|
||||
if(Game.getObjectById(creep.memory.destsource.id)==undefined){creep.memory.destsource=undefined}
|
||||
let mysource=Game.getObjectById(creep.memory.destsource.id)
|
||||
try{
|
||||
if(mysource.energy==0){
|
||||
//console.log(creep.room.memory.creepcounts)
|
||||
if((mysource.energy==0 || ((creep.room.memory.creepcounts.sourceminer!=null ||creep.room.memory.creepcounts.sourceminer!=undefined )))){
|
||||
creep.say("2.1")
|
||||
//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){
|
||||
let storagetarget = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_CONTAINER) && s.store.getUsedCapacity('energy') >= 100) ;}});
|
||||
if(storagetarget===undefined || storagetarget==null){
|
||||
creep.say('2.2')
|
||||
storagetarget=creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE) && s.store.getUsedCapacity('energy') >= creep.room.controller.level * 125000) ;}});
|
||||
if((storagetarget===undefined || storagetarget==null) && creep.room.terminal && creep.room.terminal.store.getUsedCapacity('energy') > 100000){
|
||||
creep.say('2.3')
|
||||
storagetarget=creep.room.terminal
|
||||
}
|
||||
}
|
||||
if(storagetarget != undefined && creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) {
|
||||
//console.log(Game.getObjectById(storagetarget.id))
|
||||
if((storagetarget != undefined || storagetarget != null) && creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) {
|
||||
creep.say('3')
|
||||
//creep.say('Getting Energy')
|
||||
creep.travelTo(storagetarget);
|
||||
} else {
|
||||
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE){
|
||||
creep.moveTo(mysource,{ignoreCreeps:ignorecreeps})
|
||||
}
|
||||
creep.say("NSE-Ming")
|
||||
}
|
||||
}else {
|
||||
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE){
|
||||
|
@ -4,8 +4,31 @@ let rolesourceMiner = {
|
||||
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);
|
||||
if ((creep.ticksToLive < 300 || creep.ticksToLive <= creep.memory.renewto) && (Game.rooms[creep.room.name].find(FIND_MY_SPAWNS, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>200)}})) ) {
|
||||
if(creep.memory.renewto == undefined){
|
||||
creep.memory.renewto = 1200
|
||||
} else {
|
||||
if(creep.ticksToLive >= creep.memory.renewto){
|
||||
delete creep.memory.renewto
|
||||
}
|
||||
}
|
||||
creep.say('renewing')
|
||||
console.log(creep.name + ": " + creep.ticksToLive + " " + creep.memory.renewto)
|
||||
let spawn = creep.pos.findClosestByRange(FIND_MY_SPAWNS)
|
||||
if(creep.room.memory.NeedsRecharge==1 && creep.carry.energy>0){
|
||||
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.moveTo(creep.room.controller)
|
||||
}
|
||||
} else {
|
||||
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE){
|
||||
creep.moveTo(spawn);
|
||||
}
|
||||
}
|
||||
} else{
|
||||
if(creep.harvest(mysource) == ERR_NOT_IN_RANGE) {
|
||||
creep.travelTo(mysource);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user