[SOLVED] Need help on Clash Of Clones ASAP

@brooksy125

I tried your advice but now my hero doesn’t attack what so ever!
What’s going on?

I’ll have to see your updated code to see what is happening. Which flag are you using?

Some possible culprits:

  1. There is a loop happening where you don’t want it
  2. An if - elif - else chain may be limiting what code is running
  3. Code linked to the flag movements prevents other code
self.moveXY(66, 57)
back = 0
while True:
    enemys = self.findEnemies()
    index = 0
    closest_soldier = None
    soldier_dist = 999
    closest_archer = None
    archer_dist = 999
    closest = None
    dist = 999
    while(index<len(enemys)):
        distance = self.distanceTo(enemys[index])
        if(enemys[index].health>0 and enemys[index].type != "sand-yak" ):
            if(enemys[index].type == 'archer' and distance<archer_dist):
                archer_dist=distance
                closest_archer = enemys[index]
            if(enemys[index].type == 'soldier' and distance<soldier_dist):
                soldier_dist=distance
                closest_soldier = enemys[index]
            if(distance<dist):
                soldier_dist=dist
                closest = enemys[index]
        index +=1
    if(closest_soldier and soldier_dist<10):
        enemy = closest_soldier
    elif(closest_archer and archer_dist<20):
        enemy = closest_archer
    else:
        enemy = closest
    if(enemy):
        if(self.health<self.maxHealth/2.5 and back==0):
            self.moveXY(40, 85)
            back = 1
        elif(self.health<self.maxHealth/5 and back==1):
            self.moveXY(40, 85)
            back = 2
        elif(self.isReady("jump") and self.distanceTo>15):
            self.jumpTo(enemy.pos)
        elif(self.isReady("bash")):
            self.bash(enemy)
        elif(self.isReady("cleave")):
            self.cleave(enemy)
        else:
            self.attack(enemy)

I have just purchased the boots of leaping so the hero.jump works
Here's my gear...

![52|307x425](upload://u7GXdkjhBgaAtqvGwzR8vhT6Eza.png) 

I have tried the tip where you don't use the strongest armour/weapon and that didn't work for me

Why didn’t my image pop up?

Close out the code with the back ticks ``` to switch back to regular comments.

else:
self.attack(enemy)
# did not add closing back ticks
comments

vs (start and end with back ticks with code in the middle) period is a place holder to prevent the formatting
.```

else:
self.attack(enemy)

.```
comments

I noticed that this line is messing up your soldier_dist variable so you won’t ever attack the soldiers.

            if(distance<dist):
                soldier_dist=dist # assigning wrong value to wrong variable

52
I only have a pet because of a Glitch I did

I see you have a command for cleave, but don’t have the sword that can cleave. You need the Long Sword equipped to cleave.

        elif(self.isReady("cleave")):
            self.cleave(enemy)

Using your gear (except the Long Sword) and the flags tactic, I was able to beat the level with a few minor modifications to your code.

Since I used the flags to move the hero around, I removed your move code and just made him shield if I wasn’t having him move unless the special attacks were available. Keep in mind, you have to click submit to use the flags live. It may take a few times to figure out where to move to survive, but it can be done. Key idea is keep your archers alive and be the decoy while they kill everyone else while you run around and shield.

@brooksy125
Thanks so much :laughing:
I will try that and hope that I can finally move onto the Mountain World!:mountain::mountain:

Is this solved? I presume not from your other post (Must have “missed” it, but…-the code for planting a flag in the first place)
If not please post your current code and I’ll see what I can do.
Thanks
Danny

@RiceRunner So, you don`t have Emperors Gloves or VIkings Helmet?

self.moveXY(66, 57)
back = 0
while True:
    enemys = self.findEnemies()
    index = 0
    closest_soldier = None
    soldier_dist = 999
    closest_archer = None
    archer_dist = 999
    closest = None
    dist = 999
    while(index<len(enemys)):
        distance = self.distanceTo(enemys[index])
        if(enemys[index].health>0 and enemys[index].type != "sand-yak" ):
            if(enemys[index].type == 'archer' and distance<archer_dist):
                archer_dist=distance
                closest_archer = enemys[index]
            if(enemys[index].type == 'soldier' and distance<soldier_dist):
                soldier_dist=distance
                closest_soldier = enemys[index]
            if(distance<dist):
                soldier_dist=dist
                closest = enemys[index]
        index +=1
    if(closest_soldier and soldier_dist<10):
        enemy = closest_soldier
    elif(closest_archer and archer_dist<20):
        enemy = closest_archer
    else:
        enemy = closest
    if(enemy):
        if(self.health<self.maxHealth/2.5 and back==0):
            self.moveXY(40, 85)
            back = 1
        elif(self.health<self.maxHealth/5 and back==1):
            self.moveXY(40, 85)
            back = 2
        elif(self.isReady("jump") and self.distanceTo>15):
            self.jumpTo(enemy.pos)
        elif(self.isReady("bash")):
            self.bash(enemy)
        elif(self.isReady("cleave")):
            self.cleave(enemy)
        else:
            self.attack(enemy)

@Alexbrand No, I don’t have emperors gloves or viking helmet
image

1 Like

Do you really need all thees extra brackets?
Try to remove like
if self.health<self.maxHealth/2.5 and back==0

1 Like

What would I do to change that?

That isn’t my post…

Sorry, I’m meant your post at the bottom of that topic.
About the level.
You don’t need to change much of your code.
I won quite easily (using your equipment) when I changed two things:

  1. The sword. Runesword has high damage, but it’s really slow and archers only have 30 life anyway. I would strongly recommend the short sword for killing lots of little enemies quickly.
  2. The way you came towards the archers. Instead of going to the bottom of the archer line, why not go to the top? The ogres will then die on your soldiers and archers while you kill their archers from above.

You definitely still need to run away at the end using that code, though I did it when Tharin had barely any health.
Danny

The variable you want is dist and assign the distance. This leaves your soldier_distance variable set for the soldiers only.

            if(distance<dist):
                dist = distance

Sorry, I was busy IRL.

So, it takes me a couple of days to beat this level without all this stuff: emperors gloves, viking helmet, invisibility. Interesting, but pretty hard for me)

First, I tried to find health balance. If hero is weak, he can’t survive for the whole quest time. After all, I think the more health you have at the start, the more chances to pass the level you have. With 2850 hp at the start, hero has 160 hp in the end (actaully 12 hp for the first time as i forget to except "sand-yak" from targets).

Then, you need tactics. I’d recommend to stop enemy hero, kill some archers, eleminate shaman, kill the rest of archers, retrieve back.

As for code (Python) I used len(archers) as condition to determine target.
Tricks: “bash”+“bear-trap” to stop enemy hero.

These advices are hints, not the straight instructions. There are many ways to complete the level I think. Hope you’ll find your one.

Good luck!

1 Like

@RiceRunner
One important thing about equipment - I changed copper ring to damage reflection circlet. My solution didn’t work without it.
And yes, as Deadpool198 said, there is no need in such powerful sword.

3 Likes

Frick me, I don’t know how to thank you!
Just that one change and BOOM I completed the level
I :smiley: happily clicked :green_heart: solution and let out a HUGE sigh of relief
Thank you SO MUCH and keep on going…
@Deadly_Rice0769

P.S.
I shouted out “YEEEES” in my computing class and felt imediatly embarassed but, I didn’t care :blush:

P.P.S. Check out my other topics if u can :slight_smile:

2 Likes

Hi)
Well, I’m glad that it helped) Thank you for feedback)

Someimes even one . or any other symbol in code repairs or ruins the whole success) It happend many times to me. So do equipment things.

Wish you good luck) Try, try and don’t ever give up)

1 Like