Can’t seem to get past this one. The code works perfectly but then will only cleave when the last ogre comes. No normal attack.
# This shows how to define a function called cleaveWhenClose # The function defines a parameter called target def cleaveWhenClose(target): if hero.distanceTo(target) < 5: pass # Put your attack code here hero.isReady("cleave") hero.cleave(target) else: hero.attack(target) # else, just attack target! # This code is not part of the function. while True: enemy = hero.findNearestEnemy() if enemy: # Note that inside cleaveWhenClose, we refer to the enemy as target. cleaveWhenClose(enemy)