Inflict State After Attack With Chance?

Hello!

So, I've been developing games with quite complicated database.
I've come to a problem, actually.

I made a skill with inflicting state to enemy after attack, so I use this formula.
b.addState(x); (a.atk * 4 - b.def * 2) * 2

But I want one of the skill has chance to inflict the state to enemies after the attack. Is there any further information about this formula? Like, adding the chance or something.

Thanks!
Yes there is!
If you're using Yanfly's Damagecore plugin you can paste this on the skills notebox:
Code:
<Damage formula>
value = (a.atk * 4 - b.def * 2) * 2;
if (randomNumber=Math.randomInt(4) !== 4){
target.addState(x);
}
</Damage formula>

If not you can write it the ugly way on the damage formula box:
Code:
if (randomNumber=Math.randomInt(4) !== 4){b.addState(x);} (a.atk * 4 - b.def * 2) * 2

Were the 4 on the formula represents the chance, if you write a 4 you have a 1/4 chance of success, you write an 8 you get 1/8 an so on.
The x is the sate ID you want to apply.
Yes there is!
If you're using Yanfly's Damagecore plugin you can paste this on the skills notebox:
Code:
<Damage formula>
value = (a.atk * 4 - b.def * 2) * 2;
if (randomNumber=Math.randomInt(4) !== 4){
target.addState(x);
}
</Damage formula>

If not you can write it the ugly way on the damage formula box:
Code:
if (randomNumber=Math.randomInt(4) !== 4){b.addState(x);} (a.atk * 4 - b.def * 2) * 2

Were the 4 on the formula represents the chance, if you write a 4 you have a 1/4 chance of success, you write an 8 you get 1/8 an so on.
The x is the sate ID you want to apply.
Thank you, mate!

Original thread: https://forums.rpgmakerweb.com/threads/inflict-state-after-attack-with-chance.88137/