Chance to apply self state on hit?

Hey everyone,

I was wondering how to do something that should be pretty easy to pull off, but I'm not sure how. I want to have an ability that when it is used, does damage and has a chance to apply a state to the user. I know that I can use a.addState(#) in the damage formula to apply the state, but how can I make it so it's a chance instead of a guarantee? Like a 10% chance?

Thanks for any help on this 🙂
Instead of doing it in the formula, just click the "effects" box. Tab over to the tab with "state" on it, pick the state, determine the percentage you want. 😀 It's built into the basic UI.
Hm...but doesn't that apply it to the target? I need it applied to the user.
Can be done easily with the help of Yanfly's Skill Core plugin. Do you want to use it?
I have it installed already, so definitely! If you know how I can use it to do this, that would be great!
if (Math.random() < .1) a.addState(#);

Edit: It probably makes more sense to use the plugin. Having to change this formula in multiple locations would be a pain.
if (Math.random() < .1) a.addState(#);

Ah ha! I probably should have looked back at the healing variance thread we worked on last week. Thanks!
For a better look if you don't want to use damage formula to add state to the user, here is the note tag for your skill:
Code:
<Post-Damage Eval>
if (Math.random() < 0.1){ //10% chance to add state. Change it to another number if you need.
user.addState(x);} //where X is your state ID
</Post-Damage Eval>
This will provide a chance to add state X to the user when damage is dealt to target.
Ah ha! I probably should have looked back at the healing variance thread we worked on last week. Thanks!
Lol, that's exactly what I did. Took a few minutes to test.
For a better look if you don't want to use damage formula to add state to the user, here is the note tag for your skill:
Code:
<Post-Damage Eval>
if (Math.random() < 0.1){ //10% chance to add state. Change it to another number if you need.
user.addState(x);} //where X is your state ID
</Post-Damage Eval>
This will provide a chance to add state X to the user when damage is dealt to target.

Could I possibly use this as a notetag for a class?

What I actually want to do is have the class itself have this ability. Anytime they use a Physical element attack, I want a 10% chance to buff themselves with a certain state.

So to make this more simplified, I was looking at just adding the formula into each Physical skill they can learn, making a separate version for that class and a separate version for anyone else that can learn it that doesn't have the addState in the formula.

But if there is a way I can just somehow make this a blanket statement applied to the class, that would alleviate a lot of duplicate skills I would be making.

Of course, the one stipulation would be that it should only be possible if the skill the class is using is a Physical element skill.
Unfortunately it can't be. You can only use that note tag in your skill note box. If you want your class to have this ability, you can use Yanfly's Auto Passive States and Buffs & States Core. By the help of these two plugins, you can create a passive effect for your class.

First, create a passive state (For example this state ID is Y, use the very first icon in your icon sheet) with its note box below:
Code:
<Custom Establish Effect>
if (this.isPhysical() && Math.random() < 0.1){ //will check if your skill is a physical attacks (Skills with Hit Type "Physical" in your database).
user.addState(x);} //where X is your state ID you want to apply to user
</Custom Establish Effect>

Second, add this note tag to your class:
Code:
<Passive State: Y>
where Y is the state ID i mention above.

By this way, you don't have to add this feature to each skill one by one manually.
Oh awesome. I have both those Yanfly plugins so I should be able to do this!

That makes things a lot easier, thanks so much!
Just spend a little time to toy with his state-related plugins and watch the Tips & Tricks videos on his Youtube channel. They will bring you so many benifits.
Quick question - if I changed 'user.addState(x);}' to 'target.addState(x);}' instead, would this have the chance to apply the state to the target hit instead of the user? Just wondering if I'm reverse engineering this correctly.
That's true. The target will have a chance to get the state instead of user.
Perfect! Thanks so much!

Original thread: https://forums.rpgmakerweb.com/threads/chance-to-apply-self-state-on-hit.85880/