Hi!
I’m trying to pass the first level of Sarven Treasure and this is the code I wrote:
loop:
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:
hero.move(teleport)
elif coin:
hero.move(coin.pos)
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?
Thanks!