Hi,
I am trying to do level kelvintaph burgler but I keep getting an error message saying that paladin.canCast is not a function.
I am not sure why this isn’t working as I’ve used this before so it should do.
Any ideas?
Man thanks,
The code I’m using is below the screen shot
# What eldritch artifacts are these? Don't let them blast you!
# The ice gate will open when both ogres are defeated.
def commandPalatt():
armyExit=Vector( 78,40)
paladin=hero.findByType('paladin',hero.findFriends())
witch=hero.findByType('witch',hero.findEnemies())
chieftain=hero.findByType('chieftain',hero.findEnemies())
if paladin and paladin.canCast("heal", paladin) and paladin.health<paladin.maxHealth*0.8:
hero.command(paladin,'cast','heal',paladin)
elif witch and paladin:
hero.command(paladin, "attack", witch)
elif witch and chieftain:
hero.command(paladin, "attack", chieftain)
elif paladin:
hero.command(paladin, "move", armyExit)
def commandRest():
armyExit=Vector( 78,40)
chieftain=hero.findByType('chieftain',hero.findEnemies())
soldiers=hero.findByType('soldier',hero.findFriends())
archers=hero.findByType('archer',hero.findFriends())
for soldier in soldiers:
if soldier and chief:
hero.command(soldier, "attack", chief)
elif soldier and witch:
hero.command(soldier, "attack", witch)
elif soldier:
hero.command(soldier, "move", armyExit)
for archer in archers:
if archer and chief:
hero.command(archer, "attack", chief)
elif archer and witch:
hero.command(archer, "attack", witch)
elif archer:
hero.command(archer, "move", armyExit)
enemies=hero.findEnemies()
robots=[]
for enemy in enemies:
#hero.say(enemies[7].type)
#hero.say(enemy.type[0:5])
if enemy.type[0:5]=='robot':
robots.append(enemy)
midX=(robots[0].pos.x+robots[1].pos.x)/2
midY=(robots[0].pos.y+robots[1].pos.y)/2
#hero.say('x: '+midX +" y: "+midY)
midPoint=Vector(midX+2,midY)
while hero.posx<midPoint.x-2:
hero.move(midPoint)
iceGatePos=Vector(61,15)
#while hero.pos!=iceGatePos:
# hero.move(iceGatePos)
armyExit=Vector( 78,40)
#heroExitPos=Vector(78,14)
enemyMissile = hero.findNearest(hero.findEnemyMissiles())
while True:
iceGateVectorFromHero=Vector.subtract(iceGatePos,hero.pos)
iceGateVectorFromHero=Vector.normalize(iceGateVectorFromHero)
iceGateVectorFromHero=Vector.multiply(iceGateVectorFromHero,5)
enemyMissile = hero.findNearest(hero.findEnemyMissiles())
if enemyMissile:
distToEM=hero.distanceTo(enemyMissile)
#hero.say(distToEM)
if distToEM<5:
missileAttackVector=Vector.subtract(hero.pos,enemyMissile.pos)
missileAttackVector1=Vector.normalize(missileAttackVector)
missileAttackVector5=Vector.multiply(missileAttackVector1,5)
#hero.say(missileAttackVector)
goal=Vector.add(missileAttackVector5,iceGateVectorFromHero)
pass
if enemyMissile:
moveToPos=Vector.add(hero.pos,goal)
hero.move(moveToPos)
commandPalatt()
commandRest()