MV Looking to change how mdef works

Hello fellow game makers,
I would like to use magic defense (renamed Resistance) in my game to not only reduce magical damage, but also to reduce the effectiveness of all status effects.
base% - base%*.5(Resistance/MaxResistance)
Something like that equation, where base% is the base chance to land a status effect (poison, for instance). I, however, do not want this to block friendly buffs, which adds to the difficulty. Any ideas/scripts/plug-ins? Thank you in advance!
What is MaxResistance?
What is MaxResistance?
Probably 999. =]
I'm good ~enough~ at scripts to change that if I need to, though. Thank you!
OK, there are two different parts of your plans.
The first is easy - mdef has absolutely no function in the game by default, it is only there for your to use in the damage formulae - and those are completely under your control.

The second part about the state resistance is much more difficult to do.
If it were to affect all state you could do that with the extra parameter formulae plugin from yanfly, but the problem is that you don't want that to happen for friendly states.

To solve this you need to answer one specific questions:
how do you identify the states this should apply to and those it should not apply to?

As soon as you can give a formula to identify that, you can do what you want.
Without that formula you can't do it.

That formula might be something like "all states with ID 1-50 are nice states, with ID 51+ are bad states", or you might define this by placing a notetag with the meta function or several other ways, but we can't answer that for you without knowing your states.
OK, there are two different parts of your plans.
The first is easy - mdef has absolutely no function in the game by default, it is only there for your to use in the damage formulae - and those are completely under your control.

The second part about the state resistance is much more difficult to do.
If it were to affect all state you could do that with the extra parameter formulae plugin from yanfly, but the problem is that you don't want that to happen for friendly states.

To solve this you need to answer one specific questions:
how do you identify the states this should apply to and those it should not apply to?

As soon as you can give a formula to identify that, you can do what you want.
Without that formula you can't do it.

That formula might be something like "all states with ID 1-50 are nice states, with ID 51+ are bad states", or you might define this by placing a notetag with the meta function or several other ways, but we can't answer that for you without knowing your states.
I could easily organize them like that... I only have like 20-25 of the "bad" states. Thank you for this way of thinking about it.
base% - base%*.5(Resistance/MaxResistance)
So I wasn't exactly sure what the end of that meant, if it's .5*(Res/maxRes), but that's how I interpreted it. You should be able to see where it is clearly enough and modify the formula however you choose.

Code:
Game_BattlerBase.prototype.stateRate = function(stateId) {
    var rate=this.traitsPi(Game_BattlerBase.TRAIT_STATE_RATE, stateId);
    if ($dataStates[stateId].meta["hostile"])
        return rate-rate*.5*(this.param(5)/999);
    else
        return rate;
};
Copy that into a text file and save as a .js in your plugins folder, then load it into your game. It should cause your state rate to be decreased based on your MDef for any state that has the <hostile> note tag.

I have not tested it, so that's up to you - let me know if there are any errors.
So I wasn't exactly sure what the end of that meant, if it's .5*(Res/maxRes), but that's how I interpreted it. You should be able to see where it is clearly enough and modify the formula however you choose.

Code:
Game_BattlerBase.prototype.stateRate = function(stateId) {
    var rate=this.traitsPi(Game_BattlerBase.TRAIT_STATE_RATE, stateId);
    if ($dataStates[stateId].meta["hostile"])
        return rate-rate*.5*(this.param(5)/999);
    else
        return rate;
};
Copy that into a text file and save as a .js in your plugins folder, then load it into your game. It should cause your state rate to be decreased based on your MDef for any state that has the <hostile> note tag.

I have not tested it, so that's up to you - let me know if there are any errors.
Wow!!! This looks excellent! I will test it over the next couple of days. THANK YOU SO MUCH. What are you terms for credit?
Thank you, but I don't care about credit for a forum post 😀

Original thread: https://forums.rpgmakerweb.com/threads/looking-to-change-how-mdef-works.140500/