// 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) {
var potion = hero.findFriendlyMissiles()[0];
var firetraps = hero.findNearest(hero.findHazards());
// Remember that a Fire Trap will trigger if you move closer than 3 meters!
var omarn = hero.findByType("potion-master")[0];
if (potion) {
var dest = new Vector(potion.Targetpos);
// Go get the potion.
var potion = Vector.subtract(dest, hero.pos);
potion = Vector.normalize(potion);
potion = Vector.multiply(potion, 5);
if (hero.distanceTo(firetraps) < 3) {
var mineVec = Vector.subtract(hero.pos, firetraps.pos);
mineVec = Vector.normalize(mineVec);
mineVec = Vector.multiply(mineVec, 3);
potion = Vector.add(potion, mineVec);
}
var moveToPos = Vector.add(hero.pos, potion);
hero.move(moveToPos); // Warning: isPathClear doesn't work with Hazards!
} else {
if (omarn && hero.distanceTo(omarn) > 10) {
// Move back to Omarn.
hero.move(omarn.pos);
} else {
hero.say("Hup, hup!");
}
}
}
The code seems to move my character to the negatives, however I don’t understand why. When debugging it by saying what potion was, it kept on saying negative x and y coordinates