Summit's gate pls help me (python)

i need help with this level
this is the code:

while True:
    paladins = []
    enemies = hero.findNearestEnemy()
    greenFlag = hero.findFlag("green")
    blackFlag = hero.findFlag("black")
    violetFlag = hero.findFlag("violet")
    if violetFlag:
        friends = hero.findFriends()
        if friends:
            for friend in friends:
                if friend:
                    hero.command(friend, "move", violetFlag.pos)
    if greenFlag:
        hero.pickUpFlag(greenFlag)
    if blackFlag:
        hero.pickUpFlag(blackFlag)
        hero.attack(enemy)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    friends = hero.findFriends()
    for enemy in hero.findEnemies():
        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:
            if hero.canCast("invisibility", hero):
                hero.cast("invisibility", hero)
            hero.attack(fire)
            hero.shield()
        if fire.type == "tower":
            pass
        if hero.gold > hero.costOf("soldier"):
            hero.summon("soldier")
    if hero.health < 3000:
        for friend in friends:
            if friend and friend.type == "paladin":
                if friend.canCast("heal"):
                    hero.command(friend, "cast", "heal" , hero)
1 Like

@AnSeDra poti sa ma ajuti

Could you explain more clearly what you are having trouble with and also post a screenshot of what happens when you run your code?

@AnSeDra isn’t really active anymore, try asking @Chaboi_3000 or @Deadpool198

when i run the code i die at the the beam-towers

1 Like

@Deadpool198 or @Chaboi_3000 can you help me

Why do you pass the tower?

my hero stops moving and only spawns soldiers

code

while True:
    paladins = []
    enemies = hero.findNearestEnemy()
    greenFlag = hero.findFlag("green")
    blackFlag = hero.findFlag("black")
    violetFlag = hero.findFlag("violet")
    if violetFlag:
        friends = hero.findFriends()
        if friends:
            for friend in friends:
                if friend:
                    hero.command(friend, "move", violetFlag.pos)
    if greenFlag:
        hero.pickUpFlag(greenFlag)
    if blackFlag:
        hero.pickUpFlag(blackFlag)
        hero.attack(enemy)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    friends = hero.findFriends()
    for enemy in hero.findEnemies():
        friends = hero.findFriends()
        for friend in friends:
            e = friend.findNearestEnemy()
            if e:
                hero.command(friend, "attack", e)
    fire = hero.findNearestEnemy()
    if fire:
        if fire.type == "thrower":
            hero.findFriends()
            if friend.type == "archer":
                hero.command(friend, "attack", target)
        if fire.type == "beam-tower":
            if hero.canCast("chain-lightning", target):
                hero.cast("chain-lightning", target)
            hero.attack(enemy)
            pass
        if hero.gold > hero.costOf("archer"):
            hero.summon("archer")
    if hero.health < 3000:
        for friend in friends:
            if friend and friend.type == "paladin":
                if friend.canCast("heal"):
                    hero.command(friend, "cast", "heal" , hero)

problemdsjkfdgkjsdhf

Yeah, the problem is here. You have to write target = hero.findNearestEnemy()
Also, you have to write friends = hero.findFriends(), and then you have to write for, and only in it command your friends.

where do i need to write for?

After friends = hero.findNearestFroends().

what are froends?

you mean like this

if fire:
        if fire.type == "thrower":
            friend = hero.findFriends() for
            if friend.type == "archer":
                hero.command(friend, "attack", fire)

@PeterPalov means like this:

friends = hero.findFriends()
for friend in friends:
    if friend:
        #command your friends and everything else

i tried but i die at the beam towers

@PeterPalov , @abc and @Deadpool198 can you guys help me

Please could you post the very latest version of your code so I can see what’s going on. Thanks

@Deadpool198 this is my latest code:

while True:
    paladins = []
    enemies = hero.findNearestEnemy()
    greenFlag = hero.findFlag("green")
    blackFlag = hero.findFlag("black")
    violetFlag = hero.findFlag("violet")
    if violetFlag:
        friends = hero.findFriends()
        if friends:
            for friend in friends:
                if friend:
                    hero.command(friend, "move", violetFlag.pos)
    if greenFlag:
        hero.pickUpFlag(greenFlag)
    if blackFlag:
        hero.pickUpFlag(blackFlag)
        hero.attack(enemy)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    friends = hero.findFriends()
    for enemy in hero.findEnemies():
        friends = hero.findFriends()
        for friend in friends:
            e = friend.findNearestEnemy()
            if e:
                hero.command(friend, "attack", e)
    fire = hero.findNearestEnemy()
    if fire:
        if fire.type == "thrower":
            pass
        while fire.health > 0:
            if hero.canCast("invisibility", hero):
                hero.cast("invisibility", hero)
            hero.attack(fire)
            hero.shield()
        if fire.type == "beam-tower":
            hero.command("archer", "attack", "beam-tower")
        if hero.gold > hero.costOf("archer"):
            hero.summon("archer")
    if hero.health < 3000:
        for friend in friends:
            if friend and friend.type == "paladin":
                if friend.canCast("heal"):
                    hero.command(friend, "cast", "heal" , hero)

Did it work For you?