Forest miners help!


#1

hi,
well there is always some kind of delay before the second enemy spawns so my hero call a clear environnment then he spawns and kill a peasants…

function kill(target) {
if(target) {
hero.attack(target);
}else{
hero.say(“clear”);
}
}

while (true) {
hero.moveXY(64, 54);
var enemy1 = hero.findNearestEnemy();
if(enemy1);
kill(enemy1);
hero.moveXY(16, 14);
var enemy2 = hero.findNearestEnemy();
if(enemy2);
kill(enemy2);

}


#2

I’m not too familiar with the language you’re using but you have a function, kill(target), with an if statement. You shouldn’t need another one in your code. Try just moving, defining enemy, and then calling your function. Also, I don’t believe you need to break down enemy1 & 2. Try just using “enemy”.in both. That’s the way it worked for me in Python anyways.


#3

i changed both and still, didnt change anything the result is the same, there is a bug with synchronisation


#4

its cool i found an alternative pattern ^.^