// This level is supposed to be VERY hard! You may need a great strategy and or gear to complete it!
// Find and defeat the yeti then gather its essence for the ritual.
// You might want to gather the coins the yeti leaves behind, you'll need them to summon an army
// Stand at the summoning stone (red x) to begin summoning
// Now you just have to survive the undead hoard
function attack(enemy) {
if (hero.isReady("bash")) {
hero.bash(enemy);
}
if (hero.canCast("chain-lightning", enemy)) {
hero.cast("chain-lightning", enemy);
}
else {
hero.attack(enemy);
}
}
function collect() {
var item = hero.findNearestItem();
if (item) {
moveTo(item.pos);
}
}
function summon() {
if (hero.gold >= hero.costOf("soldier")) {
hero.summon("soldier");
}
}
function command() {
var enemy = hero.findNearestEnemy();
var friends = hero.findFriends();
for (var i = 0; i < friends.length; i ++) {
if (enemy) {
hero.command(friend, "defend", hero);
}
}
}
function moveTo(position) {
if (hero.isReady("jump")) {
hero.jumpTo(position);
}
else {
hero.move(position);
}
}
moveTo({'x': 56, 'y': 12});
while(true) {
var enemy = hero.findNearestEnemy();
if (enemy) {
attack(enemy);
}
collect();
}
moveTo({'x': 19, 'y': 39});
while (enemy.health > 0) {
var enemy = hero.findNearestEnemy();
attack(enemy);
}
collect();
moveTo({'x': 19, 'y': 40});
while(true) {
summon();
command();
}
the hero is trying to reach the coin, he can’t reach and causing a timeout, please how to fix it?
// This level is supposed to be VERY hard! You may need a great strategy and or gear to complete it!
// Find and defeat the yeti then gather its essence for the ritual.
// You might want to gather the coins the yeti leaves behind, you'll need them to summon an army
// Stand at the summoning stone (red x) to begin summoning
// Now you just have to survive the undead hoard
function attack(enemy) {
if (hero.isReady("bash")) {
hero.bash(enemy);
}
if (hero.canCast("chain-lightning", enemy)) {
hero.cast("chain-lightning", enemy);
}
else {
hero.attack(enemy);
}
}
function collect() {
var item = hero.findNearestItem();
if (item) {
moveTo(item.pos);
}
}
function summon() {
if (hero.gold >= hero.costOf("soldier")) {
hero.summon("soldier");
}
}
function command() {
var enemy = hero.findNearestEnemy();
var friends = hero.findFriends();
for (var i = 0; i < friends.length; i ++) {
var friend = friends[i];
if (enemy) {
hero.command(friend, "defend", hero);
}
}
}
function moveTo(position) {
if (hero.isReady("jump")) {
hero.jumpTo(position);
}
else {
hero.moveTo(position);
}
}
var enemies = hero.findEnemies();
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
while (enemy.health > 0) {
attack(enemy);
}
}
collect();
hero.moveXY(19, 40);
while(true) {
summon();
command();
}
you didn’t put this in the while true loop. this would only run once in the beginning and that would be it. you should also put the collect function in the loop for it to constantly search for the gold
yes but the for loop runs once, once the level starts, it checks for enemies, which returns 0 indexes, so no enemy, so it doesn’t attack, and then the for loop finishes
// This level is supposed to be VERY hard! You may need a great strategy and or gear to complete it!
// Find and defeat the yeti then gather its essence for the ritual.
// You might want to gather the coins the yeti leaves behind, you'll need them to summon an army
// Stand at the summoning stone (red x) to begin summoning
// Now you just have to survive the undead hoard
function attack(enemy) {
if (hero.isReady("bash")) {
hero.bash(enemy);
}
if (hero.canCast("chain-lightning", enemy)) {
hero.cast("chain-lightning", enemy);
}
else {
hero.attack(enemy);
}
}
function collect() {
var item = hero.findNearestItem();
if (item) {
moveTo(item.pos);
}
}
function summon() {
if (hero.gold >= hero.costOf("soldier")) {
hero.summon("soldier");
}
}
function command() {
var enemy = hero.findNearestEnemy();
var friends = hero.findFriends();
for (var i = 0; i < friends.length; i ++) {
var friend = friends[i];
if (enemy) {
hero.command(friend, "defend", hero);
}
}
}
function moveTo(position) {
if (hero.isReady("jump")) {
hero.jumpTo(position);
}
else {
hero.moveTo(position);
}
}
hero.moveXY(57, 23);
while(true) {
var enemies = hero.findEnemies();
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
while (enemy.health > 0) {
attack(enemy);
}
}
collect();
}
hero.moveXY(19, 40);
while(true) {
summon();
command();
}
when i tried running the code, it arised the error of this line
make it as i told you, hero.moveXY(position.pos.x, position.pos.y)
also, put everything inside the function in an if statement to check if the item exists
// This level is supposed to be VERY hard! You may need a great strategy and or gear to complete it!
// Find and defeat the yeti then gather its essence for the ritual.
// You might want to gather the coins the yeti leaves behind, you'll need them to summon an army
// Stand at the summoning stone (red x) to begin summoning
// Now you just have to survive the undead hoard
function attack(enemy) {
if (hero.isReady("bash")) {
hero.bash(enemy);
}
if (hero.canCast("chain-lightning", enemy)) {
hero.cast("chain-lightning", enemy);
}
else {
hero.attack(enemy);
}
}
function collect() {
var item = hero.findNearestItem();
if (item) {
moveTo(item.pos);
}
}
function summon() {
if (hero.gold >= hero.costOf("soldier")) {
hero.summon("soldier");
}
}
function command() {
var enemy = hero.findNearestEnemy();
var friends = hero.findFriends();
for (var i = 0; i < friends.length; i ++) {
var friend = friends[i];
if (enemy) {
hero.command(friend, "defend", hero);
}
}
}
function moveTo(position) {
if (hero.isReady("jump")) {
hero.jumpTo(position);
}
else {
hero.moveXY(position.x, position.y);
}
}
hero.moveXY(57, 23);
while(true) {
var enemies = hero.findEnemies();
for (var i = 0; i < enemies.length; i++) {
var enemy = enemies[i];
while (enemy.health > 0) {
attack(enemy);
}
}
collect();
}
hero.moveXY(19, 40);
while(true) {
summon();
command();
}