// You'll need good strategy to win this one!
// Your clone will have the same equipment you have!
// But, they're not very skilled at using special powers.
while (true) {
while (hero.health > hero.health / 4) {
var enemy = hero.findNearestEnemy();
if (enemy && enemy.health > 0) {
if (enemy && hero.isReady("cleave")) {
hero.cleave(enemy);
} else if(hero.isReady("bash")){
hero.bash(enemy);
}
else {
hero.attack(enemy);
}
}
}
}
How do I let my hero run away after it’s health is lower then 100
Do more replayable levels, do some previous levels that u didn’t finish, or jump ahead to the mountains (kind of cheating but u can use codecombat.com/play/level/(level name here) to access any level. This also allows you to bypass the “Restricted Equipment” check.
Dungeon Brawl, Backwoods Brawl, Backwoods Treasure, Sarven Brawl, Sarven Treasure, Sarven Siege, and more. You can play them over and over again. Each time you beat the level, you get more gems and exp but the level gets harder.
About gems see this How to get GEMS, Stuck in Sarven Desert
the while loop you have is some kind of while True loop
If you have 800 health -> 800>200 then 400>100 then… you die
Stuck on Clash of Clones. New day - new problem lol. So I really don’t want to use flags or kill enemies or do an array of teleports, I want to understand why my while loops (with crosses) here don’t work(I know it’s quite lengthy). I also see that the positions and teleports are buggy… Is there a way of beating the level with my idea?
appreciate any help.
hero.moveXY(35, 42);
while (hero.gold < 150) {
var item = hero.findNearestItem();
var enemy = hero.findNearestEnemy();
var cross1 = {
x: 76,
y: 51
};
var cross2 = {
x: 76,
y: 19
};
var cross3 = {
x: 5,
y: 49
};
var cross4 = {
x: 6,
y: 19
};
if (enemy) {
var heroX = hero.pos.x;
var heroY = hero.pos.y;
var enemyX = enemy.pos.x;
var enemyY = enemy.pos.y;
if (enemy && hero.distanceTo(enemy) < 20 && enemyX < heroX && enemyY < heroY) {
while (hero.pos.x !== cross1.x && hero.pos.y!== cross1.y) {
hero.move(cross1);
}
} else if (enemy && hero.distanceTo(enemy) < 20 && enemyX < heroX && enemyY > heroY) {
while (hero.pos.x !== cross2.x && hero.pos.y== cross2.y) {
hero.move(cross2);
}
} else if (enemy && hero.distanceTo(enemy) < 20 && enemyX > heroX && enemyY < heroY) {
while (hero.pos.x !== cross3.x && hero.pos.y!== cross1.y) {
hero.move(cross3);
break;
}
} else if (enemy && hero.distanceTo(enemy) < 20 && enemyX > heroX && enemyY > heroY) {
while (hero.pos.x !== cross4.x && hero.pos.y!== cross4.y) {
hero.move(cross4);
}
}
} else {
hero.say("no enemies");
}
if (item && hero.distanceTo(item) < 10) {
hero.moveXY(item.pos.x, item.pos.y);
}
}
Hi! I am also having issues with this level. I already completed it in Python, but I started to work with JavaScript. I modified the code from the Python code I used the first time I beat the level, but it still gives me an error “Code never finished. It’s either really slow or has an infinite loop.” Any help would be greatly appreciated.
Here’s my code:
var index = 0;
while (true) {
var archers = hero.findByType("archer", hero.findEnemies());
if (index < archers.length) {
while (index < archers.length) {
index += archers;
}
}
var archer = archers[index];
if (archer) {
if (hero.isReady("bash")) {
hero.bash(archer);
} else {
while (archer) {
hero.shield();
if (hero.isReady("bash")) {
hero.bash(archer);
}
}
}
}
}