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?
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.
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…
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. ;-;
What language? Python?
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.
I do not have the action “cleave”. Is there a specific item I need that is not being indicated by any arrows?
It sounds like a bug. Do you have the Long Sword? If not, try doing Ogre Encampment again so you can get it.
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.
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.
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!
enemy = self.findNearestEnemy()
# Cleave the enemy!
else: # Else (if cleave isn't ready), do your normal attack. self.attack(enemy)
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?
I figured out the level from a different post. Thanks for the concern!
Stuck. Tried many times and still says failing. I have the right sword. Watched video and copied code exactly.
enemy = self.findNearestEnemy()
Huh. Have you tried resubmitting? Every submission gives a new random seed, so it might change the way events play out.
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
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.
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
Still stuck. I tried the code and it won’t work. Can I have a plain code anyone?