# Summits gate help

**URL:** https://discourse.codecombat.com/t/summits-gate-help/6878
**Category:** Uncategorized
**Created:** [February 29, 2016, 6:21pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878 "2016-02-29T18:21:05Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [February 29, 2016, 6:21pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/1 "2016-02-29T18:21:05Z")

</div>

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

```python
# 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()

```

---

<div class="post-metadata">

### Author: ![AdrianCgw](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@AdrianCgw](https://discourse.codecombat.com/u/AdrianCgw)
#### Post date: [February 29, 2016, 10:26pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/2 "2016-02-29T22:26:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 1, 2016, 5:43pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/3 "2016-03-01T17:43:34Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 1, 2016, 5:43pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/4 "2016-03-01T17:43:53Z")

</div>

I tried flags and they didnt help much

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 1, 2016, 5:44pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/5 "2016-03-01T17:44:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 1, 2016, 5:57pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/6 "2016-03-01T17:57:31Z")

</div>

I added a self.move to the def commandHero part

```python
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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 1, 2016, 5:59pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/7 "2016-03-01T17:59:50Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 1, 2016, 6:18pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/8 "2016-03-01T18:18:05Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 1, 2016, 6:19pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/9 "2016-03-01T18:19:27Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 4, 2016, 5:39pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/10 "2016-03-04T17:39:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 4, 2016, 6:02pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/11 "2016-03-04T18:02:35Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 4, 2016, 6:07pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/12 "2016-03-04T18:07:02Z")

</div>

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

```python
# 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)
```

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 4, 2016, 6:07pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/13 "2016-03-04T18:07:17Z")

</div>

Any tips with staying alive

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 4, 2016, 6:20pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/14 "2016-03-04T18:20:39Z")

</div>

i die after killing the head ogre

---

<div class="post-metadata">

### Author: ![AdrianCgw](https://avatars.discourse-cdn.com/v4/letter/a/ac8455/32.png) [@AdrianCgw](https://discourse.codecombat.com/u/AdrianCgw)
#### Post date: [March 5, 2016, 8:38am UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/15 "2016-03-05T08:38:47Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 7, 2016, 5:39pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/16 "2016-03-07T17:39:54Z")

</div>

Ok Ill do it 🙂

---

<div class="post-metadata">

### Author: ![ARasberrypy-thon](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@ARasberrypy-thon](https://discourse.codecombat.com/u/ARasberrypy-thon)
#### Post date: [March 7, 2016, 5:50pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/17 "2016-03-07T17:50:55Z")

</div>

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

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 7, 2016, 5:52pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/18 "2016-03-07T17:52:32Z")

</div>

I just beat it so i completed it

---

<div class="post-metadata">

### Author: ![ARasberrypy-thon](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@ARasberrypy-thon](https://discourse.codecombat.com/u/ARasberrypy-thon)
#### Post date: [March 7, 2016, 5:53pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/19 "2016-03-07T17:53:37Z")

</div>

Very nice! What was your strategy?

---

<div class="post-metadata">

### Author: ![lundor5](https://avatars.discourse-cdn.com/v4/letter/l/7993a0/32.png) [@lundor5](https://discourse.codecombat.com/u/lundor5)
#### Post date: [March 7, 2016, 5:55pm UTC](https://discourse.codecombat.com/t/summits-gate-help/6878/20 "2016-03-07T17:55:48Z")

</div>

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

[Next page](https://discourse.codecombat.com/t/summits-gate-help/6878.md?page=2)
