[SOLVED] Please help me on Mad Maxer

please help me on Mad Maxer this is my code

loop:
    farthest = None
    maxDistance = 0
    enemyIndex = 0
    enemies = self.findEnemies()
 
    
    while enemyIndex < len(enemies):
        target = enemies[enemyIndex]
        enemyIndex += 1
 
        
        distance = self.distanceTo(target)
        if distance > maxDistance:
            maxDistance = distance
            farthest = target
 
    if farthest:
        while farthest.health>=0:
            if self.isReady("bash"):
                self.bash(farthest)
            else self.attack(farthest)

Hi @Gabriel_Knight, you have 2 issues with your code. The first one is this:

In python, this will never work, what you need to do is have a while loop like this:

While True:

The second issue with your code is this:

The indention and placement is wrong. It should look like this:

else:
     self.attack(farthest)

Hope this helps!
Grzmot

2 Likes

I don’t know if Python will work with self, if it works great! If it doesn’t work, try changing it to

hero

And try what @Grzmot said.
Lydia

1 Like

Yes, self does work in python, but like other people, I just learned to use hero instead, so that’s what I stick with.
Grzmot

1 Like

Oh ok. I learned Python with hero too, so I was confused.
Lydia

have u passed the level @Gabriel_Knight?

@Gabriel_Knight Have you passed the level?
Lydia

if you have please check the box that says solution next to the comment that gave u the answer

sorry no I did not pass the level my motem router went out so I could not hop on. sorry for answering so late.

2 Likes

also I tried what Grzmot said and it did not work it almost worked though but
the decoys just got in the way and pushing my character back so I could not attack the ogre thing that can shoot blue stuff.

Could you post your lastest code and can you send me a link to this level?
Thanks, Lydia

wait I just put on the sword of the forgotten and it worked fine.

2 Likes

Congrats on solving it!! :partying_face: :partying_face: Don’t forget to do that little tick mark next to the comment that helped you solve this level!

Lydia

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.