Clash of Clones: Help with retreat code (python)

Hey everyone,

I am so close to beating this (granted through kind of a passive strategy… but, hey, it seems to be working), so close I die right as my final three archers kill the enemies. Rawr. The issue as I perceive it is that my hero won’t bail out of the fight when I tell her to. I’ve tried to use a “while” loop with conditions about there being remaining enemies AND she needs over a certain amount of health (her maxHealth / 4). However, she’s not bailing and it’s literally killing her/me.

Note: I do not have a weapon equipped. Just a ton of armor. And a shield with bash. Also, I have no more gems. Womp. GET ME TO THE MOUNTAINS!!! Rawr.

Code:

loop:
    enemyIndex = 0
    enemies = self.findEnemies()
    while enemyIndex < len(enemies) and self.health > self.maxHealth / 4:
        enemy = enemies[enemyIndex]
        enemyIndex += 1
        if enemy.type != 'sand-yak':
            while enemy.health > 0:
                if self.isReady("bash"):
                    self.bash(enemy)
                else: 
                    self.shield()
    if self.health <= self.maxHealth / 4:
        self.jumpTo({"x": 44, "y":44})
        enemy = enemies[enemyIndex]
        distance = self.distanceTo(enemy)
        enemyIndex += 1
        if distance < 2:
            if self.isReady("bash"):
                self.bash(enemy)
            else:
                self.shield()

Oh wait, nvm, I may have figured it out. I wasn’t breaking out of the second “while” loop.

I cannot unequip my sword. help.

try selecting a hammer.

Don’t revive dead threads especially when it is unrelated to the title of the topic.