My code so far:
hero.findByNotType = function (type) {
var enemies = [];
for (let enemy of hero.findEnemies()) if (type.indexOf(enemy.type) == -1) enemies.push(enemy);
return enemies;
};
hero.buildXY("fence", 20, 15);
while (true) {
if (hero.isPathClear({x: 63, y: 14}, {x: 78, y: 14})) break;
for (let friend of hero.findFriends()) {
if (friend.type == "paladin") {
if (friend.pos.x < 50) hero.command(friend, "move", {x: 50, y: 50});
else hero.command(friend, "shield");
continue;
}
else hero.command(friend, "attack", friend.findNearest(hero.findByNotType(["robot-walker", "ice-yak", "cow"])));
}
}
But I can’t seem to get the archers or soldiers to stop attacking the ice yaks and cows and then dying. 
