[SOLVED] Backwoods Standoff help! First Post

This is my first post. Thank you to whoever helps.

The level Backwoods Standff appears to have changed, so most threads about solutions are no longer relevant.

I’m having an issue that a few people have realized: my hero cleaves and continues to attack during the reset phase, but he still dies. Que paso?

Here is the task and my code.

Munchkins are attacking!

The swarms will come at regular intervals.

Whenever you can, cleave to clear the mass of enemies.

while True:
enemy = hero.findNearestEnemy()
# Use an if-statement with isReady to check “cleave”:
if hero.isReady(“cleave”):
# Cleave!
hero.cleave(enemy)
# Else, if cleave is not ready:
else:
# Attack the nearest ogre!
hero.findNearestEnemy()
hero.attack(enemy)

The second to last line: ***hero.findNearestEnemy(), is probably not necessary, and doesn’t appear to serve a functional difference to the process.

I know people don’t post solutions, but I’d appreciate some help. Maybe I’m supposed to focus on Ogre and not Munchkins?

Anyone???

Thank you!

1 Like

Correct, there is no need for hero.findNearestEnemy() in the second to last line, since you have already defined enemy at the very beginning.

Note: findNearestEnemy is only a function. It will return the nearest enemy, but you must assign it to a variable.

var x = hero.findNearestEnemy()

2 Likes

Also, please format your code with harmonic formatting (put triple backticks in front and finishing on a seperate line of the code).

Endercore

3 Likes

Thank you for the response. In this case is the hero the variable?

I took that line of code out and still failed. Is there anything else evidently wrong?

1 Like

Hero is not a variable. It is an object that represents the character (a.k.a, the guy you control)

Just tested this out on Python. It could be an indentation error. Make sure everything is inside the while loop. Correct indentation would look something like this:

while True:
    enemy = hero.findNearestEnemy()
    if hero.isReady("cleave"):
        hero.cleave(enemy)
    else: 
        hero.attack(enemy)

However, if your code is like this,

while True:
    enemy = hero.findNearestEnemy()
if hero.isReady("cleave"):
    hero.cleave(enemy)
else: 
    hero.attack(enemy)

the program will recognize that hero.findNearestEnemy, is the only line of code inside the while loop and hero.isReady is a whole new line, meaning that everything that comes after enemy = hero.findNearestEnemy() is actually out of the loop.

1 Like

Thanks for the answer. By black ticks do you mean —? or something else?

I’ve removed notes and added hash marks (*) to indicate indentation. * is one; ** is two.

The code still appears written incorrectly. Ideas?

—while True:—
—*enemy = hero.findNearestEnemy()—
—*if hero.isReady(“cleave”):—
—*hero.cleave(enemy)—
else:—
hero.attack(enemy)–

He means these: `

Surround your code with three of them at the start and three at the bottom.

Instead of:

var x = 0;

Your code will look like:

var x = 0

Kind of like:

Triple ticks

–Code–

Triple ticks

This is still a bit confusing. do you mean at the start of every single line of code? Or just the beginning of while true and end of the last line?

Can you give another example?

What I am referring to is the indentation of the code. For example, in this while loop, everything indented is inside the loop, and everything not indented, the program recognizes is not inside the loop. In this case, everything is inside the while loop:

while True:
    enemy = hero.findNearestEnemy()
    if hero.isReady("cleave"):
        hero.cleave(enemy)
    else: 
        hero.attack(enemy)

However, in this case:

while True:
enemy = hero.findNearestEnemy()
if hero.isReady("cleave"):
hero.cleave(enemy)
else: 
hero.attack(enemy)

Nothing is indented, so the program thinks there is nothing inside the while loop. Therefore, your code will not continuously loop.

I understand what you mean by indentation; is the above code incorrectly indented? It appears in my python exactly as yours was written.

The function appears to occur properly; the hero cleaves when appropriate and available, and attacks individual targets when not available.

I still do not understand what is meant by tick-marks: ’

If everything is correctly indented, and the hero performs the task for half the engagement, why does he die at the end?

What I want you to do is paste your code again. Go to the line above where your code starts and put three of these: `, then go to one line below your code and put three more. I’ll show you an example.

your code here

the ‘tick’ marks is simply the key to the left your ‘1’ key. The key directly above tab and below escape.

also, when doing loops, everything within a loop must be indented 4 spaces, or 1 tab length. so this would be correct:

while True:
    thisLineHasFourSpaces.correct()
if noSpaces:
Incorrect.thisWontWork()

Hope this cleared some things up for you!

I did that and it didn’t do anything.

I don’t understand why you posted that “your code here”, and I don’t see what you’re trying to show me with it.

I downloaded whatever that is, but have no idea what to do with it.

Can someone personally contact me to give a solution?

I have no idea why you’re talking about tabs and indentation, mine appears exactly as the, allegedly, correct code above. There is literally nothing different in the code.

var enemy = hero.findNearestEnemy.:grin:

1 Like

How’s this look?

So, I ran the code without the 3 hash tags, so without harmonious formatting, and with them. Neither worked.

Any ideas?

If nothing else, I have to thank everyone in this thread for helping me figure out gyazo.

Thank you for posting about gyazo. Learned something new.

I posted my code already. Any hints?

I’m sorry if I mean to confuse you.

I mean to add the three ticks in the discourse when you post your code, so its easier to read.

Without ticks:

if hero.isReady(“cleave”)

With ticks

if hero.isReady("cleave")

Remove those ticks and you should be able to pass the level

When you want to paste your code into this forum the indentations will get all messed up.

To fix that, you can put three tick marks before your code, then paste your code, then put three more tick marks at the end of your code. Then all of your indentations will be as you had them in the game. This is needed because sometimes the whole problem has to do with how things are indented.

In the game you never use the tick marks.

I just tried your code as you have it but without the tick marks and it is working.

In order to use cleave you do need to equip a weapon with the cleave ability. I think the long sword is the only one.

1 Like

Thank you for the post, and for trying my code to see if it worked.

I’ve run the code and it still isn’t working. The character is getting slightly further and appears to be on the last swarm when he is finally killed.

If the code is wrong, and I’ve tried different browsers and cleared my history and cookies, what can I do to get it to run correctly? Why would it still not be working?

Thanks again.

This level requires you to have solid armor / gear. Before you enter this level, on the world screen, click on the chest icon near the bottom:

From there, select Armor and then click on Warrior to filter the options. You can then buy armor with the gems you get by beating levels.

Here is the armor I used to beat this level (some of the gear is given out for free):

Faux Fur Hat
Leather Belt
Long Sword
Bronze Shield
Tarnished Bronze Breastplate