Antipodes Help (Cloudrip Mountain)

Hello!
I am currently trying to complete the Antipodes level in Cloudrip Mountain. Here is my code:

// The warlock used the "clone" spell and created evil antipodes of our archers.
// But even that evil spell has weakness.
// If your archer touches his antipode, then it will disappear.
// If an archer touches the wrong clone or attacks one of them, then the clones start to fight.
// We can find antipodes by their names - they are each other''s reverse.

// This function check two units whether they are antipodes or not.
function areAntipodes(unit1, unit2) {
    var reversed1 = unit1.id.split("").reverse().join("");
    return reversed1 === unit2.id;
}

var friends = hero.findFriends();
var enemies = hero.findEnemies();

// Find antipodes for each of your archers.
// Iterate all friends.
for (var i = 0; i < friends.length; i++) {
    // For each of friends iterate all enemies.
    for (var j = 0; j < enemies.length; j++) {
        // Check if the pair of the current friend and the enemy are antipodes.
        if (areAntipodes(friends[i], enemies[j])) {
            // If they are antipodes, command the friend move to the enemy.
            hero.command(friends[i], "move", enemies[j].pos);
        }
    }
}

// When all clones disappears, attack the warlock.
// I have Ritic, by the way
var e = hero.findNearestEnemy();
while (e.health > 0) {
    var d = hero.distanceTo(e);
    var c = "chain-lightning";
    if (d < 30 && hero.canCast(c)) {
        hero.cast(c, e);
    }
    if (d <= 46) {
        hero.attack(e);
    }
    if (d <= 34) {
        hero.throw(e);
    }
}

To command the archers, the comment states:
// If they are antipodes, command the friend move to the enemy.
My archers can identify their antipode correctly, but by the time they start moving, they die because the enemy archers are so powerful.
I’ve tried commanding them to attack their antipode as well, but they die again.
I need them to survive so I can attack the warlock :joy:

Thank you in advance for the help! :heart:

Wait so the archers destroy their antipodes, and after that attack the warlock. So put your attack code in this:

if hero.time <= 4:
1 Like

You destroy them by commanding the archers to move to their antipodes btw.

Ohhh, thank you!
I was commanding my hero to start attacking before the archers had barely moved. The program then started attacking me.
I put a hero.wait(4) before my attack code, and that did the trick!
Thanks again! :grin:

No problem! Glad I could help!

1 Like