I have a problem with this map. I’m pretty sure the code is correct but for some reason he uses cleave a bit too soon which doesn’t kill the mobs. This is the code:
def enemyInRange(enemy):
# Return true if the enemy is less than 5 units away.
distance = hero.distanceTo(enemy)
if distance < 5:
return True
def cleaveOrAttack(enemy):
if hero.isReady(‘cleave’):
hero.cleave(enemy)
else:
hero.attack(enemy)
while True:
enemy = hero.findNearestEnemy()
if enemy:
# Check the distance of the enemy by calling enemyInRange.
if enemyInRange(enemy):
cleaveOrAttack(enemy)