dismantle energy recovery?



  • So i read the API and it says you can recover a propotion of energy used to make/repair a structure by using a dismantle command.. But I don't seem to be getting any energy from dismantling buildings at all (no drops and no energy added to my creeps carry store). I have tried dismantling both a wall and enemy tower (in abandoned rooms), both got destroyed but neither dropped or gave me any energy. my creep has 3x work and 3x carry along with 6x move parts. the snippet from the code i use is bellow. Has this feature been taken out or am i doing something wrong?

    if (creep.dismantle(enemyStruct[0]) == ERR_NOT_IN_RANGE) {
    creep.moveTo(enemyStruct[0]);
    }

     


  • Culture

    1 work dismantle 0.25 energy so you need at least 4 work to not get rounded down to 0.



  • Thanks :), i will try it with 4x WORK. Grrr i hate the Screeps API... I have just read the part about the 0.25 of 1 energy per tick. I originally thought the 0.25 was the fraction recovered from the energy used in creating/repairing the structure and proportional to the decrease in hits you cause a building relative to its total hits.. I did not think the 0.25 just relates to an arbitrary 1 energy, because that is not related to the amount of energy used to repair/construct the structure (maybe with the exception of walls). Also, the API states 2 different values for the fraction 0.25 (like you pointed out) and 50%/0.5. I really like this game, but for me the API documentation is just poor; it words some things very badly and can also be quite misleading (unintentionally). I understand it has had big changes recently which i have not really looked at much yet so maybe the API has been improved ~

    quotes of the differing explanations from the same API reference page. 

    "Dismantles any (even hostile) structure returning 50% of the energy spent on its repair. Requires the WORK body part. If the creep has an empty CARRY body part, the energy is put into it; otherwise it is dropped on the ground. The target has to be at adjacent square to the creep."

    "Dismantles a structure for 50 hits per tick returning 0.25 energy unit per tick."


  • Dev Team

    amount of energy used to repair/construct the structure

    This is where your issue is coming from. The API says nothing about energy spent on construction, but only on repair. You get 50% of energy spent on repair, or 0.25 energy per 50 hits, which is the same thing.



  • I'm having the same problem. I got two guys dismantling enemy controller. Multiple ticks have gone by and the code dismantle code is 0 but I am not seeing any energy.

    To me 50% returned on repair would mean I have had a creep repairing this structure for 1000 energy and now I can recover 500 of his investment. Or maybe that is my issue since this controller I have never personally repaired..

    😂


  • @frop You can't destroy controllers.



  • @frop ugh this reminds me of the first time I encountered my "dismantle all buildings in the room" bug



  • @duckymirror I wasn't trying to .destroy() them 😉



  • @frop I meant destroying via .destroy() and .dismantle(). A controller doesn't have hits and it belongs to the room so it would be strange if you could destroy it. Both methods still return 0 which is a bit confusing because nothing happens.