I’m having a problem with Sarven Shepherd level, as it’s throwing me a infinite loop error and the character just stands still. I think it’s because it is looping on the first Yak… and I’m not sure how to remedy this.
while(enemyIndex < enemies.length) {
var enemy = enemies[enemyIndex];
if (enemy.type != "sand-yak") {
while(enemy.heath > 0) { // If I comment this
hero.attack(enemy);
} // & this, it works..
}
enemyIndex++;
}
But when I remove while(enemy.heath > 0)
and the curly brackets around attack, it seems to run fine, abit kind of funky as they hit the enemies a few times and run back to the X, etc. 761 health doesn’t seem to be enough health for this level.
I tried looking at other similar threads, but they don’t seem to help with the looping, and I dunno how I feel about necroing an old thread.