From c48b481abaf0fe2b16ed3fce79c58bf9d25e4367 Mon Sep 17 00:00:00 2001 From: "Clarence \"Sparr\" Risher" Date: Fri, 22 Sep 2017 23:02:32 -0700 Subject: [PATCH] sourcer near storage deposits directly, no carry --- src/prototype_creep_harvest.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/prototype_creep_harvest.js b/src/prototype_creep_harvest.js index 5dda47022..07b9e8a51 100644 --- a/src/prototype_creep_harvest.js +++ b/src/prototype_creep_harvest.js @@ -14,8 +14,17 @@ Creep.prototype.handleSourcer = function() { this.buildContainer(); - if (!this.room.controller || !this.room.controller.my || this.room.controller.level >= 2) { - this.spawnCarry(); + const nearStorage = this.room.storage && this.pos.isNearTo(this.room.storage); + + if (nearStorage) { + const workParts = this.body.filter((part) => part.type === WORK).length; + if (_.sum(this.carry) > this.carryCapacity - workParts * 2) { + this.transfer(this.room.storage, RESOURCE_ENERGY); + } + } else { + if (!this.room.controller || !this.room.controller.my || this.room.controller.level >= 2) { + this.spawnCarry(); + } } if (this.inBase()) {