> def friendApart(friends):
> friends = hero.findFriends()
> friendsEast = []
> friendsWest = []
> for i in range(len(friends)):
> if friends[i].pos.x > 100:
> friendsEast.append(friends[i])
> else:
> friendsWest.append(friends[i])
> for friendEast in friendsEast:
> item = friendEast.findNearestItem()
> if item.pos.y > 60:
> hero.command(friendsEast[0], "move", item.pos)
> else:
> hero.command(friendsEast[1], "move", item.pos)
> for friendWest in friendsWest:
> item = friendWest.findNearestItem()
> if item.pos.y > 60:
> hero.command(friendsWest[0], "move", item.pos)
> else:
> hero.command(friendsWest[1], "move", item.pos)
>
> troopsType = ["griffin-rider", "soldier", "archer", "archer", "griffin-rider"]
>
> def summomTroop():
> type = troopsType[len(hero.built) % len(troopsType)]
> if hero.gold > hero.costOf(type):
> hero.summon(type)
>
> def commandTroop():
> friends = hero.findFriends()
> for friend in friends:
> enemy = friend.findNearestEnemy()
> if friend and friend.type != "peasant":
> hero.command(friend, "attack", enemy)
>
> while True:
> enemy = hero.findNearestEnemy()
> friendApart()
> summomTroop()
> commandTroop()
>
> if enemy:
> if hero.canCast("chain-lightning", enemy):
> hero.cast("chain-lightning", enemy)
> else:
> hero.attack(enemy)
alarm:
type Error: friendWest.findNearestItem() is not a function.
My peasants can go to collect coins when i run the code, even there is an alarm. But after some seconds they stopped, i dont know why. Help!!!