Someone please help me with python on summit's gate!

The projectile is called Flaming Shell

oooooooooooh!!! thanks!

Everyone still dies though. Maybe my army just isn’t fast enough.

Basically, it is better to take out the catapults as soon as possible but I believe trying to avoid the projectile is a good idea and fun to learn :slight_smile:

Oh well… thanks for helping me though.

ROOM ONE IS DONE!!! Would you look at that, it rhymed! Does anyone have tips for the towers in room two? They kill off my remaining allies, and I might just end up running past them. I used a flag strategy thing, so I can write new strategies.

Oh great. I was updating my whole code to go with the flag strategy, and there was an error again! And it was an infinite loop error. Again. Here’s my code, hopefully one of you guys can see what’s wrong with it this time:

def didPhaseEnd():
    enemy = hero.findNearestEnemy()
    if enemy and enemy.pos.x < door.pos.x and enemy.type != "door" and enemy.health > 0:
        return False
    else:
        return True

def summonGriffin():
    if hero.gold >= hero.costOf("griffin-rider"):
        hero.summon("griffin-rider")

def findLowestFriend():
    friends = hero.findFriends()
    lowestFriend = None
    lowestHealth = 9999999999999999999999999999999999999999999999999999999999999999999999999999999
    for friend in friends:
        if friend.type == "paladin":
            if friend.health/friend.maxHealth < lowestHealth and friend.health < friend.maxHealth:
                lowestFriend = friend
                lowestHealth = friend.health/friend.maxHealth
    if not lowestFriend:
        for friend in friends:
            if friend.health/friend.maxHealth < lowestHealth and friend.health < friend.maxHealth:
                lowestFriend = friend
                lowestHealth = friend.health/friend.maxHealth
    if lowestFriend:
        return lowestFriend
    else:
        return None

def commandPaladin(paladin):
    if strategy == 0:
        needsHeal = findLowestFriend()
        if needsHeal:
            if needsHeal == paladin:
                hero.command(paladin, "shield")
            elif paladin.canCast("heal", needsHeal):
                hero.command(paladin, "cast", "heal", needsHeal)
            else:
                target = paladin.findNearest(hero.findByType("catapult"))
                if target:
                    hero.command(paladin, "attack", target)
                else:
                    target = paladin.findNearestEnemy()
                    if target and target.type != "door":
                        if paladin.distanceTo(target) < 5:
                            hero.command(paladin, "shield")
                        hero.command(paladin, "attack", target)
        else:
            target = paladin.findNearest(hero.findByType("catapult"))
            if target:
                hero.command(paladin, "attack", target)
            else:
                target = paladin.findNearestEnemy()
                if target and target.type != "door":
                    if paladin.distanceTo(target) < 5:
                        hero.command(paladin, "shield")
                    hero.command(paladin, "attack", target)

def commandGriffin(griffin):
    if strategy == 0:
        target = griffin.findNearest(hero.findByType("catapult"))
        if target:
            hero.command(griffin, "attack", target)
        else:
            target = griffin.findNearestEnemy()
            if target and target.type != "door":
                hero.command(griffin, "attack", target)

def commandSoldier(soldier):
    if strategy == 0:
        target = soldier.findNearest(hero.findByType("catapult"))
        if target:
            hero.command(soldier, "attack", target)
        else:
            target = soldier.findNearestEnemy()
            if target and target.type != "door":
                hero.command(soldier, "attack", target)

def commandArcher(archer):
    hero.command(archer, "defend", hero.pos)

def heroToBattle():
    if strategy == 0:
        enemy = hero.findNearest(hero.findByType("catapult"))
        if enemy:
            if hero.canCast("chain-lightning", enemy):
                hero.cast("chain-lightning", enemy)
            elif hero.isReady("bash"):
                hero.bash(enemy)
            else:
                hero.attack(enemy)
            hero.shield()
        else:
            enemy = hero.findNearestEnemy()
            if enemy:
                if hero.canCast("chain-lightning", enemy):
                    hero.cast("chain-lightning", enemy)
                elif hero.isReady("bash"):
                    hero.bash(enemy)
                else:
                    hero.attack(enemy)
                hero.shield()

def armyAttack():
    summonGriffin()
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "paladin":
            commandPaladin(friend)
        if friend.type == "griffin-rider":
            commandGriffin(friend)
        if friend.type == "soldier":
            commandSoldier(friend)
        if friend.type == "archer":
            commandArcher(friend)
    heroToBattle()

strategy = 0
while True:
    door = hero.findNearest(hero.findByType("door"))
    endPhase = didPhaseEnd()
    while not endPhase:
        armyAttack()
        endPhase = didPhaseEnd()
    door = hero.findNearest(hero.findByType("door"))
    if door:
        while door.health > 0:
            hero.attack(door)
    strategy += 1

My hero pauses once he’s about to hit the door, so maybe that’s some sort of clue.

Edit: The real problem was, that the returned value is: while True a while True do an infinite loop.

This whole explanation was not correct, I’m sorry about that

I get it, but how would I fix that? Do you think changing the nature of the function would work? like, instead of the function returning true when the phase has ended, it should return true while the phase hasn’t ended?

I just think this function should be removed altogether
you already have a while True loop
you can just put if conditions in that loop

for example this conditions:

if enemy and enemy.pos.x < door.pos.x and enemy.type != “door” and enemy.health > 0 and strategy == 0:
strategy += 1

if strategy == 1:
more stuff to come

You could remove all your other while loops with that

Oh. Okay then! Thanks!

To destroy those super OP beam towers, you need a lot of health. The last time I tried with tharin, I failed. Every time I tried with tharin, I failed. When I tried with subscription, they would somewhat regenerate health. So, Super Congrats if you manage to finish the level.

Actually, when I was bored, I let the level play into the second room. Tharin managed to destroy all the towers. It’s probably because I have the best armor; enamaled dragonplate, enamaled dragonplate helmet, deflector, and boots of leaping. I guess my guy is just super o.p.

1 Like

0_0 what sword did you use? Actually, I failed because the towers are regenerating health, so then it’s practically impossible to beat the game until the bug is fixed.

Oh. Why do the bugs always favor the enemies anyway? Perhaps it’s a conspiracy! PERHAPS THEY’RE TRYING TO CHEAT THEIR WAY OUT OF GETTING MAULED BY YETIS!!! Sorry… I got a wee bit too into it… But anyway, I used the runesword.

Try senick with the best armor and weapon(gift of the trees) and keep healing.

1 Like

I didn’t subscribe. I’m doing just fine without premium, so why spend money on stuff I don’t even need? Also, I probably wouldn’t want to waste gems at the moment, so even if I could buy him, I still probably wouldn’t.

You know, subscription is pretty good, and I’m using it.

1 Like

well try your best on functions in this level. Some code may be repeated and functions are going to be your best friend in this level. Good luck!

That is exactly the strategy I used and the towers regenerated health faster then me attacking them

1 Like