Bonememder can be solved without writing any line of code, just click run and you are successful.
Even worse, writing the code that heals your soldiers actually breaks the pattern and kills your soldiers.
Why this happens? When you heal a soldier, he will go back to the enemies immediately, so all the future events on the level change. Once he goes away he will tank the enemies and he will receive more damage that if he was not healed at all.
At some point, you will need to heal again, and this time both soldiers will need healing. Healing the wrong one will fail the level.
Shortly: you heal them, you kill them
change the heal distance check to <12, it changes the healing pattern and you can pass the level with the intended code.
Smarter, but more work: code the soldier to go close to you only if
- their health is under a threshold
- they have less health than their friend.
So you will automatically heal the correct solider while the other tanks.
Also, make the enemies wait a bit before charging, so they will not end up fighting your soldiers into the healing zone.