// 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
but you lose so many soldiers…
didn’t try but i think you need only paladins and archers, i passed the level with a free hero, without summoning any and without losing any unit.
See Jenny's method - stacking while true loops: Summit Gate? how the level can be divided into several while true loops
I have used the explosion and heal abilities, could you please put that in Javascript?
Should I use the twilight glasses?
This is my new code for heroAction
function heroAction() {
var enemy = hero.findNearestEnemy();
if (enemy) {
hero.attack(enemy);
}
if (hero.canCast("poison-cloud",enemy)) {
hero.cast("poison-cloud", enemy);
}
if (hero.health < 500) {
hero.brew("heal",hero);
}
}
I breach the outer gate but get killed shortly after. @xython
I never played with this hero and till now i have negative feelings about his “new” abilities. Using “brew” Omarn is attacked by his wolf. I think this was supposed to happen only when skeletons are summoned. Not a fan of stacking ifs and your main goal is to stay alive. Your function can be modified to
function heroAction() {
var enemy = hero.findNearestEnemy();
if (hero.health < 500)
hero.brew("heal",hero);
else if (enemy) {
if (hero.canCast("poison-cloud",enemy))
hero.cast("poison-cloud", enemy);
else
hero.attack(enemy);
}
}
but using the above function you will die being too close to towers
so used only attack with Vine Staff ( you can equip also the Lightning Twig ( i’m a big fan of it) but it will be slower. I also modified all minion’s attack functions. They don’t need to attack the enemies when their positions are in the second battlefield.
function heroAction() {
var enemy = hero.findNearestEnemy();
if (hero.health < hero.maxHealth && hero.isReady("brew")) // only for testing
hero.brew("heal",hero); // you really don't need it
else if (enemy)
hero.attack(enemy);
}
function commandSoldier(soldier) {
var enemy = soldier.findNearestEnemy();
if (enemy && enemy.pos.x < 100){
// code
}
}
You can debug your code more successfully, find the Ids, health, positions and their relations with a specific array, find mistakes. Something like this is shown here: HELP Kelvintaph Crusader - #70 by xython (sorry - python )
Hi @xython
Sorry for the late reply, I figured out how to use the while-loops and break to make sections.
// 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 && enemy.pos.x < 100) {
hero.command(archer, "attack", enemy);
}
if (archer.health < 10) {
hero.brew("heal", archer);
}
}
function commandPaladin(paladin) {
hero.command(paladin, "shield");
}
function commandGriffin(griffin) {
var enemy = hero.findNearestEnemy();
if (enemy && enemy.pos.x < 120) {
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 (hero.health < 500) {
hero.brew("heal", hero);
} else if (enemy && hero.distanceTo(enemy) < 45) {
hero.attack(enemy);
} else {
var attack = null;
}
}
while (true) {
var friends = hero.findFriends();
var enemy = hero.findNearestEnemy();
if (enemy.type == "tower") {
break;
} else {
summonUnits();
commandUnits(friends);
heroAction();
}
}
var indexer2 = 0;
while (indexer2<1) {
var enemy = hero.findNearestEnemy();
var paladins = hero.findByType("paladin");
var paladin1 = paladins[0];
var palaldin2 = paladins[1];
if (enemy.pos.y >39) {
hero.moveXY(enemy.pos.x, enemy.pos.y + 5);
hero.command(paladin1, "move", {x:hero.pos.x,y:hero.pos.y + 5});
if (paladin1.pos.x < hero.pos.x) {
hero.brew("heal",hero);
}
else {
indexer2 = 1;
}
}
}
while(true) {
var enemy = hero.findNearestEnemy();
var paladins = hero.findByType("paladin");
var paladin1 = paladins[0];
var palaldin2 = paladins[1];
hero.attack(enemy);
if (paladin1.canCast("heal")) {
hero.command(paladin1, "cast", "heal",hero);
}
}
This is my current code. The hero moves to the beam tower but the paladin takes a long time to move and continues shielding after the hero starts moving.
Thanks