Just make one of the transformations an ability (if the shapeshifter has more than one ability to shapeshift, consider putting it into a spellbook), add it on to your shapeshifter, then inside of a new trigger make the unit casts ability event and ability comparison condition then the replace unit action and put them inside an if/then/else multiple functions action. If I misunderstood you or didn't make enough sense, then sorry.