Search code examples
screeps

How to claim a controller in an adjacent room?


Having trouble claiming a controller using a creep with one or more CLAIM body parts.

I am getting the nearest controller in the room using this function:

getNearestController: function(creep)
{
    return creep.room.find(FIND_STRUCTURES, {
    filter: function(structure) {
        return (structure.structureType == STRUCTURE_CONTROLLER);
    }
    });
}

Which works just fine, I can access the object and see it's coordinates are correct.

However, when I run this every tick (while the creep is directly next to it) the controller owner is still "None" and I see nothing happening, the creep takes no action.

if(creep.claimController(nearestController)<0)
{
    creep.moveTo(nearestController);            
}

Pretty sure the above call to claimController is incorrect, but not sure what I'm missing.


Solution

  • I can't see anything wrong here so I would think the problem is your Global Control Level.

    In order to claim new rooms you need to have a GCL at least 1 higher than the number of rooms you already own. If you're a new player your GCL is probably still at level 1. This would mean you can own just one room. You can look at your game profile to see your progress towards the next level.

    http://support.screeps.com/hc/en-us/articles/203086021-Global-control