Changed miner movement;
This commit is contained in:
@@ -55,7 +55,7 @@ function energyEmptyCheck(creep){
|
||||
|
||||
function findEnergyTarget(creep){
|
||||
var target;
|
||||
if(creep.room.storage.store.getUsedCapacity(RESOURCE_ENERGY) > creep.store.getFreeCapacity(RESOURCE_ENERGY))
|
||||
if(creep.room.storage && creep.room.storage.store.getUsedCapacity(RESOURCE_ENERGY) > creep.store.getFreeCapacity(RESOURCE_ENERGY))
|
||||
target = creep.room.storage;
|
||||
if(!target) target = creep.pos.findClosestByRange(FIND_STRUCTURES, {
|
||||
filter: (st)=>{
|
||||
|
||||
@@ -4,8 +4,7 @@ module.exports = {
|
||||
tick(creep){
|
||||
const source = Game.getObjectById(creep.memory.job.source);
|
||||
if(!creep.pos.isNearTo(source)) { creep.moveTo(source); return; }
|
||||
if(creep.memory.aboveContainer) { creep.harvest(source); return; }
|
||||
if(creep.memory.container) { moveToContainer(creep); return; }
|
||||
if(creep.memory.container) moveToContainer(creep);
|
||||
if(!(Game.time%100)) scanForContainer(creep, source);
|
||||
creep.harvest(source);
|
||||
}
|
||||
@@ -13,8 +12,8 @@ module.exports = {
|
||||
|
||||
function moveToContainer(creep){
|
||||
const container = Game.getObjectById(creep.memory.container);
|
||||
if(container.pos.x === creep.pos.x && container.pos.y === creep.pos.y) creep.memory.aboveContainer = true;
|
||||
else creep.moveTo(container);
|
||||
if(container.pos.x === creep.pos.x && container.pos.y === creep.pos.y) return;
|
||||
creep.moveTo(container);
|
||||
}
|
||||
|
||||
function scanForContainer(creep, source){
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
const math = require("Math");
|
||||
|
||||
module.exports = {
|
||||
setup: function () { StructureSpawn.prototype = _StructureSpawn.prototype; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user