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

Help me with Clash of Clones (python)

this is my code:

# 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:
    enemy = hero.findNearestEnemy()
    moveHere = hero.findFlag("green")
    health = hero.health
    maxHealth = hero.maxHealth
    hero.say(hero.health)
    if moveHere:
        hero.moveXY(moveHere.pos.x,moveHere.pos.y)
        hero.pickUpFlag(moveHere)
    else:
        if enemy and enemy.type != "yak":
            while enemy.health > 0:
                hero.attack(enemy)
                if enemy.health > 25:
                    hero.bash(enemy)
        if health < maxHealth /10:
            hero.shield()
    

2 Likes

hello @minecraftLord77 and welcome to the forum! :partying_face:

Maybe you want to check first if you can do abilities like bash using hero.isReady("bash")

what is your equipment? and your strategy?

For this level you might want to have a lower damage sword with a higher damage shield (ie: deflector, dragonplate). Emperor’s gloves and rings that provide casted abilities are a hugehelp as well.

-@Anna

3 Likes

i have engraved obisdion armor and sheild with runesword

use something with less damage than the runesword. are there any rings/gloves with casted abilities you can use?

1 Like

i bought the eltricute ring

then try using something like this:

if hero.canCast("electrocute"):
    # do the ability

in your code to use that ability.

1 Like

so use a sword with weak dmg and a ring with high dmg? what about armor

1 Like

is using longsword a good idea? it has cleave

2 Likes

I prefer the long sword…your enemy will match your equipment, but is not able to use the special abilities.

2 Likes

Yea that’s basically the idea here.

1 Like

its legit impossible. back to my code issue:

# 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:
    enemy = hero.findNearestEnemy()
    moveHere = hero.findFlag("green")
    health = hero.health
    maxHealth = hero.maxHealth
    if moveHere:
        hero.moveXY(moveHere.pos.x,moveHere.pos.y)
        hero.pickUpFlag(moveHere)
    else:
        if enemy and enemy.type != "yak":
            while enemy.health > 0:
                hero.attack(enemy)
                if enemy.health > 25:
                    hero.bash(enemy)
            if hero.canElectrocute(enemy):
                hero.electrocute(enemy)
        enemies = hero.findEnemies()
        if len(enemies) < 4:
            hero.cleave(enemy)
        if health < maxHealth /10:
            hero.shield()
    

What is wrong with it?

Is there any recommendations on armor so i can buy useful stuff?

Put your “electrocute” code inside the second while loop. and put the attack enemy line inside an elif or an else.

elif enemy:
        if enemy and enemy.type != "yak":
            while enemy.health > 0:
                if enemy.health > 25:
                    hero.bash(enemy)
                if hero.canElectrocute(enemy):
                    hero.electrocute(enemy)
                else:
                    hero.attack(enemy)
1 Like

A recommendation of armor is one of the dragonplate armors, although it just makes your opponent harder to kill.

2 Likes

got dragonplate helm, rest is engraved obsidion, alo wut is the hero.isreadyTo thing for building bear traps?

so i got a new code:

# 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:
    enemy = hero.findNearestEnemy()
    moveHere = hero.findFlag("green")
    health = hero.health
    maxHealth = hero.maxHealth
    if moveHere:
        hero.moveXY(moveHere.pos.x,moveHere.pos.y)
        hero.pickUpFlag(moveHere)
    elif enemy and enemy.type != "yak":
        while enemy.health > 0:
            if enemy.health > 25:
                hero.bash(enemy)
            if hero.canElectrocute(enemy):
                hero.electrocute(enemy)
            else:
                hero.attack(enemy)
        enemies = hero.findEnemies()
        if len(enemies) > 4:
            hero.cleave(enemy)
        if health < maxHealth /10:
            hero.shield()

but its still not working. did i put something in the wrong place?

Here try to check if cleave is avalible for use before using it. (PS I will go to bed soon)

Andrei

2 Likes