Level: Woodland Cleaver

This is the first time we introduce players to object properties, although we’re still keeping the data type of the property homogenous (we’ll mix it up in a few levels). Does this gel with the progression?

3 Likes

Too easy

Way too easy,just had to add 1 line of code to make it work.

I think what would be a good idea is if we could use cleave very intelligently, i.e using it only when there are like 5 or more enemies attacking the Hero. That would be more challenging rather than just using cleave when its ready.

2 Likes

Ah, did you just add an attack instead of using the else-branch? The hope was to get the player practicing else, but now I see that it’s not needed. I wonder what we could do here to make the else necessary…

3 Likes

Too hard! I can’t beat the level, loop isn’t working, and I die no matter what I try.

My code so far:

self.moveXY(24, 9)
enemy = self.findNearestEnemy()
self.cleave(enemy)
self.isReady("cleave") and self.distanceTo (enemy)<10
enemy =self.findNearestEnemy()
self.attack(enemy)
enemy=self.findNearestEnemy()
self.cleave(enemy)
loop:    
    enemy = self.findNearestEnemy()
    self.attack(enemy)
    self.attack(enemy)
    self.attack(enemy)
    enemy=self.findNearestEnemy()
    self.cleave(enemy)

BECAUSE LOOP WON’T WORK. ;-;

2 Likes

What language? Python?

2 Likes

Put all of your code inside the loop statement (by putting loop: at the top and indenting the other code below).

Inside the loop, you should just need to find the nearest enemy, then use if/else statement: if cleave is ready, then cleave the enemy, else attack the enemy.

Hope this helps.

2 Likes

I do not have the action “cleave”. Is there a specific item I need that is not being indicated by any arrows?

2 Likes

It sounds like a bug. Do you have the Long Sword? If not, try doing Ogre Encampment again so you can get it.

2 Likes

I can’t beat the level as well. I don’t what’s wrong.
It says "you don’t have action “cleave”, also I don’t know how to use it.

2 Likes

You need to make sure you have equipped the Long Sword for this level to give yourself the cleave method. After that, read the sample code and the cleave documentation to see how to do it.

2 Likes

Hello guys, im new to coding, but this is what i have as the code, its very simple, just add in 2 lines of code!

self.moveXY(23, 23)
loop:
enemy = self.findNearestEnemy()
if self.isReady(“cleave”):
self.cleave(enemy)
# Cleave the enemy!

else:
    # Else (if cleave isn't ready), do your normal attack.
    self.attack(enemy)
2 Likes

@SJ7Gaming i tried this. it keeps getting the line up error. i need help.

2 Likes

Possible Parsing Bug (Python):

loop:
    if self.findNearestEnemy():
        if self.isReady("cleave"):
            self.cleave(self.findNearestEnemy())
        else:
            self.attack(self.findNearestEnemy())

The above code should work, shouldn’t it?

2 Likes

I figured out the level from a different post. Thanks for the concern! :smile:

2 Likes

Stuck. Tried many times and still says failing. I have the right sword. Watched video and copied code exactly.
loop:
enemy = self.findNearestEnemy()
if self.isReady(“cleave”):
self.cleave(enemy)

else:
    self.attack(enemy)
2 Likes

Huh. Have you tried resubmitting? Every submission gives a new random seed, so it might change the way events play out.

2 Likes

I don’t get it. After trying about 20 times from copying the code from the videos verbatim to re-writing the code over and over, the loop is still not working. It skips over the “cleave” steps and my hero gets slaughter.

After a week of trying and failing to pass this level, I tried contacting the webmasters and have yet to receive a response. There’s only so much I can do before walking away from an otherwise great game.

Please help :-(.
Frustrated in California

2 Likes

Dear CodeCombat1,

we as community can not see your communication with the webmasters. As such we can not know what your current code is.

If you want to receive help from us you have to post your post here in radiant, harmonious formatting as described in the FAQ.


More often than not the error is just a missing double-colon or something like this. Do you get any error-message? This would help us extremely to help you.

2 Likes

Thank you J_F_B_M:

I was able to figure out what went wrong later on by reading this thread. It turned out that I was using the wrong sword the entire time. Didn’t know that swords each have different capabilities, so I’m learning. Thank you so much everyone for all your help! The posts has been very helpful :smile:

2 Likes

Still stuck. I tried the code and it won’t work. Can I have a plain code anyone? :fearful:

2 Likes