How to have a stat effect crit chance/damage?

I decided to replace the MP defense stat with a critical stat, and I want it to affect the chance and damage of crits. Is there any MZ plugin for this?
There is a stat in the Ex-Parameters called Critical Rate which does what you describe. To get it to display instead of M.Def, you probably have more than one option at your disposal. The VisuStella Core Engine can be downloaded for free and has a plugin parameter called Parameter Settings that will let you remove M.Def and add CRI or Critical Rate.

Note that M.Def will still factor into damage formulae. Is there a reason you’d like to rid your game of it? Are you planning on replacing all instances of M.Def with Def? That will be a tad out of the scope of my post/knowledge.

Additionally, Critical Rate is a percentage and can go above 100%, which is a bit nonsensical IMO, so you might want to account for that in how you plan out your advancement system.
Note that M.Def will still factor into damage formulae.
Only if the OP has put it there, or is using the default spells unmodified. There are no instances of mdf in the code.

Additionally, Critical Rate is a percentage and can go above 100%, which is a bit nonsensical IMO
The attacker's critical rate is multiplied by the target's critical evasion rate, so it's only "nonsensical" if you don't want to be able to ensure a battler can get a high enough critical rate to guarantee critical hits.
There is a stat in the Ex-Parameters called Critical Rate which does what you describe. To get it to display instead of M.Def, you probably have more than one option at your disposal. The VisuStella Core Engine can be downloaded for free and has a plugin parameter called Parameter Settings that will let you remove M.Def and add CRI or Critical Rate.

Note that M.Def will still factor into damage formulae. Is there a reason you’d like to rid your game of it? Are you planning on replacing all instances of M.Def with Def? That will be a tad out of the scope of my post/knowledge.

Additionally, Critical Rate is a percentage and can go above 100%, which is a bit nonsensical IMO, so you might want to account for that in how you plan out your advancement system.
For my game, instead of Magic attack and defense there's just a stat called magic that functions both ways.
Only if the OP has put it there, or is using the default spells unmodified. There are no instances of mdf in the code.
My mistake.

The attacker's critical rate is multiplied by the target's critical evasion rate, so it's only "nonsensical" if you don't want to be able to ensure a battler can get a high enough critical rate to guarantee critical hits.
Well, I’m just arguing that seeing a number above 100% in the UI can be counterintuitive. You’re right in that, if a player had a character with a crit rate of 100% and still wasn’t seeing all crits, that would be highly frustrating. I would personally get rid of crit evade altogether if the character advancement, weapon upgrades, etc. could afford a 100% CRI stat for the sake of simplicity.

Of course in that scenario there could be exceptions, like in my game I have a version of adamantine armor from D&D which has a critical evasion rate of 100%. But I digress.


EDIT: As far as critical damage becoming dependent on critical rate, that's a separate issue, which I can't help with, sorry. I've done some digging and I don't know where to start to help you with that. Maybe ATT_Turan has some expertise on the matter.
When it comes down to it, here's the function for determining whether something is a critical hit:
Code:
Game_Action.prototype.itemCri = function(target) {
    return this.item().damage.critical
// This is the line you care about vv
        ? this.subject().cri * (1 - target.cev)
        : 0;
};
The result of that formula is compared to a random number from 0 to .9 barred. If the random number is lower, it's a critical hit.

Then damage is:
Code:
Game_Action.prototype.applyCritical = function(damage) {
    return damage * 3;
};

You could refer to the attacker as in itemCri() with this.subject() and to the target with BattleManager._targets[0]

You can modify either of those equations, paste the resulting functions in a text editor, save it as a plugin file.

If you're using any other plugins that modify battle, it's quite possible they'd conflict with each other.
When it comes down to it, here's the function for determining whether something is a critical hit:
Code:
Game_Action.prototype.itemCri = function(target) {
    return this.item().damage.critical
// This is the line you care about vv
        ? this.subject().cri * (1 - target.cev)
        : 0;
};
The result of that formula is compared to a random number from 0 to .9 barred. If the random number is lower, it's a critical hit.

Then damage is:
Code:
Game_Action.prototype.applyCritical = function(damage) {
    return damage * 3;
};

You could refer to the attacker as in itemCri() with this.subject() and to the target with BattleManager._targets[0]

You can modify either of those equations, paste the resulting functions in a text editor, save it as a plugin file.

If you're using any other plugins that modify battle, it's quite possible they'd conflict with each other.
Thanks, I got all that down but my issue was the formula.
I want to use
(this.subject().cri + (this.subject().mdf * 0.075)) * (1 - target.cev);
The stat will do crit chance and damage, and it would be 2 at level 1 and go to 50 at level 99. I wanted it to have a pretty minor effect on chance. However, even at level 1 it seems like a crit happens every turn. I have no idea why... The crit chance should literally be 4.075 but it always ends up critting. Idk what the issue with my formula is
The crit chance should literally be 4.075 but it always ends up critting. Idk what the issue with my formula is
The result of that formula is compared to a random number from 0 to .9 barred. If the random number is lower, it's a critical hit.

4.075 is higher than .9, so the random number will always be lower - ergo, always a crit.

If you want a 4% chance, you'll have to divide those values by a magnitude before you compare them to the target's cev.
To elaborate a little: "MDF * 0.075" means +7.5% per point of MDF, because 0.01 ≡ 1%. So, like Turan says, you may want to add some extra zeroes in there.

Otherwise it looks like you've pretty much found a solution, but I just thought I'd mention that I have a plugin named Cae_OnUseEffects - link to thread. Amongst (probably too many) other things, it has plugin parameters for defining custom "action formulae". E.g. the "JS: Crit Rate" parameter lets you define an override for the critical hit check that Turan mentioned, and "JS: Crit Damage" is for the critical damage calculation.
To elaborate a little: "MDF * 0.075" means +7.5% per point of MDF, because 0.01 ≡ 1%. So, like Turan says, you may want to add some extra zeroes in there.

Otherwise it looks like you've pretty much found a solution, but I just thought I'd mention that I have a plugin named Cae_OnUseEffects - link to thread. Amongst (probably too many) other things, it has plugin parameters for defining custom "action formulae". E.g. the "JS: Crit Rate" parameter lets you define an override for the critical hit check that Turan mentioned, and "JS: Crit Damage" is for the critical damage calculation.
Oh my god, that was so simple lol. Thanks for the help

Original thread: https://forums.rpgmakerweb.com/threads/how-to-have-a-stat-effect-crit-chance-damage.158359/