# Brewball level help (python)

Hi! I’ve been stuck on glacier level brewball when I put the code for me to go back to omarn my hero just starts shaking like crazy and just keep setting them off or just running into traps

PS. I’m not very good at vectors so if someone could explain them it would be really appreciated

code
``````# Say anything within 10m of Omarn for him to throw a potion.
# Catch the potion by standing near it before it lands.
# DO NOT LET THE POTION LAND ON THE GROUND!
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.
firetrap = hero.findNearest(firetraps)
distance = hero.distanceTo(firetrap)
if distance < 4:
dest = Vector.normalize(dest)
vector = Vector.subtract(firetrap.pos, hero.pos)
vector = Vector.normalize(vector)
vector = Vector.multiply(vector, 4)
hero.move(dest)
else:
if omarn and hero.distanceTo(omarn) > 10:
# Move back to Omarn.
dest2 = Vector(14, 34)
firetrap = hero.findNearest(firetraps)
distance = hero.distanceTo(firetrap)
if distance < 4:
dest2 = Vector.normalize(dest2)
vector2 = Vector.subtract(firetrap.pos, hero.pos)
vector2 = Vector.normalize(vector2)
vector2 = Vector.multiply(vector2, 4)
hero.move(dest2)
else:
hero.say("hi")

``````

vector= * In programming, this name “vector” was originally used to describe any fixed-length sequence of scalar numbers . A vector of length 2 represents a point in a 2D plane, a vector of length 3 represents a point in a 3D space, and so on.

1 Like

So its just like `hero.pos` or a cordinate?

yea but its 3D mode and its EXACT not rounded, so it is like 54.342345678987678987890987654321234567890987654321234567892235656687464216345467897621232366o775221287657543323456789765432345434677657654565454345445

1 Like

Oh so is that why you need `Vector.normalize(vector)`?

I’ve also noticed another problem with my code, its that my hero always wants to go under the trap and not above it. And that cause’s my hero to shake like crazy and get to a 3m distance and activate the trap… Is there a way to fix that?

Update : I review skating away and saw that I needed to add my hero position to the vector. So always wanting to go down isn’t the problem now, sometimes I still activate the traps and my hero just keeps trying to go to `Vector(0,0)`

code
``````# Say anything within 10m of Omarn for him to throw a potion.
# Catch the potion by standing near it before it lands.
# DO NOT LET THE POTION LAND ON THE GROUND!
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.
firetrap = hero.findNearest(firetraps)
distance = hero.distanceTo(firetrap)
if distance < 4:
dest = Vector.normalize(dest)
dest = Vector.multiply(dest, 4)
vector = Vector.subtract(hero.pos, firetrap.pos)
vector = Vector.normalize(vector)
vector = Vector.multiply(vector, 4)
hero.move(dest)
else:
if omarn and hero.distanceTo(omarn) > 10:
# Move back to Omarn.
dest2 = Vector(14, 34)
dest2 = Vector.normalize(dest2)
firetrap = hero.findNearest(hero.findHazards())
distance = hero.distanceTo(firetrap)
if distance < 4:
vector2 = Vector.subtract(hero.pos, firetrap.pos)
vector2 = Vector.normalize(vector2)
vector2 = Vector.multiply(vector2, 4)