I need help for Summits Gate!

Hi now I need help on Summits Gate too. Here is my code:

# Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
def commandPaladin(paladin):
    down = {"x": paladin.pos.x, "y": paladin.pos.y - 40}
    if hero.health <= 300:
        hero.command(paladin, "cast", "heal", hero)
    elif enemy:
        hero.command(paladin, "attack", enemy)
    else:
        hero.command(paladin, "move", down)
        if enemy:
            hero.command(paladin, "attack", enemy)
        else:
            hero.command(paladin, "move", down)
def commandSoldiers(friend):
    if enemy and enemy.type is "catapult":
        hero.command(friend, "attack", enemy)
    elif enemy:
        hero.command(friend, "attack", enemy)
def commandArchers(friend):
    if enemy:
        hero.command(friend, "attack", enemy)
def commandFriends():
    if friend and friend.type == "soldier":
        commandSoldiers(friend)
    if friend and friend.type == "paladin":
        commandPaladin(paladin)
    if friend and friend.type == "archer":
        commandArchers(friend)
loop:
    friend = hero.findNearest(hero.findFriends())
    friends = hero.findFriends()
    paladins = hero.findByType("paladin")
    paladin = hero.findNearest(paladins)
    enemy = friend.findNearest(friend.findEnemies())
    heroEnemy = hero.findNearest(hero.findEnemies())
    flag = hero.findFlag("violet")
    if flag and paladin.canCast("heal"):
        hero.pickUpFlag(flag)
        hero.command(paladin, "cast", "heal", hero)
    elif flag and enemy:
        hero.jumpTo(flag)
        hero.pickUpFlag(flag)
    elif flag:
        hero.pickUpFlag(flag)
    if friend and heroEnemy and heroEnemy.type == "warlock":
            hero.command(friend, "attack", heroEnemy)
    elif heroEnemy and heroEnemy.type == "tower":
        hero.attack(heroEnemy)
    elif heroEnemy:
        hero.attack(heroEnemy)
    else:
        hero.moveXY(hero.pos.x, hero.pos.y - 20)
        elif heroEnemy:
            hero.attack(heroEnemy)
        else:
            hero.moveXY(hero.pos.x, hero.pos.y + 10)
    commandFriends()

Any suggestions? @UltCombo @AdrianCgw?

Looks like you are in the right path, but you will need a bit more of strategy to beat this level. Some general tips:

  • You should have a boss star equipped by now, and it generates gold every second. Use that gold to summon more troops. I personally like summoning griffin-riders, but perhaps you can find more cost-effective units.

  • Your hero is always attacking the nearest enemy. That will likely fail when you reach the warlocks, which constantly summon skeletons. I recommend prioritizing your target, I mean, find the most dangerous enemy (one way to do that is checking their type) and attack it instead of the nearest one. You can even define a function to find the best enemy, that way your code will stay tidy.

  • When attacking the towers, you should try to position your hero as far from the opposite tower as possible, so that only one tower will attack your hero at a time.

This level is very long and extremely harder than the previous levels (more so if you are using the free-to-play heroes). It places a real challenge, and what comes after it is even harder. My advice is to keep your code tidy, think throughout before writing the code—that will save you a lot of time in the end—and have patience. Good luck! :slight_smile:

I have incorporated abilities in my code and I edited it a bit I’m planning to incorporate the boss star. Any other suggestions? Here is my code:

# Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
def commandPaladin():
    for paladin in paladins: 
        down = {"x": paladin.pos.x, "y": paladin.pos.y - 40}
        if hero.health <= 300:
            hero.command(paladin, "cast", "heal", hero)
        elif enemy:
            hero.command(paladin, "attack", enemy)
        else:
            hero.command(paladin, "move", down)
            if enemy:
                hero.command(paladin, "attack", enemy)
            else:
                hero.command(paladin, "move", down)
def commandSoldiers(friend):
    for friend in friends:
        if enemy and enemy.type is "catapult":
            hero.command(friend, "attack", enemy)
        elif enemy:
            hero.command(friend, "attack", enemy)
def commandArchers(friend):
    for friend in friends:
        if enemy:
            hero.command(friend, "attack", enemy)
def commandFriends():
    if friend and friend.type == "soldier":
        commandSoldiers(friend)
    if friend and friend.type == "paladin":
        commandPaladin()
    if friend and friend.type == "archer":
        commandArchers(friend)
def flagFunction(flag):
    if flag and enemy:
        hero.jumpTo(flag)
        hero.pickUpFlag(flag)
    elif flag:
        hero.pickUpFlag(flag)
def commandHero(hero):
    if friend and enemy and enemy.type == "warlock":
            hero.command(friend, "attack", heroEnemy)
    elif heroEnemy and heroEnemy.type == "tower":
        hero.attack(heroEnemy)
    elif heroEnemy:
        if hero.isReady("stomp"):
            hero.stomp()
        elif hero.isReady("throw"):
            hero.throw(heroEnemy)
        elif heroEnemy:
            hero.attack(heroEnemy)
    else:
        hero.moveXY(hero.pos.x, hero.pos.y - 20)
        elif heroEnemy:
            hero.attack(heroEnemy)
        else:
            hero.moveXY(hero.pos.x, hero.pos.y + 10)
    
loop:
    friends = hero.findFriends()
    friend = hero.findNearest(friends)
    paladins = hero.findByType("paladin")
    enemy = friend.findNearest(friend.findEnemies())
    heroEnemy = hero.findNearest(hero.findEnemies())
    flag = hero.findFlag("violet")
    commandFriends()
    flagFunction(flag)
    commandHero(hero)

Hey I am new and I need help with summits gate:here is my code

# Fight your way into the Inner Sanctum of the ogre chieftain, and defeat
hero.cast("invisibility", hero)
while True:
    flag = self.findFlag("green")
    warlock = self.findNearest(self.findByType("warlock"))
    chief = self.findNearest(self.findByType("chieftain"))
    witch = self.findNearest(self.findByType("witch"))
    friends = hero.findFriends()
    if hero.time >= 67:
        break
    for friend in friends:
        if friend.type is 'paladin':
            if hero.health<1000:
                hero.command(friend, "cast", 'heal', hero)
    if flag:
        self.pickUpFlag(flag)
    if witch:
        self.attack(witch)
    if chief:
        self.attack(chief)
    if warlock:
        self.attack(warlock)
    else:
        enemy = self.findNearest(self.findEnemies())
        if enemy:
            self.attack(enemy)
hero.moveXY(184, 6)
hero.cast("invisibility", hero)
while True:
    flag = self.findFlag("green")
    warlock = self.findNearest(self.findByType("warlock"))
    chief = self.findNearest(self.findByType("chieftain"))
    witch = self.findNearest(self.findByType("witch"))
    friends = hero.findFriends()
    for friend in friends:
        if friend.type is 'paladin':
            if hero.health<1000:
                hero.command(friend, "cast", 'heal', hero)
    if hero.canCast("invisibility", hero):
        hero.cast("invisibility", hero)
    if flag:
        self.pickUpFlag(flag)
    if witch:
        self.attack(witch)
    if chief:
        self.attack(chief)
    if warlock:
        self.attack(warlock)
    else:
        enemy = self.findNearest(self.findEnemies())
        if enemy:
            self.attack(enemy)

Hi @InvincibileDude999, welcome to the forum! :tada:
I see you’ve also made a another topic about this level. Please only make one post about your issue: a new topic would be best (which you have now done).
Thank you,
Danny