for friend in hero.findFriends():
enemy = friend.findNearestEnemy()
skeleton = hero.findNearest(hero.findByType('skeleton'))
witch = hero.findNearest(hero.findByType('witch'))
if friend.type == "archer":
if witch:
hero.command(friend, "attack", enemy)
if friend.type == "soldier":
if enemy:
hero.command(friend, "attack", witch)
if friend.type == "paladin":
if enemy:
hero.command(friend, "attack", witch)
while True:
enemy = hero.findNearestEnemy()
flag = hero.findFlag("green")
friend = hero.findFriends()
if flag:
hero.pickUpFlag(flag)
You have to put the for loop in the while True loop because if you don’t then it will iterate through your friends only one time so they will attack only one time.
if you’re experienced and know how to do this, then command the paladin to cast heal on the weakest soldier: hero.command(friend, "cast", "heal", target)