New to code combat and confused on the level 'backwoods brawl


#1

i’m kinda new to code combat but on this level i’m very confused on how to survive.
if the problem is that I don’t have enough armor or health then please let me know.
this is my code so far; (with all of the help things poping up this is what my code came too.)

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

#3

Keep in mind. all you have to do is survive. You don’t have to fight. I’d rethink your strategy and try to stay away from the enemies.


#4

thanks, i’ll try that.
i’ll tell you if it works.


#5

ok, I tried to run from the enemies and keep some distance away from them but, the munchkin ogres caught up to me quickly or the archers rapidly shot at me and took down tons of health.
this is the code I used;

loop:
enemy = self.findNearestEnemy()
if enemy:
self.distanceTo(enemy) <5
self.moveXY(52 , 33)
self.moveXY(74 , 77)
self.moveXY(95 , 38)

what should I do now?


#6

:sob: nothing I do changes the fact that i’m going to fail!
I need help badly.


#7

please edit your code snippet post and put three backticks on a line before and after the code so that it indents the way you wrote it, so we can make sure it is indented properly.

```
loop:
enemy = …
```
will become: (assuming you have 4 spaces in front of enemy =… )

loop:
    enemy = .....

#8

ok.

 loop:
     enemy = self.findNearestEnemy()
    if enemy:
       self.distanceTo(enemy) <5
     self.moveXY(52 , 33)
     self.moveXY(74 , 77)
     self.moveXY(95 , 38)

that’s my code then.
I hope that helps.


#9

now i’m seriously confused.
I now have no idea what to do… AT ALL!
I just don’t understand how to do the level without dying! :pensive:


#10

it doesn’t complain about “self.distanceTo(enemy) < 5”?? it is on a line by itself, doing nothing…
so the code is really:

loop:
     enemy = self.findNearestEnemy()
     self.moveXY(52 , 33)
     self.moveXY(74 , 77)
     self.moveXY(95 , 38)

sounds like you aren’t fast enough to out run them, not armored enough to just run and let them beat on you occasionally, and not armed/armored enough to stand and fight. :frowning:

I looked back at your first snippet and you need a “:” at the end of the isReady if and an indent in front of the cleave command to make it be inside the if. (you’ve already moved the enemy= in your later code)

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

otherwise it will always try to cleave.
It would also be better to ask the cleave question before the attack.

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

try combining the two ideas “attack” and run" by adding the distance to check to the if enemy line and adding a move command to an else clause to that if (the: if enemy and self.distance…: )


#11

so attack and run at the same time?
seems simple but what code would I use?
I still have no idea HOW to do the code, but know I know WHAT to do in the code.
i’ll try it out and give you the code afterwards.
until then, you don’t have to do (almost) anything.
P.S just a question but where are YOU in code combat? just want to know how far you are.


#12

ok. :neutral_face:
I tried it out and guess what?
I FAILED AGAIN!!! :rage:
this is the code I used, it’s a mixture of your example code and what I put in.

loop:
if enemy:  
   enemy =  self.findNearestEnemy()
   if self.isReady("cleave"):
        self.cleave(enemy)
    else:
        self.attack(enemy)
   
   self.distanceTo(enemy) >2
   self.moveXY(60, 51) 
   if not enemy:
       self.moveXY(85, 84)

it doesn’t work at all!
how did you win? can you at least give me some more advice?
i’m really confused on this level right now and for me there is no wat for me to beat it.
there are more levels I can move on to but they’re just as confusing… maybe even MORE confusing!
but this level is more HARD then confusing, but it being confusing makes it hard and even that is confusing!
my brain is in knots because of this level and I need serious help!
help.


#13

for right now i’m going to try helping other people and their levels and maybe I can know/learn more about this and be able to defeat this level. so… just please help me with this level.
thx.


#14

This level is fairly hard and Im on desert(world 3) and I still have a hard time beating it


#15

The idea is not running, but rather you have to fight the ogres intelligently.

First I tried to simply make a loop for finding enemies and killing them- didnt work.
The archers stay at a distance and the MC keeps targeting the melee ogres.

What I am currently trying to implement is putting the enemies into an array, then searching it for enemy.type = Thrower and then making the MC kill those as soon as they are detected.


#16

Oh hey if you have a hard time just go get a set of code from mad maxer it beat the first few for me

(Mind you I have full painted steel kithsteel sword and ring of speed so yeah)


#17
loop {
    var enemy = this.findNearestEnemy();
    
    if (enemy) {
        if (this.isReady("cleave")) {
            this.cleave(enemy);
        } else if (enemy) {
            this.attack(enemy);
        }
    } else {
        this.shield();
    }
    
    
}

Hi kewlboy1212!

I am on Javascript. This is my code and it got me pas the first level. I am not really sure how to code python but possibly you could use the same principles I did just in Python mode. I had to buy a really expensive shield for this level, the engraved obsidian shield, so if you have the gems to buy that, definitely do that. So go ahead and tweak this to your heart’s content! Hope this helps!


#18

In case anyone was wondering, the principle used by I_like_bunnies is . . . “massive armor wins”. :wink:


#19

HAHA, I guess that’s totally true.


#20

Okay guys first things first dont use xy boots use the simple boots (up,down,left,right)
You dont have to fight anyone it give clear instructon to walk all the way to the end
the other warriors fight for you try it