State resist based on parameter

I have a random question. For my RPG I am making, I do not need magic attack nor magic defense parameters, but I thought it would be cool it utilize them for different purposes. I already am using plugins that can modify accuracy and evasion based on the base parameters, but I was wondering if I can do the same for state resistance, for example, if I had a magic defense of 30, could I translate that to a poison resistance of 30%?
There are likely plugins out there that can assist you with this, and I'm not sure if you want these effects to be general rules for all actors/enemies or only apply to specific ones.

If you don't mind using an extra plugin, you could try to replace the "stateRate" function of Game_BattlerBase for this:
Spoiler
JavaScript:
/*:
 * @plugindesc
 * Custom state rates, see plugin code
 * @help
 * <Placeholder for plugin instructions>
 */

// Create a snapshot copy (alias) of the current version of "stateRate"
// This way the previous code is not lost when "stateRate" is replaced:
const stateRateBeforeCustomParameters =
    Game_BattlerBase.prototype.stateRate;
 
// Replace the "stateRate" function with a new definition:
// this    : the battler that the state rate is calculated for
// stateId : the ID of the state
// returns the state rate as a share of 1 (e.g. 0.5 = 50% state rate)
Game_BattlerBase.prototype.stateRate = function(stateId) {
    // Calculate the previous state rate:
    let result = stateRateBeforeCustomParameters.call(this, stateId);
    // << --- >>>
    // Here custom code can be added to modify the result:
 
    // Example: Reduce the "Poison" (state 4) rate by 1% for each point of MDF:
    // (But don't allow a negative multiplier if the battler has too much MDF)
    if (stateId == 4) {
        result = result * Math.max(1 - 0.01 * this.mdf, 0);
    }
 
    // << --- >>>
    // Return the new, modified result:
    return result;
};

You can do similar stuff with for most other traits. The functions are mostly named the same as the english trait names in the editor, you can find the original function names in the "rpg_objects.js" file, around line 2442ff.

Probably not relevant in your case, but special caution may be needed if you use this to change parameter rates or traits that may have an immediate effect on the target (like reducing the targets MHP below their current HP).

Hope this helps. (Not sure how familiar you are with Javascript coding, you can generally follow the same patterns as in a damage formula.)

Edit: Small fix
I was thinking of this being a general rule for all actors and enemies

Original thread: https://forums.rpgmakerweb.com/threads/state-resist-based-on-parameter.168272/