int main() {
// You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while (true) {
auto friends = hero.findFriends();
auto weak_friend = null;
auto low_friend = 99999;
// Use for-loop and for each friend:
for(int i = 0; i < friends.length; i ++){
// If they see an enemy then command to attack.
auto friend = friends[i];
auto enemy = friend.findNearestEnemy();
if(friend.health < low_friend){
weak_friend = friend;
low_friend = friend.health;
}
if(enemy){
hero.command(friend, "attack", enemy);
}else{
hero.command(friend, "move", {friend.pos.x + 15, hero.pos.y});
}
if(weak_friend){
hero.command(weak_friend, "move", {weak_friend.pos.x - 30, weak_friend.pos.y});
}
// Command to move east by small steps.
}
auto enemy = hero.findNearestEnemy();
if(enemy){
if(hero.isReady("jump") && hero.isReady("cleave")){
hero.jumpTo(enemy.pos);
hero.cleave(enemy);
}else{
hero.attack(enemy);
}
}else{
hero.moveXY(hero.pos.x + 15, hero.pos.y);
}
}
return 0;
}
soldier moving all together in one place
how do i fix this?