[SOLVED] Zoo Keeper Stuck! Help


#1

Can someone help me my hero collects the 80 coins but doesn’t make any soldiers to protect the cage?
Here is my code.

# Protect the cage.
# Put a soldier at each X.
points = []
points[0] = {"x": 33, "y": 42}
points[1] = {"x": 47, "y": 42}
points[2] = {"x": 33, "y": 26}
points[3] = {"x": 47, "y": 26}


# 1. Collect 80 gold.
while True:
    coin = hero.findNearest(hero.findItems())
    if hero.gold <=80:
        if coin:
            hero.move(coin.pos)


# 2. Build 4 soldiers.
for i in range(4):
    hero.summon("soldier")
# 3. Send your soldiers into position.
while True:
    friends = hero.findFriends()
    for j in range(len(friends)):
        point = points[j]
        friend = friends[j]
        enemy = friend.findNearestEnemy()
        if enemy and enemy.team == "ogres" and friend.distanceTo(enemy) < 5:
            # Command friend to attack.
            hero.command(friend, "attack", enemy)
            pass
        else:
            hero.command(friend, "move", point.pos)
            # Command friend to move to point.
            pass

#2

I think you need to add an else somewhere in


#3

Yeah.

Under the else, put break


#4

ok thx for advise :sun_with_face: