Jenny's method - stacking while true loops: Summit Gate

nope its for a higher level

Ah, okay. So did you try commenting soldiers?
Also, if you want to heal yourself, command paladins. I saw that in your code.

what do you mean whit commenting?

Like:

'''if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
'''
or

#if hero.gold > hero.costOf("soldier"):
#hero.summon("soldier")

1 Like

i tried it doesn’t work

When your hero freezes he doesn’t go on flags?

yes that happens

Maybe because you have many almost same things. Like you have many while true’s when you attack. And you have second paladin’s heal. Try to comment everything that repeated.

i upgraded my code to this:

[/quote]
```while True:
    paladins = []
    enemies = hero.findNearestEnemy()
    flag = hero.findFlag("green")
    if flag:
        hero.pickUpFlag(flag)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin": 
            paladins.append(paladin)
    for enemy in hero.findEnemies():
        if enemy.type == "catapult":
            while enemy.health > 0:
                hero.attack(enemy)
                hero.shield()
        friends = hero.findFriends()
        for friend in friends:
            e = friend.findNearestEnemy()
            if e:
                hero.command(friend, "attack", e)
    fire = hero.findNearestEnemy()
    if fire:
        while fire.health > 0:
            hero.attack(fire)
            hero.shield()
        if fire.type == "tower":
            pass
        if hero.pos.x > 160:
            hero.moveXY(175, 8)
            hero.moveXY(245, 14)
            while hero.health < hero.maxHealth:
                hero.moveXY(277, 34)
                if hero.gold > hero.costOf("soldier"):
                    hero.summon("soldier")
                hero.moveXY(247, 34)
                paladin = hero.findByType("paladin")
                for paladin in paladins:
                    if paladin:
                        if paladin.canCast("heal",paladin):
                            hero.command(paladin, "cast", "heal", hero)
                    poop = hero.findNearestEnemy()
                    if poop:
                        while poop.health > 0:
                            hero.bash(poop)
                        hero.moveXY(277, 48)
                        dumb = hero.findNearestEnemy()
                        if dumb:
                            while dumb.health > 0:
                                hero.bash(dumb)
                        while True:
                            n00B = hero.findNearestEnemy()
                            if n00B:
                                if hero.isReady("bash"):
                                    hero.bash(n00B)
                                else:
                                    hero.attack(n00B)

but when i want to move to (247, 34) i go to the inner gate and that why i die

Try to not to use moveXY, try to use flags. Because you can change where you want to go.

ok i will try it

what is wrong here

    flags = hero.findFlags()
    if greenFlag:
        hero.pickUpFlag(greenFlag)
    if blackFlag:
        hero.pickUpFlag(blackFlag)
        hero.bash(enemy)
    if violetFlag:
        hero.pickUpFlag(violetFlag)
        hero.attack(enemy)

Your code doesn’t know what is greenFlag, etc. Try:

greenFlag = hero.findFlag("green")
if greenFlag:
   hero.pickUpFlag(greenFlag)

Do the same with other colours but change the colour in hero.findFlag(). Also, to use bash without freezing you, you need to write if hero.isReady("bash") hero.bash(enemy)

thx for the tip

what is wrong whit my code this is it:

while True:
    paladins = []
    enemies = hero.findNearestEnemy()
    greenFlag = hero.findFlag("green")
    blackFlag = hero.findFlag("black")
    violetFlag = hero.findFlag("violet")
    if greenFlag:
        hero.pickUpFlag(greenFlag)
    if blackFlag:
        hero.pickUpFlag(blackFlag)
        if hero.isReady("bash"):
            hero.bash(enemy)
    if violetFlag:
        hero.pickUpFlag(violetFlag)
        hero.attack(enemy)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    friends = hero.findFriends()
    for enemy in hero.findEnemies():
        if enemy.type == "catapult":
            while enemy.health > 0:
                hero.attack(enemy)
                hero.shield()
        friends = hero.findFriends()
        for friend in friends:
            e = friend.findNearestEnemy()
            if e:
                hero.command(friend, "attack", e)
    fire = hero.findNearestEnemy()
    if fire:
        while fire.health > 0:
            hero.attack(fire)
            hero.shield()
        if fire.type == "tower":
            pass
        if hero.gold > hero.costOf("soldier"):
            hero.summon("soldier")
    if hero.health < 1000:
        targets = hero.findByType("paladin")
        if paladin.canCast("heal" ,hero):
            hero.command(paladin, "cast", "heal" ,target)

thx for helping

Where does your her die?

he doesn’t die he freezes at the upper beam tower

A hint: try not to use bash in flag, try to use it just in While True, where you attack enemy.

  1. Try to use Heal when your health is hero.health - 150.
  2. I think you need to write a for, like you did it before. But in this for you need to write the type of paladin, like:
for friend in friends:
    if friend and friend.type == "paladin":
      if friend.canCast("heal"):
            hero.command(paladin, "cast", "heal" , hero)

or

hero.command(paladin, "cast", "heal", hero.findNearest(hero.findByType("paladin")

This is if you want to heal only paladin.

i copied

hero.command(paladin, "cast", "heal", hero.findNearest(hero.findByType("paladin")

and it says
i dont know