Help with fire shield state.

Hello guys! First post here,
Anyways I was trying to make a fire shield state that has a chance to add burn to attackers.
In these forums I've found this code I'll include below that allows me to add burn to attackers, however I don't want it to happen every time.

<Custom React Effect>

// Check to see if any physical damage is dealt.

if (value > 0 && this.isPhysical()) {

user.addState(x);

}

</Custom React Effect>

I was hoping someone could enlighten me on a way to use random variable in this code that would cause this to
happen only 50% of the time. I am using Yanflys states plugin and many others.

I've moved this thread to Javascript Support. Thank you.

Try this:
<Custom React Effect>

// Check to see if any physical damage is dealt.

if (value > 0 && this.isPhysical()) {

var chance = Math.random();

if (chance < .50) {

user.addState(x);

}

}

</Custom React Effect>

The chance line makes the effect trigger 50% of the time.
awesome! thanks it works perfectly. I love this forum already.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-fire-shield-state.117914/