Minor changes

This commit is contained in:
unknown
2023-08-31 19:04:10 +02:00
parent 29aa48dc3b
commit 8d67dcb8b8
4 changed files with 31 additions and 28 deletions

View File

@@ -1,7 +1,6 @@
module.exports = {
begin(creep){
if(!creep.memory.collecting) creep.memory.collecting = false;
if(!creep.memory.counter) creep.memory.counter = 0;
},
tick(creep){
@@ -71,27 +70,21 @@ function findWithdrawTarget(creep){
}
function findTransferTarget(creep) {
var target;
switch (creep.memory.counter%3) {
case 0: target = creep.pos.findClosestByRange(FIND_MY_STRUCTURES, {
var target = creep.pos.findClosestByRange(FIND_MY_STRUCTURES, {
filter:(s)=> {
return (s.structureType == STRUCTURE_EXTENSION)
&& s.store.getFreeCapacity(RESOURCE_ENERGY) > 0;
}});
if(!target) target = creep.pos.findClosestByRange(FIND_MY_STRUCTURES, {
filter:(s)=> {
return (s.structureType == STRUCTURE_SPAWN)
&& s.store.getFreeCapacity(RESOURCE_ENERGY) > 0;
}});
break;
case 1: target = creep.pos.findClosestByRange(FIND_STRUCTURES, {
if(!target) target = creep.pos.findClosestByRange(FIND_MY_STRUCTURES, {
filter:(s)=> {
return (s.structureType == STRUCTURE_SPAWN)
&& s.store.getFreeCapacity(RESOURCE_ENERGY) > 0;
}});
if(!target) target = creep.pos.findClosestByRange(FIND_STRUCTURES, {
filter:(s)=> {
return s.structureType == STRUCTURE_CONTAINER
&& s.store.getFreeCapacity(RESOURCE_ENERGY) > 1000;
}});
break;
case 2: target = creep.room.storage; break;
}
}})
if(!target) target = creep.room.storage;
if(target) creep.memory.target = target.id;
creep.memory.counter++;
}