Backwoods Standoff

Having issues with Backwoods Standoff. Using Python.

while True:
    enemy = hero.findNearestEnemy()
    if enemy:

I think my problem is passing the variable through the else statement. The hero will find an enemy, cleave, and then he approaches a singular enemy and just bumps into them. I assume this is because the variable enemy has him find the nearest one but I thought hero.attack would cause him to find and attack. Can’t quite figure out how to fix it, advice is appreciated.

1 Like

Please hava a look at your indentation: Your else: refers to “if enemy”.

Have a look at your isReady method, too - I suppose you wanted to use it for a certain reason ;-).


1 Like

I think it should be

if enemy and hero.isReady("cleave")

Correct me if my solution is wrong…

1 Like

That’s correct but it may be more convenient to first check

if enemy:

and then set up the cleave and attack code block with the if hero.isReady("cleave"): and all that stuff, or else the hero might only cleave the enemy if one exists and cleave has finished cooling down, and spend the rest of the time doing nothing. The separate cleave code block within the if enemy statement prevents this.
Or use Luke10’s idea and do

elif enemy and not hero.isReady("cleave"):
1 Like