mirror of
https://github.com/paradizelost/screeps.git
synced 2024-11-25 02:14:44 -06:00
25 lines
879 B
JavaScript
25 lines
879 B
JavaScript
let roleWarrior = {
|
|
run: function(creep) {
|
|
var hostile = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
|
|
var hostilebuilding = creep.pos.findClosestByRange(FIND_HOSTILE_STRUCTURES||FIND_HOSTILE_SPAWNS );
|
|
if(hostile!=undefined) {
|
|
creep.say('Sorry')
|
|
creep.moveTo(hostile);
|
|
creep.attack(hostile);
|
|
|
|
} else if(hostilebuilding!=undefined){
|
|
creep.say('Sorry')
|
|
creep.moveTo(hostilebuilding);
|
|
creep.attack(hostilebuilding);
|
|
|
|
}else if(Game.flags.Attack) {
|
|
creep.say('ATK')
|
|
creep.moveTo(Game.flags.Attack)
|
|
|
|
} else{
|
|
creep.say('parking')
|
|
creep.moveTo(creep.room.memory.warriorparkx,creep.room.memory.warriorparky,creep.room.roomName)
|
|
}
|
|
}
|
|
};
|
|
module.exports = roleWarrior; |