# Help in clash of clones

**URL:** <https://discourse.codecombat.com/t/help-in-clash-of-clones/26026>\
**Category:** Level Help\
**Created:** [December 11, 2020, 11:30pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026 "2020-12-11T23:30:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [December 11, 2020, 11:30pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/1 "2020-12-11T23:30:55Z")

</div>

pls help me I have been trying to beat this level for days here is my code:

```python
hero.moveXY(65, 66)
while True:
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    if enemy.type=="soldier" or enemy.type=="knight" or enemy=="scout":
        if enemy:
            if hero.isReady("bash"):
                heor.bash(enemy)
                hero.wait(1);
            else:
                hero.attack(enemy)
    else:
        if hero.health>hero.maxHealth/4:
            hero.shield()
        else:
            hero.moveXY(42, 77)

```

and here is my equipments:

 ![Screen Shot 2020-12-11 at 15.30.22](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/4/2/42e987109e35fda6533163a50d57891969039e82.jpeg)

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [December 11, 2020, 11:33pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/2 "2020-12-11T23:33:45Z")

</div>

okay tell me what type is knight and how many gems do you have you will need better equipment if you are combating head to head

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [December 11, 2020, 11:39pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/3 "2020-12-11T23:39:03Z")

</div>

I have 1.2k gems

must be 20 characters

---

<div class="post-metadata">

**Author:** ![milton.jinich](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/milton.jinich/32/21419_2.png) [@milton.jinich](https://discourse.codecombat.com/u/milton.jinich)\
**Post date:** [December 11, 2020, 11:40pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/4 "2020-12-11T23:40:47Z")

</div>

okay you might want to get a better breast plate if you can afford it

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 11, 2020, 11:41pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/5 "2020-12-11T23:41:30Z")

</div>

findNearest returns a array of enemies you want to attack a single enemy not a array

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 11, 2020, 11:42pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/6 "2020-12-11T23:42:46Z")

</div>

> [@Ryan\_Wong](#):
>
> `hero.wait(1);`

Why do you need this line?

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [December 11, 2020, 11:43pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/7 "2020-12-11T23:43:21Z")

</div>

I having a coding teacher and he said to add that idk why

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 11, 2020, 11:44pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/8 "2020-12-11T23:44:14Z")

</div>

So bassicly after you bash you wait one second? yea no you really don’t need that.

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 11, 2020, 11:44pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/9 "2020-12-11T23:44:52Z")

</div>

> [@Ryan\_Wong](#):
>
> `heor`

You spelled hero wrong right here

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [December 11, 2020, 11:45pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/10 "2020-12-11T23:45:03Z")

</div>

so it should be:

```python
hero.moveXY(65, 66)
while True:
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    if enemy.type=="soldier" or enemy.type=="knight" or enemy=="scout":
        if enemy:
            if hero.isReady("bash"):
                hero.bash(enemy)
            else:
                hero.attack(enemy)
    else:
        if hero.health>hero.maxHealth/4:
            hero.shield()
        else:
            hero.moveXY(42, 77)

```

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 11, 2020, 11:46pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/11 "2020-12-11T23:46:13Z")

</div>

> [@Ryan\_Wong](#):
>
> ```python
> if enemy.type=="soldier" or enemy.type=="knight" or enemy=="scout":
> if enemy:
> if hero.isReady("bash"):
> hero.bash(enemy)
> else:
> hero.attack(enemy)
> 
> ```

well righyt here your saying to only attack if it is in those types or else he won’t do anything.

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [December 11, 2020, 11:49pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/12 "2020-12-11T23:49:57Z")

</div>

Use a weaker sword. Your armor is fine, since you don’t your clone to be too strong.

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [December 11, 2020, 11:51pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/13 "2020-12-11T23:51:20Z")

</div>

![Screen Shot 2020-12-11 at 15.50.43](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/2/0/20a3ad154106fa924cd615d012fa777f36eac6a6.jpeg)  
is that fine?

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 11, 2020, 11:51pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/14 "2020-12-11T23:51:49Z")

</div>

Yes, and if you equip that sword try to use cleave to and chain-lightning

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [December 11, 2020, 11:52pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/15 "2020-12-11T23:52:46Z")

</div>

so same code???

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 11, 2020, 11:53pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/16 "2020-12-11T23:53:11Z")

</div>

Yes and try to improve it.

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [December 11, 2020, 11:53pm UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/17 "2020-12-11T23:53:43Z")

</div>

ok I’ll try thanks for the tip

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [December 12, 2020, 12:00am UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/18 "2020-12-12T00:00:44Z")

</div>

```python
hero.moveXY(64, 70)
while True:
    enemies = hero.findEnemies()
    enemy = hero.findNearest(enemies)
    if enemy.type=="soldier" or enemy.type=="knight" or enemy=="scout":
        if enemy:
            if hero.isReady("bash"):
                hero.attack(enemy)
            else:
                hero.cast("chain-lightning", enemy)
    else:
        if hero.health>hero.maxHealth/4:
            hero.shield()
        else:
            hero.moveXY(42, 77)

```

here is my new code but my clone still kills me

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [December 12, 2020, 12:02am UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/19 "2020-12-12T00:02:49Z")

</div>

> [@Ryan\_Wong](#):
>
> ```python
> else:
> hero.cast("chain-lightning", enemy)
> 
> ```

you need to say if chain lightning is ready

> [@Ryan\_Wong](#):
>
> ```python
> if hero.isReady("bash"):
> hero.attack(enemy)
> 
> ```

replace the attack with bash

> [@Ryan\_Wong](#):
>
> `if enemy.type=="soldier" or enemy.type=="knight" or enemy=="scout":`

you only attack enemies in the types you said

> [@Ryan\_Wong](#):
>
> `enemy = hero.findNearest(enemies)`

this provides a array

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [December 12, 2020, 12:04am UTC](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026/20 "2020-12-12T00:04:49Z")

</div>

In your if statement checking if you are able to bash, instead of attacking, bash your enemy with hero.bash(enemy). Next, check if your hero can cast chain-lightning, if he can then make him use chain lightning. Then add an else statement after chain-lightning and attack in the else statement, so if your cannot bash or cast chain-lightning, then he would attack. Another thing is that you should attack all enemies except if they are types sand-yaks or ogres.

[Next page](https://discourse.codecombat.com/t/help-in-clash-of-clones/26026.md?page=2)
