[SOLVED] Am stuck at Siege of Stonehold

I’m stuck at this level, even though I have 730 health and a 28 DPS. Please help.
This is my kinda crappy code:

while True:
    enemy = hero.findNearestEnemy()
    flag = hero.findFlag("green")
    if enemy and hero.isReady("cleave"):
        hero.cleave(enemy)
    elif flag:
        hero.moveXY(19, 69)
        hero.moveXY(53, 69)
    elif enemy:
        hero.attack(enemy)

(Python) (has been edited)
Does anyone have a working code I can use or some help for me?

Before any one can help you, you need to format your code properly, otherwise it is all the same line, and you can’t see the indentation. To format your code you should click on the button on the top which looks like this </>. Then this should appear on your screen.
09
copy all your code into where it says, type or paste code here. Otherwise the code is not formatted properly is impossible to read.

2 Likes

Your code,

while True:
    enemy = hero.findNearestEnemy()
    flag = hero.findFlag(“green”)
    if enemy and hero.isReady(“cleave”):
        hero.cleave(enemy)
    elif flag:
        hero.moveXY(19, 69)
        hero.moveXY(53, 69)
    elif enemy:
        hero.attack(enemy)

I think it’s to do with your flags, if you don’t hero.pickUpFlag() in the elif flag: then the flag will stay there and you won’t be able to put down another one. Instead you could use hero.pickUpFlag() and you would remove the flag and move to the location of the flag. Also maybe instead of elif enemy: you could say,

else:
    if enemy:
        hero.attack(enemy)

maybe, I think it goes a bit weird if you have 2 elifs after each other.
Hope this helps :grin:

Thanks, I’m going to try that.

Well I tried it and it worked. Tysm

1 Like

So it’s solved? (20)

yeah it is solved :slight_smile:

hi

[en_US.composer.my_button_text]

If you need help with your code, can you post it formated as it is described below?

Andrei

hi

[en_US.composer.my_button_text]

Did you mean to send that again? If you’re just saying hi, then… Hi!
If you could avoid posting in old topics that would be good. This one is 2 years old. Why not post in a more recent topic that’s supposed to be for non-codecombat related talk. Check out this topic:

Danny

1 Like

can you help me out tommorow on codecombat

So you do need help… Why specifically tomorrow?

1 Like

i dont have time to play

1 Like

Ok, well maybe just wait until you can and then post. There’s not that much point posting you’re going to post is there? :smile:
It just saves a few posts if you don’t.
Danny

1 Like