From 8f7e8fa40439b41582e408eede6e2e2eb7d3d600 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Tue, 26 Jun 2018 16:24:10 +0100 Subject: Change builders to withdraw from spawner --- src/role.builder.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/role.builder.js b/src/role.builder.js index 8c7fc6b..f243eac 100644 --- a/src/role.builder.js +++ b/src/role.builder.js @@ -4,6 +4,7 @@ module.exports = { run: (creep) => { if (creep.memory.state === "building") { if (creep.carry.energy > 0) { + // still building const targets = creep.room.find(FIND_CONSTRUCTION_SITES); if (targets.length) { if (creep.build(targets[0]) == ERR_NOT_IN_RANGE) { @@ -11,16 +12,18 @@ module.exports = { } } } else { + // just finished building creep.memory.state = "collecting"; } } else { if (creep.carry.energy < creep.carryCapacity) { // still filling up const spawn = Game.spawns['Initial']; - if (creep.transfer(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { + if (creep.withdraw(spawn, RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) { util.move(creep, spawn); } } else { + // just finished filling up creep.memory.state = "building"; } } -- cgit v1.2.1