Range Finder HELP! Solved!


#1

I’ve been trying to “conquer” the Range Finder level in backwoods forest. Here’s my code:

enemy1 = "Gort"
distance1 = hero.distanceTo(enemy1)
hero.say(distance1)

enemy2 = "Smasher"
distance2 = hero.distanceTo(enemy2)

Say the distance2 variable!

hero.say(distance2)
enemy3 = "Charles"
enemies = hero.findEnemies()
hero.attack(enemy3)
continue
enemy4 = "Gorgnub"
enemies = hero.findEnemies()
hero.attack(enemy4)

But the thing is I can’t reach and/or attack the ogre near the tent. Does anyone have any suggestions or help me reach the ogre?


#2

Make sure you do not attack Charles. Delete the code for “enemy3”.

Also, do not use hero.attack. The mortar will fire for you. Instead of hero.attack(enemy4), find the distance to enemy4 using distanceTo and then say distance4


#3

Also please format your code according to the FAQ. It helps us better understand you code and also helps us figure out what is wrong. Go to: https://discourse.codecombat.com/faq.

To format correctly, you would put triple (`)'s, around your code so that:

enemy = self.findNearestEnemy
if enemy:
self.attack(enemy)

becomes this:

enemy = self.findNearestEnemy
if enemy:
self.attack(enemy)

Cheers! :beers:

Please :heart: this post if you find it useful


#4

Thanks, @Luke10. I never knew we were supposed to do that in the Discourse. And thanks, @_TD_RodYT. I completed that code thanks to you. :slight_smile:


#5

(solution removed)

(20 characters minimum)


#6

Please don’t post solutions. The purpose of this board is to help people learn so that they can figure out levels on their own. Simply providing solutions does not help and is counterproductive to this goal. The two main rules here on this board are no swearing and no posting solutions. Thanks and welcome to the board.