Im on CS3 on the Forest shadow level, I have tried doing all the ways I could but my code just does not do what it needs to.
while (true) {
// Find the nearest enemy.
var enemy = hero.findNearestEnemy();
// Attack it only if its type is "thrower" or "munchkin".
if (enemy.type == "thrower" || "munchkin") {
hero.attack(enemy);
// Find the nearest item.
var item = hero.findNearestItem();
if (item) {
// Collect it only if its type is "gem" or "coin".
if (item.type == "gem" || "coin") {
hero.moveXY(item.pos.x, item.pos.y);
}
}
}
}
Despite the enemy.type it keeps attacking the ogres and brawlers, without killing munchkins or throwers first. Javascript language, no errors shown in code