Claiming Controller Kills moveTo?



  • So I just got to GCL2 and claimed a new room. I had everything set up for multi-room control and was building a new spawn in the second room when every single creep i had stopped moving. After some debugging, I determined that not a single one of them was able to path to their memory targets. (yes, i store id numbers and use Game.getObjectById()). Every creep that was told to move was giving me -2 (no path). So I unclaimed the new controller and lo and behold they all started functioning as if nothing had happened. here is the code for my room upgrader in case it will mean something to anyone. I apologize for the lack of formatting.

    EDIT* I suppose it is also necessary to mention i checked the creep's memory as well. The source id was good, and the creep was only 6 squares or so from the controller with a clear path that worked before.

    EDIT** Ive done some more debugging. It turns out there is something affecting room position objects as well. My wall repairers are able to correctly identify walls and ramparts in need of upgrading when I only own one room, but as soon as I grab a second, their creep.pos.find() starts returning null, even though I have no maximum allowed level to upgrade my walls, and there are definitely walls in the room. I tried to jury rig it with var myRoom = Game.rooms[creep.pos.roomName]; and then using myRoom.find. myRoom was properly instantiated, but myRoom.find returned null. I'm stumped, and I can't expand until I get this figured out. 

     

     

    var roleUpgrader = {
    run: function (creep) {
    //check to make sure mem is initialized
    if (creep.memory.upgrading == undefined)
    creep.memory.upgrading = false;

    //toggle between working and gathering
    if(creep.memory.upgrading && creep.carry.energy == 0) {
    creep.memory.upgrading = false;
    }
    if(!creep.memory.upgrading && creep.carry.energy == creep.carryCapacity) {
    creep.memory.upgrading = true;
    }

    //go and upgrade
    if(creep.memory.upgrading) {
    if (creep.upgradeController(creep.room.controller) == ERR_NOT_IN_RANGE) {
    //----------------------This is the move command that was acting up (along with all the rest)
    creep.moveTo(creep.room.controller, { reusePath: 10 });
    }
    }
    //get more energy
    else {
    //source is set during spawning process for max efficiency
    mySource = Game.getObjectById(creep.memory.source);
    if(creep.harvest(mySource) == ERR_NOT_IN_RANGE) {
    creep.moveTo(mySource, {reusePath: 10},{visualizePathStyle: {stroke: '#ffaa00'}});
    }
    }
    }
    };

    module.exports = roleUpgrader;