[SOLVED] Backwoods standoff if/else

i run the code and it does everything right until i get to hero.cleave(enemy) it cleaves and then doesn’t go onto the else statement it just waits till cleave is ready again and never goes to else

while True:
    enemy = hero.findNearestEnemy()
    # Use an if-statement with isReady to check "cleave":
    if enemy: 
        ready = hero.isReady("cleave")
        # Cleave! 
        hero.cleave(enemy)
    # Else, if cleave is not ready: it never goes to else
    else:
        hero.attack(enemy)
        # Attack the nearest ogre!

There’s an issue in your if-condition statement; hero.isReady("cleave") isn’t
in the condition, and the else: should be on the same indentation.

Meaning:
if ready-to-cleave:
then cleave
else:
then attack

So, your code should be something like:

You can also combine the if statement with the isReady in one line.

if hero.isReady("cleave"):
    hero.cleave(enemy)
1 Like

thank you so much!!!

1 Like