I neeed some help on hit and freeze i dont understand it

my code is `# 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 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.
enemy = hero.findNearestEnemy()
meow = 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!
canAttack
pass
`

can someone help meee

# 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 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.
    enemy = hero.findNearestEnemy()
    meow = 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!
    canAttack
    pass

Please make sure your code is formatted, try for the next time to insert the code on a new line different from the text you out :slight_smile: I have formatted it for you for this time.

so this is unnecessary, you can remove it.

This means that you should make a variable called canAttack and assign the function inAttackRange(enemy) to it.

Hint: canAttack = inAttackRange(enemy)

Now the inAttackRange function either returns True or False so this means that canAttack's value will be True or False.

So make an if-statement chceking if canAttack is True, and if so, cleave.


this is my code so far

im kind of getting it so i need to attack without moving ^u^

i didnt cleave

  • List item

I FORGOT ABOUT THE ATTACK ENEMY ON TOP OF THE if canAttack:

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.