# {UNSOLVED}Hunting party level help

@dedreous

enemy = hero.findNearest(hero.findEnemies())
hero.moveXY(60, 72)
if enemy:
hero.attack(enemy)
else:
pass

hero.moveXY(64, 24)
if enemy:
hero.attack(enemy)
else:
pass

hero.moveXY(88, 60)
if enemy:
hero.attack(enemy)
hero.cleave(enemy)
else:
pass
# here is my code
while True:
friends = hero.findFriends():
// Use for-loop and for each friend:
???
// If they see an enemy then command to attack.
enemy = friend.findNearestEnemy():
if enemy:
# hero.command(friend, "attack", enemy);
}
// Command to move east by small steps.
else:
# hero.command(friend, "move", {'x':??? + 3, 'y':friend.pos.y}):

thats javascript not python

i dont know what i am doing wrong @Chaboi_3000

You’re not quite following the instructions of the level. Ready the comments at the start of the level and in the hints. You’re supposed to be commanding your soldiers, not moving yourself.
Danny

i tried that and that wasn’t working

Well you may have to try again and post your code, you kind of need to know how to use a for loop.
Danny

# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while True:
friends = hero.findFriends()
# Use for-loop and for each friend:
for
# If they see an enemy then command to attack.
if enemy:
hero.command(friends, "attack", enemy)
# Command to move east by small steps.

is this looking good so far

That’s not a bad start, you need to do the for loop properly, define enemy and use an else to command the friends to move eastwards when there isn’t an enemy.
The For loop:

# this is how you do a simple for loop (I think I can tell you this without giving too much away)
Option 1) Simple:
units = hero.findUnits()
for unit in units:
#code follows

Option 2) More complicated, but sometimes necessary:
units = hero.findUnits()
for i in range(0, len(units)):
unit = units[i]
#code follows

I hope this helps,
Danny

# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.
while True:
friends = hero.findFriends()
# Use for-loop and for each friend:
units = hero.findFriends
for i in range(0, len(units)):
unit = units[i]
if enemy:
hero.command(units, "attack", enemy)
else:
hero.command(units, "move", east)

hows this much better and is normal that when i summit it is laggy

# You can use findNearestEnemy() on your soldiers to get their nearest enemy instead of yours.

how does this work

i don’t get this error at all could you explain it @Deadpool198

You need to put the for loop inside the while true loop and I was giving unit as an example, you should use friend.
Danny

@everybody
i need help on this so very bad please help me out soon please because i am about to rage if i cannot solve this level it is hunting party on the cloud rip mountain

@ZAX155

Change to python and it will be success.

okay
i will try that @brotherofall

[en_US.composer.my_button_text]

Im not a Python kinda guy but I can give it to u in Javascript?

define east as {‘x’:friend.pos.x+1, ‘y’:friend.pos.y}

Please don’t revive dead topics. This person is inactive.