Mad maxer please help! [SOLVED]


#1

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


#2

Typo here. Health instead of helath


#3

okay thanks i’ll try that


#4

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


#5

You have to attack farthest not enemy


#6

okay i’ll try that also


#7

yesssssssss thank you it worked :grinning::grinning::grinning::crossed_swords::crossed_swords::crossed_swords:


#8

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