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:
    hero.say("Fire!")
# Say second range: distanceToEnemy divided by 1.5
if distamce == hero.distanceTo(enemy) / 2:
    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:
    hero.attack(enemy)

Thanks for the help!

1 Like

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.

1 Like

distanceToEnemy is not the same variable as distance

1 Like

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

1 Like

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

1 Like

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

1 Like

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

1 Like