Welcome to the forum @Logan_Jordan1 ! This is a friendly place where you can ask help on levels, report bugs, or just chat with other coders! Have a great time!
Thank you for formatting your code
I think we can fix some things:
put the whole thing in a while true loop
define what enemyIndex, farthest, and what maxDistance are in before the while loop that loops over all the enemies
i suggest you remove both move commands and the 3 attack commands
inside the if farthest, add a while loop checking if the health if farthest is greater than 0
the if enemy == wizard should be removed with the lines inside it
farthest = None
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()
enemy = hero.findNearestEnemy()
target = enemies[farthest]
enemyIndex = enemyIndex+1
# Is this enemy farther than the farthest we've seen so far?
distance = hero.distanceTo(target)
while True:
if distance > maxDistance:
maxDistance = distance
farthest = target
if farthest:
hero.attack(farthest)
if enemy==wizard:
hero.attack(enemy)
hero.attack(enemy)
this is my updated code any other suggestions
farthest = target
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()
enemy = hero.findNearestEnemy()
while True:
target = enemies[farthest]
enemyIndex = enemyIndex+0
# Is this enemy farther than the farthest we've seen so far?
if enemy:
if target: distance = hero.distanceTo(target)
while True:
if distance > maxDistance:
maxDistance = distance
farthest = target
if farthest:
while farthest.health > 0:
hero.attack(furthest)
this is my new code but my guy wont stop running into the wall and not fighting
hmmm this is my new code but he attacks all the decoys
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()
# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
target = enemies[enemyIndex]
enemyIndex += 1
# Is this enemy farther than the farthest we've seen so far?
distance = hero.distanceTo(target)
if distance > maxDistance:
maxDistance = distance
farthest = target
if farthest:
# Take out the farthest enemy!
# Keep attacking the enemy while its health is greater than 0.
enemy = hero.findNearestEnemy()
while enemy.health > 0:
hero.attack(enemy)
pass
this is my new code he attacks the flying person then the decoys push him to the wall any thing else
maxDistance = 0
enemyIndex = 0
enemies = hero.findEnemies()
while True:
# Look at all the enemies to figure out which one is farthest away.
while enemyIndex < len(enemies):
target = enemies[enemyIndex]
enemyIndex += 1
# Is this enemy farther than the farthest we've seen so far?
distance = hero.distanceTo(target)
if distance > maxDistance:
maxDistance = distance
farthest = target
if farthest:
# Take out the farthest enemy!
# Keep attacking the enemy while its health is greater than 0.
while farthest.health > 0:
hero.attack(farthest)
pass