Kelvintaph Burgler need help

My code so far:

hero.findByNotType = function (type) {
    var enemies = [];
    for (let enemy of hero.findEnemies()) if (type.indexOf(enemy.type) == -1) enemies.push(enemy);
    return enemies;
};
hero.buildXY("fence", 20, 15);
while (true) {
    if (hero.isPathClear({x: 63, y: 14}, {x: 78, y: 14})) break;
    for (let friend of hero.findFriends()) {
        if (friend.type == "paladin") {
            if (friend.pos.x < 50) hero.command(friend, "move", {x: 50, y: 50});
            else hero.command(friend, "shield");
            continue;
        }
        else hero.command(friend, "attack", friend.findNearest(hero.findByNotType(["robot-walker", "ice-yak", "cow"])));
    }
}

But I can’t seem to get the archers or soldiers to stop attacking the ice yaks and cows and then dying. :face_with_monocle:

I can take a look at your code. Can you please send me the link? Thanks!

I put my code there…

I mean send the link so I could know how to fix the bug

I don’t know how to send a link

The link to the level is:

When I test your code it seems to me that the archers are not intentionally attacking the ice yak. They are attempting to attack the Ogre Chieftain from a distance despite the fact that there is a wall preventing the arrows from reaching their target. These arrows ricochet off the walls and attack the cows and provoke the ice yak causing the ice yak to kill the archers. You need to lure the ogre chieftain from its position to the ice yak. Then the Chieftain will provoke the ice yak, and the ice yak will defeat the Chieftain for you. Then you need to proceed and kill the witch and defeat the robot walkers.

Thanks, I’ll try that :slight_smile:

Worked with flags. :slight_smile:

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