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

Siege of Stonehold [Help Python] [Solved]

#1

This is my code. The character won’t move to the flag to pick it up.

# Help your friends beat the minions that Thoktar sends against you.
# You'll need great equipment and strategy to win.
# Flags might help, but it's up to you–be creative!
# There is a doctor behind the fence. Move to the X to get healed!
flag = hero.findflag("green")
enemy = hero.findNearestEnemy()

while True:
    if flag:
        hero.pickUpFlag(flag)
    elif enemy:
        if hero.isReady("cleave"):
            hero.cleave(enemy)
        else:
            hero.attack(enemy)
        pass
#2

Your current code just looks for the flag once at the beginning. Move the flag variable line into the while True loop and it will always be checking for a flag. You’ll want to do the same with the enemy variable, move that into the while True to make sure your hero is always looking for one.

#3

Okay, I’ll try that really quick.

#4

Thank you @brooksy125, for your help it worked.

#5

You are welcome! Glad to help. :nerd_face: