Oasis (in JS) timing wrong

My hero moves left after a Yak comes too close, but then continues too quickly to the right again only to be trampled to death. I’ve tried making him wait by adding a

this.say("Howdy!"); 

after the move to the left, but then he gets trampled later anyway. It’s as if the hero only looks once for distance and then rushes to his death. Can anyone tell what’s missing or wrong?

// Move right to reach the oasis,
// but move left to avoid nearby yaks.
loop {
    enemy = this.findNearestEnemy();
    if (enemy && this.distanceTo(enemy) < 10) {
        // Move to the left by subtracting 10 from your X coordinate.
        this.moveXY(this.pos.x - 10, this.pos.y);
    } else {
        // Move to the right by adding 10 to your X coordinate.
        this.moveXY(this.pos.x + 10, this.pos.y);
    }
}

What hero and gear do you have? Also, is timing wrong on both seeds (try submitting again until you get a different yak configuration)? I wonder if something has changed yet again to mess this one up.

I’ve tried three heroes: Sir Tharin Thunderfist, Senick Steelclaw, and the faster Hattori Hanzō to no avail.

I just loaded up my code and some seeds worked and some failed. (no speed ring, +2 moveXY boots (“Leather”))

Here is the info from one where it fails: the yak in question is at 35,40 and I’m at 30,30. so he is more than 10 away from me (according to say: 10.23740418487249). so when I move forward BAM!! (without the say of course)

So if I understand you correctly, the code is OK, but I have to play it out a few times until I get a sleepy yak. :grinning:

2 Likes

After 2 more failed tries, the 3rd time it passed. :joy:

1 Like

Thanks for the heads up–I’ve adjusted the timing again. (Not sure what changed, but it’s working again now for both random configurations and all the hero speeds I tested.) Sorry about that!