[SOLVED] Help! Distracting Dungeon Why Hero Go To Yetis

HOW DO I FIX HERO GO TO YETIS!!!.
Why Hero Go To Yetis

THIS CODE!!!. I TRY TO USE FLAG BUT TI NOT WORKING

# Navigate the mountain maze with a peasant pal.
# Advanced while-loop usage is required!


def moveBothTo(point):
    while hero.distanceTo(point) > 1:
        hero.move(point)
        hero.command(peasant, "move", point)

peasant = hero.findNearest(hero.findFriends())
while True:
    # Command your friend to build a decoy towards x + 1:
    hero.command(peasant, "buildXY", "decoy", peasant.pos.x + 2, peasant.pos.y)
    nextPoint = {"x": hero.pos.x, "y": hero.pos.y + 28};
    moveBothTo(nextPoint)
    # Create a new x/y dict +28 units away in the x dir:
    nextPoint = {"x": hero.pos.x + 28, "y": hero.pos.y}
    # Find the nearest enemy:
    enemy = hero.findNearestEnemy()
    flags = hero.findFlags("green")
    for flag in flags:
        if flag:
            hero.pickUpFlag(flag)
    # While there is an enemy:
    while enemy:
        # While the enemy's health is > 0:
        while  enemy.health > 0:
            # Attack the enemy:
            hero.attack(enemy)
        # Update the variable to the next nearest enemy:
        enemy = hero.findNearestEnemy()
    moveBothTo(nextPoint)




If you want to use flags you can just do this:

flag = hero.findFlag("green")
if flag:
   hero.pickUpFlag(flag)

You don’t need for to get them.

1 Like

You should also put this line on the very top (before the first function)

1 Like
if enemy.type != "yeti":
    #attack
1 Like

I see the problem. If you have twilight glasses you should unequip them, and you won’t see the yeti.

2 Likes

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