I'm stuck with Sarven Brawl in [JavaScript]

Here is my code:

var t = 0;
while(true){
    var enemy = hero.findNearestEnemy();
    if (hero.distanceTo(enemy)<30 || enemy.type != "sand-yak"){
        if (hero.isReady("power-up")) {
            hero.powerUp();
        } else {
            hero.attack(enemy);
        }
    } else {
        hero.say("time waisted in sec: " + t);
        t = t + 1;
    }
}

t is just for fun and not relevant at all.

Hi @5010, welcome to the forum! :tada:
I can’t see any errors as such in your code. Do you just need help with tactics?
If so, I would recommend not attacking the sand yaks. At the moment your hero attacks if the enemy is closer than thirty meters, or if it’s not a sand yak. This means you’ll attack sand yaks which are closer than thirty meters. Why not use and (&&)?
Apart from that, I’m not exactly sure what to recommend without knowing your equipment. Do you have emperor’s gloves? If not, I recommend buying them, they’re great for killing quite a lot of scouts and fangriders.
Danny

Well I didn’t saw anything wrong either, but the hero.distanceTo(enemy)<30 hicks up and won’t complete the program properly.

You should probably also check if the enemy exists (if (enemy && hero.distan…