Skip to content

Instantly share code, notes, and snippets.

@ho0ber
Forked from chrisinajar/battle.js
Last active January 18, 2019 15:04
Show Gist options
  • Save ho0ber/fdee980686035c696d0ebef08bf755ce to your computer and use it in GitHub Desktop.
Save ho0ber/fdee980686035c696d0ebef08bf755ce to your computer and use it in GitHub Desktop.
Battle whitelist for screeps
// usernames are all lowercase, we compare with to lower
var USERNAME_WHITELIST = ['chrisinajar', 'ho0ber', 'fractaloop', 'n7-anthony', 'overra', 'tyrel', 'fervens'];
module.exports = {
findEnemy: findEnemy
};
/*
var target = findEnemy(creep);
*/
function findEnemy (creep) {
var targets = creep.room.find(FIND_HOSTILE_CREEPS, {
filter: (c) => {
return (USERNAME_WHITELIST.indexOf(c.owner.username.toLowerCase()) === -1);
}
});
return creep.pos.findClosestByPath(targets);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment