Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Borrowed Sword Please Help

Please help I I’ve been stuck for a while

function findStrongestEnemy() {
    var enemies = hero.findEnemies();
    var highestHealth = null;
    var health = 0;
    for (var i = 0; i < enemies.length; i++) {
        var enemy = enemies[i];
        if (enemy.health >= health) {
            highestHealth = enemy;
            health = enemy.health;
            return highestHealth;
        }
    }
}
while (true) {
    var enemies = hero.findEnemies();
    var friends = hero.findFriends();
    var highestHealth = null;
    var health = 0;
    for (var i = 0; i < enemies.length; i++) {
        var enemy = enemies[i];
    }
    if (enemy.health >= health) {
        highestHealth = enemy;
        health = enemy.health;
        for (var i = 0; i < friends.length; i++) {
            var friend = friends[i];
            if (highestHealth) {
                hero.command(friend, "attack", highestHealth);
            }
        }
    }
    findStrongestEnemy;
    for (var i = 0; i < friends.length; i++) {
        findStrongestEnemy;
    }
}
1 Like

Please give more information about your issue such as a screenshot and any errors that pop up when you run your code

@Luke10
:fox_face::fox_face::fox_face:

There are no errors that pop up. The objective ends as incomplete because all of the archers die.

1 Like

I made a little amount of progress as now only one Yeti lives but the archers die so it’s not complete. I updated the code to my more effective one

1 Like

Why are you using two find strongest enemies? the one in the while true loop is enough.
:lion: :lion: :lion:

Hello guys, this is a friendly reminder that this topic is for assisting @monsterjam23 with code, not talking about why some members put an emoji at the end of their sentences. @SuperSmacker, please bring these kind of discussions in PMs. Thank you.

1 Like