# Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
def attack():
enemy = hero.findNearestEnemy()
if enemy and enemy.type != "skeleton":
if hero.distanceTo(enemy) <= 20:
while enemy.health > 0:
if hero.isReady("backstab"):
hero.backstab(enemy)
if hero.isReady("chain-lightning"):
hero.cast("chain-lightning", enemy)
if hero.isReady("scattershot"):
hero.scattershot()
else:
hero.attack(enemy)
def move():
flagG = hero.findFlag("green")
if flagG:
hero.pickUpFlag(flagG)
def summon():
if hero.costOf("griffin-rider") <= hero.gold:
hero.summon("griffin-rider")
if hero.costOf("griffin-rider") <= hero.gold:
hero.summon("griffin-rider")
if hero.costOf("archer") <= hero.gold:
hero.summon("archer")
if hero.costOf("soldier") <= hero.gold:
hero.summon("soldier")
def heal():
paladins = hero.findByType("paladin")
paladinIndex = 0
if paladins:
while paladinIndex < len(paladins):
paladin = paladins[paladinIndex]
currentHealth = hero.health
healingThreshold = hero.maxHealth - 150
paladins = hero.findByType("paladin")
if paladin:
if paladin.canCast("heal"):
hero.command(paladin, "cast", "heal", hero)
paladinIndex += 1
def command():
friends = hero.findFriends()
friendIndex = 0
while friendIndex < len(friends):
friend = friends[friendIndex]
enemy = friend.findNearestEnemy()
if enemy:
if friend:
hero.command(friend, "attack", enemy)
friendIndex += 1
def attack2():
enemies = hero.findEnemies()
enemyIndex = 0
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
summon()
command()
attack()
enemyIndex += 1
while True:
if hero.maxHealth > hero.currentHealth:
heal()
move()
summon()
command()
attack()
Here is my code… I have no idea what is wrong, but I always die when I have to go to fight the ogre chieftain.