Well, so I searched and reviewed a lot in the forum and many people had problems with this level and I am one of them. My code has no error, it just never ends and it gets stuck. Can someone help me?
# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
def command():
friends = hero.findFriends()
for friend in friends:
witch = hero.findByType("witch",friends[0].findEnemies())[0]
if witch and witch.health>0:
if friend.type=="paladin" or friend.type=="archer":
hero.command(friend,"attack",witch)
elif friend.type=="soldier":
ogre = hero.findByType("ogre",friend.findEnemies())
if ogre:
hero.command(friend,"attack",ogre[0])
if friend.type=="paladin":
if friend.canCast("heal") and friend.health<300:
hero.command(friend,"cast","heal",friend)
else:
enemy=friend.findNearestEnemy()
if enemy:
hero.command(friend,"attack",enemy)
else:
point2 = { "x" : 61, "y" : 57 }
while hero.distanceTo( point2 ) > 1:
hero.command(friend,"move",point2)
point2 = { "x" : 78, "y" : 40 }
while hero.distanceTo( point2 ) > 1:
hero.command(friend,"move",point2)
if friend.type=="paladin":
if friend.canCast("heal") and friend.health<300:
hero.command(friend,"cast","heal",friend)
while True:
command()
enemy = hero.findNearest(hero.findEnemies())
if "Trogdor":
hero.cast( "chain-lightning", "Trogdor" )
else:
hero.cast( "chain-lightning", "Rusty" )
point1 = { "x" : 69, "y" : 15 }
point2 = { "x" : 37, "y" : 16 }
while hero.pos.x<69:
command()
hero.move( point1 )
while hero.pos.x>37:
command()
hero.move( point2 )
for i in range(3):
enemy = hero.findNearest(hero.findByType("catapult"))
if enemy:
hero.attack(enemy)
point3 = { "x" : 37, "y" : 16 }
point4 = { "x" : 78, "y" : 14 }
while hero.pos.x>37:
command()
hero.move( point3 )
while hero.pos.x<78:
command()
hero.move( point4 )