Desert Combat (SOLVED)

i need help with the Desert combat level. i have been with this for over an HOUR! HELP

ordersGiven = 0

while ordersGiven < 5:

# Move down 10 meters.
x = self.pos.x
y = self.pos.y - 10
hero.moveXY(x, y)

# Order your ally to "Attack!" with hero.say
# They can only hear you if you are on the X.
hero.say("Attack!")

# Be sure to increment ordersGiven!

while ordersGiven:

while True:

enemy = hero.findNearestEnemy()
# When you're done giving orders, join the attack.
enemy = hero.findNearestEnemy()
hero.moveXY(57, 31)
if enemy:
    hero.attack(enemy)
if hero.isReady("cleave"):
    hero.cleave(enemy)

Please could you format your code as explained in this article so we can help you
[Essentials] How To Post/Format Your Code Correctly

Thanks,

Jenny

1 Like


if you are wondering what is beyond this here it is

if enemy:

        hero.attack(enemy)
    if hero.isReady("cleave"):
        hero.cleave(enemy)
2 Likes

please help this is my code
code1

Hi CocoCharlie,

Put the line

y = hero.pos.y - 10

inside the while loop so the y variable updates each time the loop runs. Otherwise the x and y stay the same and the hero won’t move.

Jenny

On line 7, try hero.pos.x, hero.pos.y - 10
Also a sword that cleaves is quite helpful on this level when it says “Join the attack”

Oh, I use a gun, so its fine.

moving the x.pos / y.pos down helped thanks!