Mountain Merceneys code combat help java script

This is my code

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

Um what’s the error ?

its not working and the code looks fine i looked at some github finished code and it is exactly the same

:worried:

Could you screenshot the problem you’re having and explain it in a bit more detail?

1 Like

i dosnt give a error it says that it is inconplete

Try commenting out line 4. The hero.say will halt ALL of the code until the hero finishes yapping, so all the commands and movements and what not in the code will just not work properly. Also it was supposed to be a placeholder anyway so it should be removed.

2 Likes

it didnt work but it helped

could it be my heros speed health or attack my hero is Arryn

I got it i just had to hit reload and hit submit.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.