Desert Combat - What am I missing?

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

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

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

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

I guess the reload button would help alot lol xD

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!

1 Like

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

2 Likes

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

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

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!

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

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

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.

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?

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

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.

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

I ended up just letting my troops do most of the fighting when my health got too low … worked ok after getting better armor

1 Like

I have no idea what to do why my hero doesn’t attack.
Can someone please point out what’s wrong with my code?

loop:
    if ordersGiven >= 5:
        self.moveXY(52, 29)
    if enemy:
        self.attack(enemy)
    else:
        self.isReady("cleave")
        self.cleave(enemy)

Look at the previous post in this thread

note : you have used if instead if while , you haven’t told your friends to attack

1 Like