I think what he means is to make one big if statement broken down into sub ifs, elifs and elses.
This is a basic enemy attack structure which I always use:
enemy = hero.findNearestEnemy()
I think what brooksy (welcome back! ) meant here:
Is that you checked your health at the start, like you have done. Then you move to your safe location, then you do something like:
while certainCondition == True, or while certainValue <= 10.
Then, you can shield while that condition you’ve chosen is true, or, if it’s a value, while it’s above a certain level. Then you can continue with the rest of your code.
To stop your hero from ignoring the retreat part of you code, as brooksy said, you need to implement elifs like in the basic attack structure above.
if retreat == True:
elif somethingElse: # all if statements from hereon downwards need to be elifs instead
# continue your code
The reason for the elifs is because otherwise your hero is confused about what to do:
“My health is less than 500, BUT there’s also a weak enemy. What should I do?!!??”
When you use elif it only does the elif code if the condition of the if statement above is not met.
I hope this helps