def findAndCleaveEnemy():
# Define a function to cleave enemies (but only when the ability is ready).
if enemy:
hero.attack(enemy)
enemy = hero.findNearestEnemy()
enemy = hero.findNearestEnemy()
hero.cleave(enemy)
pass
while True:
# Move to the patrol point, cleave, and attack.
hero.moveXY(35, 34)
findAndCleaveEnemy()
findAndAttackEnemy()
def findAndCleaveEnemy():
# Define a function to cleave enemies (but only when the ability is ready).
if enemy:
hero.attack(enemy)
enemy = hero.findNearestEnemy()
enemy = hero.findNearestEnemy()
hero.cleave(enemy)
pass
also, you don’t need to repeat enemy = hero.findNearestEnemy() twice every time
def findAndCleaveEnemy():
# Define a function to cleave enemies (but only when the ability is ready).
ready = hero.isReady(“cleave”)
hero.attack(enemy)
ready = hero.isReady(“cleave”)
Please learn to post your code correctly. The way it is now, we can’t see the structure. Help us help you. It’s very easy to do and just takes a tiny bit of effort. Please read this topic and format your code again correctly
I also am needing help, i dont really know how to post this with the correct formatting, but its in JavaScript.
function findAndAttackEnemy() {
var enemy = hero.findNearestEnemy();
if (enemy) {
hero.attack(enemy);
}
}
function findAndCleaveEnemy() {
var enemy = hero.findNearestEnemy();
if (enemy) {
}
if (hero.isReady("cleave")) {
}
hero.cleave(enemy);
}
while (true) {
hero.moveXY(35, 34);
findAndCleaveEnemy();
findAndAttackEnemy();
Hi @Mocharug, welcome to the codecombat discourse!
Please could you format your code so I can see the indents (the gaps at the start of each line). Read this topic for an explanation of how to do it: