Kevintalph Crusader - Error with level?


#1

I believe that there is a problem with the level, seeing as everything is executed properly in my code, but nothing actually happens.
Here is my code:

# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
hero.moveXY(68, 16)
def killThemAll(friends):
    for friend in friends:
        enemy = friend.findNearestEnemy()
        if enemy.type == "witch":
            hero.command(friend, "attack", witch)
        elif enemy:
            hero.command(friend, "attack", enemy)
while True:
    friends = hero.findFriends()
    enemy1 = hero.findNearestEnemy()
    enemyMissile = hero.findNearest(hero.findEnemyMissiles())
    killThemAll(friends)
    if enemyMissile and hero.distanceTo(enemyMissile) < 5:
        if hero.isReady("shield"):
            hero.shield()
        else:
            hero.moveXY(12, 12)
    if enemy1 and enemy1.type == "catapult":
        hero.attack(enemy1)
    elif enemy1 > 20:
        hero.attack(enemy1)
    else:
        hero.moveXY(77, 14)

Someone please help me.:anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished::anguished:


#2

Hi,
could you post a screen shot of the screen and your equipment.
Thanks.
:lion:


#3

Ok, Here:


Is that enough for you to help me, or do I need a beginning screenshot too?


#4

At least one of your soldiers (on top) needs to reach the white X. (Read the goals)


#5

I saw that, but how do I do it? Here is my updated code:

# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
hero.moveXY(68, 16)
def killThemAll(friends):
    for friend in friends:
        enemies = friend.findEnemies()
        for enemy in enemies:
            if enemy.type == "witch":
                hero.command(friend, "attack", enemy)
            if enemy.type != "witch":
                break
while True:
    friends = hero.findFriends()
    enemy1 = hero.findNearestEnemy()
    enemyMissile = hero.findNearest(hero.findEnemyMissiles())
    killThemAll(friends)
    if enemyMissile and hero.distanceTo(enemyMissile) < 5:
        if hero.isReady("shield"):
            hero.shield()
        else:
            hero.moveXY(12, 12)
    if enemy1 and enemy1.type == "catapult":
        hero.attack(enemy1)
    elif enemy1 and hero.distanceTo(enemy1) < 20:
        hero.attack(enemy1)
    else:
        hero.moveXY(77, 14)

I’m not focusing on the enemies on the top other than the witch.


#6

In your function you’re using break, read the description of break in the promatticon carefully, imagine the first enemy you check in the for loop isn’t a witch?
:lion: :lion: :lion: