# Please Help me on Kelvintaph Crusader

**URL:** <https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199>\
**Category:** Level Help\
**Created:** [April 25, 2020, 8:11pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199 "2020-04-25T20:11:50Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 25, 2020, 8:11pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/1 "2020-04-25T20:11:50Z")

</div>

```python
# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!

enemy = hero.findNearestEnemy()
hero.cast("chain-lightning", enemy)
# def lowestHealthSoldier():
# lowestSoldier = False
# lowestHealth = 9999
# soldiers = hero.findByType("soldiers")
# for soldier in soldiers:
# if soldier.health < lowestHealth:
# lowestHealth = soldier.health
# lowestSoldier = soldier
# return lowestSoldier

def commandPaladin(paladin):
    witch = paladin.findNearest(hero.findByType('witch'))
    enemy = paladin.findNearest(hero.findEnemies())
    
    if witch and witch.health > 0:
        hero.command(paladin, "attack", witch)
    elif enemy:
        hero.command(paladin, "attack", enemy)
    if paladin.canCast('heal'):
        hero.command(paladin, "cast", 'heal', paladin)
    

def commandSoldier(soldier):
    enemy = soldier.findNearestEnemy()
    if enemy:
        hero.command(soldier, "attack", enemy)

def commandArcher(archer):
    enemy = archer.findNearestEnemy()
    if enemy:
        hero.command(archer, "attack", enemy)

def commandTroops():
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == 'soldier':
            commandSoldier(friend)
        if friend.type == 'archer':
            commandArcher(friend)
        if friend.type == 'paladin':
            commandPaladin(friend)

def commandHero():
    catapult = hero.findNearest(hero.findByType("catapult"))
    enemy = hero.findNearestEnemy()
    
    if catapult:
        hero.attack(catapult)
    elif enemy:
        hero.attack(enemy)

while True:
    commandTroops()
    commandHero()

```

What is wrong with my code? My friends/units are stuck once in a while. Why did that happen? Can someone tell me please. Thank!

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 25, 2020, 8:14pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/2 "2020-04-25T20:14:09Z")

</div>

![Screen Shot 2020-04-25 at 1.12.38 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/8/831434256b712407f3a088148963bebda74b4ca2.jpeg) here is what I wear

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 25, 2020, 8:15pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/3 "2020-04-25T20:15:19Z")

</div>

and I am using okar stomp foot

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [April 25, 2020, 8:32pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/4 "2020-04-25T20:32:04Z")

</div>

You are missing the exit strategy…you need to get both your hero and friends to the Xs on the east side of the map.

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 26, 2020, 6:59pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/5 "2020-04-26T18:59:55Z")

</div>

I know that, but all of my friends died before the ogres are killed

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [April 26, 2020, 7:01pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/6 "2020-04-26T19:01:45Z")

</div>

Well, you can take out the south guys with the catapults…your friends can outrun the others; only the witch needs to be killed, actually.

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 26, 2020, 7:02pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/7 "2020-04-26T19:02:13Z")

</div>

I know I can just add

```python
noEnemy = not (hero.findNearestEnemy)
if noEnemy:
    #move to the exit

```

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 26, 2020, 7:02pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/8 "2020-04-26T19:02:45Z")

</div>

oh thanks  
(20 chars)

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 26, 2020, 7:04pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/9 "2020-04-26T19:04:10Z")

</div>

But then I can’t get the bonus

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [April 26, 2020, 7:07pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/10 "2020-04-26T19:07:12Z")

</div>

True, if not all friends escape. Think paladin (heal) and archer (range), others run like heck once the witch is down…it is possible.  
 ![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/add7aecdae3dcb914ac915e599edc7228defec6d.png)

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 27, 2020, 7:41pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/11 "2020-04-27T19:41:35Z")

</div>

I got it!!! I made some adjustments and my friends killed everything! I just used flags in the end to make sure that nobody dies by the trap.

 ![Screen Shot 2020-04-27 at 12.40.16 PM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a402f092b453b8c54257c6b530ce6bad4c0a8fde.png)

---

<div class="post-metadata">

**Author:** ![Code\_Master](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/code_master/32/16184_2.png) [@Code\_Master](https://discourse.codecombat.com/u/Code_Master)\
**Post date:** [April 27, 2020, 7:42pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/12 "2020-04-27T19:42:51Z")

</div>

They are all surviving!!

---

<div class="post-metadata">

**Author:** ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)\
**Post date:** [April 27, 2020, 7:45pm UTC](https://discourse.codecombat.com/t/please-help-me-on-kelvintaph-crusader/21199/13 "2020-04-27T19:45:56Z")

</div>

WOOT!!! (Yes, it’s a complete sentence!)
