Agrippa defence

Im stuck on that level… please help, my hero doesnt attack them with normal attack and uses
cleave only once.

while(true) {
    var enemy = hero.findNearestEnemy();
    if(enemy) {
    var distance = hero.distanceTo(enemy);
    if(distance < 5) {
        if (hero.isReady("cleave")){
            hero.cleave(enemy);
        }
    } else {
        hero.attack(enemy);
        
    }
    }
}

That part is working for that: if(distance < 5) {

So your hero attacks when the distance greater than 5. Use indents to organize your code and make it more readable, then you’ll see your code blocks and can reorganize { }.

Fixed it, thank you!