Hold The Forest Pass javascript!

I’m still a little new to code combat. i just can’t get past Hold The Forest pass! This is my code:

 loop {
var enemy = this.findNearestEnemy();
var flag = this.findFlag();
if(flag) {
    // Pick up the flag.
    this.pickUpFlag(flag);
} else if (enemy) {
    this.attack(enemy);
    else {
        this.shield(enemy);
        
    }
}
1 Like

That can be a tough level.

I’m not exactly sure what problem you are having? Error? always dying?

this.shield() is the command, but I’m not sure what you are expecting it to do, since the only time you try to use it is when there are no enemies…

Do you try to lead the ogres around to the archers?

What equipment are you using? Are you using the best you have?

I assume you are hitting submit, so you can place flags…

I’d suggest getting a flag before the level even starts, that way as soon as it has started you can issue your first order (go to the “X”, you know you’ve that part down when she say “Ogres! To Arms!” while move toward the X) Try to lead the whole first wave around to the archers. And after that as many as you can…

Although with the code you’ve put here you have unbalanced curly brackets, probably need one before the final else? Also shield doesn’t take any arguments. Are you having a problem with the code compiling?

I’d also make sure to use cleave in there, since that’s a great skill for clearing out a bunch of enemies and then darting away to your archers on this level.

make sure you are delete the this.attack because you dont want to sucide yourself since there is so many guys out there. I would suggested you by pickup the flag forth and back to your team archers let them kill for you…

That is very close to the solution I had for this, my difference was that IF there was an enemy I checked to see if I could cleave, if so I cleaved. If not I shielded.

I used that code and translated it into Python also adding bash and cleave commands and did it so you’re on the right track :smile:

You can’t cleave or attack in the Forest Pass.

it wont let me attack or cleave and I’ve tried on every other language.

i dont get anything T-T please help i’ve being trying for hours and i cant do it, sorry if my english isnt very well :s

Use flags to join the battle or retreat.

loop:
enemy = self.findNearestEnemy()
flag = self.findFlag()
if flag:
pass # Pick up the flag.

elif enemy:
    pass  # Fight!
 self.findFlag("violet")
self.moveXY(43, 16)
 self.moveXY(56, 23)
 self.cleave(enemy)

my code

Well, you both need to post your code so we can help you.

@Calvin_Heath you’ve already said what you problem is, so just the code would be fine, unless you’ve fixed it and moved on of course.

@isaid_gomez you need to provide more info, as to what is happening or not happening along with the code that isn/isn’t doing it.

I need help, it tells me to put a flag to retreat or fight in the battle. I place a flag but it doesn’t work.
My code is:
loop:
enemy = self.findNearestEnemy()
flag = self.findFlag()
if flag:
pass # Pick up the flag.

elif enemy:
    pass  # Fight!

Nevermind, I got it! I stole the coding from the free coins level and then put that coding in. I will leave the rest up to you. Don’t wanna spit the answer! Heh!