# "Long-Range Division" is impossible - hostage dies

**URL:** <https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087>\
**Category:** Bugs\
**Created:** [August 3, 2017, 3:57pm UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087 "2017-08-03T15:57:02Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enderhippo](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@Enderhippo](https://discourse.codecombat.com/u/Enderhippo)\
**Post date:** [August 3, 2017, 3:57pm UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/1 "2017-08-03T15:57:02Z")

</div>

So I’ve gotten to the level “Long-Range Division”, and there is a problem. One of the level’s goals is that the hostage must survive, but whatever I do, the ogres kill him. According to other threads, my code is correct, but when I approach the two ogres, they immediately kill the hostage before I can fight them. Any ideas on what to do?

Here is my code:

> **Code**
>
> # Use say to call out the range to the mines.
> 
> # Use division to calculate the range.
> 
> enemy = hero.findNearestEnemy()  
> distanceToEnemy = hero.distanceTo(enemy)
> 
> # Say first Range: distanceToEnemy divided by 3
> 
> hero.say(distanceToEnemy/3)  
> hero.say(“Fire!”)
> 
> # Say second range: distanceToEnemy divided by 1.5
> 
> hero.say(distanceToEnemy/1.5)  
> hero.say(“Fire!”)
> 
> # Say these things for motivation. Really. Trust us.
> 
> hero.say(“Woo hoo!”)  
> hero.say(“Here we go!”)  
> hero.say(“Charge!!”)
> 
> # Now, use a while-true loop to attack the enemies.
> 
> while True:  
> enemy = hero.findNearestEnemy()  
> if enemy:  
> hero.attack(enemy)

---

<div class="post-metadata">

**Author:** ![Hellenar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellenar/32/9100_2.png) [@Hellenar](https://discourse.codecombat.com/u/Hellenar)\
**Post date:** [August 3, 2017, 6:09pm UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/2 "2017-08-03T18:09:08Z")

</div>

Try equipping your hero with faster boots and the Speed Ring, if necessary. If you are a subscriber, try using a faster hero like Pender.

---

<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:** [August 15, 2017, 8:25pm UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/3 "2017-08-15T20:25:55Z")

</div>

Hi there,  
We made a few changes to the way CodeCombat runs, and it has made some older levels behave in slightly strange ways.

For example, on this level, it made the ogres attack the hostage before any warriors got close enough to fight.

Our good friend Bryukh has already fixed this, but there may be more out there. Please keep letting us know if you see something strange.

Please hide your code, @Enderhippo – we try not to have successful code on the forums.

Maka

---

<div class="post-metadata">

**Author:** ![Enderhippo](https://avatars.discourse-cdn.com/v4/letter/e/a183cd/32.png) [@Enderhippo](https://discourse.codecombat.com/u/Enderhippo)\
**Post date:** [August 15, 2017, 9:35pm UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/4 "2017-08-15T21:35:13Z")

</div>

Thank you so much! (the code is hidden now as well)

---

<div class="post-metadata">

**Author:** ![Sayaf](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Sayaf](https://discourse.codecombat.com/u/Sayaf)\
**Post date:** [August 27, 2020, 8:42am UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/5 "2020-08-27T08:42:43Z")

</div>

Good day, looks like a bug is still exists.  
After killing the first enemy the hero stop and cant complete the lvl.

Thank you.

---

<div class="post-metadata">

**Author:** ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)\
**Post date:** [August 27, 2020, 8:50am UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/6 "2020-08-27T08:50:49Z")

</div>

Hi @Sayaf Welcome to the Discourse 🥳 🥳  
For the bug I don’t think @maka is active anymore.

---

<div class="post-metadata">

**Author:** ![Sayaf](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Sayaf](https://discourse.codecombat.com/u/Sayaf)\
**Post date:** [August 27, 2020, 9:07am UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/7 "2020-08-27T09:07:44Z")

</div>

Maybe there is someone else from the administration. 🧐

---

<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:** [August 27, 2020, 9:29am UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/8 "2020-08-27T09:29:30Z")

</div>

Hi Sayaf,

Welcome to the forum!

It might be a bug, but it might also be an issue in your code. Could you post your code (formatting instructions at [[Essentials] How To Post/Format Your Code Correctly](https://discourse.codecombat.com/t/essentials-how-to-post-format-your-code-correctly/15521)), and we can try to run it… We can then give you help if it’s a code issue, or give more information to CoCo if it’s a bug.

Jenny

---

<div class="post-metadata">

**Author:** ![Sayaf](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Sayaf](https://discourse.codecombat.com/u/Sayaf)\
**Post date:** [August 28, 2020, 8:40pm UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/9 "2020-08-28T20:40:00Z")

</div>

```python
var enemy = hero.findNearestEnemy();
var distanceToEnemy = hero.distanceTo(enemy);
// Say first Range: distanceToEnemy divided by 3
distanceToEnemy / 3;
hero.say(distanceToEnemy / 3);
// Say second range: distanceToEnemy divided by 1.5
distanceToEnemy / 1.5;
hero.say(distanceToEnemy / 1.5);
// Say these things for motivation. Really. Trust us.
hero.say("Woo hoo!");
hero.say("Here we go!");
hero.say("Charge!!");
// Now, use a while-true loop to attack the enemies.
while (true) {
    if (enemy) {
    hero.attack(enemy);        
    }
}

```

Also Tried to put name of the Enemy as an argument, but still cant attack second ogre.

Thank you.

---

<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:** [August 29, 2020, 6:41am UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/10 "2020-08-29T06:41:35Z")

</div>

Put

```python
    var enemy = hero.findNearestEnemy();

```

inside the while loop. That way the second time the loop runs the other ogre is set as the enemy.

Jenny

---

<div class="post-metadata">

**Author:** ![Sayaf](https://avatars.discourse-cdn.com/v4/letter/s/c57346/32.png) [@Sayaf](https://discourse.codecombat.com/u/Sayaf)\
**Post date:** [August 29, 2020, 10:44am UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/11 "2020-08-29T10:44:07Z")

</div>

Thank you very much!

---

<div class="post-metadata">

**Author:** ![cuss\_detector\_bot](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cuss_detector_bot/32/37045_2.png) [@cuss\_detector\_bot](https://discourse.codecombat.com/u/cuss_detector_bot)\
**Post date:** [January 27, 2024, 7:17pm UTC](https://discourse.codecombat.com/t/long-range-division-is-impossible-hostage-dies/12087/12 "2024-01-27T19:17:37Z")

</div>

Omg. Thank you so much! I was stuck on the level.
