MV Help with D20 System and Accuracy Calculation?

Howdy y'all, I'm new to RPG Maker! I'm having some trouble making Yanfly's Hit Accuracy plugin work.

I'm currently working on a D20 inspired system in RPG Maker MV. For my proposed system, which is like a simplified Fifth Edition, the Ability Scores are one-to-one with their modifiers, so when rolling a to-hit formula, it essentially would be a D20+Attack versus the enemies’ Armor Class, which is expressed as Defense+10. Also, I’m attempting to keep the Stats as “small” as I can, with most ability scores and damage numbers effectively being stuck in the single digits, to mimic the feeling of early-game 5E.

For most formulas, I’ve seen most people just use the formula of Skills to bake in the To-Hit (or accuracy) roll, and the “Damage dice.”

See Vrykerion’s updated formula for example (https://vrykerion.com/2017/11/27/d20-style-combat-in-rpg-maker/):

b.def <= (Math.randomInt(20) + 1 + (Math.floor((MOD – 10)/2)) + (Math.floor(a.level/2))) ? Math.random(X*Y) + 1 + (Math.floor((a.atk – 10)/2)) : 0;

From my understanding, I’d like to not use the above listed method, because then if the attack “misses” it simply reads an output of 0 damage, instead of a missed attack.

I’m currently using Yanfly’s Hit Accuracy plugin, where I’m attempting to use the following formula to calculate Hit Accuracy:

(b.def + 10) <= (Math.randomInt(20) + 1 + (Math.floor(a.atk)) ? 1 : 0;

My understanding of it is that the above formula states that if an enemy’s Defense stat, plus 10, is less than a D20 roll plus the Attack of the enemy, then the attack lands. Otherwise, the attack misses.
helpplease.png

I thought that I’d gotten this formula to work, and began testing it to make sure. I put a player character through multiple tests, with items that increased their Attack or Defense score to an absurd level, so that their attacks always land, to which it worked initially. Then I did it with minimal score edits, where attacks landed primarily with the RNG in mind, which I thought worked.

Then, I’d created enemies with absurdly high stats to test whether or not they’d ever get hit or if they’d ever miss, and then that’s when I noticed something strange. An enemy with an effective AC of 30 (10 base and 20 Defense) should’ve been mathematically impossible to hit without special weapons but was being struck more often than not. Then, out of nowhere in other tests where enemies were given their own special skills to test different damage roles, now nothing lands and all attacks are misses!

Besides just writing the formula and praying it works, is there any way I can see mechanically that it is working? Like possibly seeing the results of the random integers that are “rolled?”

Also, I noticed that enemies and players alike can't land any attacks if they don't have the Ex-Parameter (Hit Rate) specified in the traits menu. Do I have to use this?

Initially, my Damage Dice rolls were working perfectly too:

(Math.randomInt(6*1) + 1) + a.atk

The above formula simulates a 1d6 + Attack roll for damage. Currently I’m using this as a placeholder in my base “Attack” skill. I know the random damage dice rolls on the skills are working fine, but for some reason the “To-Hit” formula just stopped working. Does anyone have any ideas on how to make this work?

Should I plug in the to-hit formula to the Yanfly Extra Parameter Formula plugin for HIT rate?

Thanks in advance, all!
Why do you have your formula in both 'Accuracy Formula' and 'User Physical Hit'?

Shouldn't it be:

Accuracy Formula: userHitRate - targetEvadeRate
User Physical Hit: Math.randomInt(20) + 1 + user.atk
Target Physical Evade: 10 + target.def
I originally thought that I'd needed to put the formula in both places in order for it to work, but I was mistaken.

Perhaps I'm royally messing this up, but I've managed to fix it up a little bit by changing my previous post to the current formulas:

Accuracy Formula: userHitRate - targetEvadeRate
Evade Formula: 0
User Physical Hit: (b.def + 10) <= (Math.randomInt(20) + a.atk) ? 1 : 0

My understanding is that using the Accuracy Formula as it is out of the box, the formula compares the "userHitRate" (which I understand to be any of the --User Hit Rate-- formulas), and compares it against the Evade Formula (or rather the ---Target Evade Rate--- formulas which are referenced by the Evade Formula). If the Evade Formula is set to 0, then it should always "hit," or always process the Physical Hit Formula, which is the D20 to-hit formula (which has a baked in miss condition, being that the check must succeed against the enemies defense class + 10).

I've also learned that altering any of the formulas in the ---Target Evade Rate--- section seems to irreparably break the accuracy calculation in RPG Maker MV as a whole, even after disabling the plugin. Again, I could be mistaken but I've tried it two additional times on other projects and was unable to fix the accuracy calculation after disabling the plugin, or re-enabling a different copy of the same plugin. Seen in the OP, I'd changed the initial parameters to 0 also to make it so that no matter what, the User Hit Rates should always land (making it so that magic attacks and "certain hits" should always hit, but alas, nothing did).

I've managed to somewhat fix it right now. Now, for sure, the physical attacks work as intended, but now, for whatever reason, certain hits don't always hit random enemies and magic attacks don't always land as they're expected to in the plugin. Not sure how to fix that, honestly.

By the way, thank you for replying!
Base RPG Maker first checks hit and then eva separately.

Accurary formula -> hit check (plugin standard settings combine hit and eva).
Evade formula -> eva check (plugin standard settings set to 0, so the separate eva check is practically not used)

The 'User hit rate' and 'Target evade rate' is stuff that's returned for the 'userHitRate' and 'targetEvadeRate' variables depending on skill hit type. You can use the variables in any way you want in both the accuracy formula and the evade formula.

At least that's how I think it is.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-d20-system-and-accuracy-calculation.180962/