Find dropped energy



  • Have this tines in code:
    ```js
    if (creep.carry.energy < creep.carryCapacity)
    {
    var energy = creep.pos.findInRange(
    FIND_DROPPED_ENERGY,
    1
    );

        if (energy.length) {
            console.log('found ' + energy[0].energy + ' energy at ', energy[0].pos);
            creep.pickup(energy[0]);
        }
    }
    
    
    And noticed 2 bugs:
    1) when few creeps harvesting near each other there is often found 1-4 energy
    2) after calling ```someCreep.suicide()``` there is NaN energy!
    


  • Arr... Sample code again:

        if (creep.carry.energy < creep.carryCapacity)
        {
            var energy = creep.pos.findInRange(
                FIND_DROPPED_ENERGY,
                1
            );
    
            if (energy.length) {
                console.log('found ' + energy[0].energy + ' energy at ', energy[0].pos);
                creep.pickup(energy[0]);
            }
        }
    


  • I don't get your issue? Range 1 means a 3X3 grid around the creep, like 1 away from the creep. The second bug, well.. are you trying to get the energy from that creep or what?



  • I think (1) is becouse some type of owerflow. For example creep has 43 energy, 50 energyCapacity and harverts 10 per round. After calling creep.harvest() there will be 3 dropped energy on ground. Next creep gets it from ground and so on... Problem is that there is no way to get 7 energy instaed of 10.

    As for (2) i'm not trying to do anything special. Just noticed this strange behaviour.