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

[SOLVED] Zoo keeper help please (level help) Java Script

I am struggling with this level a lot can anyone help me?

// Protect the cage.
// Put a soldier at each X.
var points = [];
points[0] = {x: 33, y: 42};
points[1] = {x: 47, y: 42};
points[2] = {x: 33, y: 26};
points[3] = {x: 47, y: 26};

// 1. Collect 80 gold.
while(hero.gold < 80) {
     var coin = hero.findNearestItem();
    if (coin.type == "coin")
hero.move(coin.pos);
    
}
// 2. Build 4 soldiers.
for(var i=0; i < 4; i++) {
    hero.summon("soldier");
}

// 3. Send your soldiers into position.
while(true) {
    var friends = hero.findFriends();
    for(var j=0; j < friends.length; j++) {
        var point = points[j];
        var friend = friends[j];
        var enemy = friend.findNearestEnemy();
        if(enemy && enemy.team == "ogres" && friend.distanceTo(enemy) < 5) {
            // Command friend to attack.
            hero.command(friend, "attack", enemy);
        } else {
            // Command friend to move to point.
            hero.command(friend, "move", point);
        }
    }
}

Oh, I finished the level, I think that was a bug

1 Like

or maybe it was a bad seed but congrajulations you completed the level

please delete your code if it is a working one

I had to submit, the output was different.

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