Stuck in Stranded in the Dunes

Well, I can honestly say, this level hates my guts, and bug after bug tried to stop me… But I finally made it to the skeleton king… aaand…

No waves spawn, the skeleton king isn’t in the enemy list, and rushes at me straight away. Seeing it doesn’t show up in the array of enemies, I can’t really make my hero ‘run’ from it, or attack it, or anything of the sorts… :confused: What am I supposed to do here?


Here is my script:

var neutralEnemy = {'sand-yak':true, 'raven':true};
var rangedEnemy = {'brittle-skeleton-archer':true, 'archer':true, 'thrower':true, 'shaman':true};
var maxRange = this.attackRange+2;
var moveSpeed = this.maxSpeed;
var bashDamage = 74;

var mapswaps = 0;
var lastDist = 0;
var sameDist = 0;
var triggered = false;
loop {
	
	var enemies = this.findEnemies();
	var selected = null;
	var closest = 999;
	var count = 0;
	var closestNeutral = 20;
	var closeEnemies = 0;
	var closeEnemiesHealth = 0;
	var closestRanger = null;
	var closestRangerDist = 999;
	
	for(var en = 0; en < enemies.length; en++){
		var enemy = enemies[en];
		var distance = this.distanceTo(enemy);
		if(neutralEnemy[enemy.type]){
			if(distance < closestNeutral){
				closestNeutral = distance;
			}
		}else if(enemy.health > 0){
			count++;
			if(distance <= closest){
				selected = enemy;
				closest = distance;
			}
			if(distance < maxRange || rangedEnemy[enemy.type]){
				closeEnemies++;
				closeEnemiesHealth += enemy.health;
				if(rangedEnemy[enemy.type] && distance < closestRangerDist){
					closestRangerDist = distance;
					closestRanger = enemy;
				}
			}
		}
	}
	
	if(count > 0 && selected){
		if(lastDist == closest){
			sameDist++;
		}else{
			sameDist = 0;
			lastDist = closest;
		}
		
		if(this.hasEffect("hide")){
			if(closestRanger && closestRangerDist > maxRange){
				this.move(closestRanger.pos);
			}
		}else{
			if(closest <= maxRange){
				if(selected.health > this.attackDamage){
					if(this.isReady("bash")){
						this.bash(selected);
					}else{
						this.attack(selected);
					}
				}else{
					this.attack(selected);
				}
			}else{
				//this.move(selected.pos);
				if(closestRanger && closestRangerDist > maxRange){
					
					if(this.canCast("invisibility", this)){
						this.cast("invisibility", this);
					}
					
					if(closestRangerDist < maxRange+moveSpeed){
						this.move(closestRanger.pos);
					}else{
						if(this.isReady("jump")){
							this.jumpTo(closestRanger);
						}else{
							this.move(closestRanger.pos);
						}
					}
					
					/*
					if(this.distanceTo(closestRanger) > maxRange){
						if(this.canCast("invisibility", this)){
							this.cast("invisibility", this);
						}
					}
					*/
				}else{
					//this.move(selected.pos);
					if(sameDist > 4){
						this.move(selected.pos);
					}else{
						this.shield();
					}
				}
			}
		}
	}else{
		if(mapswaps < 4){
			var moveTo = {x:this.pos.x+moveSpeed, y:this.pos.y};
			if(moveTo.x >= 118 || this.isPathClear(this.pos, moveTo)){
				this.move(moveTo);
			}else{
				if(this.pos.y > 37){
					moveTo = {x:this.pos.x, y:this.pos.y-moveSpeed};
				}else{
					moveTo = {x:this.pos.x, y:this.pos.y+moveSpeed};
				}
				if(this.isPathClear(this.pos, moveTo)){
					this.move(moveTo);
				}else{
					this.say("I'm stuck...");
					this.wait(5);
				}
			}
		
			//this.wait(0.1);
			if(this.pos.x < 10 && prevX > 100){
				mapswaps++;
				this.jumpTo({x:45, y:36});
			}
			prevX = this.pos.x;
		}else{
			if(triggered){
				this.shield();
				this.say(enemies.length);
			}else{
				if(this.distanceTo({x:60, y:15}) < 1){
					triggered = true;
				}else{
					this.move({x:60, y:15});
				}
			}
		}
	}
}

Duck and cover! Errr… I mean shield… You may also summon some friends to use as a human shield. Oh, and yes, this level is hard.

I almost passed it but the problem is that my hero is not attacking the skeleton king. It is attacking regular skeleton but not the skeleton king. I need help.

Have you tried targeting the king directly?

Yes, and wasn’t possible. the only way I could unglitch the king was to move onto the X to trigger it spawning, then run around the corner and use the invisibility ring (thank god that I bought that) otherwise no waves of skeletons spawned, and the king stayed invincible as the help thing explains. :confused: obviously a bug, as otherwise the level is impossible without the ring… I finished it, but yeh… that level is buggy as hell.

list of bugs;

  • My archer kept shooting at rocks blocking the shot between her and the target even though I used “this.isPathClear(this.pos, target.pos)”.
  • My hero kept walking over mines, even though I checked “isPathClear”.
  • Waves of yaks randomly spawning in the start area.
  • No skeletons spawning in the boss fight.
  • The boss not walking to his designated location, and instead attacking player.
  • The raven getting stuck randomly when I go “invisible” and no longer dropping potions.
  • the level freezing when the raven drops a potion sometimes.
  • I had to swap from using lua to javascript because of memory leaks in the lua scripting that didn’t allow to get past even the second section.
  • and many many more…

The map itself wasn’t as difficult as the ‘scripting around random bugs’ was… My code ended up being 400 lines .___. That whole level wasn’t worth the time and effort needed for it just by the sheer ammount of bugs, crashes, freezes, and frustration.

When does the raven drop a potion on me.

That should happen on the last stage, when you’re fighting the skeleton king and his minions.

But it never did that to me. Anyway thanks.

I keep on making it to the skeleton king but I keep on failing because my hero does not attack him.

MisterInSayne I have a question for you:

What experience level were you when you got the invisibility ring?
Also, what was it called?

Your code is too smart for its own good.
Get a good chest armor and a sword and 4 lines of code.

loop
   find flag
   if flag   move to and pick it up
   find nearest enemy
   if not yak attack it

It solves the level like a charm, Yes it is buggy: it will not attack anyone if a yak is closer to you, does not pick up potions by itself, search for mines, give you flowers, etc …
But does it:
- take 1 minute to write?
- solve the level without headache?

1 Like

I have met this question too.
any one could slove this question?

 var item = hero.findNearestItem();
   function flagmove(){
  while (true) {
      var flag = hero.findFlag();
    
       if(flag && flag.color == "green"){
           hero.moveXY(flag.pos.x, flag.pos.y);
       hero.pickUpFlag(flag);
      }

        if(flag&& flag.color == "black")
        {
        }
        fight();
            
        }
  }

  function fight(){
      while (true) {
            var enemy = hero.findNearestEnemy();
            if(enemy && enemy.type != "sand-yak")
        {   hero.say("fight!");
            hero.attack(enemy);
        }else
        {
            hero.say("no enemy!");
            break;
        }
        if(flagmove()){
            break;
        }
      }

  }
  
    flagmove();
 

when I met S king.hero cant’ attack S king.

At first, you can’t fight the king. After killing a few rounds of his skeleton buddies, you can finally attack the king.


hello.
thank you for reply.
but I am waiting for the plan as you said.
it still stuck in here.
the hero is not attack king.

ok.this way is work!
I try 4 times .and last time king is moving and attack me .
so it is a bug .if anyone met this bug.you can try more time.