25 lines
447 B
JavaScript
25 lines
447 B
JavaScript
var energyUtils = require('utils.energy');
|
|
|
|
const body = [
|
|
MOVE, RANGED_ATTACK
|
|
];
|
|
|
|
var roleGuard = {
|
|
body,
|
|
|
|
/** @param {Creep} creep **/
|
|
run: function(creep) {
|
|
const target = creep.pos.findClosestByRange(FIND_HOSTILE_CREEPS);
|
|
if(target) {
|
|
if(creep.rangedAttack(target) == ERR_NOT_IN_RANGE) {
|
|
creep.moveTo(target);
|
|
}
|
|
}
|
|
else {
|
|
creep.moveTo(Game.flags.IdleArea);
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = roleGuard;
|