Guard Break type abilities in MV?

Basically, I'm trying to figure out how to make an ability, if used on a blocking opponent, remove their guard state, and add a stun state, but do nothing if they do not have that state. I've tried to crack this for about a month and have no clue. Anyone up for it?
Damage formula (assuming state 2 is your guard, replace X with stun state id):

if (b.isStateAffected(2)) {b.removeState(2); b.addState(X)}; 0

Original thread: https://forums.rpgmakerweb.com/threads/guard-break-type-abilities-in-mv.178266/