Clash of Clones, Javascript


#1

This is my code

while (true) {
    var enemy = hero.findNearestEnemy();
    if (enemy && enemy.health > 0) {
        if (hero.health < hero.health / 4) {
            hero.shield(enemy);
        } else if (hero.isReady) {
            hero.bash(enemy);
        }
    }
}

My hero will keep bashing until it died


#2

“else if (hero.isReady)” to do what?


#3
// You'll need good strategy to win this one!
// Your clone will have the same equipment you have!
// But, they're not very skilled at using special powers.
while (true) {
    while (hero.health > hero.health / 4) {
        var enemy = hero.findNearestEnemy();
        if (enemy && enemy.health > 0) {
            if (enemy && hero.isReady("cleave")) {
                hero.cleave(enemy);
            } else if(hero.isReady("bash")){
                hero.bash(enemy);
            }
            else {
                hero.attack(enemy);
            }
        }
    }
}

How do I let my hero run away after it’s health is lower then 100

@SuperSmacker


#4

if hero.health < 100 {
hero.moveXY…

That code wouldn’t let u beat the clone tho.

I suggest buying emperor’s gloves, go behind the enemy’s archers and chain-lightning them. Then let your archers and soldiers do the rest.


#5

I don’t have any gems to buy them, how do I get them @SuperSmacker?


#6

Do more replayable levels, do some previous levels that u didn’t finish, or jump ahead to the mountains (kind of cheating but u can use codecombat.com/play/level/(level name here) to access any level. :stuck_out_tongue: This also allows you to bypass the “Restricted Equipment” check.


#7

Thanks! What are replayable levels?


#8

Dungeon Brawl, Backwoods Brawl, Backwoods Treasure, Sarven Brawl, Sarven Treasure, Sarven Siege, and more. You can play them over and over again. Each time you beat the level, you get more gems and exp but the level gets harder.


#9

Levels like sarven brawls


#10

Any way I can pass the level without buying those gloves?

This is my inventory:


image


#11

About gems see this How to get GEMS, Stuck in Sarven Desert
the while loop you have is some kind of while True loop
If you have 800 health -> 800>200 then 400>100 then… you die

 while (hero.health > hero.health / 4)

replace with

hero.health > hero.maxHealth / 4:

#12

@xython good catch didn’t see that


#13

You can pass every level with this equipment:


/ I never use flags/


#15

My Mac can see it. :wink:


#16

Oh wait nevermind I can see it now. Internet lag b4. Wasn’t loading.


#17

I dont have any pets…


#18

@BrendGroen that’s needed for like Arrowproof Wolf level and stuff. Not needed for clash of clones.

@xython btw sometimes griffin pet or pugicorn is needed instead of the wolf pet