Having issues with Backwoods Standoff. Using Python.
while True:
enemy = hero.findNearestEnemy()
if enemy:
hero.isReady("cleave")
hero.cleave(enemy)
else:
hero.attack(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.
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