Hmm.. If the HERO lets the BUILDING cast an ABILITY: It would change the OWNER of the BUILDING and it would also change the BUILDING to another type of BUILDING?
Set the BUILDING to NEUTRAL and let it sell an ITEM which is the ABILITY.
This is for changing the owner of the BUILDING:
Event: Unit sells an item (from shop).
Condition: Item type of sold item is equal to ITEM (Ability to change owner)
Action: Change ownership of selling unit to owner of buying unit and change color.
This is for changing the BUILDING to another BUILDING:
Event: Unit sells an item (from shop)
Condition: Item type of sold item is equal to ITEM (Diner Extort)
Action: -Change ownership of selling unit to owner of buying unit and change color.
-Replace selling unit (Diner) with a DINER EXTORT.
I hope this would help.. Just try one of those if you want