while True:
# Move to the nearest coin.
# Use move instead of moveXY so you can command constantly.
items = hero.findItems()
itemIndex = 0
hero.say("I need coins!")
item = items[itemIndex]
hero.move(itemPos)
# 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")
enemy = hero.findNearest(hero.findEnemies())
if enemy:
# Loop over all your soldiers and order them to attack.
soldiers = hero.findFriends()
soldierIndex = 0
soldier = soldiers[soldierIndex]
# Use the 'attack' command to make your soldiers attack.
#hero.command(soldier, "attack", enemy)
hero.command(soldier, "attack", target)
# 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.
items = hero.findItems()
itemIndex = 0
hero.say("I need coins!")
item = items[itemIndex]
if item < hero.costOf("soldier"):
hero.move(item.Pos)
item +=1
# 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")
enemy = hero.findNearest(hero.findEnemies())
soldier = soldiers[soldierIndex]
if enemy:
# Loop over all your soldiers and order them to attack.
soldiers = hero.findFriends()
soldierIndex = 0
# Use the 'attack' command to make your soldiers attack.
#hero.command(soldier, "attack", enemy)
hero.command(soldier, "attack", target)
soldierIndex += 1