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

HELP Kelvintaph Crusader

glad i could help, my only problem with your setup is just trying to get the bonus.

I need a little help this is my new command and it seems that the move command works fine but my friends die what can I do?

# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
def command():
    friends = hero.findFriends()
    for friend in friends:
        witch = hero.findByType("witch",friends[0].findEnemies())[0]
        if witch and witch.health>0:
            if friend.type=="paladin" or friend.type=="archer":
                hero.command(friend,"attack",witch)
            else:
                pass
                
        if friend.type=="soldier":
            ogre = hero.findByType("ogre",friends[0].findEnemies())[0]
            if ogre:
                hero.command(friend,"attack", ogre) 
                if enemy:
                    enemy = hero.findNearestEnemy()
                    hero.command(friend, "attack", enemy)
                else:
                    pass
                
        if friend.type=="paladin":
            if friend.canCast("heal") and friend.health<300:
                hero.command(friend,"cast","heal",friend)
            else:
                enemy=friend.findNearestEnemy()
                if enemy:
                    hero.command(friend,"attack",enemy)
                else:
                    while True:
                        
                        if (friend.pos.x < 47):
                            hero.command(friend, "move", {x : 50, y: 59})
                        if (friend.pos.y > 42):
                            hero.command(friend, "move", {x : 50, y: 39})
                            hero.command(friend, "move", {x : 78, y: 40})
                        else:
                            break
                

while True:
    point1 = { "x" : 69, "y" : 15 } 
    point2 = { "x" : 37, "y" : 16 }
    while hero.pos.x<69:
        command()
        hero.move( point1)
    while hero.pos.x>37:
        hero.wait(2)
        command()
        hero.move( point2 )
        
    point3 = { "x" : 37, "y" : 16 }
    point4 = { "x" : 78, "y" : 14 }
    while hero.pos.x>37:
        command()
        hero.move( point3 )
    while hero.pos.x<78:
        command()
        hero.move( point4 )


That’s kind of the issue… after killing the witch focus attacking the ogres before the skeletons. the skellys will attack the paladin and force it to heal, and after the ogres are down you can attack the skeletons.

# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
def command():
    friends = hero.findFriends()
    for friend in friends:
        witch = hero.findByType("witch",friends[0].findEnemies())[0]
        if witch and witch.health>0:
            if friend.type=="archer":
                hero.command(friend,"attack",witch)
            else:
                pass
                
        if friend.type=="paladin":
            skeleton = hero.findByType("skeleton",friends[0].findEnemies())[0]
            if skeleton:
                hero.command(friend,"attack", skeleton) 
                if friend.type=="soldier":
                    ogre = hero.findByType("ogre",friends[0].findEnemies())[0]
                    if ogre:
                        hero.command(friend, "attack", enemy)
                else:
                    pass
                
        if friend.type=="paladin":
            if friend.canCast("heal") and friend.health<300:
                hero.command(friend,"cast","heal",friend)
            else:
                enemy=friend.findNearestEnemy()
                if enemy:
                    hero.command(friend,"attack",enemy)
                else:
                    
                    while True: 
                        if (friend.pos.x < 47):
                            hero.command(friend, "move", {x : 50, y: 59})
                        if (friend.pos.y > 42):
                            hero.command(friend, "move", {x : 50, y: 39})
                            hero.command(friend, "move", {x : 78, y: 40})
                        else:
                            break
                

while True:
    point1 = { "x" : 69, "y" : 15 } 
    point2 = { "x" : 37, "y" : 16 }
    while hero.pos.x<69:
        command()
        hero.move( point1)
    while hero.pos.x>37:
        hero.wait(2)
        command()
        hero.move( point2 )
        
    point3 = { "x" : 37, "y" : 16 }
    point4 = { "x" : 78, "y" : 14 }
    while hero.pos.x>37:
        command()
        hero.move( point3 )
    while hero.pos.x<78:
        command()
        hero.move( point4 )


So I changed my strategy and made my paladin attack the skeleton my archers attack the witch and my soldiers attack the ogres but it still doesn’t work

I don’t think this code structure is workable:

13	        if friend.type=="paladin":
            # code
24	        if friend.type=="paladin":
            # code
34	                        if (friend.pos.x < 47):
35	                            hero.command(friend, "move", {x : 50, y: 59})
36	                        if (friend.pos.y > 42):
37	                            hero.command(friend, "move", {x : 50, y: 39})
38	                            hero.command(friend, "move", {x : 78, y: 40})

You can see the conclusions of Quiz: Issuing successive commands? topic

i should put the move command somewhere else?

What you have just experienced is known here as a ‘xythonism’. What xython means is that stacking (nesting) multiple if statements, as your code is doing, does not always work the way you think it would. Check out the link provided and do some testing on your own, if you like…I did when this was first shown to me and was surprised at the results.

Btw it is normally good practice to nest a couple of statements, but as the nest grows, things get really weird.

So this is my new command I put the while loop on another line but this error gave me can you help me?

# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
def command():
    friends = hero.findFriends()
    for friend in friends:
        witch = hero.findByType("witch",friends[0].findEnemies())[0]
        if witch and witch.health>0:
            if friend.type=="archer":
                hero.command(friend,"attack",witch)
            else:
                pass
        if friend.type=="paladin":
            skeleton = hero.findByType("skeleton",friends[0].findEnemies())[0]
            if skeleton:
                hero.command(friend,"attack", skeleton) 
                if friend.type=="soldier":
                    ogre = hero.findByType("ogre",friends[0].findEnemies())[0]
                    if ogre:
                        hero.command(friend, "attack", enemy)
                else:
                    pass
        if witch and witch.health<0:
            if friend.type=="archer":
                ogre = hero.findByType("ogre",friends[0].findEnemies())[0]
                if ogre:
                    hero.command(friend, "attack", enemy)
                else:
                    pass
        if friend.type=="paladin":
            if friend.canCast("heal") and friend.health<300:
                hero.command(friend,"cast","heal",friend)
            else:
                enemy=friend.findNearestEnemy()
                if enemy:
                    hero.command(friend,"attack",enemy)
                else:
                    pass
        while True: 
            if (friend.pos.x < 47):
                hero.command(friend, "move", {"x": 50, "y": 59}
                if (friend.pos.y > 42):
                    hero.command(friend, "move", {"x": 50, "y": 39})
                    hero.command(friend, "move", {"x": 78, "y": 40})
                else:
                    break
                

while True:
    point1 = { "x" : 69, "y" : 15 } 
    point2 = { "x" : 37, "y" : 16 }
    while hero.pos.x<69:
        command()
        hero.move( point1)
    while hero.pos.x>37:
        hero.wait(2)
        command()
        hero.move( point2 )
        
    point3 = { "x" : 37, "y" : 16 }
    point4 = { "x" : 78, "y" : 14 }
    while hero.pos.x>37:
        command()
        hero.move( point3 )
    while hero.pos.x<78:
        command()
        hero.move( point4 )
            if (friend.pos.x < 47):
                hero.command(friend, "move", {"x": 50, "y": 59}
                if (friend.pos.y > 42):
                    hero.command(friend, "move", {"x": 50, "y": 39})
                    hero.command(friend, "move", {"x": 78, "y": 40})

If friend.pos.x is between 42 and 47 your friend will move only to {“x”: 78, “y”: 40}. See the link above.

I took a codecombat break for a few days to come back with a fresh mind for this level and I started from scratch so this is my new code

# You can find friends through walls, but not enemies.
# Watch out for smooth, frictionless ice patches!
#Define friend
friend = hero.findFriends()
friends = hero.findFriends()
#Define all enemy
witch = hero.findByType("witch",friends[0].findEnemies())[0]
skeleton = hero.findByType("skeleton",friends[0].findEnemies())[0]
ogre = hero.findByType("ogre",friends[0].findEnemies())[0]
enemy = hero.findNearestEnemy()
#Command archer to kill the witch
for friend in friends:
    if witch and witch.health>0:
        if friend.type=="archer":
            hero.command(friend,"attack",witch)
        else:
            pass
#Command paladin to atack skeletons
if skeleton and skeleton.health>0: 
    if friend.type=="paladin":
        hero.command(friend,"attack", skeleton) 
    else:
        pass
#Command soldier to atack ogres
if ogre and ogre.health>0:
    if friend.type=="soldier":
        hero.command(friend, "attack", ogre)
    else:
        pass
#Command Paladin to Cure
if friend.type=="paladin":
    if friend.canCast("heal") and friend.health<300:
        hero.command(friend,"cast","heal",friend)
    else:
        pass
#Command friend to leave

#Command hero to move
point1 = { "x" : 69, "y" : 15 } 
point2 = { "x" : 37, "y" : 16 }
while hero.pos.x<69:
    hero.move( point1)
while hero.pos.x>37:
    hero.wait(2)
    hero.move( point2 )
hero.moveXY(78, 14)

What I do is command my archers to kill the witch my soldiers to the ogres and my paladin to the skeletons, the archers manage to kill the witch and my paladin kills a skeleton, but then they die and my hero escapes perfect

I want to manage to kill all enemys and then leave with all my friends alive but first i got to kill everybody

same i also am stuck it is just too hard

yeah stuck for about a week and half on this level lmao

ya so hard so hard(super hard)

I ran your code - your hero is still dying. See carefully all the videos published in the topic and read the comments. Solve the problems one by one: moving hero, commanding minions…
Another hint:

1 Like

Wait did his work(20 characters)

xython is just demonstrating a simplistic method by which to complete the level, visually. Notice the hero has no armor, but emits a funny green bolt of something…

Also, the tips xython suggests are quite valid…there is a lot of help available out there.

I solved it YAY thanks @xython

For those who are still haven’t solved the level: hint: tell Archers to attack queen and paladins to heal the other in battle.

But it says that my hero escaped and gives me the green mark why is that?