Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.
I'm not sure how to stop the form reversion, but the actual changing form part is quite easy:
Here's the move effect (Note: This assumes effect ID 159 isn't used)
class PokeBattle_Move_159 < PokeBattle_Move
def pbEffectAfterHit(attacker,opponent,turneffects)
if...