Skip to content

Commit

Permalink
feat(processor): limit energy return on recycleCreep to CREEP_PART_MA…
Browse files Browse the repository at this point in the history
…X_ENERGY per part
  • Loading branch information
artch committed Sep 9, 2018
1 parent 2bc4666 commit efc703f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/processor/intents/creeps/_die.js
Expand Up @@ -36,14 +36,19 @@ module.exports = function(object, dropRate, {roomObjects, bulk, stats, gameTime,

if(dropRate > 0 && !object.userSummoned) {
var lifeTime = _.any(object.body, {type: C.CLAIM}) ? C.CREEP_CLAIM_LIFE_TIME : C.CREEP_LIFE_TIME;
var bodyResources = {energy: utils.calcCreepCost(object.body) * dropRate * object._ticksToLive / lifeTime};
var lifeRate = dropRate * object._ticksToLive / lifeTime;
var bodyResources = {energy: 0};

object.body.forEach(i => {
if(i.boost) {
bodyResources[i.boost] = bodyResources[i.boost] || 0;
bodyResources[i.boost] += C.LAB_BOOST_MINERAL * dropRate * object._ticksToLive / lifeTime;
bodyResources.energy += C.LAB_BOOST_ENERGY * dropRate * object._ticksToLive / lifeTime;
bodyResources[i.boost] += C.LAB_BOOST_MINERAL * lifeRate;
bodyResources.energy += C.LAB_BOOST_ENERGY * lifeRate;
}
bodyResources.energy += Math.min(
C.CREEP_PART_MAX_ENERGY,
C.BODYPART_COST[i.type] * lifeRate
);
});

_.forEach(bodyResources, (amount, resourceType) => {
Expand Down
2 changes: 1 addition & 1 deletion src/processor/intents/spawns/recycle-creep.js
Expand Up @@ -19,5 +19,5 @@ module.exports = function(object, intent, scope) {
return;
}

require('../creeps/_die')(target, C.CREEP_RECYCLE_RATE, scope);
require('../creeps/_die')(target, 1.0, scope);
};

0 comments on commit efc703f

Please sign in to comment.