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.
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);
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.
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 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.