[SOLVED] Need help w Mountain Mercs

this is my code

// Gather coins to summon soldiers and have them attack the enemy.
while(true) {
    // Move to the nearest coin.
    // Use move instead of moveXY so you can command constantly.
    var coin = hero.findNearestItem();
    hero.move(coin.pos);
    
    // If you have funds for a soldier, summon one.
    if (hero.gold > hero.costOf("soldier")) {
        hero.summon("soldier");
    }
    var enemy = hero.findNearest(hero.findEnemies());
    if (enemy) {
        
        var soldiers = hero.findFriends();
        var soldierIndex = 0;
        var soldier = soldiers[soldierIndex];
        // Loop over all your soldiers and order them to attack.
        while(true) {
            hero.command(soldier, "attack", enemy);
        }
        
            // Use the 'attack' command to make your soldiers attack.
            //hero.command(soldier, "attack", enemy);
    }
}
1 Like

for some reason, only one soldier goes to attack the orcs

1 Like

Since soldierIndex is 0 and it never changes, the soldier you are commanding will always be soldiers[0].

2 Likes

ok… so do I have to increase that value?

1 Like

OH no wait I have to increment that I am so dumb

1 Like