// Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
function summonUnits() {
if (hero.gold >= hero.costOf("griffin-rider")) {
hero.summon("griffin-rider");
} else {
var summonable = null;
}
}
function commandUnits(friends) {
for (var i = 0; i < friends.length; i++) {
var friend = friends[i];
if (friend.type == "paladin") {
commandPaladin(friend);
} else if (friend.type == "archer") {
commandArcher(friend);
} else if (friend.type == "griffin-rider") {
commandGriffin(friend);
} else if (friend.type == "soldier") {
commandSoldier(friend);
} else {
var commandable = null;
}
}
}
function commandArcher(archer) {
var enemy = archer.findNearestEnemy();
if (enemy) {
hero.command(archer, "attack", enemy);
}
if (archer.health < 10) {
hero.brew("heal", archer);
}
}
function commandPaladin(paladin) {
var enemy = paladin.findNearestEnemy();
if (paladin.health < 100) {
if (paladin.canCast("heal")) {
hero.command(paladin, "cast", "heal", paladin);
} else {
hero.command(paladin, "shield");
}
} else {
hero.command(paladin, "attack", enemy);
}
}
function commandGriffin(griffin) {
var enemy = griffin.findNearestEnemy();
if (enemy) {
hero.command(griffin, "attack", enemy);
}
if (griffin.health < 50) {
hero.brew("heal", griffin);
}
}
function commandSoldier(soldier) {
var enemy = soldier.findNearestEnemy();
if (enemy && enemy.type == "catapult") {
hero.command(soldier, "attack", enemy);
} else {
hero.command(soldier, "move", {
x: soldier.pos.x + 5,
y: soldier.pos.y
});
}
var catapults = hero.findByType("catapult");
for (var i = 0; i < catapults.length; i++) {
var catapult = catapults[i];
if (catapult.health <= 0) {
hero.command(soldier, "attack", enemy);
}
}
}
function heroAction() {
var enemy = hero.findNearestEnemy();
if (enemy.type == "tower") {
if (hero.distanceTo("enemy" > 29)) {
hero.moveXY(enemy.pos.x - 29, hero.pos.y);
} else if (hero.canCast("disintegrate", enemy)) {
hero.cast("disintegrate", enemy);
} else {
hero.attack(enemy);
}
}
}
while (true) {
var friends = hero.findFriends();
summonUnits();
commandUnits(friends);
heroAction();
}
I breach the outer gate, however the hero does not disintegrate or move toward the beam towers. I have enchanted lenses. What do I do to fix this? (No error) I might need help in future parts of summits gate.
Thanks