Ability only effective while having X State

Without seeing the database and the exact formula and how it's being applied, I think it's the else{0} that's giving grief.

Try a.isStateAffected(29) ? a.addState(75) : 0;

change a.addState to b.addState as necessary as I don't know which one you're trying to apply to who.

All that said:
https://forums.rpgmakerweb.com/index.php?threads/damage-formulas-101.81905/
is going to have a more details on how to use the damage formula box to get what you want.

You also have Yanfly's damage core installed, which will allow you to do all kinds of pre/post eval work.

Original thread: https://forums.rpgmakerweb.com/threads/ability-only-effective-while-having-x-state.110553/