I have tried very hard to debug my code, but I have not found the error.
The message is:
Unreachable after return
Here is my code:
loop {
var enemy = this.findNearestEnemy();
if (enemy) {
var distance = this.distanceTo(enemy);
if (distance < 15) {
// Cast "drain-life" on the enemy.
this.cast("drain-life", this.findNearestEnemy());
}
else {
// Attack the enemy with your staff.
this.attack(enemy);
}
}
}
Same for me, no evident mistake.
I could just advise you to replace: this.cast("drain-life", this.findNearestEnemy());
by this.cast("drain-life", enemy);
Are you sure you show us all the code ? Where the error took place in the code ?