Make State Only Activate Sometimes

I'm using Yanfly's auto passive state plugin, and I have a state that I want to add as a passive state, but have it only activate sometimes. This state adds 1000 to the character's Defense for the rest of the turn when activated. I want it to trigger based on their Luck stat or 10% of the time, whichever is easier to code. Basically, the character randomly decreases incoming damage for one turn.

I'm using MV. How might I go about doing this?
There's not really a way to make a state just activate and deactivate at random times.

You would have to do something external like call a common event or code that randomly toggles a switch and have the passive state dependent on that switch.

I think a more efficient solution is to make the state have no Traits, but just interact directly with attacks.

For example:
Code:
<Custom React Effect>
if (this.isPhysical() && this.isDamage() && Math.randomInt(100)<10)
    value=Math.round(value*0.9);
</Custom React Effect>

That has a 10% chance to reduce damage from Physical Hit skills by 10%. I know you mentioned luck, but you didn't give any clue as to how a luck equation would work, so you'd have to modify the last part of the line as you like.

Original thread: https://forums.rpgmakerweb.com/threads/make-state-only-activate-sometimes.157385/