Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

! need help (backwood forest)! [SOLVED]

On level Long-Range Division in Backwood Forest, my Code doesnt seem to Work.
Thats why i need Help.
This is my Code :

var enemy = hero.findNearestEnemy();
var distanceToEnemy = hero.distanceTo(enemy);
hero.say(distanceToEnemy / 3);
hero.say("Fire!");

var distanceToEnemy2 = hero.distanceTo(enemy);
hero.say(distanceToEnemy / 1.5);
hero.say("Fire!");

hero.say("Woo hoo!");
hero.say("Here we go!");
hero.say("Charge!!");

while(true) {   
    hero.attack(enemy);
}

My last Goal is to kill BOTH of the enemys. But my Code only kills one of the Enemy.
Can somebody help please ? :face_with_raised_eyebrow:

I only know python not JS, but in python we’re supposed to have the hero.findNearestEnemy() inside the while true loop. So would it help if you put everything but all the hero.say stuff inside a while true loop?

I think you don’t need this part. This might be takign up time where you are perhaps dying? can you send a link?

1 Like

This was in the level i didnt extra code it in.

Thank u @enPointe77, it worked. :grin:

1 Like

No problem, glad it helped!