[SOLVED] Clash of Clones

i have 1040 gems and my level is 27.

so im asking what level you need to be to get it unlocked.

I do not remember. ( I do not have it either ) But I know that on level 20 you can purchase this shield.

i have the shield. 20 characters

whenever i move to the archers a fix your code appears on the screen and says " Line 5 argumenterror: attack’s argument target should have type object, but got null. Target is null. Is there always atarget to attack? (Use if)"

what is the sword? 20 characters

is EpicCoder999 here by any chance?

because my code has a problem…
I set it NOT to attack yaks 3 times. 3! and he still attacks them!

here is my code:

def KillArchers(enemies):
    for enemy in enemies:
        if enemy.type is 'archer' and enemy.type != "yak":
            while enemy.health > 0:
                hero.attack(enemy)
    pass

    
def KillAllOthers(enemies):
    for enemy in enemies:
        if enemy and enemy.type != "yak":
            if enemy.health > 0 and enemy.type != "yak":
                hero.attack(enemy)
    

def KillThemAll():
    while True:
        enemies = hero.findEnemies()
        KillArchers(enemies)
        KillAllOthers(enemies)

while True:
    KillThemAll()

Please help if you can. Thank you.

Nvm. i just deleted everything but the killarchers and set the hero to move to a flag and wait there so he won’t get hurt. Sooooo, yeah.

do you live after doing the attacking of yaks? @Joel_Greeley

and if you want to see the code i will give some of it ok?

because, I BEAT THE LVL FINALLY, thanks for the help all of u! :heart:

1 Like

yes whooo hooo, yay, u beat it, congragualions

Hello, I have been stuck on this for ages and out of gems to buys anything new - I have to pass this to get gems. Any help here?:

while True:
    hero.moveXY(82, 79)
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.attack(enemy)
    enemyIndex = 0
    enemies = self.findEnemies()
    hero.moveXY(82, 78)
    enemy = hero.findNearestEnemy()
    if enemy < 5:
        hero.attack(enemy)
    while enemyIndex < len(enemies) and self.health > self.maxHealth / 4:
        enemy = enemies[enemyIndex]
        enemyIndex += 1
        while enemy.health > 0:
            if hero.isReady("cleave"):
                    self.cleave(enemy)
            else:
                    self.attack(enemy)
    if self.health <= self.maxHealth / 4:
        enemy = enemies[enemyIndex]
        distance = self.distanceTo(enemy)
        enemyIndex += 1
        if distance > 2:
            if self.isReady("cleave"):
                self.cleave(enemy)
            else:
                self.attack(enemy)

I’m really stuck plz help

Hi @KingOfTheDead9999, welcome to the forum! :tada:
It looks like you’ve used hero.moveXY() statements inside a while True loop, which means they will be repeated constantly and your hero will be unlikely to do anything except move.
Please could you format your code by putting three ``` (backticks, not quotes) on a new line at the beginning and end of your code. Make sure you copy the code in from Codecombat, otherwise it won’t have the indentation (the spaces at the beginning of the line).
Okay: I’ve actually done it this time because I wanted to see the indentation, but next time you post your code, it would be great if you could format it like I have.
Thanks
Danny

1 Like

Hello there, I’ve been really stuck on this for a very long time - I have little gems (32) because I need to pass this to get more - any help here plz?:

while True:
hero.moveXY(82, 79)
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
enemyIndex = 0
enemies = self.findEnemies()
hero.moveXY(82, 78)
enemy = hero.findNearestEnemy()
if enemy < 5:
hero.attack(enemy)
while enemyIndex < len(enemies) and self.health > self.maxHealth / 4:
enemy = enemies[enemyIndex]
enemyIndex += 1
while enemy.health > 0:
if hero.isReady(“cleave”):
self.cleave(enemy)
else:
self.attack(enemy)
if self.health <= self.maxHealth / 4:
enemy = enemies[enemyIndex]
distance = self.distanceTo(enemy)
enemyIndex += 1
if distance > 2:
if self.isReady(“cleave”):
self.cleave(enemy)
else:
self.attack(enemy)

1 Like

Sorry I’m not too sure how to format… :frowning_face:

2 Likes

Also here is my gear:

1 Like

I moved these posts from this topic:

because it’s better to only use one topic to get help. If you have more than one it’s very confusing for everyone else.
Instead of using moveXY() in this level, why not try using flags?

2 Likes

You press the </> Button @KingOfTheDead9999. Also welcome it is great to see you here! :partying_face:

1 Like