I am having an issue with this block of code, specifically with the game loop patrolling. My avatar will move to (60, 31) and it will register that the enemy has been seen but it will not execute an attack on the enemy using the variable findAndAttackEnemy() considering cleave is not ready yet.
Thanks!
# This function attacks the nearest enemy.
def findAndAttackEnemy():
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
# Define a function to cleave enemies (but only when the ability is ready).
def findAndCleaveEnemy():
# Find the nearest enemy:
enemy = hero.findNearestEnemy()
# If an enemy exists:
if enemy:
# And if "cleave" is ready:
hero.isReady("cleave")
# It's time to cleave!
hero.cleave(enemy)
pass
# In your main loop, patrol, cleave, and attack.
while True:
# Move to the patrol point, cleave, and attack.
hero.moveXY(35, 34)
findAndCleaveEnemy()
findAndAttackEnemy()
hero.moveXY(60, 31)
findAndCleaveEnemy()
findAndAttackEnemy()
pass