Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Clouddrip Mountain-Make Advances

while True:
    friends = hero.findFriends()
    for friend in friends:
        if friend.type is "paladin":
            # Find the projectile nearest to the friend:
            arrow = hero.findNearest(hero.findEnemyMissiles())
            # If the projectile exists
            # AND is closer than 10 meters to the paladin:
            if arrow:
                # Command the friend to "shield":
                distance = friend.distanceTo(arrow)
                if distance < 10:
                    hero.command(friend, "shield")
                    hero.command(friend, "cast", "heal", friend)
                # ELSE, when there is no potential danger:
                else:
                    # Advance the paladin:
                    hero.command(friend, "move", {'x':friend.pos.x +1, 'y':friend.pos.y})
        else:
            # If not a paladin, just advance:
            hero.command(friend, "move", {'x':friend.pos.x +1, 'y':friend.pos.y})
    # Advance the hero in the x direction:
    x = hero.pos.x +1
    y = hero.pos.y
    hero.moveXY(x, y)

my code runs properly, yet my troops just won’t go for the last step to disable the traps, is this a bug or something?

I’d recommend moving your paladins in increments of +10 and your hero by +5. Also, the archers do nothing except act as targets…I just passed on that else clause, letting them stay where they are.

Healing is a nice touch, but should not be needed to complete the level.

yes now the paladins move in increments of +10, and only 2 of them succeeded in disabling the traps

ok…add the heal back in, but limit it to only when the paladin is less than 1/2 health. This way, they don’t waste time casting when they don’t need to.

ok thanks, I found the problem and solved it.