# Help on Reaping Fire

**URL:** <https://discourse.codecombat.com/t/help-on-reaping-fire/13390>\
**Category:** Level Help\
**Created:** [December 30, 2017, 5:14pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390 "2017-12-30T17:14:33Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [December 30, 2017, 5:14pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/1 "2017-12-30T17:14:33Z")

</div>

On the level Reaping Fire, my griffin-riders are not responding when I command them to attack the ogres. Can you help me?

Here is my code:

```python

# The goal is to survive for 30 seconds, and keep the mines intact for at least 30 seconds.

def chooseStrategy():
    enemies = hero.findEnemies()
    # If you can summon a griffin-rider, return "griffin-rider"
    if hero.gold >= hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
        return "griffin-rider"
    # If there is a fangrider on your side of the mines, return "fight-back"
    for enemy in enemies:
        if enemy and enemy.type is "fang-rider":
            return "fight-back"
    # Otherwise, return "collect-coins"
        else:
            return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and enemy.type is "ogre":
        hero.command("griffin-rider", "attack", "ogre")
    
    
def pickUpCoin():
    # Collect coins
    items = hero.findItems()
    for item in items:
        if item and item.value > 1:
            hero.moveXY(item.pos.x, item.pos.y)
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and enemy.type is "fang-rider":
        hero.attack(enemy)
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == "griffin-rider":
        commandAttack()
    if strategy == "fight-back":
        heroAttack()
    if strategy == "collect-coins":
        pickUpCoin()
```

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 30, 2017, 5:44pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/2 "2017-12-30T17:44:01Z")

</div>

Are there any ogres? Your commandAttack function specifies that the griffin riders only attack ogres.

---

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [December 30, 2017, 5:48pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/3 "2017-12-30T17:48:17Z")

</div>

But the comments say that the the griffin riders should only attack ogres. I assumed that munchkins and throwers fell into the ogre group.

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 30, 2017, 6:03pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/4 "2017-12-30T18:03:01Z")

</div>

Try attacking all enemies (if enemy). Also, fangrider should not be hyphenated.

---

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [December 30, 2017, 6:07pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/5 "2017-12-30T18:07:15Z")

</div>

Yeah, I just realized that last part.

---

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [December 30, 2017, 6:09pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/6 "2017-12-30T18:09:40Z")

</div>

Now I am not summoning enough griffin-riders. I am only summoning one.

Here is my new code:

```python

def chooseStrategy():
    enemies = hero.findEnemies()
    # If you can summon a griffin-rider, return "griffin-rider"
    if hero.gold >= hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")
        return "griffin-rider"
    # If there is a fangrider on your side of the mines, return "fight-back"
    for enemy in enemies:
        if enemy and enemy.type is "fangrider":
            return "fight-back"
    # Otherwise, return "collect-coins"
        else:
            return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friend = hero.findNearest(hero.findFriends())
    enemy = hero.findNearest(hero.findEnemies())
    if enemy: 
        hero.command(friend, "attack", enemy)
        
def pickUpCoin():
    # Collect coins
    items = hero.findItems()
    for item in items:
        if item and item.value > 1:
            hero.moveXY(item.pos.x, item.pos.y)
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and enemy.type is "fangrider":
        hero.attack(enemy)
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == "griffin-rider":
        commandAttack()
    if strategy == "fight-back":
        heroAttack()
    if strategy == "collect-coins":
        pickUpCoin()
```

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 30, 2017, 6:15pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/7 "2017-12-30T18:15:10Z")

</div>

Try defining a single coin using a different method, like hero.findNearestItem. Currently, you are using hero.findItems, which finds an array of items but doesn’t define a particular position of each item or which one to move to. With findNearestItem, you are defining a single position of a single item to move to - the nearest coin.

What character are you using and do you have the ring of speed? You need some speed to get as many grif-riders as possible.

---

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [December 31, 2017, 4:03pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/8 "2017-12-31T16:03:41Z")

</div>

I am using Pender Spellbane and I have the ring of Speed.

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [December 31, 2017, 4:28pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/9 "2017-12-31T16:28:45Z")

</div>

I was able to pass the level with Pender but couldn’t get the 60 second bonus with it. Pender just doesn’t have enough health. Are you casting haste? Mana blast? I wound up using Nalfar to get the bonus.

---

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [December 31, 2017, 4:36pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/10 "2017-12-31T16:36:13Z")

</div>

Thanks for the advice

---

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [December 31, 2017, 5:37pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/11 "2017-12-31T17:37:31Z")

</div>

I finished the level! I have been working for a month on it! Thanks!

---

<div class="post-metadata">

**Author:** ![Awsomedude1](https://avatars.discourse-cdn.com/v4/letter/a/c37758/32.png) [@Awsomedude1](https://discourse.codecombat.com/u/Awsomedude1)\
**Post date:** [December 31, 2017, 5:38pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/12 "2017-12-31T17:38:00Z")

</div>

By the way, I got the bonus and won with Tharin

---

<div class="post-metadata">

**Author:** ![maka](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/maka/32/3261_2.png) [@maka](https://discourse.codecombat.com/u/maka)\
**Post date:** [January 4, 2018, 4:05pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/13 "2018-01-04T16:05:33Z")

</div>

> [@Awsomedude1](#):
>
> I finished the level! I have been working for a month on it! Thanks!

Well done! You just need to keep working on it!

---

<div class="post-metadata">

**Author:** ![mostro](https://avatars.discourse-cdn.com/v4/letter/m/6a8cbe/32.png) [@mostro](https://discourse.codecombat.com/u/mostro)\
**Post date:** [July 12, 2020, 10:14pm UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/14 "2020-07-12T22:14:42Z")

</div>

i need help with my code, my griffin-riders are not responding to the command and also my code maybe has other problems.

```python
def chooseStrategy():
    enemies = hero.findEnemies()
    # If you can summon a griffin-rider, return "griffin-rider"
    if hero.gold > hero.costOf("griffin-rider"):
        return "griffin-rider"
    # If there is a fangrider on your side of the mines, return "fight-back"
    enemy = hero.findNearestEnemy()
    if enemy and enemy.type == "fangrider":
        return "fight-back"
    # Otherwise, return "collect-coins"
    return "collect-coins"

def commandAttack():
    # Command your griffin riders to attack ogres.
    friend = hero.findFriends()
    friends = hero.findFriends()
    if friend in friends:
        hero.command(friend, "attack", enemy)
        for enemy in enemies:
            hero.command(friend, "attack", enemy)
    pass
    
def pickUpCoin():
    # Collect coins
    coin = hero.findNearestItem()
    if coin:
        hero.move(coin.pos)
    pass
    
def heroAttack():
    # Your hero should attack fang riders that cross the minefield.
    if enemy and enemy.pos > hero.pos:
        hero.attack(enemy)
    pass
    
while True:
    commandAttack()
    strategy = chooseStrategy()
    # Call a function, depending on what the current strategy is.
    if strategy == "griffin-rider":
        hero.summon("griffin-rider")
    if strategy == "fight-back":
        heroAttack()
    if strategy == "collect-coins":
        pickUpCoin()

```

---

<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:** [July 13, 2020, 3:34am UTC](https://discourse.codecombat.com/t/help-on-reaping-fire/13390/15 "2020-07-13T03:34:02Z")

</div>

> [@mostro](#):
>
> `if enemy and enemy.type == "fangrider"`

But what happens when the enemy is far away and you see it? Wouldn’t be better to collect coins even if there is a fangrider but if is on the other side of the mines or above the mines?

> [@mostro](#):
>
> ```python
> friend = hero.findFriends()
> friends = hero.findFriends()
> if friend in friends:
> hero.command(friend, "attack", enemy)
> for enemy in enemies:
> hero.command(friend, "attack", enemy)
> pass
> 
> ```

Here I belive that you want to attack each griffin rider’s nearest enemy, so first first loop over each element from the friends array, then say who is enemy, then check if it exists and if it does, then command to attack.

> [@mostro](#):
>
> `if enemy and enemy.pos > hero.pos:`

I belive that this is not necesarry.

Andrei
