You can Make a custom engineering update (lets call it E ability)
put it in a disabled spell book and give that spell book to your hero
in Level 1 it turns B to A (B is the one at lower than % or whatever its)
in Level 2 it turns A to B
When Unit Learns Ability
If its C ability(the one allows you to change abilities)
Add it to YHTA group
Every Second
Pick Every Units in YHTA group
if Picked Units Health is Bellow %(35+(Level of C for Picked Unit)*10)
then
Set Level of E for Picked Unit to 2
else
Set Level of E for Picked Unit to 1
simple no jass no leaks
I will try to make same kind of spell and post it.
I was trying to make it but it doesn't work, i am going to try a difrent aproach and see if it works, sorry to keep you waiting, difrent time zone + school = busy.