# New Level: Grim Determination

**URL:** <https://discourse.codecombat.com/t/new-level-grim-determination/3907>\
**Category:** Adventurer\
**Created:** [May 14, 2015, 10:02pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907 "2015-05-14T22:02:55Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![steog88](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@steog88](https://discourse.codecombat.com/u/steog88)\
**Post date:** [May 14, 2015, 10:02pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/1 "2015-05-14T22:02:55Z")

</div>

Dear all,  
i find that this level is very interesting, but…  
After having defined `lowH=lowestHealthPaladin()`, checked that it is not `None` and that the current `paladin.canCast("heal")`, i use

```python
self.command(paladin, "cast", "heal", lowH)

```

as suggested in the comments and no-one is healed. I am sure the previous points are correct, since target is actually the lowest health paladin, but simply the cast does not work.  
Is there a bug? Does someone else have the same problem?

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [May 14, 2015, 10:09pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/2 "2015-05-14T22:09:34Z")

</div>

Give us your entire code; maybe there’s something in there that blocks it.

---

<div class="post-metadata">

**Author:** ![DonutsHaveEggs](https://avatars.discourse-cdn.com/v4/letter/d/9de0a6/32.png) [@DonutsHaveEggs](https://discourse.codecombat.com/u/DonutsHaveEggs)\
**Post date:** [May 15, 2015, 2:59pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/3 "2015-05-15T14:59:36Z")

</div>

@steog88 please give us the entire block of code. You might have a issue in your code that is causing your code to not heal you.  
Thanks,  
DonutsHaveEggs

---

<div class="post-metadata">

**Author:** ![steog88](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@steog88](https://discourse.codecombat.com/u/steog88)\
**Post date:** [May 15, 2015, 3:48pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/4 "2015-05-15T15:48:55Z")

</div>

Thank you in advance!  
I used `say` to check if the code enters the `if`, and it does, so the conditions are verified. However, the cast still doesn’t work.

> **Code**
>
> ```python
> def commandPaladin(paladin):
> lowH=lowestHealthPaladin()
> if lowH is not None:
> if paladin.canCast("heal"):
> #self.say("heal"+lowH)
> self.command(paladin, "cast", "heal", lowH)
> self.command(paladin, "shield")
> 
> ```

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [May 15, 2015, 4:37pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/5 "2015-05-15T16:37:12Z")

</div>

First, you don’t need to check to see if `lowH` is `None`, just ask `if lowH:`

Second, your problem is the `shield` command. The `shield`, for some reason, is overriding all other commands, so your paladins won’t heal, only shield.

---

<div class="post-metadata">

**Author:** ![steog88](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@steog88](https://discourse.codecombat.com/u/steog88)\
**Post date:** [May 15, 2015, 5:18pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/6 "2015-05-15T17:18:35Z")

</div>

Thank you @ChronistGilver, in fact `else:` before the `shield` command solved the issue.

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 15, 2015, 5:53pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/7 "2015-05-15T17:53:09Z")

</div>

@Catsync Is it my imagination or is the reward backwards?

[Edit: The upper “view” “continue” links work not the bottom ones…for this “image”]

![](https://sea2.discourse-cdn.com/flex016/uploads/codecombat/2606/2055dbe2ddb6fe7e.png)

---

<div class="post-metadata">

**Author:** ![Magicfloatincow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/magicfloatincow/32/3855_2.png) [@Magicfloatincow](https://discourse.codecombat.com/u/Magicfloatincow)\
**Post date:** [May 15, 2015, 5:57pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/8 "2015-05-15T17:57:32Z")

</div>

Wow glitch huge glitch, I think it is imagination…

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 15, 2015, 6:02pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/9 "2015-05-15T18:02:06Z")

</div>

Hmm, Glitch may be right on.

It still shows “Loading” so I hit “esc”, it removed the bottom half of the image (the part with scores) leaving the top “0” portion and seems stuck now (nothing responds, links, more “Esc”, etc). Next I “back” buttoned, got the Moutain Map with the Victory display over it still…

…Welcome to the Twilight Zone…

---

<div class="post-metadata">

**Author:** ![Magicfloatincow](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/magicfloatincow/32/3855_2.png) [@Magicfloatincow](https://discourse.codecombat.com/u/Magicfloatincow)\
**Post date:** [May 15, 2015, 6:03pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/10 "2015-05-15T18:03:31Z")

</div>

does it happen with other levels?

[merged double post]

det twightlight zone 🕶

---

<div class="post-metadata">

**Author:** ![Vlevo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/vlevo/32/2074_2.png) [@Vlevo](https://discourse.codecombat.com/u/Vlevo)\
**Post date:** [May 15, 2015, 6:21pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/12 "2015-05-15T18:21:35Z")

</div>

Yup, must have been a Twilight Zone Glitch

![](https://sea2.discourse-cdn.com/flex016/uploads/codecombat/2607/3a3b16d3a27cea46.png)

Although, I am wondering why I have the same total gems? (since I didn’t succeed at the bonus, previously . . . the first image was my first success at submitting and this image is my second.) @Catsync

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [May 15, 2015, 6:35pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/14 "2015-05-15T18:35:32Z")

</div>

Yes, that happened to me as well. I got the bonus without fulfilling the requirements.

---

<div class="post-metadata">

**Author:** ![arkustrew](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@arkustrew](https://discourse.codecombat.com/u/arkustrew)\
**Post date:** [June 14, 2015, 9:01pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/15 "2015-06-14T21:01:11Z")

</div>

```
  # Your goal is to protect Reynaldo

# Find the paladin with the lowest health.
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = self.findFriends()
    for friend in friends:
        if friend.type != "paladin":
            continue
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend

    return lowestFriend

def commandPaladin(paladin):
    # Heal the paladin with the lowest health using lowestHealthPaladin() 
    if paladin:
        lowPaladin = lowestHealthPaladin()
        if lowPaladin:
            self.command(paladin, "cast", "heal", lowPaladin)
            lowPaladin.say("paladin healed")
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
        else:
            self.command(paladin, "shield")

def commandFriends():
    # Command your friends.
    friends = self.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            commandPeasant(friend)
        elif friend.type == "griffin-rider":
            commandGriffin(friend)
        elif friend.type == "paladin":
            commandPaladin(friend)
def commandGriffin(griffin):
    enemy = griffin.findNearest(griffin.findEnemies())
    self.command(griffin, "attack", enemy)
    
def commandPeasant(peasant):
    coin = peasant.findNearest(peasant.findItems())
    peasant.move(coin)
    
loop:
    commandFriends()
    # Summon griffin riders!
    self.summon("griffin-rider")

```

whenever i run the code  
I get the message:  
Line 45: tmp384[tmp385] is not a function  
What does this mean and how can I fix my code?

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [June 14, 2015, 10:07pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/16 "2015-06-14T22:07:26Z")

</div>

Hello, arkustrew, and welcome.

Line 45 is `peasant.move(coin)`. Peasants do not take commands in this way. Command them using your Boss Star.

```python
self.command(friend, "move" place_you_want_your_friend_to_move)

```

Also, you should tell your peasants to move to the coin’s position, not the coin itself.

---

<div class="post-metadata">

**Author:** ![csd](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@csd](https://discourse.codecombat.com/u/csd)\
**Post date:** [October 12, 2015, 12:48am UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/17 "2015-10-12T00:48:51Z")

</div>

def commandGriffin(griffinrider):  
enemies = self.findEnemies()  
enemy = None  
for enemy in enemies:  
self.say(enemy.type)  
if enemy.type == “warlock”:

```
        self.command(griffinrider, "attack", enemy)
        break;
if enemy:        
    enemy = self.findNearest(self.findEnemies())
    if enemy:
        self.command(griffinrider, "attack", enemy)

```

# Your goal is to protect Reynaldo

def commandPeasant(peasant):  
item = self.findNearest(self.findItems())  
if item:  
if peasant:  
self.command(peasant, “move”, item.pos)

def lowestHealthPaladin():  
lowestHealth = 99999  
lowestFriend = None  
friends = self.findFriends()  
for friend in friends:  
if friend.type != “paladin”:  
continue  
if friend.health \< lowestHealth and friend.health \< friend.maxHealth:  
lowestHealth = friend.health  
lowestFriend = friend  
if lowestHealth \>150:  
lowestFriend = None;

```
return lowestFriend

```

def commandPaladin(paladin):  
lowestFriend = lowestHealthPaladin()  
if paladin.canCast(“heal”) and lowestFriend:  
self.command(paladin, “cast”, “heal”, lowestFriend)  
# 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”)  
#self.command(paladin, “shield”)  
enemies = self.findEnemies()  
enemy = None  
for enemy in enemies:  
if enemy.type == “warlock”:  
self.command(paladin, “attack”, enemy)  
break;  
if enemy:  
enemy = self.findNearest(self.findEnemies())  
if enemy:  
self.command(paladin, “attack”, enemy)

def commandFriends():  
# Command your friends.  
friends = self.findFriends()  
for friend in friends:  
if friend.type == “peasant”:  
commandPeasant(friend)  
pass  
elif friend.type == “griffin-rider”:  
commandGriffin(friend)  
pass  
elif friend.type == “paladin”:  
commandPaladin(friend)

loop:  
commandFriends()  
# Summon griffin riders!  
if self.costOf(“griffin-rider”) \< self.gold:  
self.summon(“griffin-rider”)

---

<div class="post-metadata">

**Author:** ![csd](https://avatars.discourse-cdn.com/v4/letter/c/46a35a/32.png) [@csd](https://discourse.codecombat.com/u/csd)\
**Post date:** [October 12, 2015, 12:50am UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/18 "2015-10-12T00:50:03Z")

</div>

I need help a lot. Please help me. I did indent.

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [October 12, 2015, 1:09am UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/19 "2015-10-12T01:09:02Z")

</div>

Please format your code according to the FAQ, as **everyone** should to before posting even once.

Phrases like “I need help!” or “This code isn’t working!” are not helpful to us, or to you, in any way possible. Give us more information, e.g your code (properly formatted), the error (if any), and perhaps a screenshot of what happens when you run it.

---

<div class="post-metadata">

**Author:** ![Ben\_Smith](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@Ben\_Smith](https://discourse.codecombat.com/u/Ben_Smith)\
**Post date:** [November 11, 2015, 10:01pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/20 "2015-11-11T22:01:36Z")

</div>

my code isn’t working out so good, there arent any errors, but everything isnt executed

```
def lowestHealthPaladin():
lowestHealth = 99999
lowestFriend = None
friends = self.findFriends()
for friend in friends:
    if friend.type != "paladin":
        continue
    if friend.health < lowestHealth and friend.health < friend.maxHealth:
        lowestHealth = friend.health
        lowestFriend = friend

return lowestFriend

def commandPaladin(paladin):
    # Heal the paladin with the lowest health using lowestHealthPaladin() 
    if paladin:
        lowPaladin = lowestHealthPaladin()
        if lowPaladin:
            self.command(paladin, "cast", "heal", lowPaladin)
            lowPaladin.say("paladin healed")
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
        else:
            self.command(paladin, "shield")

def commandFriends():
    # Command your friends.
    friends = self.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            pass
        elif friend.type == "griffin-rider":
            commandGriffin(friend)
        elif friend.type == "paladin":
            commandPaladin(friend)
def commandGriffin(griffin):
    enemy = griffin.findNearest(griffin.findEnemies())
    self.command(griffin, "attack", enemy)
    
    
loop:
    commandFriends()
    # Summon griffin riders!
    self.summon("griffin-rider")
```

---

<div class="post-metadata">

**Author:** ![ChronistGilver](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chronistgilver/32/3778_2.png) [@ChronistGilver](https://discourse.codecombat.com/u/ChronistGilver)\
**Post date:** [November 11, 2015, 11:46pm UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/21 "2015-11-11T23:46:25Z")

</div>

You first have to check if the paladin can cast `"heal"` in the first place. Otherwise, it won’t work. Also, paladins can’t speak.

---

<div class="post-metadata">

**Author:** ![Ben\_Smith](https://avatars.discourse-cdn.com/v4/letter/b/b2d939/32.png) [@Ben\_Smith](https://discourse.codecombat.com/u/Ben_Smith)\
**Post date:** [November 13, 2015, 3:32am UTC](https://discourse.codecombat.com/t/new-level-grim-determination/3907/22 "2015-11-13T03:32:41Z")

</div>

my griffins arent doing anything…

[Next page](https://discourse.codecombat.com/t/new-level-grim-determination/3907.md?page=2)
