[SOLVED] Sarven gaps JavaScript

// Get to the Oasis by moving down 10m at a time.
// Build fences 20m to the left of each ogre.

while(true) {
    var enemy = hero.findNearestEnemy();
    if (enemy) {
        // buildXY a "fence" 20 meters to enemy's left.
        hero.buildXY("fence", enemy.pos.x - 20, enemy.pos.y);
    } else {
        // moveXY down 10 meters.
        var x = hero.pos.x;
        var y = hero.pos.y;
        y -= 10;
        hero.moveXY(x, y);

I am not sure what I have done wrong with the code. I put the first fence up and then when I move down it is just half way to the next opening and then is stuck and says that they can’t get there. I have tried a few things but nothing has worked. Any ideas would be awesome.

Which hero are you using?

Hattori Hanzo. Why does it matter what one I am using in this level?

Because i was using a different hero than the basic ones and the level failed, but with anya it worked fine

1 Like

Ok, I’m no JS pro, barely even a beginner, but instead of defining X and Y as variables, use

hero.moveXY(hero.pos.x, hero.pos.y - 10);

instead of

Hopefully this helps,


1 Like

Yeah i think that’d work

1 Like

I tried that first and when it did not work going to try a different person.

I got farther than before so the change of person did help just have to find out what else I need to do.

the problem was the shoes and the person I was using.

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.