Simple change to State Rates

I would like a simple change to the way the engine calculates state rates.   I would like the target's state resistance to be subtracted from the attacker's state chance.

For example, say a skill has 50% chance to stun.  If I have 50% stun resistance, I would like to never be stunned.  If I have 40% stun resistance, I would like the net chance for me to be stunned to be 10%.  

I would like this to be the case for all state resistance, regardless of whether it's coming from the "add state" feature on a skill, or the "attack state" property of an actor/class/enemy/equipment/item.

Thank you.
/*:


* @plugindesc Addition of state rate instead of multiplication


*/


(function($) {


$.prototype.itemEffectAddAttackState = function(target, effect) {


this.subject().attackStates().forEach(function(stateId) {


var chance = this.subject().attackStatesRate(stateId);


chance *= effect.value1;


chance -= target.stateRate(stateId);


chance *= this.lukEffectRate(target);


if (Math.random() < chance) {


target.addState(stateId);


this.makeSuccess(target);


}


}.bind(this), target);


};


$.prototype.itemEffectAddNormalState = function(target, effect) {


var chance = effect.value1;


if (!this.isCertainHit()) {


chance -= target.stateRate(effect.dataId);


chance *= this.lukEffectRate(target);


}


if (Math.random() < chance) {


target.addState(effect.dataId);


this.makeSuccess(target);


}


};


})(Game_Action);

Original thread: https://forums.rpgmakerweb.com/threads/simple-change-to-state-rates.53278/