def cleaveOrAttack(enemy):
# If "cleave" is ready, cleave; otherwise, attack.
if hero.isReady("cleave"):
pass
while True:
enemy = hero.findNearestEnemy()
if enemy:
distance = hero.distanceTo(enemy)
if distance < 5:
# Call the "cleaveOrAttack" function, defined above.
cleaveOrAttack(enemy)
The problem I am having is Im getting errors that should not be there and I have tried different things to get it to work but I am stuck.
Howdy Charles and welcome to the forum!
# If "cleave" is ready, cleave; otherwise, attack.
Per the instructions in the comment, your cleaveOrAttack function isn’t quite complete. You need 3 more lines of code to finish it.
def cleaveOrAttack(enemy):
# If "cleave" is ready, cleave; otherwise, attack.
if hero.isReady("cleave"):
hero.cleave()
else:
hero.attack(enemy)
while True:
enemy = hero.findNearestEnemy()
if enemy:
distance = hero.distanceTo(enemy)
if distance < 2:
# Call the "cleaveOrAttack" function, defined above.
cleaveOrAttack(enemy)
I changed my codes so that it attacks instead of cleave, but the hero dies before it can cleave again.
Never mind if he shields it protects him long enough that he does not die.
Use if distance < 5 and you won’t need to use shield.