Hello, Im trying to make it to where my character will try to attack the highest health enemy if there is no shaman. If there is a shaman then they attack it instead.
I keep getting an arguement error at line 8 saying “Find the distance to a target unit”
while True:
enemies = hero.findEnemies()
BestEnemy = FindBestEnemy()
if BestEnemy:
if hero.distanceTo(BestEnemy)>20:
hero.jumpTo(BestEnemy)
else:
hero.move(BestEnemy.pos)
while BestEnemy.health > 0:
if hero.isReady("cleave") and hero.distanceTo(BestEnemy)<20:
hero.cleave(BestEnemy)
elif hero.isReady("bash"):
hero.bash(BestEnemy)
else:
hero.attack(BestEnemy)
def FindBestEnemy():
index = 1
highestHealth = 0
Sourcerer=hero.findByType("shaman", hero.findEnemies())
while index < len(enemies):
if enemies[index].health > highestHealth:
highestHealth = enemies[index].health
highestHPEnemy = enemies[index]
index += 1
if Sourcerer:
enemy = Sourcerer
else:
enemy = highestHPEnemy
return enemy