solved you problems but used chain lightning
var enemies = hero.findEnemies();
if(!enemies){ // will be always false - find why
// code
}
if(f.pos.x != 50) { // this will never work, find in the forum why
hero.command(f, "move", {x: 48, y: 58});
hero.command(f, "move", {x: 78, y: 40});
}
see how you can move with move() and command minions [Solved] Chained statements like .moveXY() and behavior override each other?
The level is working in a random javascript session taken from the leaderboard:
Corrections made to the original code:
// code
function commandPaladin() {
// original code
else {
var f = findWeakestFriend();
if(f && f.type != "archer" && paladin.canCast("heal", f))
hero.command(paladin, "cast", "heal", f);
else
hero.command(paladin, "shield"); // shield if paladin cannot heal
}
// original code
var points = [{x: 35, y: 15}, {x: 20, y: 14}, {x: 68, y: 14}, {x: 45, y: 14}, {x: 78, y: 14}];
hero.cast("chain-lightning", hero.findNearestEnemy());
for(var i = 0; i < points.length; i++) {
// original code
}
while(true) {
// original code
var enemies = hero.findEnemies();
if( !enemies.length ) break; // enemies.length will be 0 if enemies is empty
// you can insert the code for moving minions here or
// call previously created function moveMinions()
}
// Instead of putting the moveMinions code in the above loop
// you can put the code in a new and last while true loop
// i call this Jenny's method
while(true) {
var friends = hero.findFriends();
for(var i = 0; i < friends.length; i++) {
var f = friends[i];
// i don't think this is the best way to move minions
// but it's closer to your original approach
if(f.pos. x < 60)
hero.command(f, "move", {x: 60, y: 39});
else if(f.pos. x > 50)
hero.command(f, "move", {x: 78, y: 39});
}
}
the result:
You can improve the hero’s code. He/she barely survives. It can be done with no armor :