Ok I need help now
Code
// The ogres are trapping you with their dark rituals!
// Your hero can't do anything besides command and move without angering the warlocks.
// Beware ice, robots, traps, antigravity fields, and other dark magic.
// Somehow, you'll need to defeat Nalfar and save your paladin.
// The great treasure of Kelvintaph awaits your victory.
function heal() {
var paladin = hero.findNearest(hero.findByType("paladin"));
if (paladin.canCast("heal", paladin)) {
hero.command(paladin, "cast", "heal", paladin);
}
}
function command() {
var paladin = hero.findNearest(hero.findByType("paladin"));
var friends = hero.findFriends();
for (var friendIndex = 0; friendIndex < friends.length; friendIndex++) {
var friend = friends[friendIndex];
if (friend.type == "paladin") {
var enemy = friend.findNearestEnemy();
if (enemy) {
hero.command(friend, "shield", friend);
}
if (friend.health < 500) {
heal();
}
}
if (friend.type == "soldier") {
enemy = friend.findNearestEnemy();
if (enemy) {
hero.command(friend, "attack", enemy);
}
if (!enemy) {
hero.command(friend, "move", {
"x": 82,
"y": 72
});
}
}
if (friend.type == "archer") {
enemy = friend.findNearestEnemy();
if (enemy) {
hero.command(friend, "attack", enemy);
}
if (!enemy) {
hero.command(friend, "move", {
"x": 23,
"y": 40
});
}
}
}
}
hero.moveXY(33, 8);
while (true) {
command();
}