screeps/role.claimer.js

21 lines
760 B
JavaScript
Raw Normal View History

2017-06-06 13:17:26 -05:00
let roleClaimer = {
run: function(creep) {
if(creep.memory.originroom === undefined){
creep.memory.originroom = creep.room.name
}
//let mycontroller= creep.room.find(STRUCTURE_CONTROLLER)
if(!creep.room.controller.my){
creep.say('claiming')
if(creep.claimController(creep.room.controller) == ERR_NOT_IN_RANGE) {
creep.moveTo(creep.room.controller);
}
} else if(Game.flags.claim){
creep.say('claim')
creep.moveTo(Game.flags.claim)
} else{
creep.say('parking')
creep.moveTo(creep.room.memory.claimerparkx,creep.room.memory.claimerparky,creep.room)
}
}
};
module.exports = roleClaimer;