Summits gate help


#1

My hero just walks into a wall or thing after destroying the towers and after a griffin destroys the gate past the towers

# Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
self.toggleFlowers(False)
def commandArchers():
    for archer in self.findByType("archer", self.findFriends()):
        nearestEnemy = archer.findNearestEnemy()
        if nearestEnemy:
            self.command(archer, "attack", nearestEnemy)

def commandSoldiers():
    for soldier in self.findByType("soldier", self.findFriends()):
        nearestEnemy = soldier.findNearestEnemy()
        if nearestEnemy:
            self.command(soldier, "attack", nearestEnemy)         

def commandGriffins():
    for griffin in self.findByType("griffin-rider", self.findFriends()):
        enemies = griffin.findEnemies()
        nearestEnemy = self.findNearest(enemies)
        if nearestEnemy:
            self.command(griffin, "attack", nearestEnemy)
        else:
            self.command(griffin, "defend", self)

def weakestFriend():
    weakestFriend = None
    weakestHealth = 999
    for friend in self.findFriends():
        if friend.health < friend.maxHealth and friend.health < weakestHealth:
            weakestHealth = friend.health
            weakestFriend = friend
    if weakestFriend:
        return weakestFriend
            
def commandPaladins():
    for paladin in self.findByType("paladin", self.findFriends()):
        if paladin.canCast("heal", self):
            if self.health < 3000:
                self.command(paladin, "cast", "heal", self)
            else:
                weakestFriend2 = weakestFriend()
                if weakestFriend2:
                    self.command(paladin, "cast", "heal", weakestFriend2)
        else:
            self.command(paladin, "move", {'x': self.pos.x - 4, 'y': self.pos.y})

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

def moveForward():
    targetPos = {'x': 328, 'y': 35}
    self.move(targetPos)

def pickTarget():
    enemies = self.findEnemies()
    target = None
    minDistance = 9999
    for enemy in enemies:
        if enemy.type is not "door":
            if enemy.type is "catapult":
                target = enemy
                break
            elif enemy.type is "warlock":
                target = enemy
                break
            elif enemy.type is "witch":
                target = enemy
                break
            elif enemy.type is "chieftain":
                target = enemy
                break
            else:
                if self.distanceTo(enemy) < minDistance:
                    minDistance = self.distanceTo(enemy)
                    target = enemy
    if target:
        return target

       
def commandHero():
    target = pickTarget()
    if target:
        while target.health > 0:
            if self.isReady("bash") and target.health > 116:
                self.bash(target)
            else:
                self.attack(target)
    else:
        moveForward()

loop:
    summonGriffin()
    commandArchers()
    commandSoldiers()
    commandGriffins()
    commandPaladins()
    commandHero()

#2

In the commandHero function, the hero will move forward if he cant see any enemies.
You can use flags or add more than one move point to make him avoid the center wall


#3

Ok but would it be a loop since the def commandHero since he continues to do that and the commandHero is under a loop


#4

I tried flags and they didnt help much


#5

Like i was trying to move with them and my hero ignored the flags and kept going for the ogres instead of luring them out


#6

I added a self.move to the def commandHero part

def commandHero():
    target = pickTarget()
    if target:
        while target.health > 0:
            if self.isReady("bash") and target.health > 116:
                self.bash(target)
            else:
                self.attack(target)
    else:
        moveForward()
        self.moveXY(194,51)

I tried to put and else: in for the self.move but it said code needs to line up unexpected indent


#7

My hero dies when dealing with ogres after the first gate in between the beam towers and dies from ogres and towers the paladins die


#8

I have 2609 health and i dont have enough for better armor i have enough for armor that gives less health


#9

i had enough for a new helmet that gives over 400 health now i have 2833 health


#10

My hero gets to the xy i gave him but then he just walks in a little circle i only want him to go to it once and not move in a little circle


#11

now my hero just dies i give up no one ever replies to me


#12

This is my new code with flags and it works but my hero dies

# Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
self.toggleFlowers(False)
def commandArchers():
    for archer in self.findByType("archer", self.findFriends()):
        nearestEnemy = archer.findNearestEnemy()
        if nearestEnemy:
            self.command(archer, "attack", nearestEnemy)
def commandSoldiers():
    for soldier in self.findByType("soldier", self.findFriends()):
        nearestEnemy = soldier.findNearestEnemy()
        if nearestEnemy:
            self.command(soldier, "attack", nearestEnemy)         
def commandGriffins():
    for griffin in self.findByType("griffin-rider", self.findFriends()):
        enemies = griffin.findEnemies()
        nearestEnemy = self.findNearest(enemies)
        if nearestEnemy:
            self.command(griffin, "attack", nearestEnemy)
        else:
            self.command(griffin, "defend", self)
def weakestFriend():
    weakestFriend = None
    weakestHealth = 999
    for friend in self.findFriends():
        if friend.health < friend.maxHealth and friend.health < weakestHealth:
            weakestHealth = friend.health
            weakestFriend = friend
    if weakestFriend:
        return weakestFriend
def commandPaladins():
    for paladin in self.findByType("paladin", self.findFriends()):
        if paladin.canCast("heal", self):
            if self.health < 3000:
                self.command(paladin, "cast", "heal", self)
            else:
                weakestFriend2 = weakestFriend()
                if weakestFriend2:
                    self.command(paladin, "cast", "heal", weakestFriend2)
        else:
            self.command(paladin, "move", {'x': self.pos.x - 4, 'y': self.pos.y})
def summonGriffin():
    if self.gold >= self.costOf("griffin-rider"):
        self.summon("griffin-rider")
def moveForward():
    targetPos = {'x': 328, 'y': 35}
    self.move(targetPos)
def pickTarget():
    enemies = self.findEnemies()
    target = None
    minDistance = 9999
    for enemy in enemies:
        if enemy.type is not "door":
            if enemy.type is "catapult":
                target = enemy
                break
            elif enemy.type is "warlock":
                target = enemy
                break
            elif enemy.type is "witch":
                target = enemy
                break
            elif enemy.type is "chieftain":
                target = enemy
                break
            else:
                if self.distanceTo(enemy) < minDistance:
                    minDistance = self.distanceTo(enemy)
                    target = enemy
    if target:
        return target
    
def commandHero():
    target = pickTarget()
    if target:
        while target.health > 0:
            if self.isReady("bash") and target.health > 116:
                self.bash(target)
            else:
                self.attack(target)
    else:
        moveForward()
        
loop:
    summonGriffin()
    commandArchers()
    commandSoldiers()
    commandGriffins()
    commandPaladins()
    commandHero()
    flag = self.findFlag("green")
    if  flag:
        self.pickUpFlag(flag)

#13

Any tips with staying alive


#14

i die after killing the head ogre


#15

There are a lot of crystals before the last door, you can collect them and build a huge army.
Just don’t let your army go near the chieftain - he has permanent AOE cleave attack.


#16

Ok Ill do it :slight_smile:


#17

Also, just a thought. Couldn’t you make archers stay away from chieftan and shoot it down?


#18

I just beat it so i completed it


#19

Very nice! What was your strategy?


#20

i gathered the crystals in front of the last gate to get griffins summoned and then i killed the ogres around where the crystals were with my griffins and other troops and then the boss was left and then i charged and my griffins killed it