Https://codecombat.com/play/level/army-training-2?

been trying to beat this level. i satisfy the mission yet can not pass

game.spawnXY("soldier", 35, 20);
game.spawnXY("soldier", 45, 20);
game.spawnXY("soldier", 15, 20);
game.spawnXY("soldier", 25, 20);
game.spawnXY("archer", 35, 10);
game.spawnXY("archer", 45, 10);

function fightEnemies(event) {
    while(true) {
        var friendUnit = event.target;
        var enemy = friendUnit.findNearestEnemy();
        friendUnit.attack(enemy)
    }
}

game.setActionFor("soldier", "spawn", fightEnemies);
game.setActionFor("archer", "spawn", fightEnemies);

this is the code im using to run this mission.

At the top of your code, you’re spawning 4 soldiers. The game only asks for 2. I tested this and if you spawn more than 2 soldiers, the level ‘Runs out of time’. Try deleting 2 of the soldiers’ game.spawnXY lines, that should fix the problem.

thank you. i relly have to read the conditions dont i.

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