Yanfly's Hit Accuracy (YEP)

http://www.yanfly.moe/wiki/Hit_Accuracy_(YEP)
The plugin works as intended (as far as I can tell, anyway), other than the issue this thread is about. If a skill has a chance to inflict a State, and that skill's Hit Type is set to "Certain Hit," it will ignore any State Rate the target has (even 0%) to always inflict it; the only exception is if the target has the State Resist trait (e.g. State Resist - Poison). While a simple enough workaround would be to set State Resist where desired, doing this for Knockout causes them to become immortal due to how MV functions. As I am not a programmer, does anyone else know how to fix this? I have tested both with all my other plugins and without, and can confirm that Hit Accuracy itself is at fault.
The default behaviour for Certain Hit skills is to ignore the target's state rate and the mutual "luck effect". Supporting excerpt from base code:
Code:
Game_Action.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);
    }
};
Yanfly's Hit Accuracy plugin is quite simple and does not change anything with regards to states. Maybe you have an error of some kind in one of your hit rate formulae?
The hit formulae in the plugin are unchanged from the default. Turning every plugin off and doing a test battle, I can confirm that a Certain Hit skill will still ignore State Rate. That is incredibly unfortunate.
You could try saving this as a .js file and importing as a plugin:
Code:
Game_Action.prototype.itemEffectAddNormalState = function(target, effect) {
    var chance = effect.value1;
    chance *= target.stateRate(effect.dataId);
    chance *= this.lukEffectRate(target);
    if (Math.random() < chance) {
        target.addState(effect.dataId);
        this.makeSuccess(target);
    }
};
Basically, this just removes the "if not Certain Hit" part so that all states will check for the target's state rate. This is an override, so you may want to put it near the top of your Plugin Manager load order. I think that'll account for all "state add via skill" situations, but haven't tested. 😅
This is actually not a bug, as certain hit is meant to mean certain, as in, always works. That is why states ignore the resistance in that skill. The best way to fix it is to change your skill to a physical or magical skill instead.

Original thread: https://forums.rpgmakerweb.com/threads/yanflys-hit-accuracy-yep.111683/