One of the obstacles to creating your own RPG is: what the heck do I do for math?

There’s now been well over 30 years of computer RPGs, in both C- and J- styles, and one feature most of them have in common is that they’re awfully vague about their combat math.

CRPGs in the really old days often cribbed their battle mechanics from Dungeons & Dragons. Any game that uses the term Armor Class is basically admitting this outright. If Armor Class counts down as it improves, it’s being extra cavalier about its inspiration.

There is an advantage to this, though: players familiar with D&D will know generally how things work, that an improved AC (whichever way it counts) means a decreased chance of being hit, and that a weapon like a longsword will probably do a Gygax-approved 1d8 points of damage.

I cannot say if early JRPGs also passed through a phase where most developers outright stole their system from D&D, but my belief, from what I have seen (which mostly comes from reading Hardcore Gaming 101) is that they did not. It seems like what happened there is that popular early JRPGs, like Dragon Quest and Dragon Slayer, were inspired not by D&D but by Western games that were inspired by it, like Wizardry and Ultima. Coming at their ideas from one or more removes meant they weren’t struck in awe of TSR’s beast like many early RPGs seemed to be, and went on to develop their own ideas sooner.

But that meant that players didn’t have those assumptions to fall back on as far as how the game system worked. What the heck does a point of “Strength” mean, in game terms? What is the proper effect or armor? How strong should magic be? Having only other games for inspiration, themselves with poorly-explicated systems, meant everyone came up with their own system, a state which largely persists to this day.

Some things to keep in mind...

When you, too, make an RPG, you'll have to come up with the math to underlie it. You may have to take into consideration things like:

How strong should PCs (“Player Characters”) start?

Should there be experience levels? (Hint: Consider not having them! These days, many traditional RPGs that aren’t D&D or retroclones have abandoned experience levels! They could be on to something! Maybe do more gradual character growth, or even throw out experience-based growth completely like Brogue does!)

Assuming you’re doing levels, how much does a character rise in power when gaining a level?

How strong should equipment be? What portion of character power should come intrinsically, and how much from what he wears and uses?

What is the numerical difference between, say, a fight-y class and a magick-y class?

How much trouble should a party be in if all its mages are dead? If all its fighters are?

Should parties be automatically refreshed after victories? (My opinion: no! Party depletion is an important element of gameplay!) Should a character be refreshed after gaining a level? (My opinion: probably not unless there’s a strong play reason, like in Desktop Dungeons!)

If a party runs out of resources and can’t afford an inn, how can they de-screw themselves?

What keeps adventurous players from venturing into difficult areas and accelerating their growth? Should you even worry about that?

I am not here to give you solid answers. In fact, I think there’s multiple good answers to all of those questions! It all depends on what you’re going for in your design, how you want the game to play and the player to experience. But what I can do is, by examining a couple of classic games (with the help of a bevy of FAQs), tell you how some classic games did it. Maybe that will get you started off in finding your own solutions.

"Abstract math systems can only take you so far by themselves; once you know what the calculations look like, you have to design monsters to put up to them."

Whatever you decide, take note that is almost certainly just the beginning of a journey. Abstract math systems can only take you so far by themselves; once you know what the calculations look like, you have to design monsters to put up to them. The same battle system can be either very easy or very hard depending on the numbers you give your monsters, and even with excellent foresight, it can be easy to get them wrong. Only playtesting, both by yourself and others, can help you there.

Note 1: For the most part, we don’t discuss bugs in the games, focusing on what the designer intended, although with FF1 we have to exclude whole parts of the design (weapon elemental effects) because they simply don’t work in the original game. This also means we don’t discuss overflow bugs, which were fairly common on 8-bit hardware.

Note 2: We’re interested in the gist, not the specifics. Some of these formulas may be missing a +1 or -1 somewhere or other, and special cases like blindness or paralysis may be ignored. If the omission is insignificant to the general case I am not overly concerned. My aim is to provide examples to you for basing your systems, not make recreations. If you really want to know the details, I provide all my sources for this article at the end where you can read about them yourself.

The Dragon Quest Attack Formula

The power of a character’s normal attack is the sum of their Strength statistic and the attack power of their weapon and assisting items. Skill attacks have their own formulas, as do magic spells, which utilize the Intelligence stat in later games; the first game has no such stat, and spells simply heal/cause damage in a set range for that spell.

Defensive power is the sum of the player’s Defense (or Agility) plus all his sources of defense, such as armor, shields and miscellaneous items like the Dragon’s Scale. Similar to the player, monsters have Attack and Defense power, although they are not modified by equipment.

One of the strengths of the Dragon Quest series’ design is that the underlying math is quite simple. While some minor specifics change between games, the formula for doing base damage is largely the same between games, and is similar between player and enemy attacks. It is this:

(Attack Strength – (Opponent Defense / 2)) / 2

For strategic and thematic variety, there are other means of doing damage that go outside this formula, but this gives the game a baseline. This is the standard reward a side receives for using its combat turn to just “fight.” As such, it can nearly always be fallen back upon, say if the player is low on magic, or spells are blocked or not known.

What does this mean?

It takes two points of Strength to add up to one additional point of damage. This can be from a level advance that raises Strength by 2, or from a good roll on a Strength Seed, or from some other, game-specific source. So, “Attack +10” means “do five more points of damage.”

Two points of weapon power also results in one more point of damage.

It requires four points of defense, from any source, to reduce physical, non-critical damage taken by one.

Because it has no other costs besides that of opportunity, it is unexciting, but for many classes it’s their bread-and-butter move. Because all combat actions consume a turn, anything else a player does should be at least as valuable as making a simple attack. A spell that consumes both magic points and a combat turn should be more powerful, on the average. (Situations, of course, vary. Against an opponent with high magic defense, or if the player purposely uses an early-game spell while carrying late-game equipment, could produce situations where simple attacks will have greater effect than spells. We’re talking about the general case, and assuming the player is trying to play optimally and has the knowledge to do so.)

Some points of interest about this formula:

1.) This is the traditional Dragon Quest formula for “base damage.” Most JRPGs, Dragon Quest included, don’t just apply damage, but modify it by something called variance. To simulate some of the uncertainty of battle, the value coming out of this expression is adjusted randomly. In Dragon Quest/Warrior I and II, the actual damage done is in a range between this and double. So, if the result is 10 points of damage, the damage dealt is actually between 10 and 20. While not as random as, say, Dungeons & Dragons tends to be, that is actually quite random by JRPG standards. Dragon Quest/Warrior III uses a formula that uses double this base damage, but in the variance step halves it again, +/- 10%. A tendency in later JRPGs is to reduce variance, with DQ VIII damage being in a range from just 1/16th below to 1/16th above the base.

2.) While it’s offset a bit by the fact that some player characters have extra item types adding into defense (shields, helmets, some miscellaneous items), all other things being the same, a point of attack strength is twice as strong as a point of defensive power. In play terms, this helps to keep players and monsters “in play” longer, allowing even lower-level participants to do at least some damage. The consequences of a very high Defense is to shut a battle down (assuming no critical hits happen), making things hopeless. This way, high Defense enemies, while still unlikely to outright defeat a player character, may still have a chance of taking off some hit points, and thus eventually forcing them to consume resources in healing or retreating back to town.

3.) Anyway, the fact that Defense is divided by two before it’s applied seems significant, but, and this is one of the things about RPGs that can make them a bit confusing to examine, it needn’t be. As mentioned, player characters may carry shields or wear helmets in addition to wearing armor, and that means the total Defense may be higher than expected. Or, defense items may be stronger to make up for it. Or it’s possible that PCs gain innate Defense/Agility faster than they gain Strength. Or it may even be that enemies simply have less attack than players to make up for it. If you examine any aspect of a system in isolation, you risk missing relevant factors outside of it that may change its implications.

4.) This is also the formula for base damage in the RPG Maker products. JRPGs vary greatly in design, of course, but this kind of math is both familiar and wide-spread in the genre. It stands opposed to Dungeons & Dragons battle math, where the main source of defense, Armor Class, doesn’t reduce damage done, but gets the character out of getting hurt entirely. (Dragon Quest does have a chance to evade, or dodge, but for the player it is a flat 1/32, and monsters usually have similarly low chances unless attack evasion is a special theme of that opponent, such as with its infamous Metal Slimes.) The upshot is that, on the whole, JRPG combat is a lot less random than D&D combat.

5.) The above formula is replaced by a different formula when an enemy attacks you with less Strength than you have defensive power. I don’t go into it here (check my sources if you’re curious), but notably it ensures higher-level opponents, whom you still greatly outclasss, do at least a small amount of damage, and doesn’t take your defense into account at all.

6.) “Critical hits,” which Dragon Quest sometimes calls things like “excellent moves” or “desperate blows,” use a different formula. It’s traditional for JRPGs to not take opponent defense into account when a critical hit is scored, which is effectively what Dragon Quest’s engine does.

7.) Later games have engine adjustments, like Skills and DQ8’s “Tension,” which add their own quirks to the formula.

Some Other Notes On Dragon Quest

Dragon Quest I’s statistic growth is pretty much set in stone, but there are some minor differences. The game cooks up a value based on the first four letters of the player character’s name (really!) and uses it to decide what stats are gained on gaining a level (including the first, which the player begins at). The upshot is, for two of the PC’s four primary stats (Strength, Agility, Max HP and Max MP), stats are higher than normal at low levels, but less than normal at high levels. For the precise details, see tyan8bit’s guide, linked in sources.

Dragon Quest III stat gain (information adapted from Fafnitr_Volsung’s guide, in the sources) is fairly weird. Each possible character class at each level has a kind of ceiling score in each stat. If a PC has less than that upon gaining a level, it rolls for a substantial gain in that statistic. If it has more than it, it only has a 50% chance of gaining a single point.

About those substantial gains… they can actually be quite huge, depending on the class and level (check the FAQ for details), while the “expected” stats rise at a standard amount, for each class, throughout its progression, from level 1 to 99. If the gains are very large, it’ll hit the progression ceiling quickly, and from then on, some of that class’ stat gains will become tiny. Meanwhile some class/stat combinations never get very high stat growths, and so will probably never hit their by-level caps.

An important implication this has to do with the game’s class change feature. When a character changes to a different class, its stats remain the same while level returns to 1 in the new class, so at first the character will probably only gain the ceiling-level, 50% chance of one point advancement. The character will have to grow to where the new class’ ceiling is over the current stat before substantial increases will resume.

But, as Fafnil_Volsung points out, there’s another drawback here, and one that seems a bit buggy. The game only hands out substantial max HP and MP when both those statistics are above their ceilings, and the amount gained are based on the Vitality or Intelligence gained. So, to get a substantial amount of Max HP, both Max HP and Vitality must be beneath the ceiling at the same time, and for Max MP, both Max MP and Intelligence must be beneath the ceiling. For this reason, a character’s first class matters disproportionately in terms of HP and MP possessed.

Final Fantasy Attack Formulae

Unlike the starkly traditionalist Dragon Quest games, Final Fantasy has made it a point to make each game something different, sometimes greatly so. The games do not share a common attack formula on the whole, and even the first one uses quite a complicated system, so let’s limit our examination to that one. Links to FAQs for a couple of others are included in sources for the interested reader.

There are two entirely different player character Base Attack formulae. For most characters, and armed Black Belts or Ninja, it is:

(Weapon + (Strength / 2))

For Black Belts and Ninja without a weapon in hand, it is simply

Level * 2

In an actual attack, the damage done is

randrange(Base Attack, Base Attack * 2) – Enemy Defense

Note that this includes basic variance. We’re not done here yet, as we have to take into account multiple attacks, but before that...

Final Fantasy’s chance-to-hit calculation is more involved than Dragon Quest’s. Each weapon has a specific accuracy score, and each class builds a Hit% stat at a set rate. That chance is determined with a good old fashioned to-hit roll, although its form is much different from D&D’s:

randrange(0, 200) < (168 + Hit%) - Enemy Evasion

If the random number is less than the value, the attack hits. Special cases are made of rolls of 0 (automatic hit) and 200 (automatic miss). The providence of that magic constant 168 is unknown; why did they pick that number? Maybe there was some internal formula to the design that decreed that to be the perfect value, but, honestly? I think they just picked something that they thought would work well enough, and that made it through play testing.

Now that we’ve introduced Hit%, we can talk about the “multiple hits” that some classes get, which can be a substantial modifier. Basically, you divide the character’s Hit% by 32, adding 1 to it, then multiplying the result by a random number from 0 to 2. I do not know for sure, but I suspect the resulting number of hits is rounded off before multiplying all the damage done by that attack by it. The randomness in this process is a substantial element, potentially even greater than the normal attack variance. Also note that Black Belts/Ninjas double the number of hits done, just because. Call it the home field advantage.

A character’s Defense, aka “Absorb,” is, entirely, determined by their equipment, except in the case of unarmored Black Belts/Ninja, whose Absorb is equal to their level. (Or should be; there’s a bug that in some cases uses that character’s weapon power instead. Please don’t seek to simulate the effect of such bugs in your own games.)

Critical Hits? Each weapon has its own critical hit rate, which is then completely ignored by the engine. It’s a bug: the weapon’s sequential position in the table, divided by two and in percent, is its critical hit rate. Excepted from this (as you might be expecting) are unarmed Black Belts and Ninja, whose critical rate is their level. Damage done from a critical is the same as normal, just with the random part rolled a second time and added in.

Here’s a couple of notes:

Outside of HP and MP, characters only gain single statistic points upon level increase. Level 50 is the maximum level for both Dragon Quest I and Final Fantasy I, but in Final Fantasy, a character can only gain a single point in each stat at increase. Some classes have scheduled guaranteed increases at particular levels; other levels have only a 25% increase in growth.

Since characters can only gain one point of Strength upon each level gained, and its effect in the damage calculation is halved, as far as base damage goes, for non Black Belts, weapon power seems to matter a lot more than arm power.

Balancing against that is each class’ Hit% gain. Fighters start at 10% and gain 3% with each level, putting them at getting a second hit in more times than not at level 8, and getting another on average every 11 levels after. Weapon choice may play a role in that as well; the source material seems inconclusive. Unarmed BB/Ns get twice their level, meaning an extra hit every 16 levels, but then the number of hits is outright doubled, so make it every 8. That explains why they tend to be such an attacking powerhouse in the late game.

I didn’t cover magic users in this, which is its own huge and drawn-out matter. I leave that as an exercise for the (hyper-motivated) reader.

Sources

May I take a moment to praise GameFAQs, and the enthusiastic fans who have posted there for over twenty years? Most people turn to it and similar sites when they need a walkthrough, but if you take the time to explore it, you’ll find a wealth of decent in-depth information on a wide variety of games, especially for classics! Every source used in this article was found there:

The battle formulas for Dragon Quests I and II were discovered by tyan8bit, and described in his FAQ at: https://gamefaqs.gamespot.com/snes/564868-dragon-quest-i-and-ii/faqs/61640. Notably, his discussion comes with detailed disassembly of the relevant parts of the code.

Used to confirm the behavior of item stats is this item guide to DQ/DQ I: https://gamefaqs.gamespot.com/snes/564868-dragon-quest-i-and-ii/faqs/27862

Slartifer does something similar for DQIII at: https://gamefaqs.gamespot.com/nes/587249-dragon-warrior-iii/faqs/64752. There’s another guide, specifically written for the Gameboy Color port of the game, written by Sk8erpunq, at https://gamefaqs.gamespot.com/gbc/450388-dragon-warrior-iii/faqs/70252.

And Fafnir_Volsung has one for DQVIII, useful for seeing how the formulas have evolved over the years, at: https://gamefaqs.gamespot.com/ps2/583527-dragon-quest-viii-journey-of-the-cursed-king/faqs/44904

On the Final Fantasy side of things, AstralEsper covered the first game: https://gamefaqs.gamespot.com/nes/522595-final-fantasy/faqs/57009

J.L.Tseng examined the third (Japanese version): https://gamefaqs.gamespot.com/nes/563415-final-fantasy-iii/faqs/29389

Deathlike2 explicated the formulae of Final Fantasy IV (US 2) at: https://gamefaqs.gamespot.com/snes/588330-final-fantasy-iv/faqs/54945

Terii Senshi discussed the formuae of Final Fantasy VI (US 6) at: https://gamefaqs.gamespot.com/snes/554041-final-fantasy-iii/faqs/13573

And Final Fantasy VII has multiple FAQs available, written by TFergusson. Battle Mechanics: https://gamefaqs.gamespot.com/ps/197341-final-fantasy-vii/faqs/22395, Party Mechanics: https://gamefaqs.gamespot.com/ps/197341-final-fantasy-vii/faqs/36775 and Enemy Mechanics: https://gamefaqs.gamespot.com/ps/197341-final-fantasy-vii/faqs/31903.