Kelvin Tarver Crusade'python'

After my paladin killed the witch, he would not continue to fight other enemies. What should I do? Otherwise all my soldiers will die.

This is my code

for friend in hero.findFriends():
    enemy = friend.findNearestEnemy()
    if friend.type == "archer":
        witch = hero.findNearest(hero.findByType('witch'))
        skeleton = hero.findNearest(hero.findByType('skeleton'))
        if enemy:
            hero.command(friend, "attack", witch)
            hero.command(friend, "attack", enemy)
    if friend.type == "soldier":
        if enemy:
            hero.command(friend, "attack", enemy)
        friends = hero.findFriends()
    if friend.type == "paladin":
        witch = hero.findNearest(hero.findByType('witch'))
        skeleton = hero.findNearest(hero.findByType('skeleton'))
        if witch:
            hero.command(friend, "attack", witch)
        else:
            hero.command(friend, "attack", skeleton)

New code

for friend in hero.findFriends():
    enemy = friend.findNearestEnemy()
    skeleton = hero.findNearest(hero.findByType('skeleton'))
    witch = hero.findNearest(hero.findByType('witch'))
    if friend.type == "archer":
        if witch:
            hero.command(friend, "attack", enemy)
            
    if friend.type == "soldier":
        if enemy:
            hero.command(friend, "attack", witch)
    if friend.type == "paladin":
        if enemy:
            hero.command(friend, "attack", witch)

while True:
    enemy = hero.findNearestEnemy()
    flag = hero.findFlag("green")
    friend = hero.findFriends()
    if flag:
        hero.pickUpFlag(flag)
    

You have to put the for loop in the while True loop because if you don’t then it will iterate through your friends only one time so they will attack only one time.

Thank you.
I can make the Victory Knight fight the normal enemy after finishing the witch fight.
But my soldiers will still die. Is there a solution?

This is my code

while True:
    for friend in hero.findFriends():
        enemy = friend.findNearestEnemy()
        skeleton = hero.findNearest(hero.findByType('skeleton'))
        witch = hero.findNearest(hero.findByType('witch'))
        if friend.type == "archer":
            if witch:
                hero.command(friend, "attack", witch)
            else:
                hero.command(friend, "attack", enemy)
        if friend.type == "soldier":
            if witch:
                hero.command(friend, "attack", witch)
            else:
                hero.command(friend, "attack", enemy)
        if friend.type == "paladin":
            if witch:
                hero.command(friend, "attack", witch)
            else:
                hero.command(friend, "attack", enemy)

while True:
    enemy = hero.findNearestEnemy()
    flag = hero.findFlag("green")
    friend = hero.findFriends()
    if flag:
        hero.pickUpFlag(flag)
    if enemy and hero.distanceTo(enemy) < 10:
        hero.attack(enemy)
    if hero.canCast("chain-lightning", hero.findNearestEnemy()):
        hero.cast("chain-lightning", enemy)

if you’re experienced and know how to do this, then command the paladin to cast heal on the weakest soldier: hero.command(friend, "cast", "heal", target)

what? (200000000000000 characters)

Thank you.
where you from?
I from taiwan.

My English is not good, so see if you can speak Chinese

i can’t speak chinese

Thank you.
ok i can only speak english

1 Like

I found that my archer only needs to kill the witch and wait until the paladin is dead before attacking the enemy.

I’m very much obliged to you

No worries!
Press the button that says solution underneath your post so the topic can be resolved.

Sorry, I made a typo.

Not yet,sorry.please forgive

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.