I can see that my hero instantly chooses to target some gold, meaning he is doing something. But, the game says I have no target. (the game puts the little red circle around the nearest coin marking the fact that my hero has targeted it, but the game then stops.)
I also tries using a healing ring to make it so my code isnt always going to the second “if” after a while, but nope. Nothing. It makes it stop at 3 seconds, (a little longer) but it still stops.
I might be able to help.
You might want to use some functions.
Posting all your code in a while loop is very messy.
Also, to command your troops, why not use a for loop?
It’s easier.
Here is a piece of code that makes you summon soldiers, then command them to do stuff.
def command():
friends = hero.findFriends()
for friend in friends:
if friend.type == 'soldier':
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
def summon():
item = hero.findNearestItem()
if hero.gold > 20:
hero.summon("soldier")
elif item:
hero.move(item.pos)
while True:
command()
summon()
Do you want to get coins and summon, or do you want to attack?
Some errors in your code:
Consecrate can be used indefinitely:
It heals you, and won’t damage enemies.
Maybe you should only consecrate when you are low.
def command():
friends = hero.findFriends()
for friend in friends:
if friend.type == 'soldier':
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
def summon():
item = hero.findNearestItem()
if hero.gold > 20:
hero.summon("soldier")
elif item:
hero.move(item.pos)
while True:
command()
summon()
Use this code.
It will make you get items, summon soldiers, and command them to attack THEIR nearest enemy.
You can customize it to suit your own purposes