# New Level- Direction and Magnitude

Please check out this new level here and feedback is appreciated:

Basically, what you need to do is use vector to move your hero around and kill the shamans while you are at it. Then, you need to retreat to the house.

A findEnemy check and attack action will not work, because the yaks count as an enemy.

Enjoy this level and thanks for any feedback/guidance.

Dear @Endercore79,

@steog88,
Aha! Good catch!

Iâ€™ll ask Nick to resrict all glasses with findByType on them. That should fix the problem.

Thanks!
-Endercore79

Solution without vectors
def findShamans():
return [e for e in self.findEnemies() if e.type=="shaman"]

shamans=findShamans()
for e in shamans:
while e.health>0:
self.attack(e)
ix+=1

self.moveXY(68, 32)

This do not give me the victory, however, even if the actions are the expected ones: i kill only ogres, i do not anger yaks and i reach the red cross, but the goals are â€śincompleteâ€ť.
Maybe the configuration of the goals is not correct, since even when i use the vectors i obtain â€śIncompleteâ€ť goals (only the first one, â€śKnock out the shamansâ€ť is completed).

Which is basically every but the most simple glass. I think it would be simpler to use some obstacles (can also be Ice-Yaks, semi-random distributed over the map) which you have to avoid (if magnitude < 10 move directly away)

Code could look like this:
var homePos = new Vector(65, 30); //Just some guessed values where the red x is likely
loop{
var yaks = this.findByType("ice-yak");

var nearYak = this.findNearest(yaks);
if(this.distanceTo(nearYak < 10)){
var dir = Vector.subtract(this.pos, nearYak.pos);
dir = Vector.normalize(dir);
dir = Vector.multiply(dir, 10);
dir = Vector.add(this.pos, dir);
this.move(dir);
}
else{
var shamans = this.findByType("shaman");
if(shamans.length == 0) break;
var nearShaman = this.findNearest(shamans);
if(this.distanceTo(nearShaman) > this.attackRange){
this.move(nearShaman.pos);
}
else{
this.attack(nearShaman);
}
}
}
this.moveXY(homePos.x, homePos.y);

Off topic-ish, but I get a permission error when trying to load the level (I tried this level a while back ago while looking through the levels list):

While that was signed in, attempting to play using other browsers, logged out, other accounts, direct, etc. doesnâ€™t seem to work either.

I tried the level but Iâ€™m not sure why vectors are needed.

Even if findByType was restricted, there are ways to get around that. (differences in enemy health, position, etc.)

Seems like vectors could be more useful if the yaks and shamans were wandering randomly around, such that it becomes necessary to add â€śforceâ€ť vectors to steer away from the yaks and to steer towards the shamans.

Hey everyone,

I fixed the bug with the retreat to home base goal and also scattered the yaks and shamans. Now that this is done you should be able to play the level without all the issues mentioned above. Once again, any feedback would be appreciated and thanks for playing!

-Endercore79

This means that you cannot use higher end glasses at all just disable the command findByType();

Lurkers is also pretty much the same thing

@Feinty,
I based Direction and Magnitude off Lurkers and Skating Away. As for the glasses, I donâ€™t know what Nick can do, but Iâ€™ll ask him.

Thanks for your feedback !

-Endercore79

@Endercore79 Iâ€™m checking out what needs to be done now, but I think it will be easier if you private message me the code you think would solve the level using Vectors. Currently it seems like they wouldnâ€™t be needed, which would make the level a little easy for the Glacier campaign. Also, Iâ€™ll have to make it so that the yaks attack if you get close enough.