[SOLVED] Summits Gate Please Help!

Hello, I’m finally in Summits Gate, but it says “The code wouldn’t finish”
Here my code:

while True:
    paladins = []
    enemies = hero.findEnemies()
    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 enemies:
        if enemy.type == "catapult":
            while enemy.health > 0:
                hero.attack(enemy)
        friends = hero.findFriends()
        for friend in friends:
            enemy = hero.findNearestEnemy()
            if enemy:
                hero.command(friend, "attack", enemy)
    fire = hero.findNearestEnemy()
    if fire:
        while fire.health > 0:
            hero.attack(enemy)
        if fire.type == 'tower':
            pass
        if hero.pos.x > 160:
            hero.moveXY(175, 34)
            hero.moveXY(175, 8)
            hero.moveXY(245, 14)
            hero.moveXY(245, 34)
            while hero.health < hero.maxhealth:
                hero.moveXY(245, 34)
                if hero.gold >= 20:
                    hero.summon("soldier")
                paladins = hero.findByType("paladin")
                for paladin in paladins:
                    if paladin:
                        if paladin.canCast("heal", paladin):
                            hero.command(paladin, "cast", "heal", hero)
            if hero.maxHealth <= hero.health:
                if fire:
                    hero.moveXY(277, 34)
                    hero.moveXY(277, 5)
                    DJ = hero.findNearestEnemy()
                    if DJ:
                        while DJ.health > 0:
                            hero.attack(DJ)
                    hero.moveXY(277, 48)
                    lie = hero.findNearestEnemy()
                    if lie:
                        while lie.health > 0:
                            hero.attack(lie)
                    while True:
                        paladins = hero.findByType("paladin")
                        for paladin in paladins:
                            if paladin:
                                if paladin.canCast("heal", paladin):
                                    hero.command(paladin, "cast", "heal", hero)
                        fire = hero.findNearestEnemy()
                        if fire:
                            hero.attack(fire)

I tried to load the level with your code. There were not any warnings, but hero failed to complete the goals. Looks like you need to change your strategy a bit.

As for Maybe your computer can’t manage to load all level sources.
There are several good topics about Summits Gate with discussion about hints and advices. Try to search it maybe.

Thank you ! But I have a new problem. I can’t even get in to the level and start. Please help me!

Summits Gate

Please, give us more information about what’s going on - why you can’t reach thr level?

Two ways to solve:

  1. Comment out your code by clicking the brown button.

  2. Don’t use any armor, disequip everything. So your hero might die at the start and the infinite code won’t run anymore

1 Like

I tried num. 2, but I have no armor now, I can’t use the functions.

Thank you! I’ve get in to it

I have fixed my code, but it is raning out of time:

summonTypes = ['griffin-rider']
tactick = 'hold'
stage = 1


def summonTroops():
    type = summonTypes[len(hero.built) % len(summonTypes)]
    if hero.gold > hero.costOf(type):
        hero.summon(type)


def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend
    return lowestFriend


def commandPaladin(paladin):
    if (paladin.canCast("heal")):
        if (hero.health < hero.maxHealth * 0.8):
            target = self
        else:
            target = lowestHealthPaladin()
        if target:
            hero.command(paladin, "cast", "heal", target)
    elif (paladin.health < 100):
        hero.command(paladin, "shield")
    elif stage < 4:
        hero.command(paladin, "move", {'x': 94, 'y': 34})
    elif stage == 5:
        hero.command(paladin, "move", {'x': 284, 'y': 33})
    else:
        target = hero.findNearestEnemy()
        if (warlock):
            target = warlock
        if (target):
            hero.command(paladin, "attack", target)


def commandSoldier(soldier):
    target = hero.findNearestEnemy()
    if (warlock):
        target = warlock
    if stage == 3:
        hero.command(soldier, "move", {'x': 84, 'y': 34})
    elif (target):
        hero.command(soldier, "attack", target)


def commandFriends():
    friends = hero.findFriends()
    for friend in friends:
        if tactick == 'hold':
            hero.command(friend, "defend", {'x': 1, 'y': 40})
        elif friend.type == "paladin":
            commandPaladin(friend)
        else:
            commandSoldier(friend)


def moveTo(position):
    if (hero.isReady("jump")):
        hero.jumpTo(position)
    else:
        hero.move(position)


def attack(target):
    if target:
        if (hero.distanceTo(target) > 10):
            moveTo(target.pos)
        else:
            hero.attack(target)


def pickUpNearestItem():
    nearestItem = hero.findNearestItem()
    if nearestItem:
        moveTo(nearestItem.pos)


commandFriends()
hero.moveXY(31, 56)
while True:
    catapult = hero.findNearest(hero.findByType('catapult'))
    warlock = hero.findNearest(hero.findByType('warlock'))
    target = hero.findNearestEnemy()
    nearestItem = hero.findNearestItem()
    now = hero.now()
    if catapult:
        stage = 1
        attack(catapult)
    elif now < 20:
        tactick = 'defend'
        stage = 2
        moveTo({"x": 50, "y": 33})
    elif stage < 4:
        if target:
            stage = 3
            attack(target)
        else:
            moveTo({"x": 172, "y": 46})
        if hero.pos.x > 170:
            stage = 4
    elif stage < 5:
        if hero.pos.x < 240:
            moveTo({"x": 274, "y": 35})
            tactick = 'defend'
        elif nearestItem and hero.distanceTo(nearestItem) < 10:
            pickUpNearestItem()
            tactick = 'attack'
        elif (warlock):
            target = warlock
            summonTroops()
            attack(target)
        elif target and target.type != 'gates':
            attack(target)
        elif nearestItem and hero.distanceTo(nearestItem) < 45:
            pickUpNearestItem()
            tactick = 'defend'
            summonTroops()
        else:
            attack(target)
        if hero.pos.x > 290:
            stage = 5
        tactick = 'attack'
    else:
        summonTroops()
        attack(target)
    commandFriends()


So at what point of the level your hero can get? We see now the start of the level on the screenshot and that’s kinda not much informative)


Then Gordon deosn’t move

I want to buy the sword of forgotten , but I don’t have enogh gems to buy, I only have 3378 gems

Thank you, I solved the level

1 Like

Y’all plz stop cheating by giving others the answer.

Not sure why are you so offensive though, but we are helping people out. That’s the purpose of this forum. If you state all people “cheating”, then the devs can just delete CoCo because everyone is “cheating” through the levels. And, from your perspective, you are cheating too, as when you complete levels there are hints and quotes. So do you get it?

1 Like