screeps/role.guard.js
2016-06-29 13:21:09 -04:00

17 lines
441 B
JavaScript

var battle = require("battle")
var roleGuard = {
run: function(creep){
console.log(creep, "running Guard")
var target = battle.findEnemy(creep);
console.log("\t", creep, "tageting:",target)
if(target && creep.hits > creep.hitsMax - 500 /* no more attack */) {
creep.moveTo(target);
creep.attack(target);
} else {
creep.moveTo(Game.spawns.Spawn1);
}
}
}
module.exports = roleGuard;