Why rich forager not working? Help me!


while True:
    flag = hero.findFlag()
    enemy = hero.findNearestEnemy()
    item = hero.findNearestItem()
    distance = hero.distanceTo(item)
    if flag:
        # What happens when I find a flag?
        hero.pickUpFlag(flag)
    elif enemy:
        # What happens when I find an enemy?
        if hero.isReady("cleave"):
            hero.cleave(enemy)
        else:
            hero.attack(enemy)
    elif item:
        # What happens when I find an item?
        if item.distance <=6:
            hero.moveXY(item.pos.x,item.pos.y)

Why my code is not working after the first pile of coins?

Try and swap the “item” variable w/ the flag variable

1 Like