Everything your hero does takes time. The only things that do not take time are the commands to your soldiers - they can act in parallel with you.
As a result, when you command your hero to do anything, you’re basically telling your soldiers: do whatever you are set to do right now, I am busy and I can’t instruct you.
You code basically does:
for j in range(len(friends)):
if (enemy)
self.shield()
Shield takes 0.433 seconds to process so the entire for will take 1.733 seconds to circle through 4 soldiers. During this time each soldier received only a move command with takes 0.033 seconds to be executed. That means for the rest 1.7s their behavior is not specified.
Solution
command all your soldiers first, then command your hero. The soldiers will follow their current instruction while the hero is busy
Also, you are searching for your friends on each loop.
Initially, your friends array is [soldier1,soldier2,soldier3,soldier4]
assigned to [point1, point2, …]
If the first soldier gets killed, then a new search for friends will give you [soldier2,solider3,solider4]
to be assigned to [point1,point2,point3,point4]
Result: soldier2 will have to go to point1. Once he is killed also, soldier3 will go to point1, etc
i also tried changing the points[j] and friends[j] to points[i] and friends[i] and only one soldier moved to the point of the last soldier and he got killed by ogres so i changed it back to points[j] and friends[j]
Glad to hear you have beat it. The solution is to not re-search for the friends in the loop. You are not going to get new soldiers in this level anyway, so what is the point of searching again?
So:
loop:
friends = self.findFriends()
becomes:
friends = self.findFriends()
loop:
Inside the loop, you can test if a friend is still alive:
if friends[j] && friends[j].health > 0:
self.command(friends[j], "move", points[j])
In this way, if soldier1 dies, he will be a dead soldier at j=0, soldier2 it will still be at index j=1 in friends. They do not change places