[Help] Alchemic Power

I am stuck on this level. When Omarn says “Fetch!”, it is AFTER I die. When she does say “Fetch!” BEFORE I die however, the pet carries the potion to my hero, but never delivers it and turns around instead.

Code:

// Wait for alchemist’s commands to fetch potions.

// The event handler for the pet’s event “hear”.
function onHear(event) {
// Find the nearest potion.
var potion = pet.findNearestByType(“potion”);
// If the event’s message is “Fetch”
if (event.message == “Fetch”) {
pet.fetch(potion);
}else{
pet.moveXY(54, 34);
}
// Have the pet fetch the potion.

// Else (for any other messages):

    // Return the pet to the red mark.

}

pet.on(“hear”, onHear);

// You don’t have to change the code below.
while(true) {
var enemy = hero.findNearest(hero.findEnemies());
if (enemy) {
hero.attack(enemy);
}
else {
hero.moveXY(40, 34);
}
}

Please format your code according to the FAQ.

What gear does your hero have? Maybe that’s why your hero dies before Omarn says “Fetch”.

1 Like

I have the best armor in the game. I have the Deflector, Dragon Head, and Dragon Chestplate

}else{ ?

[20 characters minimum]

Could you please post your code so I could compare mine with yours and see if yours works? I know it may sound a little greedy but I can’t think of any thing else I could do.

This is interesting. I don’t see anything wrong. I have similar code and it runs perfectly.

Maybe bug in the level? Or try clearing cache? Don’t know if it will help, but just maybe…

Hi!

I had the same problem. But when I reset the level, it works perfectly.

That’s what I did! Thanks.

2 Likes

I had to add my own check for hero health to make sure he didn’t get too low before receiving help

1 Like