diff --git a/role.guard.js b/role.guard.js index 8a2c26c..4d4d637 100644 --- a/role.guard.js +++ b/role.guard.js @@ -2,13 +2,13 @@ var battle = require("battle") var roleGuard = { getLastFlag: function(){ - return 1; // TODO. calculate me. + return 2; // TODO. calculate me. }, run: function(creep){ console.log(creep, "running Guard") - if (creep.memory.patrolDestination == undefined){ - creep.memory.patrolDestination = 0 - } + // Reset creep to 1 + creep.memory.patrolDestination = creep.memory.patrolDestination || 1; + var target = battle.findEnemy(creep); if(target != creep.room.controller && creep.hits > creep.hitsMax - 500 /* no more attack */) { console.log("\t", creep, "attacking:",target) @@ -22,7 +22,7 @@ var roleGuard = { } if (creep.memory.patrolDestination > this.getLastFlag()){ - creep.memory.patrolDestination = 0; + creep.memory.patrolDestination = 1; } destinationFlag = Game.flags["patrol_" + creep.memory.patrolDestination]; console.log("\tMoving to Patrol leg:", creep.memory.patrolDestination);