# Desert Combat - What am I missing?

**URL:** https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152
**Category:** Adventurer
**Created:** [January 1, 2015, 12:27am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152 "2015-01-01T00:27:29Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![tjchan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tjchan/32/1817_2.png) [@tjchan](https://discourse.codecombat.com/u/tjchan)
#### Post date: [January 1, 2015, 12:27am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/1 "2015-01-01T00:27:29Z")

</div>

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.
```

---

<div class="post-metadata">

### Author: ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)
#### Post date: [January 1, 2015, 12:37am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/2 "2015-01-01T00:37:34Z")

</div>

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 )

---

<div class="post-metadata">

### Author: ![tjchan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tjchan/32/1817_2.png) [@tjchan](https://discourse.codecombat.com/u/tjchan)
#### Post date: [January 1, 2015, 12:39am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/3 "2015-01-01T00:39:48Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)
#### Post date: [January 1, 2015, 12:43am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/4 "2015-01-01T00:43:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tjchan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tjchan/32/1817_2.png) [@tjchan](https://discourse.codecombat.com/u/tjchan)
#### Post date: [January 1, 2015, 12:45am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/5 "2015-01-01T00:45:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)
#### Post date: [January 1, 2015, 12:46am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/6 "2015-01-01T00:46:47Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tjchan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tjchan/32/1817_2.png) [@tjchan](https://discourse.codecombat.com/u/tjchan)
#### Post date: [January 1, 2015, 12:47am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/7 "2015-01-01T00:47:26Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)
#### Post date: [January 1, 2015, 12:48am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/8 "2015-01-01T00:48:02Z")

</div>

I guess the reload button would help alot lol xD

---

<div class="post-metadata">

### Author: ![tjchan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tjchan/32/1817_2.png) [@tjchan](https://discourse.codecombat.com/u/tjchan)
#### Post date: [January 1, 2015, 12:48am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/9 "2015-01-01T00:48:52Z")

</div>

Ahh…gotta go do real life stuff. =P

Just saw: [Commanding your troops](http://discourse.codecombat.com/t/commanding-your-troops/623/2) - Will see if they will take those commands when I get home.

Thanks!

---

<div class="post-metadata">

### Author: ![BunchofCrooks](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bunchofcrooks/32/2113_2.png) [@BunchofCrooks](https://discourse.codecombat.com/u/BunchofCrooks)
#### Post date: [January 1, 2015, 12:49am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/10 "2015-01-01T00:49:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ReFinig](https://avatars.discourse-cdn.com/v4/letter/r/8e7dd6/32.png) [@ReFinig](https://discourse.codecombat.com/u/ReFinig)
#### Post date: [January 1, 2015, 12:52am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/11 "2015-01-01T00:52:22Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tjchan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/tjchan/32/1817_2.png) [@tjchan](https://discourse.codecombat.com/u/tjchan)
#### Post date: [January 1, 2015, 12:52am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/12 "2015-01-01T00:52:59Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ashwinranade99](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ashwinranade99](https://discourse.codecombat.com/u/ashwinranade99)
#### Post date: [January 1, 2015, 1:18am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/13 "2015-01-01T01:18:11Z")

</div>

What’s wrong with my while-loop here?

```python
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!

---

<div class="post-metadata">

### Author: ![BunchofCrooks](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bunchofcrooks/32/2113_2.png) [@BunchofCrooks](https://discourse.codecombat.com/u/BunchofCrooks)
#### Post date: [January 1, 2015, 1:22am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/14 "2015-01-01T01:22:16Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ashwinranade99](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ashwinranade99](https://discourse.codecombat.com/u/ashwinranade99)
#### Post date: [January 1, 2015, 1:25am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/15 "2015-01-01T01:25:23Z")

</div>

When I have the code like this:

```python
# 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).

```python
# 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

```

---

<div class="post-metadata">

### Author: ![BunchofCrooks](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bunchofcrooks/32/2113_2.png) [@BunchofCrooks](https://discourse.codecombat.com/u/BunchofCrooks)
#### Post date: [January 1, 2015, 1:29am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/16 "2015-01-01T01:29:17Z")

</div>

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

```python
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.

---

<div class="post-metadata">

### Author: ![ashwinranade99](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ashwinranade99](https://discourse.codecombat.com/u/ashwinranade99)
#### Post date: [January 1, 2015, 1:31am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/17 "2015-01-01T01:31:26Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![BunchofCrooks](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bunchofcrooks/32/2113_2.png) [@BunchofCrooks](https://discourse.codecombat.com/u/BunchofCrooks)
#### Post date: [January 1, 2015, 1:34am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/18 "2015-01-01T01:34:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ashwinranade99](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@ashwinranade99](https://discourse.codecombat.com/u/ashwinranade99)
#### Post date: [January 1, 2015, 1:37am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/19 "2015-01-01T01:37:01Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![BunchofCrooks](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/bunchofcrooks/32/2113_2.png) [@BunchofCrooks](https://discourse.codecombat.com/u/BunchofCrooks)
#### Post date: [January 1, 2015, 1:40am UTC](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152/20 "2015-01-01T01:40:30Z")

</div>

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).

[Next page](https://discourse.codecombat.com/t/desert-combat-what-am-i-missing/2152.md?page=2)
