Range Finder HELP! Solved!


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

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

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

Say the distance2 variable!

enemy3 = "Charles"
enemies = hero.findEnemies()
enemy4 = "Gorgnub"
enemies = hero.findEnemies()

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?


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


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:

becomes this:

enemy = self.findNearestEnemy
if enemy:

Cheers! :beers:

Please :heart: this post if you find it useful


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:


(solution removed)

(20 characters minimum)


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.