So I noticed after I defeated Wandering Souls in Sarven Desert that if you define the distance variable first, the hero will just stand there and never pick up the lightstone.
For example:
var item = items[itemIndex];
// While the distance greater than 2:
while (hero.distanceTo(item) > 2) {
hero.moveXY(item.pos.x, item.pos.y);
}
The code works and the hero collects the lightstone and I finish the level.
But, instead of defining distanceTo
inside the while loop, I tried to define it as a variable and in theory, it should work the same. Here is the code:
var item = items[itemIndex];
var distance = hero.distanceTo(item);
// While the distance greater than 2:
while (distance > 2) {
hero.moveXY(item.pos.x, item.pos.y);
}
As you can see, I only created a variable distance
, and used that in the while loop, however, my hero struggles to get the lightstone. This is a bug.