Stuck in Stranded in the Dunes


#1

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});
				}
			}
		}
	}
}

#2

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.


#3

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.


#4

Have you tried targeting the king directly?


#5

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.


#6

When does the raven drop a potion on me.


#7

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


#8

But it never did that to me. Anyway thanks.


#9

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


#10

MisterInSayne I have a question for you:

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


#11

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?