[SOLVED] Make Advances

Everything goes fine until the end. My last paladin just stops, and the archers move on and die, how do I make make my paladin move to the very end? Here is what happens:
Screenshot 2020-10-15 at 4.59.14 PM

This is my code:

# Advance through the forgotten tomb.
# Be wary, traps lay in wait to ruin your day!

# The Paladins volunteer to lead the way.
# Command them to shield against incoming projectiles.
while True:
    friends = hero.findFriends()
    # findEnemyMissiles finds all dangerous projectiles.
    projectiles = hero.findEnemyMissiles()
    for friend in friends:
        if friend.type is "paladin":
            # Find the projectile nearest to the friend:
            for projectile in projectiles:
                distance = friend.distanceTo(projectile)
                # If the projectile exists
                # AND is closer than 10 meters to the paladin:
                if projectile and distance < 10:
                    # Command the friend to "shield":
                    hero.command(friend, "shield", friend)
                # ELSE, when there is no potential danger:
                    # Advance the paladin:
                    hero.command(friend, "move", {"x": friend.pos.x + 50, "y": friend.pos.y})
            # If not a paladin, just advance:
            hero.command(friend, "move", {"x": friend.pos.x + 20, "y": friend.pos.y})
    # Advance the hero in the x direction:
    hero.moveXY(hero.pos.x + 10, hero.pos.y)


Is this past mountain? If so, I cannot help you, sorry :frowning:


i’m pretty sure this is the link @Lydia_Song https://codecombat.com/play/level/make-advances

weird because for me it says paladins go and attack starting from the left and going to the right

here is where it is located and its not passed mountain

Hi abc,

Instead of:

just use:

            var projectile = friend.findNearest(projectiles);

I also made the friends stay just behind their nearest paladin (otherwise they ran ahead and got killed). And I also put a paladin heal function in, and I had to play around with the distance that the paladins and the hero moved each time to make it work.


1 Like

He is in Python, not JavaScript Jenny.
So it would be

projectile = friend.findNearest(hero.findEnemyMissiles())

If I’m not mistaken.


Good point, thanks Lydia :grin:


If I command the archers to stay back, they survive, but my last paladin stops and lets himself be killed by a fireball


The problem here is my bottom paladin, no matter what I do, he always just stops short.


is your code still the same??
edit: sorry i cannot help you as when i use your code the problem is different to yours

I tried doing that, but then I only disable my middle trap. My paladins all go for their targets, but my top one doesn’t make it to it’s target because my bottom paladin dies first. I don’t know why, but it keeps killing my bottom paladin.

1 Like

Unfortunately, I can’t help you, because I haven’t passed the level myself!

That’s okay. Now my top paladin is stuck

1 Like

I finally solved it!


Congrats! Altough I did absolutely nothing . . . :sweat_smile:

tick the box which helped you the most(even thought you just solved it yourself :rofl:)