To add to what @TheBredMeister is saying…the enemy hero will exactly match you, as far as armor, weapons and health. But, where he cannot match you is with tactics, special moves, etc…he won’t cleave, can’t use the Emperor’s Gloves (for example), etc.
I’d recommend starting with the archers and take them out first (which you might be doing with weakestEnemy already). Also, keep an eye on your hero’s health…I coded mine to have him withdraw behind his troops, to give himself a breather and allow the Wooden Strand a chance to regenerate him some, before plowing in again.
@dedreous is correct in his summation, but you should also keep in mind using the Steel Ring to slow down your clone so he can do less damage to your soldiers.
Also, if you do have access to premium, use your pet to kill the archers while taking care of the frontline soldiers, then taking a breather
Which hero are you using and what special gear (rings or emperor’s gloves) do you have? How many gems do you have? Using a hero that has special abilities helps to. The subscribers really benefit on this level with access to more gear.
To target your clone, you can check for the enemy.type using the list below since your enemy matches your type.
The one issue I see that will create prevent your hero from retreating is calling hero.attack(enemy) multiple times on the same enemy. If the enemy dies on the first attack, your hero will still try to attack the dead enemy. Since it is dead, it won’t continue the code and you can get stuck.
Consider using if - elif - else to run through the sequence of special attacks, if nothing else then attack. When you are using the special attacks, don’t look for a nearest enemy again, use the same one you declared at the top. Put the strongest attacks at the top of the list so they take priority when available. Another little thing, the shield works for less than a second, so unless you put it in a loop it doesn’t protect you much and takes away time from your attacks. If you regenerate health, maybe put a while loop with the shield after you checked your health and the hero moved to the safe location. This may buy you enough time to use the special attacks again after their cooldown period
One last detail, the function findWeakestEnemy() is not returning the weakest enemy. The return needs to be outside of the for loop (indentation inline with the “for”) to check every enemy. Now it is returning the first one on the list.
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()
if enemy:
if hero.isReady("special-attack"):
hero.specialAttack(enemy)
elif hero.canCast("cool-spell"):
hero.cast("cool-spell", enemy)
else:
hero.attack(enemy)
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.
while True:
if retreat == True:
hero.retreat()
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
Danny
Way to go @anon66968315!
Everyone needs a little nudge now and then so don’t be afraid to ask for helo in the future!
Now go and dominate Cloudrip Mountain!