Hello,
My hero survive, but my friends don’t survive. I don’t know why.
Can you help me please ?
Here my code :
var friends = hero.findFriends();
for(var i = 0 ; i < friends.length ; i++){
var friend = friends[i];
var witch = friend.findNearest(hero.findByType("witch"));
if(friend.type == "paladin"){
if (witch) {
hero.command(friend, "attack", witch);
}
else{
var target = friend.findNearestEnemy();
if (target) {
hero.command(friend, "attack", target);
}
}
}
}
while (hero.pos.x < 69) {
hero.move({'x':69, 'y':15});
}
hero.say("Hi!");
while (hero.pos.x < 37) {
hero.move({'x':37, 'y':16});
}
hero.say("Bye!");
for(var a = 0; a < 3 ; a++){
var enemy = hero.findNearest(hero.findByType("catapult"));
if (enemy) {
hero.attack(enemy);
}
hero.say("Hi!");
while (hero.pos.x > 37) {
hero.move({'x':37, 'y':16});
}
while (hero.pos.x < 78) {
hero.move({'x':78, 'y':14});
}
}