Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[Solved] Hunting party

#1
while True:
    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})

1 Like
#2

This is my code. :smiley:

#3

Structural problem. Your if enemy and subsequent else conditional statements are not inside your for loop. Also, your guys are moving WAY too fast - put a decimal point in front of that 24 so that they stay together.

#4

Thanks! :yum::yum::yum:

#5

Thanks @Chaboi_3000 for fixing that :smiley:

1 Like