# Kelvintaph Defiler Step Variable Help

**URL:** <https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493>\
**Category:** Level Help\
**Created:** [April 21, 2021, 5:25pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493 "2021-04-21T17:25:21Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:25pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/1 "2021-04-21T17:25:21Z")

</div>

Hi! My code doesn’t seem to do anything at all. I’m getting the X underneath my hero, but the duck doesn’t say why. The duck isn’t even there at all. Can someone check and see if something is wrong?  
Code:

```python
# The ogres are trapping you with their dark rituals!
# Your hero can't do anything besides command and move without angering the warlocks.
# Beware ice, robots, traps, antigravity fields, and other dark magic.
# Somehow, you'll need to defeat Nalfar and save your paladin.
# The great treasure of Kelvintaph awaits your victory.
hero.moveXY(34, 15)
hero.moveXY(34, 7)
def commandSoldiers():
    soldiers = hero.findByType("soldiers")
    for soldier in soldiers:
        enemy = soldier.findNearestEnemy()
        hero.command(archer, "move", {'x': 75, 'y': 73})
        necro = hero.findNearest(hero.findByType("necromancer"))
        if necro:
            hero.command(soldier, "attack", necro)
        elif enemy:
            hero.command(soldier, "attack", enemy)
def commandArchers():
    archers = hero.findByType("archer")
    for archer in archers:
        hero.command(archer, "move", {'x': 75, 'y': 73})
        enemy = hero.findNearest(hero.findByType("necromancer"))
        if necro:
            hero.command(archer, "attack", necro)
        elif enemy:
            hero.command(archer, "attack", enemy)
def commandPaladins():
    paladin = hero.findFriends()
    enemy = hero.findByType("necromancer")
    if enemy and paladin:
        hero.command(paladin, "shield")
        if paladin.health <= 400:
            hero.command(paladin, "heal", paladin)
while True:
    commandSoldiers()
    commandPaladins()
    commandArchers()
```

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:27pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/2 "2021-04-21T17:27:49Z")

</div>

i think that maybe the necro and enemy variables for necromancers are clashing?

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:29pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/3 "2021-04-21T17:29:03Z")

</div>

but the different variables in different functions don’t overlap, I already forgot that and had to re-add them in each function

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:29pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/4 "2021-04-21T17:29:36Z")

</div>

wait I have an error in the archers function haha

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:31pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/5 "2021-04-21T17:31:07Z")

</div>

Think it’s cuz you’re defining the necro variable in a diff function. happened to me before maybe define necro before all functions as well? or define it in archer function?

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:31pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/6 "2021-04-21T17:31:55Z")

</div>

ok now that i fixed that, i’m getting an error on line 31, or `hero.command(paladin, "shield")`. It says I need something to command? and is it a bug that the duck appears half on the screen and half off?

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:32pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/7 "2021-04-21T17:32:47Z")

</div>

YOu need a target to shield upon. Ex:

```python
hero.command(paladin,"shield",#target whatever it is)

```

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:33pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/8 "2021-04-21T17:33:16Z")

</div>

hmmm, couldn’t I just write ` hero.command(paladin, "shield", paladin)`?

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:33pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/9 "2021-04-21T17:33:36Z")

</div>

eggsactly that is what you should do if you wanna it to shield itself

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:34pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/10 "2021-04-21T17:34:13Z")

</div>

i just wrote that, but then I still get the same error?

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:34pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/11 "2021-04-21T17:34:26Z")

</div>

and you shouldn’t do that paladin is find friends, cuz that includes the archers

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:34pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/12 "2021-04-21T17:34:39Z")

</div>

Don’t think the archers can shield

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:36pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/13 "2021-04-21T17:36:09Z")

</div>

oopsie didn’t add `hero.findByType("paladin")` inside

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:36pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/14 "2021-04-21T17:36:40Z")

</div>

yup, forgot to mention that too 🤦‍♂️

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:37pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/15 "2021-04-21T17:37:47Z")

</div>

Aha! but, i can’t heal my paladin???

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:39pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/16 "2021-04-21T17:39:49Z")

</div>

OK, now that I have most of this sorted, my paladin is finally shielding. But, the paladin can’t kill Nalfar, right? So I need my troops to go over there, but they have fear spells and antigravity spells and fling spells being casted on them. How do i get rid of that?

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:41pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/17 "2021-04-21T17:41:38Z")

</div>

The paladin isn’t supposed to. Just stall time i guess. keep healing herself as nalfar does his thing

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:42pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/18 "2021-04-21T17:42:02Z")

</div>

So she stays alive while you’re doing your own thing

---

<div class="post-metadata">

**Author:** ![CryptiCrystal](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/crypticrystal/32/16228_2.png) [@CryptiCrystal](https://discourse.codecombat.com/u/CryptiCrystal)\
**Post date:** [April 21, 2021, 5:42pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/19 "2021-04-21T17:42:14Z")

</div>

but I don’t think that i can heal and shield and stay alive. Even so, how do I get my troops out of the shamans’ spells?

---

<div class="post-metadata">

**Author:** ![thebagel](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/thebagel/32/22241_2.png) [@thebagel](https://discourse.codecombat.com/u/thebagel)\
**Post date:** [April 21, 2021, 5:43pm UTC](https://discourse.codecombat.com/t/kelvintaph-defiler-step-variable-help/28493/20 "2021-04-21T17:43:54Z")

</div>

i don’t think you’re supposed to heal and shield at the same time.

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