Ok I have an issue with the fact that, although I think my code is correct, my hero doesn’t move, which obviously means it isn’t correct. Silly me. I have based it off of Skating Away and this topic, but I am not getting anywhere. Here is my code:
while True:
potion = hero.findFriendlyMissiles()[0]
firetraps = hero.findHazards()
# Remember that a Fire Trap will trigger if you move closer than 3 meters!
omarn = hero.findByType("potion-master")[0]
if potion:
dest = potion.targetPos
# Go get the potion.
potion = Vector.subtract(dest.pos, hero.pos)
potion = Vector.normalize(potion)
potion = Vector.multiply(potion, 3)
if hero.distanceTo(firetraps) < 3:
firetrap = Vector.subtract(firetrap.pos, hero.pos)
firetrap = Vector.normalize(firetrap)
firetrap = Vector.multiply(firetrap, 3)
potion = Vector.add(potion, firetrap)
moveToPos = Vector.add(hero.pos, potion)
hero.move(moveToPos)
pass
else:
if omarn and hero.distanceTo(omarn) > 10:
# Move back to Omarn.
home = omarn.targetPos
# Go get the potion.
omarn = Vector.subtract(home.pos, hero.pos)
omarn = Vector.normalize(omarn)
omarn = Vector.multiply(omarn, 3)
if hero.distanceTo(firetraps) < 3:
firetrap = Vector.subtract(hero.pos, firetrap.pos)
firetrap = Vector.normalize(firetrap)
firetrap = Vector.multiply(firetrap, 3)
omarn = Vector.add(omarn, firetrap)
moveToPos = Vector.add(hero.pos, omarn)
hero.move(moveToPos)
# Warning: isPathClear doesn't work with Hazards!
hero.say("Hup, hup!")
pass
Thanks in advance.
Elijah