(Yanfly Plugins) State add another state on attack?

I'm not sure how to build a state like this, but here's the description:

Passive State - Berserker
Any physical attacks/skills you deal have a 10% chance to apply the "Enrage" state to your character.

Thank you for your time!
On it. I'll post an answer soon enough
Assuming you use Yanfly's buffs and states plugin

Code:
<custom respond effect>
//Replace enrageId with whatever state ID you wanna add
enrageId = x
if (value > 0){
    randNo = Math.random();
    //If you wanna change the percentage 1.0 is 100%, 0.01 is 1%, 0.5 is 50%, etc.
    if (randNo < 0.1){
    user.addState(enrageId);
    }
}
</custom respond effect>

This should work, take note of what the lines say after the "//" as they're intructions
That's good, but not quite correct. It should look like this, I think:

<custom establish effect>
//Replace enrageId with whatever state ID you wanna add
enrageId = x
if (value > 0 && this.isPhysical() && this.isHpEffect()){
randNo = Math.random();
//If you wanna change the percentage 1.0 is 100%, 0.01 is 1%, 0.5 is 50%, etc.
if (randNo < 0.1){
user.addState(enrageId);
}
}
</custom establish effect>

First, the effect should be Establish, not Respond. Respond occurs when an enemy attacks the target with the state. Establish occurs when the attacker HAS the state.

Next, to ensure that the effect doesn't trigger off a magic effect, I added this.isPhysical() and this.isHpEffect() to the conditions. Since the effect is only triggered by physical attacks, leaving out this.isPhysical() allows a magical attack to trigger it as well. The HpEffect line checks if the effect alters the HP of the target. You may not need that part, depending on the exact conditions of the Berserk effect, but it's there if you need it.
Ah, I misread the OP and thought they were going for a gets angry when hurt kinda thing. Thanks for having more scrutinous eyes than I
@shockra and @Fugama Thank you very much for that! That helps me a great deal with a variety of skills. I also had not realized what <custom establish effect> really meant.
@Fugama I will likely add that into my Berserker state, as well. Although I was referring to the state being added when the actor attacks, I like the idea of it being added when damaged as well.

Thank you both very much!
~Serv

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-plugins-state-add-another-state-on-attack.74500/