I think I broke it … what did I do…the site barely loads my code and it loooks like I am cheating the level somehow…
while (true) {
var enemy = hero.findNearestEnemy();
var item = hero.findNearestItem();
if (enemy) {
var distance = hero.distanceTo(enemy);
if (distance < 30) {
if (hero.isReady("bash")) {
hero.bash(enemy);
} else if (hero.isReady("cleave")) {
hero.cleave(enemy);
} else {
hero.attack(enemy);
}
}
} else {
if (!enemy && item && item.type == "potion") {
hero.moveXY(item.pos.x, item.pos.y);
} else if (!enemy && !item) {
hero.moveXY(119, 32);
hero.moveXY(82, 29);
}
}
}