Here is my full code so far:
# Fight your way into the Inner Sanctum of the ogre chieftain, and defeat her.
def outerGate():
soldier = hero.findByType("soldier")
for i in range(len(soldier)):
if i < 2:
if i == 0:
hero.command(soldier[0], "move", {"x": 92, "y": 60})
if i == 1:
hero.command(soldier[1], "move", {"x": 92, "y": 7})
else:
hero.command(soldier[i], "defend", hero)
friends = hero.findFriends()
for friend in friends:
if friend.type != "soldier":
hero.command(friend, "defend", hero)
def doorOne():
hero.moveXY(98, 33)
enemy = hero.findNearestEnemy()
if enemy:
if enemy.health > 0:
hero.attack(enemy)
if enemy.health <= 0:
hero.moveXY(7, 41)
def defenseStrat():
friends = hero.findFriends()
enemy = hero.findNearestEnemy()
for friend in friends:
if friend.type == "paladin":
if friend.canCast("heal", friend) and friend.health < friend.maxHealth:
hero.command(friend, "cast", "heal", friend)
else:
if enemy:
if enemy.type == "thrower":
if friend.type == "archer":
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "defend", hero)
def innerGate():
hero.moveXY(129, 59)
paladins = hero.findByType("paladin")
for paladin in paladins:
hero.command(paladin, "move", {"x": 91, "y": 54})
if paladin.canCast("heal", hero):
hero.command(paladin, "cast", "heal", hero)
if paladin.health < paladin.maxHealth / 3 * 2 and paladin.canCast("heal", paladin):
hero.command(paladin, "cast", "heal", paladin)
friends = hero.findFriends()
towers = hero.findByType("tower")
tower1 = towers[0]
tower2 = towers[1]
if hero.gold >= hero.costOf("archer"):
hero.summon("archer")
if tower2 and tower2.health > 0:
while tower2.health > 0:
for friend in friends:
if friend.type != "paladin":
hero.command(friend, "attack", tower2)
if hero.isReady("bash"):
hero.bash(tower2)
else:
hero.attack(tower2)
hero.moveXY(129, 10)
if tower1 and tower1.health > 0:
while tower1.health > 0:
for friend in friends:
if friend.type != "paladin":
hero.command(friend, "attack", tower1)
if hero.isReady("bash"):
hero.bash(tower1)
else:
hero.attack(tower1)
def doorTwo():
hero.moveXY(154, 33)
enemy = hero.findNearestEnemy()
if enemy:
if enemy.health > 0:
hero.attack(enemy)
def innerSanctumOne():
friends = hero.findFriends()
for friend in friends:
hero.command(friend, "defend", hero)
if hero.gold >= hero.costOf("archer"):
hero.summon("archer")
hero.moveXY(241, 14)
if hero.time > 166:
hero.moveXY(240, 53)
def innerSanctumTwo():
hero.moveXY(276, 54)
enemy = hero.findNearestEnemy()
vax = "Vax"
vyrr = "Vyrryx"
friends = hero.findFriends()
if vax and vax.health > 0:
while vax.health > 0:
for friend in friends:
if friend.team == hero.team:
if friend.type != "paladin":
hero.command(friend, "attack", vax)
if vyrr and vyrr.health > 0:
while vyrr.health > 0:
for friend in friends:
if friend.team == hero.team:
if friend.type != "paladin":
hero.command(friend, "attack", vyrr)
if enemy:
hero.attack(enemy)
if hero.gold > hero.costOf("soldier"):
hero.summon("soldier")
while True:
outerGate()
if hero.time > 45 and hero.time < 60:
doorOne()
if hero.time > 60 and hero.time < 77:
defenseStrat()
if hero.time > 77 and hero.time < 120:
innerGate()
if hero.time > 120 and hero.time < 138:
doorTwo()
if hero.time > 138 and hero.time < 177:
innerSanctumOne()
if hero.time > 177:
innerSanctumTwo()