1 - 2 code
3 var enemies = hero.findNearestEnemy(); // findNearestEnemy or findEnemies?
4 - 5 code
6 var maxHealth = 99999; // 99999 or 0 ?
7 for (var i = 0; i < friends.length; i++) {
8 var friend = friends[i];
9 } // loop useless if "}" is put here, put the "}" after your friend has attackes the bestTarget
10 while (enemiesIndex < enemies.length) {
11 var enemy = enemies[enemiesIndex];
12 if (enemy && enemy.health < maxHealth) { // "<" or ">"
13 bestTarget = enemy;
14 maxHealth = enemy.health;
15 enemiesIndex++; // increment the index outside if clause
16 }
17 }
18 if (bestTarget) {
19 hero.command(friend, "attack", bestTarget);
20 }
21 }
Thanks for your corrections, but while the problem persists, it seems to me that my units are not purposefully shooting at Yeti, I will think about it tomorrow