mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
Try to fix movers
This commit is contained in:
parent
6f6535faf1
commit
39e648ff87
@ -34,7 +34,7 @@ let Phase1 = {
|
|||||||
console.log('Spawning sourceminer in ' + room)
|
console.log('Spawning sourceminer in ' + room)
|
||||||
require('proc.spawning').spawnsourceminer(room)
|
require('proc.spawning').spawnsourceminer(room)
|
||||||
}
|
}
|
||||||
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)
|
console.log('Spawning worker in ' + room)
|
||||||
require('proc.spawning').spawnworker(room)
|
require('proc.spawning').spawnworker(room)
|
||||||
}
|
}
|
||||||
|
@ -302,6 +302,35 @@ let buildparts = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
},
|
||||||
|
designCreep: function(availableCost,arrParts)
|
||||||
|
{
|
||||||
|
var bodyPartArray = [];
|
||||||
|
var arrCosts = [];
|
||||||
|
for(var i = 0;i<arrParts.length;i++)
|
||||||
|
{
|
||||||
|
arrCosts.push(BODYPART_COST[arrParts[i]]);
|
||||||
|
}
|
||||||
|
var partCounter = 0;
|
||||||
|
var currentCost = 0;
|
||||||
|
while(true)
|
||||||
|
{
|
||||||
|
var nextPartType = partCounter%arrParts.length;
|
||||||
|
partCounter++;
|
||||||
|
if(currentCost+arrCosts[nextPartType] <= availableCost && partCounter<=50)
|
||||||
|
{
|
||||||
|
bodyPartArray.push(arrParts[nextPartType]);currentCost+=arrCosts[nextPartType];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if(bodyPartArray.length<arrParts.length)
|
||||||
|
{
|
||||||
|
console.log("Insufficient funds for functional creep");
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
return bodyPartArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
module.exports = buildparts;
|
module.exports = buildparts;
|
@ -54,13 +54,33 @@ let mover={
|
|||||||
} else {
|
} else {
|
||||||
if(filllevel < creep.carryCapacity){
|
if(filllevel < creep.carryCapacity){
|
||||||
let storagetarget = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE || s.structureType == STRUCTURE_CONTAINER) && _.sum(s.store) >= 500) ;}});
|
let storagetarget = creep.pos.findClosestByRange(FIND_STRUCTURES, {filter: (s) => {return ((s.structureType == STRUCTURE_STORAGE || s.structureType == STRUCTURE_CONTAINER) && _.sum(s.store) >= 500) ;}});
|
||||||
if(creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) {
|
let droppedenergy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, {filter: (r) =>{return ( r.resourceType==RESOURCE_ENERGY&& r.amount>200)}});
|
||||||
creep.say('Getting Energy')
|
let tombstone = creep.pos.findClosestByRange(FIND_TOMBSTONES, {filter: (r) =>{return ( r.store[RESOURCE_ENERGY]>200)}});
|
||||||
creep.travelTo(storagetarget);
|
if((droppedenergy == undefined) && (tombstone==undefined)){
|
||||||
|
if(creep.withdraw(storagetarget,RESOURCE_ENERGY)== ERR_NOT_IN_RANGE) {
|
||||||
|
creep.say('Getting Energy')
|
||||||
|
creep.travelTo(storagetarget);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(droppedenergy){
|
||||||
|
if(creep.pickup(droppedenergy) == ERR_NOT_IN_RANGE) {
|
||||||
|
if(global.verbosity>0){
|
||||||
|
creep.say("MTDE");
|
||||||
|
}
|
||||||
|
creep.moveTo(droppedenergy,{ignoreCreeps:ignorecreeps})
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(creep.withdraw(tombstone,RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
|
||||||
|
if(global.verbosity>0){
|
||||||
|
creep.say("MTTS");
|
||||||
|
}
|
||||||
|
creep.moveTo(tombstone.pos,{ignoreCreeps:ignorecreeps})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
creep.memory.lastpos=creep.pos
|
creep.memory.lastpos=creep.pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = mover;
|
module.exports = mover;
|
@ -69,7 +69,6 @@ let Phase1Worker = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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]>1)}})) ) {
|
} 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]>1)}})) ) {
|
||||||
|
|
||||||
if(creep.memory.renewto == undefined){
|
if(creep.memory.renewto == undefined){
|
||||||
creep.memory.renewto = 1200
|
creep.memory.renewto = 1200
|
||||||
} else {
|
} else {
|
||||||
@ -80,9 +79,16 @@ let Phase1Worker = {
|
|||||||
creep.say('renewing')
|
creep.say('renewing')
|
||||||
console.log(creep.name + ": " + creep.ticksToLive + " " + creep.memory.renewto)
|
console.log(creep.name + ": " + creep.ticksToLive + " " + creep.memory.renewto)
|
||||||
let spawn = creep.pos.findClosestByRange(FIND_MY_SPAWNS)
|
let spawn = creep.pos.findClosestByRange(FIND_MY_SPAWNS)
|
||||||
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE)
|
if(creep.room.memory.NeedsRecharge==1 && creep.carry.energy>0){
|
||||||
{
|
if(creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) {
|
||||||
creep.moveTo(spawn);
|
creep.say('!MTRC!')
|
||||||
|
creep.say(creep.room.controller.ticksToDowngrade)
|
||||||
|
creep.moveTo(creep.room.controller)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(spawn.renewCreep(creep) == ERR_NOT_IN_RANGE){
|
||||||
|
creep.moveTo(spawn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let droppedenergy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, {filter: (r) =>{return ( r.resourceType==RESOURCE_ENERGY&& r.amount>200)}});
|
let droppedenergy = creep.pos.findClosestByRange(FIND_DROPPED_RESOURCES, {filter: (r) =>{return ( r.resourceType==RESOURCE_ENERGY&& r.amount>200)}});
|
||||||
|
Loading…
Reference in New Issue
Block a user