[SOLVED] The One Wizard Level

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.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

you didn’t check if the hero is ready to do regen. so it will wait until it’s ready to do regen.

1 Like

Oh thank you so much, I think it should help my problem! I’ll delete the post if I resolve it.

How do I mark your answer as Solved? THanks!

Welcome to the forum. Please don’t necroposte if you don’t need help. Also please delete your code because this forum isn’t for copy paste.

I will need to flag it.Sorry.