# Kelvintaph Glacier defiler strategy problem

**URL:** <https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243>\
**Category:** Level Help\
**Created:** [January 10, 2017, 1:01pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243 "2017-01-10T13:01:54Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![coolcolinxyz](https://avatars.discourse-cdn.com/v4/letter/c/ccd318/32.png) [@coolcolinxyz](https://discourse.codecombat.com/u/coolcolinxyz)\
**Post date:** [October 2, 2017, 3:08am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/21 "2017-10-02T03:08:59Z")

</div>

same i can’t beat it either

---

<div class="post-metadata">

**Author:** ![safe751129](https://avatars.discourse-cdn.com/v4/letter/s/bbe5ce/32.png) [@safe751129](https://discourse.codecombat.com/u/safe751129)\
**Post date:** [January 1, 2018, 3:20am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/22 "2018-01-01T03:20:31Z")

</div>

How do you kill the warlocks?

---

<div class="post-metadata">

**Author:** ![SuperSmacker](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/supersmacker/32/8385_2.png) [@SuperSmacker](https://discourse.codecombat.com/u/SuperSmacker)\
**Post date:** [January 7, 2018, 2:53am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/23 "2018-01-07T02:53:54Z")

</div>

Nalfar will kill them. Once he loses enough health (archers and soldiers should attack him), he’ll cast swap with the yeti, then cast fireball and kill the warlocks, before running off.

---

<div class="post-metadata">

**Author:** ![I\_can\_rob\_you](https://avatars.discourse-cdn.com/v4/letter/i/ed655f/32.png) [@I\_can\_rob\_you](https://discourse.codecombat.com/u/I_can_rob_you)\
**Post date:** [January 7, 2018, 7:01pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/24 "2018-01-07T19:01:14Z")

</div>

My paladin attacked him, and also used heal when health became half.

---

<div class="post-metadata">

**Author:** ![txt\_art](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/txt_art/32/12156_2.png) [@txt\_art](https://discourse.codecombat.com/u/txt_art)\
**Post date:** [June 8, 2020, 4:09am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/25 "2020-06-08T04:09:50Z")

</div>

````python
hero.moveXY(33, 23)

paladin = getPaladin()
enemy = paladin.findNearest([e for e in hero.findEnemies() if [e.id](http://e.id) is “ULD’MAK”])
if enemy:
friends = self.findFriends()
for friend in friends:
hero.command(friend, “attack”, enemy)

while True:
commandPaladin(getPaladin())

def commandPaladin(paladin):
# Heal the paladin with the lowest health using lowestHealthPaladin()
# You can use paladin.canCast(“heal”) and command(paladin, “cast”, “heal”, target)
# Paladins can also shield: command(paladin, “shield”)
# And don’t forget, they can attack, too!
# self.command(paladin, “shield”)
if paladin:
if paladin.canCast(“heal”):
self.command(paladin, “cast”, “heal”, paladin)
else:
self.command(paladin, “shield”)

def getPaladin():
paladin = None
friends = self.findFriends()
for friend in friends:
if friend.type == “paladin”:
paladin = friend
continue

return paladin
```[quote="safe751129, post:19, topic:10243, full:true"]
My code is:
# 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(33, 23)

paladin = getPaladin()
enemy = paladin.findNearest([e for e in hero.findEnemies() if e.id is "ULD'MAK"])
if enemy:
    friends = self.findFriends()
    for friend in friends:
        hero.command(friend, "attack", enemy)
      
while True:
    commandPaladin(getPaladin())

def commandPaladin(paladin):
    # Heal the paladin with the lowest health using lowestHealthPaladin()
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
    # And don't forget, they can attack, too!
    # self.command(paladin, "shield")
    if paladin:
        if paladin.canCast("heal"):
            self.command(paladin, "cast", "heal", paladin)
        else:
            self.command(paladin, "shield")

def getPaladin():
    paladin = None
    friends = self.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            paladin = friend
            continue
        
    return paladin

I can get my paladin to shield and heal, but I don't get why my troops are not attacking the ogres.

eeeeee
ereeeeeeee
[/quote]

[quote="safe751129, post:19, topic:10243"]
hero.moveXY(33, 23)

paladin = getPaladin()
enemy = paladin.findNearest([e for e in hero.findEnemies() if [e.id](http://e.id) is “ULD’MAK”])
if enemy:
friends = self.findFriends()
for friend in friends:
hero.command(friend, “attack”, enemy)

while True:
commandPaladin(getPaladin())

def commandPaladin(paladin):
# Heal the paladin with the lowest health using lowestHealthPaladin()
# You can use paladin.canCast(“heal”) and command(paladin, “cast”, “heal”, target)
# Paladins can also shield: command(paladin, “shield”)
# And don’t forget, they can attack, too!
# self.command(paladin, “shield”)
if paladin:
if paladin.canCast(“heal”):
self.command(paladin, “cast”, “heal”, paladin)
else:
self.command(paladin, “shield”)

def getPaladin():
paladin = None
friends = self.findFriends()
for friend in friends:
if friend.type == “paladin”:
paladin = friend
continue
[/quote]
````

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [June 8, 2020, 9:10am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/26 "2020-06-08T09:10:41Z")

</div>

Hi, do you need help with your code?  
Please could you explain what you mean with that post.  
Thanks  
Danny

---

<div class="post-metadata">

**Author:** ![txt\_art](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/txt_art/32/12156_2.png) [@txt\_art](https://discourse.codecombat.com/u/txt_art)\
**Post date:** [June 25, 2020, 11:10pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/27 "2020-06-25T23:10:52Z")

</div>

this is my code.

```python
def isLater(units,testUnit):
    if units[len(units)-1]==testUnit:
        return True
    else:
        return
def codeUnits():
    fs=hero.findFriends()
    es=hero.findEnemies()
    
    
    
    for target in es:
        for f in fs: 
            
            isLater2=isLater(fs,f)
            if isLater2 and f.type!='paladin' and target.id!='drun' and target.id!='gror' and target.type=='shaman':
                hero.command(f, "attack", target)            
                x=22
                y=56
                if f.type=='archer':
                    hero.command(f, "move", {'x':x,'y':y})
            if f.type!='paladin':
                hero.command(f, "attack", target)
            
def herosystem():
    step={'x':33, 'y':6}
    paladin=hero.findByType("paladin")[0]
    if paladin.health<600:
        hero.command(paladin, "shield")
    hero.move(step)
herosystem()
while True:
    codeUnits()

```

---

<div class="post-metadata">

**Author:** ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)\
**Post date:** [June 26, 2020, 6:54am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/28 "2020-06-26T06:54:03Z")

</div>

Hi @txt_art, I presume you need help with this level. Please could you describe what’s happening when you run the code.  
I also don’t think you have quite enough code for this level. Maybe try a step system based on hero.time to help divide the level into chunks.  
Danny

---

<div class="post-metadata">

**Author:** ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)\
**Post date:** [June 26, 2020, 6:56am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/29 "2020-06-26T06:56:56Z")

</div>

As @Deadpool198 said, try to use a step system that tells you in what part of the code are you, that can be based on time, flags, different enemies existing and many more (the best way is with hero.time()).

Andrei

---

<div class="post-metadata">

**Author:** ![goutham123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/goutham123/32/21341_2.png) [@goutham123](https://discourse.codecombat.com/u/goutham123)\
**Post date:** [March 15, 2021, 8:24pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/30 "2021-03-15T20:24:19Z")

</div>

HEY @Deadpool198 I SENT YOU A MESSAGE REAGRADING KELVINTAPH CRUSADER AND WHY DIDN"T YOU RESPOND!! I know you are a very good coder and have jobs to do but can you make atleast 30 minutes of time for me in your day… PLEASE!!! pleading\_face:

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [March 15, 2021, 8:46pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/31 "2021-03-15T20:46:58Z")

</div>

Hi goutha123, please understand that some people are in different time zones, so they might not see your message until later. What you can do is post your code and ask for help  
Lydia

---

<div class="post-metadata">

**Author:** ![goutham123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/goutham123/32/21341_2.png) [@goutham123](https://discourse.codecombat.com/u/goutham123)\
**Post date:** [March 16, 2021, 1:11am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/32 "2021-03-16T01:11:35Z")

</div>

@Lydia_Song I have waited a whole week, for the solutions but I didn’t get any reply

---

<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:** [March 16, 2021, 2:00am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/33 "2021-03-16T02:00:23Z")

</div>

If you ask him for the derect solution he won’t give it to you.

---

<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:** [March 16, 2021, 2:00am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/34 "2021-03-16T02:00:37Z")

</div>

And please just dont revive dead topics.

---

<div class="post-metadata">

**Author:** ![Lydia\_Song](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/lydia_song/32/31461_2.png) [@Lydia\_Song](https://discourse.codecombat.com/u/Lydia_Song)\
**Post date:** [March 16, 2021, 2:24pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/35 "2021-03-16T14:24:26Z")

</div>

If you ask for a solution directly, no one is going to give it to you since it is against the rules and it is not the purpose of CodeCombat. If you just copy and paste it in, you won’t learn anything. How about you try the level and post your code here if you have any problems?  
Lydia

---

<div class="post-metadata">

**Author:** ![goutham123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/goutham123/32/21341_2.png) [@goutham123](https://discourse.codecombat.com/u/goutham123)\
**Post date:** [March 16, 2021, 6:22pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/36 "2021-03-16T18:22:38Z")

</div>

```python
if hero.canCast("chain-lightning", "Trogdor"):
    hero.cast("chain-lightning", "Trogdor")

while True:
    friends = hero.findFriends()
    paladins = hero.findByType("paladin")
    enemies = hero.findEnemies()
    witches = hero.findByType("witch")
    enemies = hero.findEnemies()
    ogre = hero.findByType("ogre", hero.findEnemies())
    for friend in friends:
        if friend.type != 'paladin':
            if ogre.health > 0:
                hero.command(friend, "attack", "Oni")
            elif ogre.health <= 0:
                if friend.type == 'paladin':
                    hero.command(friend, "shield")
                elif 'Rusty' :
                    hero.command(friend, "attack", "Rusty")
                elif 'Skully':
                    hero.command(friend, "attack", "Skully")
        
        elif friend.type == 'paladin':
            if friend.health <= 300:
                hero.command(friend, "shield")
            else:
                witch = 'Yzzrith'
                hero.command(friend, "attack", witch)
    for enemy in enemies:
        if enemy.type is "catapult":
            while enemy.health > 0:
                hero.attack(enemy) 
            hero.moveXY(78, 14)
            enemies = hero.findEnemies()

```

This is my new code, my paladin is not shielding when asked. and he is not healing himself, so far I made some progress in the code, please feel free to try it out…

---

<div class="post-metadata">

**Author:** ![goutham123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/goutham123/32/21341_2.png) [@goutham123](https://discourse.codecombat.com/u/goutham123)\
**Post date:** [March 16, 2021, 6:25pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/37 "2021-03-16T18:25:01Z")

</div>

This is the problem with the level, can you please help me out

---

<div class="post-metadata">

**Author:** ![goutham123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/goutham123/32/21341_2.png) [@goutham123](https://discourse.codecombat.com/u/goutham123)\
**Post date:** [March 16, 2021, 6:25pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/38 "2021-03-16T18:25:27Z")

</div>

The problem is that my paladin is not shielding nor healing himself.

---

<div class="post-metadata">

**Author:** ![jka2706](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/jka2706/32/13636_2.png) [@jka2706](https://discourse.codecombat.com/u/jka2706)\
**Post date:** [March 22, 2021, 9:04am UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/39 "2021-03-22T09:04:09Z")

</div>

Hi goutham123,

Only just noticed that you don’t have any replies.

Have a look at these lines here:

```python
        if friend.type != 'paladin':
            if ogre.health > 0:
                hero.command(friend, "attack", "Oni")
            elif ogre.health <= 0:
                if friend.type == 'paladin':
                    hero.command(friend, "shield")

```

If the friend is a paladin, it will get to the first of these lines, and the if statement will be false. At that point the code will jump over all of the following lines, so the lines about the paladin shielding will never run.

How about just write it as:  
`if friend.type != 'paladin':`  
and then  
`else:`  
for the code for the paladins?

Jenny

---

<div class="post-metadata">

**Author:** ![goutham123](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/goutham123/32/21341_2.png) [@goutham123](https://discourse.codecombat.com/u/goutham123)\
**Post date:** [March 22, 2021, 8:19pm UTC](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243/40 "2021-03-22T20:19:58Z")

</div>

@jka2706 THANK YOU SO MUCH!!! I AM SO GRATEFUL… IT WORKED!! The paladin is shielding, he is healing, and everything is going to plan. Could you please help me in how to move my allies onto the X.

with Thanks,  
goutham123

[Previous page](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243.md?page=1)

[Next page](https://discourse.codecombat.com/t/kelvintaph-glacier-defiler-strategy-problem/10243.md?page=3)
