Pesant Protection help

i need help to pass the peasant protection i would like if someone would help me.:smile::smile:

Would you like to post up the code you’ve tried, and we’ll go from there.

Hello DustNite, and welcome to the forum.

It is usually not our way to simply hand out solution. Instead you post your solution, describe whats wrong (do you get an error, does your Hero act strangly ect) and we try to solve it for your code.

As the intention is that you learn something (that’s the whole point of the game), it would be active sabotage to simply give you the solution to each level. ou would also rapidly loose interest, as you would at some point meet a brickwall which you can’t pass, simply because you never learned the basics to cross it.

Long speech short: We are happy to help you, but give us something to help you with.

Best regards and happy coding,

This topic has been answered in an already existing topic. It will be closed in 24 hours.

EDIT: This topic has been answered here.

EDIT2: Due to ongoing discussion a threadclosing has been prevented.

loop {
    var enemy = this.findNearestEnemy();
    var distance = this.distanceTo(enemy);
    if (distance < 10) {
        if (this.isReady("cleave")) {
    else {

that is my code it only killed some of the enemies

So the question would be, if the enemy is less than 10 meters away, but cleave is not ready - what do you want to happen? At the moment it seems you will do nothing?

i want it to attack the enemies while the cleave is getting ready

Wait! isn’t that what his code does…

isn’t the else with the second if since there aren’t two ‘}’ before it

if (distance) { if (cleave ready) { cleave } else { attack}

The question is what does he want to happen if the enemy is more than 10m away.

if (distance < 10 && this.isReady("cleave")) {

would change it to only care about the 10m for the cleave and attack otherwise
Is that right? been to long since I’ve done anything java-ish

Yes you’re right :blush: missed the open bracket (and am too used to seeing java code which has a single line if without brackets). So yes I think the question is what happens if they are more than 10 meters away.