17 lines
441 B
JavaScript
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;
|