Created
September 14, 2015 21:50
-
-
Save Hernanduer/96dcbac94d0a0fd8cb24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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