Hi, I have been stuck on this level for quite some time and can’t seem to figure out what is wrong can someone help me?
Here is my code:
while True:
enemy = hero.findNearestEnemy()
distace = hero.distanceTo(enemy)
flag = hero.findFlag()
if distance < 20:
if hero.isReady("cleave"):
hero.cleave(enemy)
if not hero.isReady("cleave") and hero.isReady("bash"):
hero.bash(enemy)
else:
hero.attack(enemy)
hero.attack(enemy)
if not distance < 20:
flagpos = flag.pos
fx = flagpos.x
fy = flagpos.y
hero.moveXY(fx, fy)
hero.pickUpFlag(flag)
I changed by code a bit and here it is now.
Is there any problems?
while True:
enemy = hero.findNearestEnemy()
flag = hero.findFlag
if enemy and hero.distanceTo(enemy) > 20:
if hero.isReady("cleave"):
hero.cleave(enemy)
if not hero.isReady("cleave") and hero.isReady("bash"):
hero.bash(enemy)
else:
hero.attack(enemy)
hero.attack(enemy)
if flag:
hero.moveXY(pos.x, pos.y)
flagpos = flag.pos
fx = flagpos.x
fy = flagpos.y
hero.moveXY(fx, fy)
hero.pickUpFlag(flag)
The area at fx = flagpos.x it gave me an error for some reason
Ok that was the solution but now with the correct code I noticed that when my hero used the Cleave ability all the enemies around him died and he was supposed to go attack the other’s but instead he just sat there with the statement “but it’s dead…” how can I fix this?
If that was the solution please mark it with the . The “but it’s dead…” thing isn’t preventable. It happens when an ally kills the enemy you where targeting.