// You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while (true) {
var friends = hero.findFriends();
// Use for-loop and for each friend:
for(var f = 0; f < friends.length; f += 1); {
// If they see an enemy then command to attack.
var friend = friends[f];
var enemy = friend.findNearestEnemy();
if (enemy) {
hero.command(friend, "attack", enemy);
}
// Command to move east by small steps.
else {
hero.command (friend, "move", {'x': friend.pos.x + 25,'y': friend.pos.y});
}
}
}
Im pretty sure this is the correct code, but my soldiers/archers don’t move when I run it.