Hi everyone,
I spent the past week trying to beat the One Wizard level in the Forest in Javascript, but can’t get the higher bonuses.
This is my code:
while (true) {
var enemy = hero.findNearestEnemy();
if (enemy) {
var distance = hero.distanceTo(enemy);
if (enemy.type == "munchkin" && hero.canCast("lightning-bolt")) {
hero.cast("lightning-bolt", enemy);
hero.cast("regen", hero);
} else if (enemy.type == "scout" && enemy.id != "Ralthora" && distance < 30 && hero.canCast("chain-lightning")) {
hero.say('screw you all');
hero.cast("chain-lightning", enemy);
} else if (distance <= 30) {
hero.moveXY(1, 46);
hero.attack(enemy);
hero.cast("regen", hero);
}
}
}
My problem is that when the first group of scouts appears and is coming towards me, my hero is still in the process of using hero.cast(“regen”, hero), which I don’t know how to break. So my hero literally waits until he is surrounded to say the phrase and attack but it’s too late.
I don’t want to use any methods or solutions that are introduced later, only the things mentioned in ealier levels.
Please help, Thank you