Clash of Clones Help!


#65

Hey everyone, I need help with my code in ClashOfClones level. My hero dies too fast. I have tried literally everything: I got the best sword, best shield with bash, then just shield and no sword, tried to attack the healthies enemy first, then just my Clone first, then just archers etc etc… I feel like I need some sort of boost or any hint. Here is my current code, which only deals w archers because my hero dies too fast anyway so why bother with other enemies:

function bashAttack(enemyWho) {
    if (enemyWho) {
        while (enemyWho.health > 0) {
            if (hero.isReady("bash")) {
                hero.bash(enemyWho);
            } else {
                hero.attack(enemyWho);
            }
        }
    }
}
var archers = hero.findByType("archer", hero.findEnemies());
var archerIndex = 0;
while (archerIndex < archers.length) {
    var archer = archers[archerIndex];
    bashAttack(archer);
    archerIndex++;
}

#66

Use a weak sword with a good shield. Also use chain lightning if you have the emperor’s gloves.


#67

Chaboi, that’s what i’m using right now, the basic sword and the best shield in the game. I don’t have gloves though and no money to buy it, is there a way to pass the level without them?


#68

Have you tried the level with flags? It makes it much easier to beat than a standard attack code.


#69

Believe it or not, I did. My hero literally ignored it. I even copy-pasted just that code for flags from the “manual”, just couple lines of code, then I’m trying to place the flags - no reaction…


#70

Your code should be something like

while (true){
    var flag=hero.findFlag()
    var enemy=hero.findNearestEnemy()
    if flag{
       hero.pickUp(flag)
    }
    else if enemy{
        //Attack code
    }
}
   

#71

Chaboi, thanks a ton here, I didn’t put the flag code in the while loop. I’ll try now with flags, as I understand yaks play a big role here.


#72

Key is to cast invis and go behind enemy archers and kill all of them


#73

Yeah it depends, if you have both chain lightning and invis, you can invis back and chain lightning the archers. :man_shrugging:


#74

Hei Chaboi, thanks so much, I passed. Actually, the flags and yaks were helpful.