States - Percent chance calculations

Hey there - had a look around, and can't find anything on the subject, so I figured I'd post here.

In my game, I have two ways of inflicting states. One is through the "Grey Blade" skill - a physical attack that has a small chance to inflict the status, regardless of Magic Attack or Defence. So, that's been done easily.

However, I want the regular casting of the spell to be affected by the enemy's Magic Defence, and the caster's Magic Attack. For example:

Blind: 60% + [a.MAT - b.MDF]%

Can anyone point me to a way of doing this?
This works:

rand(100)+(a.mat-b.mdf) >=40 ? b.add_state(stateID):0

The number at the end is the damage, you can put a fixed number or formula.
That's almost perfect, thank you! Only follow up question is how to remove the "target took no damage!" message that plays before the state hits.
rand(100)+(a.mat-b.mdf) >=40 ? b.add_state(stateID):10;10

Not sure how to have it as a state without any damage skill.
use yanfly's anti-fail message script to remove the no damage message
Yanfly's script sorted it. Thank you very much, both of you! Issue is solved. My Grey Mage can now either rely on physical attacks that occasionally debuff, or spells that frequently debuff, without damage
This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/states-percent-chance-calculations.16050/