"Long-Range Division" is impossible - hostage dies


#1

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)


#2

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.


#3

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


#4

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