# Help with Kelvintaph-Defiler

**URL:** <https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269>\
**Category:** Level Help\
**Created:** [July 27, 2020, 11:16pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269 "2020-07-27T23:16:54Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 27, 2020, 11:16pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/1 "2020-07-27T23:16:54Z")

</div>

I need help with the level Kelvintaph Defiler.  
Here is my code:

```python
def commandPaladin():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            hero.command(friend, "move", {'x': 22, 'y': 40})
            hero.command(friend, "move", {'x': 22, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 82})
            hero.command(friend, "move", {'x': 74, 'y': 82})
            hero.command(friend, "move", {'x': 75, 'y': 68})
            enemy = hero.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                hero.command(friend, "shield")
                if friend.canCast("heal") and friend.health < friend.maxHealth:
                    hero.command(friend, "cast", "heal", friend)

def commandHero():
    hero.moveXY(34, 15)
    hero.moveXY(34, 22)

def commandHelpers():
    friends = hero.findFriends()
    for friend in friends:
        paladin = friend.findByType("paladin")
        if friend.type == "archer":
            
            if paladin:
                hero.command(friend, "move", {'x': paladin.pos.x, 'y': paladin.pos.y})

def commandOthers():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "soldiers":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                

commandHero()
while True:
    commandPaladin()
    commandHelpers()
    commandOthers()

```

can you please help me, I do not know what is wrong

---

<div class="post-metadata">

**Author:** ![MidnightWolf39](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/midnightwolf39/32/13309_2.png) [@MidnightWolf39](https://discourse.codecombat.com/u/MidnightWolf39)\
**Post date:** [July 27, 2020, 11:59pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/2 "2020-07-27T23:59:14Z")

</div>

I’m pretty sure that

> [@Speedypickle1](#):
>
> `paladin = friend.findByType("paladin")`

gives you an array. Also,

> [@Speedypickle1](#):
>
> `if friend.type == "soldiers":`

should be

```python
if friend.type == "soldier":

```

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 28, 2020, 10:45pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/3 "2020-07-28T22:45:36Z")

</div>

@minecraftLord77 great! thank you for that let me try.

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 28, 2020, 10:49pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/4 "2020-07-28T22:49:28Z")

</div>

@MidnightWolf39 could you try helping me with that because I did not exactly get that

---

<div class="post-metadata">

**Author:** ![MidnightWolf39](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/midnightwolf39/32/13309_2.png) [@MidnightWolf39](https://discourse.codecombat.com/u/MidnightWolf39)\
**Post date:** [July 29, 2020, 2:06am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/5 "2020-07-29T02:06:29Z")

</div>

@Speedypickle1, you should replace

> [@Speedypickle1](#):
>
> `if friend.type == "soldiers":`

with

```python
if friend.type == "soldier":

```

also,

> [@Speedypickle1](#):
>
> `paladin = friend.findByType("paladin")`

gives you an array like [paladin1.id, paladin2.id].

> [@Speedypickle1](#):
>
> `hero.command(friend, "move", {'x': paladin.pos.x, 'y': paladin.pos.y})`

I’m pretty sure an array doesn’t have a position.

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 29, 2020, 10:46pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/6 "2020-07-29T22:46:59Z")

</div>

I get that thank you @MidnightWolf39 I will try that

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 29, 2020, 10:50pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/7 "2020-07-29T22:50:37Z")

</div>

here is my new code:

```python
def commandPaladin():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            hero.command(friend, "move", {'x': 22, 'y': 40})
            hero.command(friend, "move", {'x': 22, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 82})
            hero.command(friend, "move", {'x': 74, 'y': 82})
            hero.command(friend, "move", {'x': 75, 'y': 68})
            enemy = hero.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                hero.command(friend, "shield")
                if friend.canCast("heal") and friend.health < friend.maxHealth:
                    hero.command(friend, "cast", "heal", friend)

def commandHero():
    hero.moveXY(34, 15)
    hero.moveXY(34, 22)

def commandHelpers():
    friends = hero.findFriends()
    for friend in friends:
        paladins = friend.findByType("paladin")
        paladin = paladins[0]
        if friend.type == "archer":
            
            if paladin:
                hero.command(friend, "move", {'x': paladin.pos.x, 'y': paladin.pos.y})

def commandOthers():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                

commandHero()
while True:
    commandPaladin()
    commandHelpers()
    commandOthers()

```

it gives me this error:

 ![Screen Shot 2020-07-29 at 3.50.01 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/7/7c1694ec99d5ed41f1c12d1cad444b0cc5a4db56.png)

could you help me with that

---

<div class="post-metadata">

**Author:** ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)\
**Post date:** [July 29, 2020, 11:44pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/8 "2020-07-29T23:44:44Z")

</div>

I see a problem your should be the one finding the paladin not your friends.

> [@Speedypickle1](#):
>
> `paladins = friend.findByType("paladin")`

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 31, 2020, 12:19am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/9 "2020-07-31T00:19:08Z")

</div>

@weary Thanks I understand that

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 31, 2020, 12:25am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/10 "2020-07-31T00:25:03Z")

</div>

it just gives me another error here is my new code:

```python
def commandPaladin():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            hero.command(friend, "move", {'x': 22, 'y': 40})
            hero.command(friend, "move", {'x': 22, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 82})
            hero.command(friend, "move", {'x': 74, 'y': 82})
            hero.command(friend, "move", {'x': 75, 'y': 68})
            enemy = hero.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                hero.command(friend, "shield")
                if friend.canCast("heal") and friend.health < friend.maxHealth:
                    hero.command(friend, "cast", "heal", friend)

def commandHero():
    hero.moveXY(34, 15)
    hero.moveXY(34, 22)

def commandHelpers():
    friends = hero.findFriends()
    
    for friend in friends:
        
        if friend.type == "archer":
            paladin = hero.findByType("paladin")
            if paladin:
                hero.command(friend, "move", {'x': paladin.pos.x, 'y': paladin.pos.y})

def commandOthers():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                

commandHero()
while True:
    commandPaladin()
    commandHelpers()
    commandOthers()

```

and here is the error:

 ![Screen Shot 2020-07-30 at 5.24.52 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/7/77b5f82843b9050955e6aa82a0467776f2446a84.png)

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 31, 2020, 12:27am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/11 "2020-07-31T00:27:50Z")

</div>

by the way @MidnightWolf39 and @weary I know this is off-topic but have you heard about the global tournament for codecombat? Here is the link:  
[https://codequest.codecombat.com/?utm\_campaign=codequest&utm\_medium=landingpage&utm\_source=codecombat](https://codequest.codecombat.com/?utm_campaign=codequest&utm_medium=landingpage&utm_source=codecombat)

---

<div class="post-metadata">

**Author:** ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)\
**Post date:** [July 31, 2020, 2:12am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/12 "2020-07-31T02:12:59Z")

</div>

Try to use moveXY instead of ‘move’

> [@Speedypickle1](#):
>
> ```python
> if paladin:
> hero.command(friend, "move", {'x': paladin.pos.x, 'y': paladin.pos.y})
> 
> ```

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [July 31, 2020, 3:31pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/13 "2020-07-31T15:31:54Z")

</div>

@weary Ok! But I am not sure that works

---

<div class="post-metadata">

**Author:** ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)\
**Post date:** [August 1, 2020, 3:25am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/14 "2020-08-01T03:25:39Z")

</div>

Yeah I’m sorry you can’t command soldiers to moveXY, My brains been going through stress lately can’t think properly and can you repost your code?

---

<div class="post-metadata">

**Author:** ![tv337](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tv337/32/12147_2.png) [@tv337](https://discourse.codecombat.com/u/tv337)\
**Post date:** [August 1, 2020, 4:42pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/15 "2020-08-01T16:42:39Z")

</div>

I suggest giving them a x and y to go to. you could send them to the chamber the paladin that the paladin is in. BTW how do they get free mine just sit afraid.

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [August 6, 2020, 1:33am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/16 "2020-08-06T01:33:12Z")

</div>

@tv337 now they just attack the yeti, here is my code:

```python
def commandPaladin():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            hero.command(friend, "move", {'x': 22, 'y': 40})
            hero.command(friend, "move", {'x': 22, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 82})
            hero.command(friend, "move", {'x': 74, 'y': 82})
            hero.command(friend, "move", {'x': 75, 'y': 68})
            enemy = hero.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                hero.command(friend, "shield")
                if friend.canCast("heal") and friend.health < friend.maxHealth:
                    hero.command(friend, "cast", "heal", friend)

def commandHero():
    hero.moveXY(34, 15)
    hero.moveXY(34, 22)

def commandHelpers():
    friends = hero.findFriends()
    
    for friend in friends:
        
        if friend.type == "archer":
            
            
            hero.command(friend, "move", {'x':75, 'y': 68})

def commandOthers():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                

commandHero()
while True:
    commandPaladin()
    commandHelpers()
    commandOthers()

```

---

<div class="post-metadata">

**Author:** ![MidnightWolf39](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/midnightwolf39/32/13309_2.png) [@MidnightWolf39](https://discourse.codecombat.com/u/MidnightWolf39)\
**Post date:** [August 6, 2020, 3:40am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/17 "2020-08-06T03:40:18Z")

</div>

You haven’t command your archers to attack, unless you want them to be idle.

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [August 7, 2020, 1:12am UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/18 "2020-08-07T01:12:53Z")

</div>

@MidnightWolf39 I know, I was just trying to test if they move.

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [August 9, 2020, 9:48pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/19 "2020-08-09T21:48:11Z")

</div>

The problem is that when the paladin attacks the yeti the archers will get blocked trying to move

---

<div class="post-metadata">

**Author:** ![Speedypickle1](https://avatars.discourse-cdn.com/v4/letter/s/9de0a6/32.png) [@Speedypickle1](https://discourse.codecombat.com/u/Speedypickle1)\
**Post date:** [August 9, 2020, 9:57pm UTC](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269/20 "2020-08-09T21:57:13Z")

</div>

here is my new code I do not understand what is wrong:

```python
def commandPaladin():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            hero.command(friend, "move", {'x': 22, 'y': 40})
            hero.command(friend, "move", {'x': 22, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 82})
            hero.command(friend, "move", {'x': 74, 'y': 82})
            hero.command(friend, "move", {'x': 85, 'y': 74})
            enemy = friend.findNearestEnemy()
            if enemy and friend.pos.x == 85 and friend.pos.y == 74:
                hero.command(friend, "shield")
                
                if friend.canCast("heal") and friend.health < friend.maxHealth:
                    hero.command(friend, "cast", "heal", friend)
                    

def commandHero():
    hero.moveXY(34, 15)
    hero.moveXY(34, 22)

def commandHelpers():
    friends = hero.findFriends()
    
    for friend in friends:
        
        if friend.type == "archer":
            hero.command(friend, "move", {'x': 22, 'y': 40})
            hero.command(friend, "move", {'x': 22, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 66})
            hero.command(friend, "move", {'x': 42, 'y': 82})
            hero.command(friend, "move", {'x': 74, 'y': 82})
            hero.command(friend, "move", {'x': 75, 'y': 68})
            
            

def commandOthers():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
                

commandHero()
while True:
    commandPaladin()
    commandHelpers()
    commandOthers()

```

[Next page](https://discourse.codecombat.com/t/help-with-kelvintaph-defiler/23269.md?page=2)
