[Solved] Cloudrip Mountain Pesky YAKS

Why hero don’t atack enemy?

// That's a lot of Yaks!
// If you are to survive, you'll need to filter out Yaks...

function removeByType(enemies, excludedType) {
    var tempArray = [];
    // Go through each enemy and check to see if its type is excludedType.
    for(var i = 0; i < enemies.length; i++) {
        // If it isn't, 'push' it onto the array.
        let enemy = enemies[i];
        if (enemy != excludedType) {
    return tempArray;

while(true) {
    // Find the enemies!
    var enemies = hero.findEnemies();
    // Remove those pesky Yaks.
    enemies = removeByType(enemies, "sand-yak");
    var enemy = hero.findNearest(enemies);
    // Now... 'remove' those enemies.
    if(enemy) {

Have another look at this line. What things do you want to push into the tempArray?


i want to push enemies. But if i push enemies hero attack sand-yak to

Look at the line above that one. You’ve just found something that isn’t a sand-yak. Now you want to put it into tempArray.

i found that the rest of enemies isn’t sand-yak. i putted them into array . and this is no work))) I understand that i have some logical problem here

 if (enemies[i] !== excludedType) {

You’ve corrected the problem with that line, but I’ve just spotted another one! It should be:

if (enemies[i].type !== excludedType)
1 Like

thank you very much!!

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