I think most users uses the "Replace unit" action.
For example; Troll in DotA, he has a spell where he can either be Melee or Ranged.
To create this, you first make the spell, then a trigger like this:
A unit starts casting your spell, then you Replace the unit with another unit (of course, you must first create another unit that uses the same model and such as the casting unit). You must also set the levels, mana, hitpoints and such as variables, and then set the new units mana and such, to those values...
If u don't understand, or need an Example trigger, I'll fix it for you.