A skill that has a chance to self inflict status

I wanted to make a skill that damages the opponent. and then has a chance to give the user a status effect. How do you do that?
It is possible to do this in the damage formula. However, if your game ever uses the autobattle Trait or if this skill can go on an enemy, you shouldn't do it that way. For information on that, see:

The better way to implement this is with Yanfly's Skill Core. Give the skill the notetag:
Code:
<Post-Damage Eval>
if (Math.random()<.83)
    user.addState(X);
</Post-Damage Eval>

where X is the ID of your state (no leading zeros), and you supply whatever number you want on the line above. So this one has an 83% chance.
It is possible to do this in the damage formula. However, if your game ever uses the autobattle Trait or if this skill can go on an enemy, you shouldn't do it that way. For information on that, see:

The better way to implement this is with Yanfly's Skill Core. Give the skill the notetag:
Code:
<Post-Damage Eval>
if (Math.random()<.83)
    user.addState(X);
</Post-Damage Eval>

where X is the ID of your state (no leading zeros), and you supply whatever number you want on the line above. So this one has an 83% chance.
Thank you. I just tested it and it worked. Literally was looking at your posts for advice before you messaged me.

Original thread: https://forums.rpgmakerweb.com/threads/a-skill-that-has-a-chance-to-self-inflict-status.156293/