# Kelvintaph Burgler helpp\[SOLVED\]

**URL:** <https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045>\
**Category:** Level Help\
**Created:** [October 24, 2021, 10:08am UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045 "2021-10-24T10:08:40Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 10:08am UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/1 "2021-10-24T10:08:40Z")

</div>

hero not moving at flag pos bug???

```python

def lowHp():
    friends = hero.findFriends()
    for friend in friends:
        if friend.health <= friend.maxHealth / 2:
            pass

def comPal(paladin):
    lH = lowHp()
    friend = hero.findFriends()
    enemy = paladin.findNearestEnemy()
    if friend.health <= lH:
        if paladin.canCast("heal", friend):
            hero.command(paladin, "cast", "heal", friend)
        elif enemy.health > 0:
            hero.command(paladin, "attack", enemy)

def comGriff():
    if hero.gold >= hero.costOf("griffin-rider"):
        # lesgoo command giffin-rider
        hero.summon("griffin-rider")
        friends = hero.findFriends()
        enemy = hero.findNearestEnemy()
    for friend in friends:
        if enemy.health > 0:
            hero.command(friend, "attack", enemy)

while True:
    flag = hero.findFlag()
    friends = hero.findFriends()
    enemy = hero.findNearestEnemy()
    if flag:
        hero.move(flag.pos)
        
    for friend in friends:
        if friend.type == "griffin-rider":
            if enemy.type == "robot-walker":
                comGriff()
        elif friend.type == "paladin":
            comPal()
        elif friend.type == "archer" and friend.type == "soldier":
            if enemy.type == "chieftain":
                hero.command(friend, "attack", enemy)
        
    hero.command(friend, "move", {'x': 32, 'y': 57})
    hero.command(friend, "move", {'x': 26, 'y': 57})
    hero.command(friend, "move", {'x': 30, 'y': 52})
    hero.command(friend, "move", {'x': 54, 'y': 59})
    hero.command(friend, "move", {'x': 76, 'y': 57})
    hero.command(friend, "move", {'x': 78, 'y': 40})
    if enemy.type == "robot-walker" and enemy.health == 0:
        hero.moveXY(76, 14)
    
    
        

```

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [October 24, 2021, 12:29pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/2 "2021-10-24T12:29:36Z")

</div>

> [@Haris](#):
>
> `flag = hero.findFlag()`

I think you should specify the flag’s colour. I think, not sure tho

---

<div class="post-metadata">

**Author:** ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)\
**Post date:** [October 24, 2021, 12:36pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/3 "2021-10-24T12:36:08Z")

</div>

Yes, you’re right.It should be

```python
hero.findFlag('[flag color]')

```

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 12:48pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/4 "2021-10-24T12:48:51Z")

</div>

ok (20charsaqwadwf) 20(chars

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 12:52pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/5 "2021-10-24T12:52:08Z")

</div>

and one more thing. i get error `Try use "hero.findNearestEnemy()"`

```python
def comPal(paladin):
    lH = lowHp()
    friend = hero.findFriends()
    enemy = paladin.findNearestEnemy()
    if friend.health <= lH:
        if paladin.canCast("heal", friend):
            hero.command(paladin, "cast", "heal", friend)
        elif enemy.health > 0:
            hero.command(paladin, "attack", enemy)

```

@Aya @Anonym

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [October 24, 2021, 12:54pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/6 "2021-10-24T12:54:28Z")

</div>

It is possible `paladin` doesn’t have property `findNearestEnemy()`

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [October 24, 2021, 12:56pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/7 "2021-10-24T12:56:29Z")

</div>

Also, there is another problem,

> [@Haris](#):
>
> `friend = hero.findFriends()`

this returns a list, so what you should do is either make a `for-loop` or get a certain index like this `friend = hero.findFriends()[number]`

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 12:58pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/8 "2021-10-24T12:58:27Z")

</div>

like this eh? `friend = hero.findFriends()[1]`??

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [October 24, 2021, 12:59pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/9 "2021-10-24T12:59:34Z")

</div>

Hint: from which number do indexes start in Python?

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 1:01pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/10 "2021-10-24T13:01:42Z")

</div>

i don’t know what do you mean

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [October 24, 2021, 1:02pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/11 "2021-10-24T13:02:32Z")

</div>

Do they start from 1 or a different number 0

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 1:03pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/12 "2021-10-24T13:03:46Z")

</div>

0 (200000 charsssssss)

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 1:05pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/13 "2021-10-24T13:05:05Z")

</div>

bruh still get error (20chars)

---

<div class="post-metadata">

**Author:** ![Aya](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/aya/32/42680_2.png) [@Aya](https://discourse.codecombat.com/u/Aya)\
**Post date:** [October 24, 2021, 1:05pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/14 "2021-10-24T13:05:37Z")

</div>

Can you please post your new code? And the error

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 1:06pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/15 "2021-10-24T13:06:28Z")

</div>

```python
def comPal(paladin):
    lH = lowHp()
    friend = hero.findFriends()[0]
    enemy = paladin.findNearestEnemy()
    if friend.health <= lH:
        if paladin.canCast("heal", friend):
            hero.command(paladin, "cast", "heal", friend)
        elif enemy.health > 0:
            hero.command(paladin, "attack", enemy)

```

---

<div class="post-metadata">

**Author:** ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)\
**Post date:** [October 24, 2021, 1:06pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/16 "2021-10-24T13:06:57Z")

</div>

Sorry, I was offline.  
`friend = hero.findFriends()[number]` do like this

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 1:06pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/17 "2021-10-24T13:06:58Z")

</div>

and i get the same errorr

---

<div class="post-metadata">

**Author:** ![Anonym](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/anonym/32/47546_2.png) [@Anonym](https://discourse.codecombat.com/u/Anonym)\
**Post date:** [October 24, 2021, 1:07pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/18 "2021-10-24T13:07:27Z")

</div>

ah, i see.Ok, have you tried for loop?

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 1:07pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/19 "2021-10-24T13:07:53Z")

</div>

oh ok i try (20chars)

---

<div class="post-metadata">

**Author:** ![Haris](https://avatars.discourse-cdn.com/v4/letter/h/ccd318/32.png) [@Haris](https://discourse.codecombat.com/u/Haris)\
**Post date:** [October 24, 2021, 1:09pm UTC](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045/20 "2021-10-24T13:09:21Z")

</div>

still.

```python
def comPal(paladin):
    lH = lowHp()
    friends = hero.findFriends()[0]
    enemy = paladin.findNearestEnemy()
    for friend in friends:
        if friend.health <= lH:
            if paladin.canCast("heal", friend):
                hero.command(paladin, "cast", "heal", friend)
            elif enemy.health > 0:
                hero.command(paladin, "attack", enemy)

```

[Next page](https://discourse.codecombat.com/t/kelvintaph-burgler-helpp-solved/31045.md?page=2)
