Desert Combat - What am I missing?


#1

What are the say-able commands to the troops for this level?

It would be nice to have those listed in the comments.

All I see so far is:

// while-loops repeat until the condition is false.
// Always take an action inside a while loop, or it'll go infinite!
var ordersGiven = 0;
while (ordersGiven < 5) {
    // Move and order each of your allies into battle.
    this.say("Move!");
    
    
    
}
// When you're done giving orders, join the attack.

#2

I’m at the same lvl , i killed the ogre but get killed too and i don’t want to buy new items lol ,gona find a solution , anyway a while loop isn’t like if loop, while loop gona stop if condition is false

now tell your allies to attack , each time you tell one of your solider to attack make ordergiven as +1 , it’s the same as the previous lvls like coins and decoy , once your order given = 5 , join the raid ( attack with allies )


#3

I can’t even get the ogre to appear. I know what I need to do overall, but I don’t know what commands I can give the soldiers to make them move. What are you telling the troops to get them to move to the “x”'s?


#4

It’s " Attack" by default Oo , don’t forget the zoom , use the middle button of your mouse to zoom ( the scroller )


#5

Uh…I just keep yelling attack and my soldier’s just sit there. LOL.


#6

Sorry i typed " attack" instead of “Attack!”


#7

The zoom out did help. But my soldier’s…I still don’t know how to command them. =P


#8

I guess the reload button would help alot lol xD


#9

Ahh…gotta go do real life stuff. =P

Just saw: Commanding your troops - Will see if they will take those commands when I get home.

Thanks!


#10

Move yourself to the x spot, then tell them to attack.


#11

LOL when i saw he’s post ,

"I can't even get the ogre to appear. I know what I need to do overall, but I don't know what commands I can give the soldiers to make them move. What are you telling the troops to get them to move to the "x"'s?
"

i tough he already moved to the X , didn’t focused on the last words


#12

Thanks. I never would have thought of that. A general orders the attack by shouting…not moving and then ordering. LOL


#13

What’s wrong with my while-loop here?

ordersGiven = 0
while ordersGiven < 5:
    # Move and order each of your allies into battle.
    x = self.pos.x
    y = self.pos.y - 10
    self.moveXY(x, y)
    self.say("Attack!")
    ordersGiven = ordersGiven + 1

My hero moves to the first soldier and tells him to attack, and then thinks that ordersGiven > 5 and decides to attack (and promptly die). The issue seems to be with the line ordersGiven = ordersGiven + 1, but that’s the same structure I used in Decoy Drill, and it worked there. Any help would be greatly appreciated!


#14

That looks good to me… could you post the rest of your code?


#15

When I have the code like this:

# while-loops repeat until the condition is false.
# Always take an action inside a while loop, or it'll go infinite!
ordersGiven = 0
while ordersGiven < 5:
    # Move and order each of your allies into battle.
    x = self.pos.x
    y = self.pos.y - 10
    self.moveXY(x, y)
    self.say("Attack!")
    ordersGiven = ordersGiven + 1
    
# When you're done giving orders, join the attack.
    enemy = self.findNearestEnemy()
    loop:
        if enemy:
            if self.isReady("cleave"):
                self.cleave(enemy)
            else:
                self.attack(enemy)
        else:
            pass

my hero decides to command my soldier and then go attack the ogre. When I move the enemy = self.findNearestEnemy() to before the while loop (from in the middle) my hero commands the one soldier and stays where he is (the following code).

# Always take an action inside a while loop, or it'll go infinite!
ordersGiven = 0
enemy = self.findNearestEnemy()
while ordersGiven < 5:
    # Move and order each of your allies into battle.
    x = self.pos.x
    y = self.pos.y - 10
    self.moveXY(x, y)
    self.say("Attack!")
    ordersGiven = ordersGiven + 1
    
# When you're done giving orders, join the attack.
    
    loop:
        if enemy:
            if self.isReady("cleave"):
                self.cleave(enemy)
            else:
                self.attack(enemy)
        else:
            pass

#16

Aha… when you are finished with the while loop, move your indenting back to the same level as the while loop: example:

ordersGiven = 0
while ordersGiven < 5:
    # Move and order each of your allies into battle.
    x = self.pos.x
    y = self.pos.y - 10
    self.moveXY(x, y)
    self.say("Attack!")
    ordersGiven = ordersGiven + 1
self.say("I am ready to run more code!")

The code on the same indent level will run once the while loop is complete.


#17

Well, that fixed one problem! Now my hero commands the soldiers, and then decides to stand there and die. How powerful must your hero be to finish the level?


#18

He shouldn’t be just sitting there… repost new code for me?


#19

It was because of the enemy = self.findNearestEnemy() was only after if enemy, so my hero would never attack.I still die because my hero isn’t strong enough, though.


#20

Well… better equipment of course, or maybe you could add flags and retreat a bit so your allies do more of the fighting. Perhaps you could try using a new tactic (shield perhaps).