It keeps saying “RAN OUT OF TIME”. I have tried multiple times. I am coding with JavaScript. I
This is my code:
while(true) {
// Check the distance to the nearest enemy.
var nearestEnemy = hero.findNearestEnemy();
var distance = hero.distanceTo(nearestEnemy);
// If it comes closer than 10 meters, cleave it!
if (distance < 10) {
hero.cleave();
}
// Else, attack the "Chest" by name.
else{
hero.attack("Chest");
hero.attack("Chest");
}
}
while(true) {
// Check the distance to the nearest enemy.
var nearestEnemy = hero.findNearestEnemy();
var distance = hero.distanceTo(nearestEnemy);
// If it comes closer than 10 meters, cleave it!
if (nearestEnemy && distance < 10) {
hero.cleave(nearestEnemy);
}
// Else, attack the "Chest" by name.
else {
hero.attack("Chest");
}
}
the duck works like this:
you understand what you need to do in the code.
you explain the duck what you need to do
and you look at the code at the same time.
and then you will see the bug!
while(true) {
// Check the distance to the nearest enemy.
var nearestEnemy = hero.findNearestEnemy();
var distance = hero.distanceTo(nearestEnemy);
// If it comes closer than 10 meters, cleave it!
if (distance < 6) {
hero.cleave();
}
// Else, attack the "Chest" by name.
else{
hero.attack("Chest");
}
}
@Codingisawesome can you post a screenshot of the level and your gear please?
I’ve tried your code with my weakest gear and Tharin and it seems to work fine for me: