I really need help in hunting party, here is my code:
enemy = hero.findNearestEnemy()
while enemy:
friends = hero.findFriends()
for friend in friends:
enemy = friend.findNearest(friend.findEnemies())
if enemy:
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", {'x': friend.pos.x + 24, 'y':friend.pos.y})
only one person moves the rest just stays right there.
wait nvm i found it (20 chars)
Ryan_Wong:
24
use 1 else it will just run into the wall
the only difference in my code is that i used enemy = friend.findNearestEnemy()
and that i didnt define enemy at the begening
Yea it does, the probleme is defining before, it will take the one before. So the troops might be confused a little
SO ur code is this:
enemy = friend.findNearestEnemy()
while enemy:
friends = hero.findFriends()
for friend in friends:
enemy = friend.findNearest(friend.findEnemies())
if enemy:
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", {'x': friend.pos.x + 1, 'y':friend.pos.y})
so I don’t need the while true loop and the “enemy=friend.findNearestEnemy()”?
No the loop is a while true loop, the reason why it did not work is that your checking if there is an enemy. They are very far away unless you have infinite range glasses it wont work
so what do I do with the while true loop
change it to while True:
and that should work fine
is there a way that the archers don’t die?
since I want the bonus.
Grzmot
January 15, 2021, 11:51pm
17
I don’t think that this is a big deal, but you can remove the
at the top of your code.
-Grzmot
1 Like
in my code, i dont get the bonus. But i dont know if you can summon more troops to help…