def shouldAttack(target):
# return False if no target
if not target:
return False
# return False if target.type == "burl"
if target.type == "burl":
return False
# Otherwise, return True
else:
return True
while True:
enemy = hero.findNearestEnemy()
# Here we use shouldAttack() to decide if we should attack!
# heroShouldAttack will be assigned the same value that shouldAttack() returns!
heroShouldAttack = shouldAttack(enemy)
if heroShouldAttack:
hero.attack(enemy)
It’s placed inside if not target: block, so it won’t be executed. Be careful with indents in python and look for indents for predefined comments, usually, they are hints
I’m stuck at this level so could someone please help me?
My hero attacks all enemy nearby except for the burls, so all goes on well until he is completly submersed by a wave of ennemies.
So i thought I could use “cleave” but no one talks about it in the forum and more importantly if I use “cleave” there is always a burl nearby being attacked. Then I end up dead once again.
The distance tool is not working as well because I can’t manage to select the burl as an object (because burl is a type for this specific target).
Any further clue?
def shouldAttack(target):
if not target:
return False
elif target.type == "burl":
return False
else:
return True
while True:
enemy = hero.findNearestEnemy()
heroShouldAttack = shouldAttack(enemy)
if heroShouldAttack:
if hero.isReady("cleave")
hero.cleave(enemy)
else:
hero.attack(enemy)
So, we don’t recommend trying to cleave in a grove full of burls, for certain.
If you took out the references to cleave (that if/else) and just attacked, you should be able to win. If not, maybe upgrade your armor? I was able to beat it with ~100 health, but individual milage may vary.
A little bit late, but I had the same issue. The problem was I changed to another hero and forgot to equip the armor, so my health was below 20, after armor it was over 170.