this is my code for it my guy is moving up and down but everytime he runs into a bason
while True:
enemy = hero.findNearestEnemy()
xPos = hero.pos.x + 5
yPos = 17
if enemy:
# Adjust y up or down to get away from yaks.
if enemy.pos.y > hero.pos.y:
# If the Yak is above you, subtract 3 from yPos.
hero.moveXY(xPos, yPos-3)
pass
elif enemy.pos.y < hero.pos.y:
# If the Yak is below you, add 3 to yPos.
hero.moveXY(xPos,yPos+3)
pass
hero.moveXY(xPos, yPos)
1 Like
You’re supposed to find the nearest yak, not the nearest enemy
Lydia
1 Like
I had the nearest yak is the nearest enemy.
1 Like
I had to rely on luck, even if I go up and down I got hit by a yak eventually.
1 Like
when he goes up for the second time the baby yak kills me
you need lots of health if you rely on luck, same happened to me when I went up or down, @logan_jordan. I think you’re a bit too slow, but if you get good equipment you should be able to beat it. By luck.
ok this is my new code
while True:
yak = hero.findNearestEnemy()
xPos = hero.pos.x + 5
yPos = 17
if yak:
# Adjust y up or down to get away from yaks.
if yak.pos.y > hero.pos.y:
# If the Yak is above you, subtract 3 from yPos.
hero.moveXY(xPos-7, yPos-1)
pass
elif yak.pos.y < hero.pos.y:
# If the Yak is below you, add 3 to yPos.
hero.moveXY(xPos,yPos+3)
pass
hero.moveXY(xPos, yPos)
and I cant afford better equipment
how much health do you have? I think 1000-2000 should be enough.
i could buy the obsidian shiled
and that would get me to like 1,400
1 Like
You’re not adding/subtracting yPos anywhere in the code.
When they are telling you to subtract/add to yPos
they mean the variable.
Change this:
hero.moveXY(xPos-7, yPos-1)
to
yPos -= 3
and change this:
hero.moveXY(xPos,yPos+3)
to
yPos += 3
Don’t buy any equipment because this level is doable without the use of a single piece of armor.
2 Likes