My code is working fine but when the big ogres come I die. Here’s my code:
# Defeat as many ogres as you can.
# Use 'cast' and 'canCast' for spells.
while True:
enemy = hero.findNearestEnemy()
if not enemy and hero.canCast("regen", hero):
hero.cast("regen", hero)
if enemy and enemy.type != "catapult":
if hero.canCast("lightning-bolt", enemy):
hero.cast("lightning-bolt", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("root", enemy) and hero.distanceTo(enemy)>5:
hero.cast("root", enemy)
hero.attack(enemy)
elif not enemy and hero.canCast("regen", hero):
hero.cast("regen", hero)
else:
if enemy:
hero.say("C'mon! Move you stupid catapult!")
hero.say("C'mon!")
hero.moveXY(hero.pos.x+20, hero.pos.y)
hero.cast("lightning-bolt", enemy)
hero.moveXY(hero.pos.x-20, hero.pos.y)
I manage to get about 32 kills but then the big orges come and kill me.