Hit and Freeze URgent! NEed HElp!

# You are trapped. Don't move, it'll be painful.

# This function checks if the enemy is in your attack range.
def inAttackRange(enemy):
    distance = hero.distanceTo(enemy);
    # Almost all swords have attack range of 3.
    if enemy:
        (distance <= 3) {
        return true;
    else:
        
        return false;
    


# Attack ogres only when they're within reach.
while True:
     
    # Find the nearest enemy and store it in a variable.
    var canAttack = inAttackRange(enemy);
    # Call inAttackRange(enemy), with the enemy as the argument
    # and save the result in the variable canAttack.
    inAttackRange(enemy)}
    # If the result stored in canAttack is true, then attack!
    hero.attack(enemy);

1 Like

Are you coding on Python or JavaScript?

2 Likes

oh your Javascript 2000000000000

1 Like

it looks like java 2000

1 Like

python

PeterPalov

I can help you then 2000

If your a beginner let’s not make it too confusing

i am a beginner 20000000000000000000000

why are you adding ;
to your code?

1 Like

you only use ;'s in Javascript

1 Like

and you should do this

1 Like

Thank you, I did…

1 Like

show me your code and I’ll see if you did it correctly

1 Like

You don’t need to use “var” or }'s in python either.

1 Like

yeah 2000000000000000000

1 Like

To sum up what everyone here has said, don’t use var, }, or ; if you are using Python. Also, with the if enemy statement, putting (distance <= 3) doesn’t really do anything. Instead, you want to put if enemy and hero.distanceTo(enemy) <= 3: Also, somewhere, you need to say what the term enemy actually means. I strongly suggest replacing var canAttack = inAttackRange(enemy); with enemy = hero.findNearestEnemy().

-Gray