Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

I need help like always on Mind the trap[SOLVED]

help plz eric i need it

Post your code.
20chd

1 Like

If you try to attack a distant enemy, your hero will charge toward it, ignoring all flags.

You’ll need to make sure you only attack enemies who are close to you!

while True:
flag = hero.findFlag()
enemy = hero.findNearestEnemy()

if flag:
    # Pick up the flag.
    
    hero.say("I should pick up the flag.")
elif enemy:
    # Only attack if the enemy distance is < 10 meters
    
    hero.attack(enemy)

format all your code.

1 Like
# If you try to attack a distant enemy, your hero will charge toward it, ignoring all flags.
# You'll need to make sure you only attack enemies who are close to you!

while True:
    flag = hero.findFlag()
    enemy = hero.findNearestEnemy()
    
    if flag:
        # Pick up the flag.
        hero.pickUpFlag(flag)
        hero.say("I should pick up the flag.")
    elif enemy:
        # Only attack if the enemy distance is < 10 meters
        
        hero.attack(enemy)

1 Like

add if hero.distanceTo(enemy) < 10:

2 Likes

is that all???

yea you can also delete the say line.

thanks im done with it now i might need help tommaro also

i hope i see ya again

:smiley:

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