Here is my non working code
# The ogres are trapping you with their dark rituals!
# Your hero can't do anything besides command and move without angering the warlocks.
# Beware ice, robots, traps, antigravity fields, and other dark magic.
# Somehow, you'll need to defeat Nalfar and save your paladin.
# The great treasure of Kelvintaph awaits your victory.
def att(enemy):
if enemy and hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
if hero.isReady("shield"):
hero.shield()
elif enemy and hero.isReady("cleave") and hero.distanceTo(enemy)<5:
hero.cleave(enemy)
if hero.isReady("shield"):
hero.shield()
elif enemy and hero.isReady("bash") and hero.distanceTo(enemy)<3:
hero.bash(enemy)
if hero.isReady("shield"):
hero.shield()
elif enemy and hero.distanceTo(enemy)<3:
hero.attack(enemy)
def soldierAtt(sPos):
soldiers=hero.findFriends()
for soldier in soldiers:
enemy=soldier.findNearestEnemy()
if soldier and soldier.type!='paladin' and enemy.type!='yeti':
hero.command(soldier, 'shield')
hero.command(soldier, "attack", enemy)
elif soldier and soldier.type!='paladin':
hero.command(soldier, "move", sPos)
def soldierAttNearest(soldier):
enemy=soldier.findNearest(hero.findByType("shaman", hero.findEnemies()))
if enemy and soldier and soldier.distanceTo(enemy)<20:
hero.command(soldier, "attack", enemy)
elif enemy:
hero.command(soldier, "move", enemy.pos)
def commandPaladin(eType):
paladin=hero.findByType("paladin", hero.findFriends())
enemy=hero.findByType(eType, hero.findEnemies())
if eType!='' and paladin and paladin.health < paladin.maxHealth*0.8:
hero.command(paladin, "cast", "heal", paladin)
if eType=='' and paladin:
hero.command(paladin, "shield")
elif enemy and eType!='' and paladin:
hero.command(paladin, "attack",enemy)
hero.command(paladin, "shield")
Hstage1=True #move to position to avoid robot missiles
Pstage1=True
m1=True
A1stage1=True
A2stage1=True
S1stage1=True
S2Stage2=True
archers=hero.findByType('archer',hero.findFriends())
#hero.say('archer 0 is '+archers[0])
soldiers=hero.findByType('soldier',hero.findFriends())
paladins=hero.findByType('paladin',hero.findFriends())
shamans=hero.findByType('shaman',hero.findEnemies())
friends = hero.findFriends()
enemy=archers[1].findNearestEnemy()
#hero.command(paladins[0], "shield")
while True:
if Hstage1:
hero.move({'x':33,'y':23})
if hero and hero.pos.y>=22:
#hero.say('disabled hstage1')
Hstage1=False
#Hstage2=True
pass
if Hstage2:
#can't do this as the warlocks go mad
if hero.canCast("undying-charm", paladins[0]) and paladins[0].health<100 and False:
hero.cast("undying-charm", paladins[0])
hero.say('cuc')
Hstage2=False
Hstage3=True
if Pstage1 and hero.time>3.5:
hero.command(paladins[0], "move", {'x':86,'y':70})
hero.command(paladins[0], "shield")
if paladins[0].canCast('heal'):
hero.command(paladins[0], "cast",'heal', paladins[0])
#Pstage1=False
Pstage2=True
if A1stage1 and hero.time>=2.7:
enemy=archers[1].findNearestEnemy()
#hero.say(archers[1])
if enemy.type=='shaman':
hero.say(enemy)
origEnemy=enemy
hero.command(archers[1], "attack", enemy)
if enemy.health<=0:
A1stage1=False
A1stage2=True
if A1stage2:
#hero.say('a1s2')
hero.command(archers[1], "move", {'x':26,'y':40})
A1stage3=False
if A1stage3:
newPos=Vector(25,66)
soldierAtt(newPos)