hello guys sorry for the repetive posting but now mad maxer is making me get stuck heres the code the problem is that my hero won’t move and my code is correct what is happening???

``````while True:
farthest = None
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()
enemy=hero.findNearestEnemy()
# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
target = enemies[enemyIndex]
enemyIndex += 1
# Is this enemy farther than the farthest we've seen so far?
distance = hero.distanceTo(target)
if distance > maxDistance:
maxDistance = distance
farthest = target
if farthest:
# Take out the farthest enemy!
# Keep attacking the enemy while its health is greater than 0.
if enemy.helath>0:
hero.attack(enemy)
pass

``````

Typo here. Health instead of helath

okay thanks i’ll try that

it was so close to working then the throwers came along and killed me because my hero kept on attacking the decoys

You have to attack farthest not enemy

okay i’ll try that also

yesssssssss thank you it worked

Just saying but if your code doesn’t work then don’t say your code is correct (I got confused for a sec)

Also don’t spam and stuff @guy_oy

Felt the need to point that out sry Chaboi

help! im having issues with this level my hero won’t even move

``````# Attack the enemy that's farthest away first.

while True:
farthest = None
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()

# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
target = enemies[enemyIndex]
enemyIndex += 1

# Is this enemy farther than the farthest we've seen so far?
distance = hero.distanceTo(target)
if distance > maxDistance:
maxDistance = distance
farthest = target

if farthest:
# Take out the farthest enemy!
# Keep attacking the enemy while its health is greater than 0.
if enemy.health > 0:
hero.attack(enemy)
pass
``````

thanks for the help.

The entire top part of your code is dedicated to define ‘farthest’, but in the end, you aren’t using it…

thanks for the help dedreous i get it now. so because i get it i passed.

1 Like

hi, I need help with my code:

``````while True:
farthest = None
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()

# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
target = enemies[enemyIndex]
enemyIndex += 1

# Is this enemy farther than the farthest we've seen so far?
distance = hero.distanceTo(target)
if distance > maxDistance:
maxDistance = distance
farthest = target

if farthest:
# Take out the farthest enemy!
# Keep attacking the enemy while its health is greater than 0.
enemy = hero.findNearestEnemy()
while enemy.health > 0:
hero.attack(enemy)
pass

``````

the person with the dragon attacked it and then the throwers kill me.

plz, help me so I can improve my skills.

Put 4 spaces before these lines. And one more tip: you need pretty good armour to complete this level.
Let me know if you need any more assistance at this level, ok?

its still does nothing
its does the same it did before

Can you resend me the code?

Here put

``````enemy = farthest
``````

Does it work now?

thank you it worked I can’t believe that thing was wrong! Thanks

1 Like

No problem! Glad I could help! And congratulations for completing the level!

``````# in my opinion, go after the fangriders like this
fangriders = hero.findByType("fangrider")
fangrider = hero.findNearest(fangriders)
``````

I can’t believe I was able to pass this level! I have been working on it for quite some time (maybe about a week or two) and honestly it is a relief to finally move on in the Desert.

Mod edit: Solution removeed thank you trying to help but copying and pasting code doesn’t help anyone learn.