My code works perfectly with no bugs, but my peasant seems to be limited to some distance near my hero, thus limiting the amount of gold I can collect. Is there a way to fix this? My hero doesn’t get enough gold to hire soldiers!
Here is my code:
# Pender wants to test you on a series of trials. Use your boss star to clear off the ogres! Remember, you cannot move or attack in this level. def summonTroops(): # These are just an example. Feel free to use griffin riders and/or other units! if hero.gold >= 100: hero.summon("soldier") hero.summon("archer") while True: summonTroops() friends = hero.findFriends() # Iterate over all troops using a for loop. Make peasants collect coins. Combat troops fight. item = hero.findNearestItem() enemy = hero.findNearestEnemy() flag = hero.findFlag("green") for friend in friends: #if friend.type == "peasant" and item: # hero.command(friend, "move", item.pos) if friend.type == "peasant": hero.command(friend, "move", item.pos) elif friend.type != "peasant": if enemy: hero.command(friend, "attack", enemy) else: hero.command(friend, "move", Vector(30, 36)) elif enemy and enemy.type == "shaman": hero.command(friend, "attack", enemy)