Reaping Fire: Pender Walking Into Mines

Hey guys. Can anyone help me with this level? Pender keeps walking into mines to attack a fangrider.

function chooseStrategy() {
    let enemies = hero.findEnemies();
    // If you can summon a griffin-rider, return "griffin-rider"
    if (hero.gold >= hero.costOf("griffin-rider")) {
        hero.summon("griffin-rider");
    }
    // If there is a fangrider on your side of the mines, return "fight-back"
    let enemy = hero.findNearestEnemy();
    let item = hero.findNearestItem();
    if (enemy && enemy.type == "fangrider" && hero.distanceTo(enemy) >= 10) {
        hero.attack(enemy);
    } else {
        // Otherwise, return "collect-coins"
        if (item) {
            hero.move(item.pos);
        }
    }
}
function commandAttack() {
    // Command your griffin riders to attack ogres.
    let friends = hero.findFriends();
    for (let friend of friends) {
        let enemy = friend.findNearestEnemy();
        if (enemy) {
            hero.command(friend, "attack", enemy);
        }
    }
}
function pickUpCoin() {
    // Collect coins
    let item = hero.findNearestItem();
    if (item) {
        hero.move(item.pos);
    }
}
function heroAttack() {
    // Your hero should attack fang riders that cross the minefield
    let enemy = hero.findNearestEnemy();
    if (enemy && enemy.type == "fangrider" && hero.distanceTo(enemy) >= 10) {
        hero.attack(enemy);
    }
}
while (true) {
    commandAttack();
    let strategy = chooseStrategy();
    // Call a function, depending on what the current strategy is.
    heroAttack();
    pickUpCoin();
}

hero.distanceTo(enemy) >= 10 Your sign is reversed; it should be <= (less than or equal to) instead of >= (greater than equal to). You can probably also increase the distance because Pender is a wizard.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.