Help for a level please


#1

Can someone help me with the level: seige of stoneholde, my code is correct but everytime my hero dies.
This is my code:
while True:
enemy = hero.findNearestEnemy()
flag = hero.findFlag(“green”)
if flag:
hero.pickUpFlag(flag)
elif enemy and hero.isReady(“cleave”):
hero.cleave(enemy)
elif enemy:
hero.attack(enemy)


#2

There is no theoretically “correct” code for this level as long as you have a strategy to fight the ogres. Maybe you need to get better armor.
You can also get healed by a wizard if you use hero.moveXY(19, 69) and your hero will move to a point on the map where the wizard instantly heals you. It requires slightly more advanced syntax and you probably don’t yet have access to sense stones that return your hero’s health and maxHealth, but just a tip :slight_smile:
Do you have sense stones that can do this? What gear does your hero have?


#3

Make sure you have good armor. I recommend getting the Deflector Shield and / or the Dragon Head and Chesplate; They serve as the ultamine barrier.


#4

Pierre’s probably not that advanced unless he can simulate a ton of games and get there. :slight_smile:


#5

Also you do not need to call elif enemy twice. Just call elif enemy once and then set up a separate code block with the cleave and attack abilities.


#6

thx everyone I will follow ur advices.


#7

Make sure that in the future, you format your code according to the FAQ.


#8

My technique is that you check when your hero’s health is low:

if hero.health<hero.maxHealth/2:
    hero.moveXY(20,68)

Otherwise keep attacking:

elif enemy:
    hero.attack(enemy)

this code will tell your hero to move to move to the x to get healed when your hero’s health is low. And also tells your hero to attack the target when your hero’s hp is higher. I hope this helps!


#9

This problem has already been solved.


#10

Thanx for your advice I will try it. it worked