D20 Style Combat in RPG Maker

UPDATE: While the logic below is sound, a recent comment drew my attention to testing what I posted here to find a number of small but crucial JavaScript syntax errors that may cause the formula to result in always returning 0 (the universal RPG Maker sign that something broke). Here is the corrected formula for use in the Damage Formula:

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;

Substitute MOD for a.atk or a.mat or whatever parameter you want to use for the attack.  Substitute X for the number of dice. Substitute Y for the dice size (4,6,8,10,12,20).

Something I’ve often toyed with aside from my own game FateStone was the idea of re-creating a Dungeons & Dragons campaign in something like RPG Maker.  Seems easy right? You’ve got dungeons, monsters, characters all there and ready to go!  However, the big hurdle is quite simply that the way combat works does not overlap. Like at all.  RPG Maker’s combat calculations are more inspired by Final Fantasy or Dragon Quest than anything you’d find in a Pen & Paper RPG tome. So I recently put my mind to work on figuring out how exactly you would be able to bring a d20 or D&D Style of combat to a RPG Maker game.

Now take in mind that this is a very basic version of what I started working with.  While I have started working on versions to incorporate all the different D&D ability scores, I haven’t hammered out all the nitty gritty of using them.  So for now I strictly went for Attack Roll (Attack) vs AC (Defense) and Spell Attack (Magic Attack) vs Saving Throw (Magic Defense).

First is the dice roll:

1dX = Math.randomInt(X)+1

YdX = Math.randomInt((X*Y), Y) + 1

For the YdX formula, it’s important to note that you’ll be setting the range of the random numbers, when it says X*Y you should replace that with the actual value of X * Y.  In other words, for 3d6 don’t put (6 * 3) just put (18).  These formulas will be used for everything from determining the attack to the damage, so they are pretty much the cornerstone of this whole thing.  But another important one would be how to you get the Ability Modifier from the Ability Score.  For that you’ll want to use the following calculation:

Math.Floor((A – 10)/2) = M

A = Ability Score.  M = Ability Modifier.

In simple terms, you subtract 10 from the Score, divide that by 2 and round down (because you always round down in D&D) and that will give you the modifier.  So an Attack (Strength) of 14 would result in a modifier of 2.

So how would this work for an actual skill?  Well, let’s take a look at one.  First, you’ll want to set the Skill in RPG Maker to be a ‘Certain Hit’.  We are just going to skip the whole Accuracy/Evade cycle of the attack in favor of our own math.  Then our damage formula will look something like this:

If (b.def <= (Math.randomInt(20) + 1 + (Math.Floor((a.atk – 10)/2) + (Math.Floor(a.lvl / 2)) )) Math.random((X*Y), X) + 1 + (MOD – Math.Floor(a.level/2)); else 0

Kind of crazy, right?  Let’s break it down.

If (b.def <=: This First bit is essentially starting an ‘If-then’ clause that says if the following math results in something equal to or higher than our target’s defense (AC).

(Math.randomInt(20) + 1: This is our d20 roll.

+ (Math.Floor((a.atk – 10)/2): This is adding our attack modifier

+ (Math.Floor(a.lvl / 2)) )): This adds half our level to the math and finishes our If condition.  So it’s a random number between 1-20, plus the modifier, plus half our level.

Math.random((X*Y), X) + 1 + (Math.Floor((a.atk – 10)/2))This part is our damage calculation. Essentially, do this much damage (a random XdY dice amount) plus our Attack modifier damage.

else 0 And if the math DIDN’T equal or beat the Target’s Defense(AC), then deal zero damage due to it being a miss.

To summarize, the formula is basically:

If (Target AC) <= 1d20 + Attack Modifier + Half Level; Deal XdY + Attack Modifier damage; else deal no damage.

Naturally, you can probably imagine how this basic formula can be applied to a lot of different things.  It forms the basic idea for skill checks, saving throws, and pretty much any Difficulty Check based roll. You could replace the target defense with a d20 roll on the enemy side as well and have an opposed check.

As I said at the top, this isn’t perfect.  It doesn’t quite yet take into account D&D’s Ability Scores, which I’m still working on.  Mostly just stuck on thinking of a way to make the Target Defense side of things work when b.def would simply be their Constitution score or something.

If I ever figure out a good solution to it, I will let you know.

In the mean time, you might find the following plug ins for RPG Maker MV to be handy when it comes to recreating the D&D experience:

Yanfly’s Weapon Unleash: Allows you to reassign a different attack skill to different weapons, thus being able to give daggers a different damage formula than a great axe.

Yanfly’s Limited Skill Usages: For those interested in bringing D&D 4th Edition’s system of At-Will, Encounter and Daily abilities to the game, this plugin can help.  However, you might want to create a common event for sleeping that gets called when using an item like ‘Camping Set’ or something to reset the Daily uses.

Welcome to the Machine


Continuing in my grand “Seriously, I don’t give two damns about Garrosh and seriously SoO feels way to grindy even on LFR” vacation from MMOs, I decided to finally boot up my copy of RPG Maker VX Ace.  I bought it on a steam sale over a year ago for like 60% off or something, and never really got around to using.  In fact my girlfriend was using it most of the time making seriously awesome stuff that would just make my jaw drop.  So I decided, Hey I like to run D&D campaigns, I’ve spent more time in Final Fantasy games than I have homework over the course of my life, why not give this thing a try?

Like being zapped by the MCP and taking my first few steps out onto the Grid, my life was forever changed.


RPG Maker is like handing a kid the world’s biggest LEGO construction kit and just saying have at.  It has a ton of power, lots to learn, and great deal of freedom.  It comes with everything you need to start making your own role playing game and even comes with built in pre-sets that allow to start tinkering as soon as you open the box.   I started with just using the basic tutorials that are on the website, which sadly appear to be incomplete.  You get to the last lesson and it just stops, teasing you with a “In our next lesson” bit that dangles a juicy fruit of useful information just beyond reach.  Luckily the web is vast and infinite and full of other non-official tutorials that offer thorough explanations of both the basics as well as the more advanced features of the game.

While the advertisements for the software will boast that no programming is required, some basic knowledge of programming is incredibly useful.  Knowing how concepts like loops, if…then…else’s, and variables will prove vital in working your way through making your story come alive.  Luckily they’re not the hardest programming ideas to grasp.  But yea, the more experience you have with programming the more you’ll be able to do.  You can also add scripts to your game to add additional functionality using the Ruby based RGSS3 engine.  For instance, I’ve added a World of Warcraft like Reputation system as well as a crafting system with the scripts in the game.


Still the sheer amount of power you wield to tell any kind of story you wish complete with cutscenes, characters, classes, monsters, etc from the get go is an amazing feeling.  Once I finished the tutorial I began work on a slightly more sandbox-y style game, where you would find clues and tips about where to go next but no clear goal or marked areas.  For instance, someone in town mentions that the statue in the park had the gem stolen from it.  That’s it.  Where is the gem? Dunno.  Maybe you’ll find it.  Maybe you’ll find more clues.  Maybe an unrelated clue will actually lead you to the same thieves that stole the gem.  It’s awesome and fun to just lay clues down.  Especially since this allows me to do a sandbox style adventure when I don’t know if I could ever accomplish one in my Dungeons & Dragons campaigns.

However, even more than a D&D game using RPG Maker requires a lot of planning ahead of time if you don’t plan on using the built in pre-sets for everything.  Just testing a formula for how much damage a character can take or dish out was a long process of trial and error.  Then planning things like stat growth, abilities, experience rates (which are somewhat limited by the software itself.  Like you can’t set it to take more than 90 XP to get from level 1 to 2. Though you might be able to change this with a script.  Probably can.  There hasn’t been much I’ve found that you CAN’T change with a script.)  So before I’ve gotten too far in the game I’m already buried neck deep in spreadsheets.  But hey kids, let this be a lesson. Learn Excel.  It can be used for fun someday!

The sheer joy is in the creation though.  You’re making something.  Something new and yours.  It’s the kind of feeling that ignites your passion when you built the Three-Headed Dragon Super Space Ship With TWENTY Lasers So It Can Totally Blow Up Mark’s Ship Yes It Can Mark Shut Up Mark III with building blocks when you were a kid.  I have no idea if anything I make will ever turn out to be decent, or even great.  Nor does it matter if I can or can’t monetize it.  For now, I’m having fun with it all.  However, I might upload a copy of the first city as a ‘demo’ or something.  I’d love to hear what people out there in the Interwebs might think of it and get some feedback. Who knows?