Help with "Stillness in Motion" level?


#1

My code works fine, but my character doesn’t seem to have good enough armor to survive the whole time. Is there a trick to the level or am I going to have to come back to it with better gear?


#2

That would be a hard question to answer with knowing your weapon and especially your armor (maxHealth - when in the level, point your mouse at the focus display (where it shows your hero right below the map) and point at the health bar: currentHealth/maxHealth).

Also how much time is left when you die? (knowing your weapon, health, and remaining time will help us decide if we would suggest a better weapon, armor, or ???)

Do you have a secondary weapon (warrior = bash shield) and are you attacking with it? It may not do as much damage as your primary, but in a lot of cases it hits faster (less wait until next action) and so lets you do more damage over time.


#3

I also thought this level was slightly too hard considering where in the campaign it is. Especially the two throwers spawning around the 30 seconds mark makes the fight extra difficult. Using the strategy suggested in the comments I think you need at least around 450 health using the long sword (which I think most players would be using) and the steel striker shield.

Maybe one thrower could be removed or have them appear a bit later to make the difficulty more in line with the surrounding levels.


#6

I’ve rebalanced this level. Let me know how it goes, if you’re still dying too quickly! Sometimes those ogres get over-eager :wink:


#7

Tried it again and now it is doable with 200ish hp. Seems more in line with the surrounding levels while still proving the point about using distance to decide whether to attack or not. Maybe too easy? Nah j/k. Good job balancing.


#10

i need the code please i cant find out how to beat it


#11

We don’t give out proper code as a regular policy. It provides an easy answer without letting the user learn how the solution works.

At least tell us what your problem is. Maybe post your code (formatted properly, of course).


#12

no matter what somthing is always saying add if statement but i already did or i cant get the >5 to work


#13

Could you show us your code?

I believe in this level you need to check IF there is enemy, and then IF their distance is less than 5m. Nested IF statements.


#14

This is my code for the level.
It keeps telling me that on the “distance to” line the target is undefined. I think there is an error in my code but can’t seem to find it. Any suggestions?

loop {
    
    var enemy = this.findNearestEnemy();
    var distance = this.distanceTo(enemy);
    
    if (enemy) {
        if (distance < 5) {
            this.attack(enemy);
        }
        else {
            this.shield();
            
        }
    }
    else {
        this.moveXY(34, 40);
    }
}

#15

Hello, Max, and welcome. Please read the FAQ prior to your next post, so that you can learn how to format code properly. I’ve done it for you this time, but you should earn to do it on your own.

Your problem is that you check the distance to an enemy before you check if there is an enemy. Move the line where you define distance inside the if (enemy) { block.


#16

Ok… Thank you! I appreciate the help and am also very impressed by the speed of that response.
I will make sure to format the code properly next time.
Thank you!
-Max


#17

It says “An unexpected token.” What does that mean?


#18

Unexpected token means you have a character (or a sequence of characters) where it does not belong, or otherwise missing a character or a sequence of characters somewhere. In other words, it means your program’s syntax is invalid.

There’s a very off chance that the syntax you’re using is not implemented yet in CodeCombat’s compiler (happens with some Python 3 and JavaScript ECMAScript 2015 features) or that you have found a compiler bug, but this is a rare case as those are not yet taught in CodeCombat nor necessary to complete the levels.

Please post your code (correctly formatted) so we can help you.


#19

It is the main reason why I can’t beat some levels. Also, that was a fast response!


#20

Hahah, no problem. If you need further help, please post the code you’re having problems with, otherwise we can’t really help on this issue. :wink:

“Unexpected token” is a very generic error that is thrown when the parser finds something “unexpected”—i.e. any kind of invalid syntax. It might be due to a dot, colon, comma, parenthesis, bracket, any character or word out of place or missing. Anything really. It happens for minuscule and large mistakes alike.


#21

loop:
enemy = self.findNearestEnemy()
distance = self.distanceTo(Enemy)
if self.distanceTo(enemy) :
self.distanceTo(enemy) > 10 :
self.cleave(enemy)
else:
self.attack(“Chest”)


#22

What’s wrong with it?


#23

It doesn’t show indents…


#24

Looks like you’re missing an if before self.distanceTo(enemy) > 10 :

Also please edit your post and add triple backticks (```) before and after your code, so the indentation is rendered correctly.