Sarven Desert - Desert Combat


#1

Hey I need help. I did everything correctly, but it won’t let me pass. My hero keeps on moving y-10 so he keeps attempting to go down and saying “I can’t get there” and “Attack” when he already did that before and all the soldiers already moved in for attack. Here is my code, please tell me what mistakes I need to fix:
// while-loops repeat until the condition is false.

var ordersGiven = 0;
while (ordersGiven<5) {
// Move down 10 meters.

hero.moveXY(10, hero.pos.y-10);
// Order your ally to "Attack!" with hero.say
// They can only hear you if you are on the X.
hero.say("Attack!");
ordersGiven;

}
hero.moveXY(55, 31);
while(true) {
var enemy = hero.findNearestEnemy();
// When you’re done giving orders, join the attack.
if (enemy) {
if (hero.isReady(“cleave”)) {
hero.cleave(enemy);
}
else {
hero.attack(enemy);
}
}
}

Thank you. Please help me I don’t know how others may do it easily while I can’t. I already tried to find the mistake but I can’t.


#2

In your while loop you have your variable ordersGiven but, you never increase its value. Not sure what language you are in so don’t know what shortened method you could use but you can always use:
ordersGiven = ordersGiven+ 1;
all you have is
ordersGiven


#3

Omg it worked! Thank you so much dude!. Just a simple mistake but hard to notice. I’m already able to make my hero out of the infinite loop but I don’t know how to kill the ogre I just end up dying all the time I’ve never faced such an overpowered enemy before. Thank you so much for the information though, I really need it!