Sarven Treasure, stuck in teleportation (first level, Python)

I’m trying to pass the first level of Sarven Treasure and this is the code I wrote:

    teleports = [{"x": 5.27, "y": 19.23}, {"x": 4.71, "y": 49.19}, {"x": 76.67, "y": 19.02}, {"x": 75.95, "y": 51.00}]
    teleport = hero.findNearest(teleports)
    coin = hero.findNearest(hero.findItems())
    enemy = hero.findNearest(hero.findEnemies())
    if enemy and hero.distanceTo(enemy) < 10:
    elif coin:

Everything goes fine until the ogre gets close to my hero - then my hero goes to the nearest X, gets teleported, goes back to the first X, gets teleported again and goes back again and so on until he gets killed.

What am I doing wrong?


1 Like

From what I understand here, the hero is around the enemy most of the time so the hero keeps moving to a teleporter, and since you can’t go to three areas at once, the hero will keep going back to the same teleporter, get teleported, and do it over again. I used flags for this level because I like to complete the level in real-time without having that many errors when I press submit for the level.

1 Like

thanks for the idea, i’ll try the flags!

1 Like