I’m trying to work my way through Brewball (Glacier). I’m not so great with Vectors, but have been trying to implement the code from Skating Away. I’m actually pretty proud of myself - I’ve gone from being clueless to getting the first potion. The problem is, even after catching the first potion, my hero doesn’t go back to Omarn, and I’m not sure why not.
Here’s the part of my code I think is relevant:
while True: potion = hero.findFriendlyMissiles() firetraps = hero.findHazards() nearestTrap = hero.findNearest(firetraps) # Remember that a Fire Trap will trigger if you move closer than 3 meters! omarn = hero.findByType("potion-master") if potion: dest = potion.targetPos; goal = Vector.subtract(dest, hero.pos) goal = Vector.normalize(goal) goal = Vector.multiply(goal, 5) disToTrap = hero.distanceTo(nearestTrap) if disToTrap < 5: trapVector = Vector.subtract(hero.pos, nearestTrap.pos) trapVector = Vector.normalize(trapVector) trapVector = Vector.multiply(trapVector, 5) goal = Vector.add(trapVector, goal) moveToPos = Vector.add(hero.pos, goal) if hero.pos == dest: hero.wait(5) else: hero.move(moveToPos)
I even threw in that bit at the end in the hope that it would stop the hero from continuing after arriving where the potion is supposed to land, but it didn’t work.
Any help would be greatly appreciated.