friend = hero.findFriends()
friends = hero.findFriends()
witch = hero.findByType("witch",friends[0].findEnemies())[0]
skeleton = hero.findByType("skeleton",friends[0].findEnemies())[0]
ogre = hero.findByType("ogre",friends[0].findEnemies())[0]
enemy = hero.findNearestEnemy()
flag = hero.findFlag("green")
#Command archer to kill the witch
for friend in friends:
if witch and witch.health>0:
if friend.type=="archer":
hero.command(friend,"attack",witch)
if enemy.health < 0:
hero.command(friend, "attack", enemy)
else:
pass
#Command paladin to atack skeletons
if skeleton and skeleton.health>0:
if friend.type=="paladin":
hero.command(friend,"attack", skeleton)
else:
pass
#Command soldier to atack ogres
if ogre and ogre.health>0:
if friend.type=="soldier":
hero.command(friend, "attack", ogre)
else:
pass
#Command Paladin to Cure
if friend.type=="paladin":
if friend.canCast("heal") and friend.health<300:
hero.command(friend,"cast","heal",friend)
else:
pass
#Command friend to leave
for friend in friends:
if enemy.health <= 0:
hero.command(friend, "move", {"x": 38, "y": 59})
if friend.pos.x > 37:
hero.command(friend, "move", {"x": 65, "y": 58})
if friend.pos.x > 64:
hero.command(friend, "move", {"x": 65, "y":40})
if friend.pos.y < 41:
hero.command(friend, "move", {"x": 78, "y": 40})
#Command hero to move
point1 = { "x" : 69, "y" : 15 }
point2 = { "x" : 37, "y" : 16 }
while hero.pos.x<69:
hero.move( point1)
while hero.pos.x>37:
hero.wait(2)
hero.move( point2 )
hero.moveXY(78, 14)
Here is my code