How are we upgrading our creeps?



  • Was interested if anyone had a good way of upgrading their creeps in a more dynamic way. So far I've only been able to successfully store the body in advance, for example:

    var gatherBody = [CARRY, MOVE, CARRY, MOVE, CARRY, MOVE];

    While it's dead simple to see the pattern here, this is a fixed string array and so trying to add another CARRY,MOVE when you've freed up another 100 energy with capacitors (easily checked with aRoomPointer.energyAvailable or aRoomPointer.energyCapacityAvailable) can't really be done (read above: FIXED array).

    I feel like I missing something obvious so I was wondering if anyone had any methods of saying (if I have this much more energy, add these components).

    This would be so much easier with a LinkedArray that supports .add() but as far as I can tell it isn't supported.



  • You can predefine levels for every role as follows:

    var carrier_levels = [ { cost: 100, body: [ CARRY, MOVE ] }, { cost: 200, body: [ CARRY, MOVE, CARRY, MOVE ] } ];

    Then select most appropriate level for certain conditions.



  • I'm not sure why I didn't think of a 2D array. Thanks a bunch Actium, I should be able to wip something up rather quick.



  • You could also do:

    var gatherBody = [CARRY, MOVE, CARRY, MOVE, CARRY, MOVE];

    if (some condition)
    gatherBody = gatherBody.concat([CARRY, MOVE]);

    Which will add another CARRY and another MOVE on to the original array.



  • var bodyparts = [];
    bodyparts.push(CARRY);
    bodyparts.push(MOVE);

    Works fine? You can then check how many parts you want and just loop the 2 .push()



  • My code

    for each role define parts percent in the body and cost. totalPercent is the max amount of a room energy it will use
        parts: {
            pieces:[
                {typeName:WORK, percent:0.5, cost:100},
                {typeName:CARRY, percent:0.25, cost:50},
                {typeName:MOVE, percent:0.25, cost:50}
            ],
            totalPercent:0.67
        },

     

    then you just have to go through parts.pieces the amount of each part is percent * energyRoom * totalpercent /cost

    And then loop pushing each typeName in an array