Screeps Wiki
Advertisement

function (target) {

   if (!this.my) {
     return C.ERR_NOT_OWNER;
   }
   if (data(this.id).spawning) {
     return C.ERR_BUSY;
   }
   if (this.room.mode == C.MODE_WORLD) {
     var controllersClaimed = _.filter(runtimeData.userObjects, {type: 'controller'}).length;
     if (controllersClaimed && (!runtimeData.user.gcl || runtimeData.user.gcl < C.GCL_MULTIPLY * Math.pow(controllersClaimed, C.GCL_POW))) {
       return C.ERR_GCL_NOT_ENOUGH;
     }
   }
   if (!target || !target.id || !register.structures[target.id] || !(target instanceof globals.Structure)) {
     return C.ERR_INVALID_TARGET;
   }
   if (!target.pos.isNearTo(this.pos)) {
     return C.ERR_NOT_IN_RANGE;
   }
   if (target.structureType != 'controller') {
     return C.ERR_INVALID_TARGET;
   }
   if (target.owner) {
     return C.ERR_INVALID_TARGET;
   }
   intents[this.id] = intents[this.id] || {};
   intents[this.id].claimController = {id: target.id};
   return C.OK;
 }

Advertisement