From bde8a2309f7f51e8e12250cf59a347440e24c19b Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 31 Aug 2023 19:13:22 +0200 Subject: [PATCH] Changed miner movement; --- JobBuilder.js | 2 +- JobMiner.js | 7 +++---- StructureSpawnClass.js | 2 -- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/JobBuilder.js b/JobBuilder.js index 1fceb6d..5a627c7 100644 --- a/JobBuilder.js +++ b/JobBuilder.js @@ -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)=>{ diff --git a/JobMiner.js b/JobMiner.js index 6ab3003..606fa42 100644 --- a/JobMiner.js +++ b/JobMiner.js @@ -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){ diff --git a/StructureSpawnClass.js b/StructureSpawnClass.js index c89efde..5193414 100644 --- a/StructureSpawnClass.js +++ b/StructureSpawnClass.js @@ -1,5 +1,3 @@ -const math = require("Math"); - module.exports = { setup: function () { StructureSpawn.prototype = _StructureSpawn.prototype; } }