When I run this code, my hero does not attack the orgs. The orgs continue to go to the villager and attacks them. Can someone help me with this problem?
}
}
// Define a function to cleave enemies (but only when the ability is ready).
function findAndCleaveEnemy() {
// Find the nearest enemy:
var enemy = hero.findNearestEnemy();
// If an enemy exists:
if (enemy) {
}
// And if "cleave" is ready:
var ready = hero.isReady("cleave");
// It's time to cleave!
hero.cleave(enemy);
}
// In your main loop, patrol, cleave, and attack.
while (true) {
// Move to the patrol point, cleave, and attack.
hero.moveXY(35, 34);
findAndCleaveEnemy();
findAndAttackEnemy();
// Move to the other point:
hero.moveXY(60, 31);
// Use findAndCleaveEnemy function:
findAndCleaveEnemy();
// Use findAndAttackEnemy function:
findAndAttackEnemy();
}