def findAndAttackEnemy():
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
def findAndCleaveEnemy():
# Define a function to cleave enemies (but only when the ability is ready).
enemy = hero.findNearestEnemy()
if enemy:
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()
# Move to the other point, cleave, and attack.
hero.moveXY(60, 31)
findAndCleaveEnemy()
findAndAttackEnemy()
Use cleave only when it ready as requested
hero.isReady(action) from wristwatch Guide for isReady
without checking if cleave ready or not the hero will try to do “cleave” over and over and over
Usually, it’s while the conditional statements like, if enemy, are true. In this case it applies to while the hero is able to moveXY to the two assigned positions.