I’ve been working on Sarven Brawl 1, and realised that I’ve been losing because I would use cleave and accidently hit a sand-yack. I then decided to see if I could find a way to detect if a sand yack was within cleave distance (10) by looking for all sand-yacks, getting their distance and getting the distance of the closest one. Here is the error I’m now getting if anybody could help me out :
For those who can’t look at pictures, here is my code :
while True:
enemy = hero.findNearestEnemy()
sand-yacks = hero.findByType("sand-yak")
yackIndex = 0
closeDistance = 9999
while yackIndex < len(sand-yacks):
distance = hero.distanceTo(yack)
if distance < smallDistance:
smallDistance = distance
yackIndex += 1
if enemy and enemy.type != "sand-yak":
if hero.isReady("cleave") and closeDistance > 10:
hero.cleave(enemy)
elif hero.isReady("bash"):
hero.bash(enemy)
elif hero.isReady("chain-lightning") and hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
else:
hero.attack(enemy)
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
soldier = hero.findNearest(hero.findFriends())
enemy2 = soldier.findNearestEnemy()
if enemy2 and enemy2.type != "sand-yak":
hero.command(soldier, "attack", enemy2)