Skip to content

Instantly share code, notes, and snippets.

@Hernanduer
Created September 14, 2015 21:50
Show Gist options
  • Save Hernanduer/96dcbac94d0a0fd8cb24 to your computer and use it in GitHub Desktop.
Save Hernanduer/96dcbac94d0a0fd8cb24 to your computer and use it in GitHub Desktop.
blindEntrance: function(creep, roomName) {
if ((creep.memory.targets.lastRoom == undefined || creep.memory.targets.lastRoom != creep.room.name) && creep.fatigue == 0) {
creep.memory.targets.position = undefined;
}
if (creep.memory.targets.position == undefined) {
if (Game.map.isRoomProtected(roomName)) {
this.log(creep.room.name, creep.name + " is trying to move to protected room " + roomName);
return;
}
var exit = creep.room.findExitTo(roomName);
if (exit == -2) {
this.log(creep.room.name, creep.name + " is unable to find an exit to " + roomName);
return false;
}
creep.memory.targets.position = creep.pos.findClosestByPath(exit);
creep.memory.targets.lastRoom = creep.room.name;
if (creep.memory.targets.position == undefined) {
this.log(creep.room.name, creep.name + " is unable to find an exit to " + roomName);
return false;
}
}
return true;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment