Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Long Range Division Help


Hey everyone I have been having some trouble on Long Range Division. It says line 8 distance isn’t defined.

here is the code:

enemy = hero.findNearestEnemy()
distanceToEnemy = hero.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
if distance == hero.distanceTo(enemy) / 3:
# Say second range: distanceToEnemy divided by 1.5
if distamce == hero.distanceTo(enemy) / 2:

# Say these things for motivation. Really. Trust us.
hero.say("Woo hoo!")
hero.say("Here we go!")

# Now, use a while-true loop to attack the enemies.
while True:

Thanks for the help!


I noticed one problem with your code and that is on what looks like line 7: you spelled distance wrong, other than that I see no problems.


distanceToEnemy is not the same variable as distance


Oh…ok I’ll fix that. Thanks for the help.


Wait…I may look stupid, but what do you mean @Serg by distanceToEnemy is not the same?


I just wanna ask you,wat the heck is distamce?


hero.distanceTo(something) is how far a unit is from the hero. :slight_smile: