[SOLVED] Python - Mountain Mercenaries


I don’t get it, my hero moves to the coin and summons alright, but will not command at all. Soldiers stay in place and get outnumbered and killed. Checked other topics but I don’t see what I’m doing wrong :

# 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.
    item = hero.findNearest(hero.findItems())
    # If you have funds for a soldier, summon one.
    if hero.gold > hero.costOf("soldier"):
    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        soldiers = hero.findFriends()
        soldierIndex = 0
        soldier = soldiers[soldierIndex]
        # Loop over all your soldiers and order them to attack.
        while soldierIndex < len(soldiers):
            # Use the 'attack' command to make your soldiers attack.
            #hero.command(soldier, "attack", enemy)
            hero.command(soldier, "attack", enemy)
            soldierIndex += 1

Thanks for your help

Nevermind, found it myself,

The soldier = soldiers[soldierIndex] was missplaced

1 Like

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