[SOLVED] Help with "Bash them all" [JavaScript]

Hello community!

This is my first post, i hope i did all the formating right :slight_smile:

My code seems to cause an infinity loop but i cant figure out how / where.

I want to bash 4 times and then collect the chests.

What did i do wrong?

KR

// Be careful with these ogres.
// They are special trained fat-free uber ogres and very strong.
// The keyword is fat-free.
// Be careful with these ogres.
// They are special trained fat-free uber ogres and very strong.
// The keyword is fat-free.
var i = 0;
while(i <= 4) {
    var enemy = hero.findNearestEnemy();
    if (enemy && hero.isReady("bash")) {
        hero.bash(enemy);
        i += 1;
    }
}
while(true) {
    var item = hero.findNearestItem();
    hero.moveXY(item.pos.x, item.pos.y);
}

Welcome to the forum @M4r ! :partying_face: This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Don’t forget to read the guidelines if you haven’t yet. Have a great time!

Yes, thanks a lot :slight_smile:

It’s just a small problem, you should only place this outside the if-statement, and i think you are good to go

3 Likes

Awesome, thanks alot! :slight_smile:

1 Like

Anytime :slight_smile:
(20chars)

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.