Hey guys so something is not right…
not getting 2 fetch item, then getting blowed into pieces…
Any hints?
// 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 ("Fetch" && potion) {
// Have the pet fetch the potion.
pet.fetch(potion);
pet.moveXY(54, 34);
}
// Else (for any other messages):
else {
// Return the pet to the red mark.
pet.moveXY(54, 34);
}
}
// You don't have to change the code below.
while(true) {
pet.on("hear", onHear);
var enemies = hero.findEnemies();
var enemy = enemies[enemyIndex];
var enemyIndex = 0;
while(enemyIndex < enemies.length) {
if (enemy && enemy.health > 0) {
if (hero.isReady("cleave") && hero.distanceTo(enemy) < 5) {
hero.cleave(enemy);
}
else if (hero.isReady("bash")) {
hero.bash(enemy);
}
else if (hero.isReady("warcry")) {
hero.warcry();
}
else if (hero.isReady("throw") && hero.distanceTo(enemy) < hero.throwRange) {
hero.throw(enemy);
}
else {
hero.shield();
}
}
else if (!enemy) {
hero.moveXY(40, 34);
}
enemyIndex++;
}
}