I am stuck on Hunting Party, mountain level. This is my code:
def spawn():
hero.move(hero.pos)
hero.move(hero.pos)
hero.move(hero.pos)
hero.move(hero.pos)
hero.move(hero.pos)
hero.moveXY(44, 67)
while enemy:
if hero.isReady("bash"):
hero.bash(enemy)
elif friend.health < 10:
hero.consecrate()
else:
hero.attack(enemy)
pet.on("spawn", spawn)
while True:
friends = hero.findFriends()
# Use for-loop and for each friend:
for i in range(len(friends)):
# If they see an enemy then command to attack.
friend = hero.findNearest(hero.findFriends())
enemy = friend.findNearestEnemy()
if enemy:
hero.command(friend, "attack", enemy)
# Command to move east by small steps.
else:
y = friend.pos.y
x = friend.pos.x + 1000
hero.command(friend, "move", {"x": x, "y": y})
Okay, It looks like you have a very different strategy than what the level wants you to do. Try using a while loop and command your friends to attack an enemy if there is one. If not, try moving them forward. It should look something like this:
while True:
friends = hero.findFriends()
for friend in friends:
(Tell them to find an enemy)
if enemy:
(command them to attack the enemy)
else:
(Command them to move forward)
If you want to use this kind of loop, try changing the second part to: friend = friends[i] so it will cycle through all of your friends. Hope this helps!
-Grzmot
while True:
friends = hero.findFriends()
# Use for-loop and for each friend:
for i in range(len(friends)):
# If they see an enemy then command to attack.
friend = friends[i]
enemy = friend.findNearestEnemy
if enemy:
hero.command(friend, "attack", enemy)
# Command to move east by small steps.
else:
y = friend.pos.y
x = friend.pos.x + 10
hero.command(friend, "move", {"x": x, "y": y})
AND THEN IT HAS A ERROR SAYING THAT ENEMY IS A FUNCTION