while True: # Move to the nearest coin. # Use move instead of moveXY so you can command constantly. 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") 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. if soldierIndex < len(soldiers): # Use the 'attack' command to make your soldiers attack. #hero.command(soldier, "attack", enemy) hero.command(soldier, "attack", enemy) soldierIndex += 1
I know I’m doing something wrong, but I can’t figure out what. My hero moves around fine, grabs coins, and he summons soldiers without a problem. The problem is that the soldiers won’t attack and I can’t figure out what I’m doing wrong.