# How to develop RPG Damage Formulas?

I'm developing a classical 2d RPG (in a similar vein to final fantasy) and I was wondering if anyone had some advice on how to do damage formulas/links to resources/examples? I'll explain my current setup. Hopefully I'm not overdoing it with this question, and I apologize if my questions is too large/broad

My Characters stats are composed of the following:

enum Stat
{
HP = 0,
MP = 1,
SP = 2,
Strength = 3,
Vitality = 4,
Magic = 5,
Spirit = 6,
Skill = 7,
Speed = 8, //Speed/Agility are the same thing
Agility = 8,
Evasion = 9,
MgEvasion = 10,
Accuracy = 11,
Luck = 12,
};


Vitality is basically defense to physical attacks and spirit is defense to magic attacks.

All stats have fixed maximums (9999 for HP, 999 for MP/SP and 255 for the rest). With abilities, the maximums can be increased (99999 for HP, 9999 for HP/SP, 999 for the rest) with typical values (at level 100) before/after abilities+equipment+etc will be 8000/20,000 for HP, 800/2000 for SP/MP, 180/350 for other stats

Late game Enemy HP will typically be in the lower millions (with a super boss having the maximum of ~12 million).

I was wondering how do people actually develop proper damage formulas that scale correctly? For instance, based on this data, using the damage formulas for Final Fantasy X as a base looked very promising. A full reference here http://www.gamefaqs.com/ps2/197344-final-fantasy-x/faqs/31381 but as a quick example: Str = 127, 'Attack' command used, enemy Def = 34.

1. Physical Damage Calculation:
Step 1 ------------------------------------- [{(Stat^3 ÷ 32) + 32} x DmCon ÷16]
Step 2 ---------------------------------------- [{(127^3 ÷ 32) + 32} x 16 ÷ 16]
Step 3 -------------------------------------- [{(2048383 ÷ 32) + 32} x 16 ÷ 16]
Step 4 --------------------------------------------------- [{(64011) + 32} x 1]
Step 5 -------------------------------------------------------- [{(64043 x 1)}]
Step 6 ---------------------------------------------------- Base Damage = 64043
Step 7 ----------------------------------------- [{(Def - 280.4)^2} ÷ 110] + 16
Step 8 ------------------------------------------ [{(34 - 280.4)^2} ÷ 110] + 16
Step 9 ------------------------------------------------- [(-246)^2) ÷ 110] + 16
Step 10 ---------------------------------------------------- [60516 ÷ 110] + 16
Step 11 ------------------------------------------------------------ [550] + 16
Step 12 ---------------------------------------------------------- DefNum = 566
Step 13 ---------------------------------------------- [BaseDmg * DefNum ÷ 730]
Step 14 --------------------------------------------------- [64043 * 566 ÷ 730]
Step 15 ------------------------------------------------------ [36248338 ÷ 730]
Step 16 ------------------------------------------------- Base Damage 2 = 49655
Step 17 ------------ Base Damage 2 * {730 - (Def * 51 - Def^2 ÷ 11) ÷ 10} ÷ 730
Step 18 ---------------------- 49655 * {730 - (34 * 51 - 34^2 ÷ 11) ÷ 10} ÷ 730
Step 19 ------------------------- 49655 * {730 - (1734 - 1156 ÷ 11) ÷ 10} ÷ 730
Step 20 ------------------------------- 49655 * {730 - (1734 - 105) ÷ 10} ÷ 730
Step 21 ------------------------------------- 49655 * {730 - (1629) ÷ 10} ÷ 730
Step 22 --------------------------------------------- 49655 * {730 - 162} ÷ 730
Step 23 ----------------------------------------------------- 49655 * 568 ÷ 730
Step 24 -------------------------------------------------- Final Damage = 38635


I simply modified the dividers to include the attack rating of weapons and the armor rating of armor.

Magic Damage is calculated as follows: Mag = 255, Ultima is used, enemy MDef = 1

Step 1 ----------------------------------- [DmCon * ([Stat^2 ÷ 6] + DmCon) ÷ 4]
Step 2 ------------------------------------------ [70 * ([255^2 ÷ 6] + 70) ÷ 4]
Step 3 ------------------------------------------ [70 * ([65025 ÷ 6] + 70) ÷ 4]
Step 4 ------------------------------------------------ [70 * (10837 + 70) ÷ 4]
Step 5 ----------------------------------------------------- [70 * (10907) ÷ 4]
Step 6 ------------------------------------ Base Damage = 190872 [cut to 99999]
Step 7 ---------------------------------------- [{(MDef - 280.4)^2} ÷ 110] + 16
Step 8 ------------------------------------------- [{(1 - 280.4)^2} ÷ 110] + 16
Step 9 ---------------------------------------------- [{(-279.4)^2} ÷ 110] + 16
Step 10 -------------------------------------------------- [(78064) ÷ 110] + 16
Step 11 ------------------------------------------------------------ [709] + 16
Step 12 --------------------------------------------------------- MDefNum = 725
Step 13 --------------------------------------------- [BaseDmg * MDefNum ÷ 730]
Step 14 --------------------------------------------------- [99999 * 725 ÷ 730]
Step 15 ------------------------------------------------- Base Damage 2 = 99314
Step 16 ---------- Base Damage 2 * {730 - (MDef * 51 - MDef^2 ÷ 11) ÷ 10} ÷ 730
Step 17 ------------------------ 99314 * {730 - (1 * 51 - 1^2 ÷ 11) ÷ 10} ÷ 730
Step 18 ------------------------------ 99314 * {730 - (51 - 1 ÷ 11) ÷ 10} ÷ 730
Step 19 --------------------------------------- 99314 * {730 - (49) ÷ 10} ÷ 730
Step 20 ----------------------------------------------------- 99314 * 725 ÷ 730
Step 21 -------------------------------------------------- Final Damage = 98633


The problem is that the formulas completely fall apart once stats start going above 255. In particular Defense values over 300 or so start generating really strange behavior. High Strength + Defense stats lead to massive negative values for instance. While I might be able to modify the formulas to work correctly for my use case, it'd probably be easier just to use a completely new formula. How do people actually develop damage formulas? I was considering opening excel and trying to build the formula that way (mapping Attack Stats vs. Defense Stats for instance) but I was wondering if there's an easier way? While I can't convey the full game mechanics of my game here, might someone be able to suggest a good starting place for building a damage formula?

Thanks

• I think you've done the right thing in first setting what kind of stats, HP etc you want. This is part of the player experience and the math should fit 'around' these values. With so many stats though, the player should intuitively know what stats will affect his magical, physical attacks, etc. So the first big question is what stats correspond to an attack, and what stats defend against these stats (For ex PhDef defends only against PhAtk). – Jonathan Connell Jun 30 '11 at 9:02
• The huge thing is balance, it would probably be a good idea to create an interactive program (say in C# or something quick) where you can change stats and see what kind of results you get. If you can change the formulae at run time, that would also help :) – Jonathan Connell Jun 30 '11 at 9:14
• Consider using Excel to do this. Seems well suited to the task and you wouldn't have to write a line of code. – Alex Schearer Jun 30 '11 at 23:22
• The most important question is: Which formula gives players the most fun? (searched the page for "fun" and non of the answers mentioned it :P) If it stats or damage go up too fast players get insensitized, if it goes up to slowly they get bored. Players need to feel happy when they gain a level, so they need to feel like they put work into it and also that it will have some noticeable effect on their game performance. (that's my 2 pence) – Annan May 26 '12 at 21:06
• "(Def - 280.4)^2" huh? Well, I would expect things to get weird not for Def > 255 or Def > 300 but pretty much exactly for Def > 280.4 ;) After that, higher def will effectively mean a lower def at this point of the formula while continuing to behave as expected at other points. BTW, you can just plot this stuff with Wolfram Alpha or so. Fix enough variables to keep only two and you'll get a nice surface plot. – Christian Jan 6 '14 at 23:16

Creating formulas like this requires knowledge of elementary mathematical functions - the things you learned about in Algebra and Pre-calculus class.

Once you have those mastered, just ask yourself (replace "value" with "damage," or "health," or "speed" or whatever):

Then just tweak it (add/multiply stuff, change the base-value, etc) until it feels right. A graphing calculator will help you visualize how changes to the parameters will affect the function.

By the way, the problems you are experiencing are due to integer overflows.

Use variable-types that are large enough to hold the numbers you're working with. Sizes differ by platform in C++, but using the 32-bit Visual Studio compiler, unsigned int is 32-bit, while unsigned __int64 (MS-specific) is 64-bit. Also consider using a double.

Additionally, try to reorganize your operations so that you don't encounter such large numbers in the first place (for example, rather than MDef * MDef / 110, do (int)((float)MDef / 110 * MDef)).

• If you're running into integer overflows, conversion to float - which only reliably supports 24 bits of integer part - is going to have a different set of accuracy problems. – user744 Jun 29 '11 at 21:16
• @Joe: I've rolled back your edit; I specifically chose __int64 over uint64_t because stdint.h is not available on Visual Studio 2008 and below, and I didn't want to confuse the poor boy any more than he already is. – BlueRaja - Danny Pflughoeft Jun 29 '11 at 21:32
• @BlueRaja: I don't see any evidence the asker is using Visual Studio, and it's present in every other standard toolchain (including Visual Studio 2010). – user744 Jun 29 '11 at 22:07
• You left out one important variant as well, I think: If you want the damage to have an upper bound which you can get close to, but never quite reach, you can use a sigmoid function. – Martin Sojka Jun 30 '11 at 5:41
• user127817: All that's really important is how the function grows. For the rest, just test it until it feels balanced. If you feel the character is too powerful, lower his damage. If you feel it takes too long to kill a particular boss or enemy, lower that enemy's health or armor. And so on. – BlueRaja - Danny Pflughoeft Jul 15 '11 at 16:51

My Characters stats are composed of the following:

There's your real problem: you defined your stats before defining what those stats actually mean. You're putting the cart before the horse.

Look at how D&D (tabletop) works. "Strength" doesn't mean anything by itself; it only means something because there's a rule that says, "Add your strength bonus to your melee attack." That rule is part of D&D's combat rules. Without the combat rules, "Strength" is generally a meaningless quantity.

The first question you need to ask yourself is this: how much differentiation do I want between characters? Again, look at D&D. There, they have 6 basic stats. These stats define different dimensions of play for characters. A character with a high Dexterity will have different options from a character with low Dexterity.

But the reason for even that difference all comes back to rules. A high Dexterity means bonuses to ranged attacks; you can hit more often with ranged attacks. So just between Strength and Dexterity, you have two dimensions of play: ranged vs. melee.

Intelligence and Wisdom also form something of a pairing, but these interact more with specific classes. Int makes Wizards and other arcane spellcasters better (or possible under some rulesets), Wisdom is vital for Clerics and other divine spellcasters. Because divine and arcane spells have different spell lists, these two stats are involved in different dimensions of play.

You need to define the basic rules around stats before you can define growth progression functions and the like. You don't need specifics; you don't need to say that "each point of strength is added into the random roll to determine if a melee attack hits." What you need are meta-rules like "dexterity makes ranged attackers better." You can figure out exactly how it makes them better later on.

There are different ways to progress characters. A common old-school Final Fantasy trick was to simply use the character's level as part of their damage computations. This could be simply multiplying the level by the appropriate stat, or it could mean applying a function to the character's level. Say, a quadratic progression, so that the rate of a character's damage would increase per level.

However you want your combat functions to work, they need to take into account progression. Your functions need hooks for progression.

D&D has a funny way of progression. It is part class-based; every time you go up in level, you get new class features and a flat bonus to your to-hit, based on your character class. However, some class features got better by themselves. Spells in D&D would have progression built into them. A spell might do 1d4 damage per 2 levels of a spellcaster above the first. So every other wizard level makes that spell better.

D&D also used item-based progression heavily. Until 4th edition, item-based progression was mainly for fighting characters, but even in older editions, spellcasters had items that gave them stat buffs or other adjustments (or flat out gave them spells).

So items are another thing your combat functions need to take into account. Do items just buff one or more stats while equipped, or do they do other things as well? D&D was a bit odd, in that stats rarely changed; weapons simply did XdY damage, possibly with a bonus based on one of your stats. And that was that. So your only way to do more damage in battle was to find a better weapon. In many videogame RPGs, they take level into account in addition to a weapon.

• "There's your real problem: you defined your stats before defining what those stats actually mean. You're putting the cart before the horse.". I strongly disagree; the numbers in themselves are just a way to inform the player of his power, etc. it is part of the game design. If you proceed the other way round, you could end up with an end boss with 147hp... who wants that really? – Jonathan Connell Jul 1 '11 at 9:13
• Well, Sarevok (in Baldurs Gate) only had 135 HP ... – Martin Sojka Jul 1 '11 at 9:51
• @3nixios: What does it matter if the end boss has 147Hp? What matters is whether the last boss is challenging, interesting, and above all rewarding to defeat. A boss with a lot of Hp isn't interesting; it's a waste of time. A boss that can mess with your party, that requires special tactics that change from moment to moment, that requires that you must to use every ability you have to its maximum potential, that is what makes for a great final boss. I'll take the interesting 147Hp boss over the boring block of Hp any day. – Nicol Bolas Jul 1 '11 at 9:53
• @Nicol Bolas I totally agree with you, I was trying to support why I believe that the starting point has to be from the stats. The stats a player starts with are the primary indication and gameplay that the player plays with during the game. I agree that huge HP bars for bosses aren't necessary, it gives the player a better indication of what is the best setup against the boss, what stats weapons etc. are more effective. The amount of course is irrelevant to the way you calculate it, because you can just divide or multiple your final calculations by a constant c and be done with it. – Jonathan Connell Jul 1 '11 at 10:22
• @3nixios: But that's part of my point. Dexterity in D&D exists to allow a differentiation between melee specialist characters and ranged specialists. If there were no concept of melee and ranged attacks (and in many FF games for example, there isn't), then this distinction would not need to exist. You could get away with 5 stats instead of 6. Defining a Hp range is one thing, but defining what basic stats you have is another. Stats require rules before you can make sense of them, and you have to know what you intend a stat to do before you can say that having that stat is a good idea. – Nicol Bolas Jul 1 '11 at 10:27

Your formulas seem pretty complicated. I'm not sure how professional RPG developers handle this, but I'd recommend on focusing on simplicity. Try to find the simplest possible formula you can that still incorporates the range of stats you want to use. For instance, could you have stats modify each other prior to damage calculation, rather than modifying the damage during the calculation? Once you've got a formula in mind, I'd try graphing it for a wide range of possible values to see how it will behave as players level up. Obviously the fewer variables you have, them more feasible this will be.

Additionally, BlueRaja provided an important explanation of why you might be seeing unexpected values at higher stat levels. Using unsigned types and checking for overflows will be important.

• +1 for simple. Anyone can make rigorously complicated stuff, that doesn't make a good game though. – aaaaaaaaaaaa Jun 29 '11 at 22:27
• @Randolf unless you're running on an Apple 2 or something, it's highly doubtful that removing a multiply or a divide here and there is going to affect performance in any measurable way. – Tetrad Jun 30 '11 at 6:34
• @Randolf A big battle in an RPG might mean something like 10 damage calculations per second, a modern CPU can do several billion operations per second. You can safely assume that the performance impact of any such "visible" maths is negligible. Simple in this case is for the sake of those who design and those who play the game, not for our computers. – aaaaaaaaaaaa Jun 30 '11 at 9:36
• @Randolf Richardson: I just think you might be missing the target a bit in this case. For an MMO a good fast no-fat protocol is paramount, and heavy tasks like physics need to be designed with performance in mind. But damage calculation is core gameplay, it should be designed with gameplay in mind, if you bring performance concerns into such a question you risk compromising the gameplay part. Talk about performance when it matters, you risk giving the impression that this is an important area to optimise, thus stealing the attention from the real performance sinners. – aaaaaaaaaaaa Jun 30 '11 at 22:21
• @Randolf: I'm implying nothing; I'm saying that optimizing something that isn't a bottleneck is a waste of time. – Nicol Bolas Jul 1 '11 at 17:17

Late game Enemy HP will typically be in the lower millions (with a super boss having the maximum of ~12 million).

This I have a problem with. You should build your bosses around what you think your players should be able to handle. You're building your players and combat formula around what you want your bosses to be like.

Once you get your combat mechanics and roles built, then you can decide on how you want to design your bosses as it should be a good balance between the damage the players can deal/absorb vs what the boss can deal/absorb.

• +1 the enemy's health should be based on what the player can reasonably handle at that point, not the other way around. – BlueRaja - Danny Pflughoeft Aug 1 '14 at 16:54

Those numbers you quoted are likely derived from a just tweaking a simulation, over thousands of runs.

So you should write a simulation create a level 20 character, and see how he fares through 200 battles or so against the enemy types he's supposed to be fighting at that point. Do it again for a level 30 character (in presumably the next section of the world).

It'll take a while to get right, but writing automated simulations will definitely make this much easier than just guessing and manually playing it out.

I think you make the mistake that you want to create a formula without having a proper design in mind.

Try to implement "types" of enemies, e.g. "armored" => a player attack if it is of type physical is reduced by 50%. Do not make a battle flow to abstract, think about what is relevant and what is not.

If your design says "armored enemies" are weak against magic but strong against physical damage, represent that in code. But remember that you have do a lot of testing, because the values won't work magically the first time you write the code. Try to create a design, put the logic into code, always check whether this the technical representation of what you had in mind and if it isn't change the values until it is.

• I was already encompassing that sort of thing - armor rating scales down physical attack damage unless the attack is flagged as armor piercing or uses a % based damage formula – user127817 Jul 1 '11 at 19:38

Although my design have not left Spreadsheet phase, I have came to one conclusion about designing math for RPG:

Keep them as simple as possible. In design that I'm working on, I used very simplistic formulas, that are adequate to semi class-less system. Ie. Fireball Spell have damage of 30. The forumal is:

BaseSpellDamage * Attribute (5 * 6)


We can also add modifiers like this:

Result = (BaseSpellDamage * Attribute) (5*6)
Result = Result + (Result * 50%) (30 = 30 + (30 * 50%))


So end result would be 45 damage. I found that using precentage multipliers is very easy, and very scalable solution to work with. Instead of coming with some odd numbers with complex math to figure out the result we want.

Now we can calulcate damage reseistance, that will just calcucate defense against set type of damage. There are two approaches and I honestly haven't decided which would suit better, but they both are simple and viable:

DamageResult = Resistance * Damage ( 50% * 45)


So the end result will be 22damage taken (I just cut the partial result).

Other formula:

DamageResult = Damage - Resistnace (45 - 22).


So end result will be 23. If it happen that resistance is bigger than damage taken then character just doesn't recieve any damage. Of course it's up to you to make sure that such situation have no place, except for when you want it be the case.

Although I must admit that precentage scaling is somewhat easier to balance and scale. But this also depends on your base numbers. Precentage scaling will work best if you start from 100 and up. If you are operating on small numbers (anything below 100 to be honest), it can get awkard as you will start getting floating point results, that will be hard to balance and actually do anything interesting with them.

Probably optimal solution in that case is to use both approaches when they see to fit. Or if you are fan of big numbers start from 1000.

And at the closing ends. I haven't come to this conclusions completly on my own. I have actually spend quite some time reading various RPG manuals (Hero, DnD). Especially DnD was helpful, as it operates on similiar principles but instead of attributes it's using levels for it's formulas, they can be sometime more complex. Than what I presented here.

In anycase, the best advice is: try to keep them as simple as possible. Do not use any advanced math, or long equations, as they are prone to errors, that are hard to spot, when you have to deal with 87234 other things at the same time.

all games in the final fantasy series have had a stat cap of 255 because of the problem you are encountering. at level 100 stats would be 255.

you say about increasing stats with abilities and equipment and I remember seeing this in the games but the way this is done is in the formula. there is an extra step that checks for ability and equipment modifiers and applies them after the stats have been used.

in your case it would be step 21: apply ability modifiers step 22: apply equipment modifiers step23: final damage.

if you are interested google for final fantasy formulas, they are out there. I have copys of the actual battle mechanics including AI for final fantasy 4, 6, 7 and 9. people cracked them from the original games when they were creating roms for emulators. There not that hard to find if you look hard enough.

the biggest thing for creating formulas is testing. set up a script to run your battle wit ai on both side and run several hundred battles. vary the monsters and the stats and see if it works or if lv 40 kills everything, it is entirely possible that a boss is actually impossible to kill lol. a tip would be to turn off all animation as it is impressive how fast AI's can battle when no one is watching.

I was wondering how do people actually develop proper damage formulas that scale correctly?

The first 2 things are:

• decide what you mean by 'correctly' - what is your idea of 'correct damage'?
• decide what you mean by 'scale' - what values are going to change, and what effect do you want those changes to have?

Once you know that, you have enough information to use the mathematical formulas that BlueRaja mentioned in his answer. Just remember there is no such thing as a 'proper' damage formula - just one that matches your design for the type of experience you want your players to have.

• This is an extremely unhelpful comment. It sums up to "I don't know" and because of that it is a waste of everyones time. Flagging for deletion. – Krythic Sep 21 '16 at 3:18

As others have mentioned, the Final Fantasy X formula is pretty complex. Generally for that series the later the game, the more complicated the formula. It's probably easier to base your damage formula on another game entirely. But in general, I think it's worth discussing from a very general level what kind of damage formulas you can find in the world, and how you can make a game based around them. The first thing you need to decide is how much damage do you want to be able to do at the end of the game, and what kind of stats do you want the player to be able to have? Once you have that, you can pick a formula system, and then optimize the formula and weapon values to reflect those ranges over time.

## Purely Stat-Based

This is a good idea if you want your characters to be flexible in terms of what levels of enemies they can challenge. A formula like this is only going to depend on the player's stats, their equipment, and the stats of the enemies. These formulas are usually fairly simple. Final Fantasy Legend II (See http://www.shenafu.com/ffl2/weapon.php for instance, has weapons that do damage based on the simple formula:

(Stat+StatBonus)*WeaponStrength - Defense*4


A formula like this is good if you want a very simple method of estimating damage, or a quick jumping off point for modifying damage based on other factors like skills and elemental weaknesses.

To show how broad this kind of formula can truly go, consider the damage formula for Inflation RPG, an Android and IOS game (See http://inflation-rpg.wikia.com/wiki/Calculations). The formula is heavily both stat and equipment dependent. Each piece of equipment has two stats - a bonus to the ATK stat, and a multiplier value. Some pieces of equipment have low multipliers, but high bonuses, others have low bonuses but high multipliers. For a character with only 10 ATK, the Battle Axe with it's 5000 ATK Bonus but low 145% multiplier is a great choice. The total damage is (10+5000)*1.45 = 7264, but the Estoc, with 0 bonus and a multiplier of 300% is a poor choice - the damage is (10+0)*3 = 30. Later in the game, a character with 5000 attack would prefer switching weapons.

## Stat- and Level-Based:

A good example of this is Final Fantasy V, VI, and Final Fantasy XII (See http://www.gamefaqs.com/ps2/459841-final-fantasy-xii/faqs/45900, for example). The formula for swords in FFXII is:

DMG = [ATK x RANDOM(1~1.125) - DEF] x [1 + STR x (Lv+STR)/256]


and the damage formula for staves is:

DMG = [ATK x RANDOM(1~1.125) - DEF] x [1 + STR x (Lv+MAG)/256]


They're very similar, but notice that the sword formula only depends on the strength and level, while the staff formula depends on strength, magic and level. The advantage to this kind of formula is that it allows the player two avenues of growth - building their stats, or building their levels. The downside is that it also penalizes characters both ways as well. What this really ends up doing is allowing the player to level up to increase their damage output (for FFXII this amounts increasing their damage output by ~4% per level around level 50 when you factor in stat gains) to help customize the difficulty to their comfort level.

## Fixed Damage:

Fixed-damage formulas do not depend on the character's stats or level, they depend only on the internal damage formula of the weapon itself. They can still vary over a range, but they deal the same damage regardless of the user (barring any other special effects or character traits). They're best used if the weapon is going to do fixed-damage and the ability to equip the weapon depends on either stats and/or level. Diablo 2, for example, does this, as do many roguelikes which have weapons that depend on die rolls. That being said, 'fixed damage' does not imply "non-random" - and in fact there's usually some element of randomness to the damage done.

This is a good methodology if you want to have weapons that are easy to transfer between characters or to carefully control the damage output that characters at certain points in the game can do if you know what equipment they have access to (via drop tables, chests, and steal tables).

Another place you'll run into this is with certain types of equipment or items in Final Fantasy. 1000 Needles, for instance, always deals 1000 damage. In Final Fantasy Legend II, martial arts deal damage based on the formula:

Damage = WeaponStrength*(90-UsesLeft) - 4*Defense


Final Fantasy XII has somewhat fixed damage for guns as well, dealing damage according to the formula:

DMG = [ATK x RANDOM(1~1.125)]^2


Although the damage is somewhat random, it only varies by 26.5 percent over the total range, so you're guaranteed to do a certain level of damage on average over time. These types of attacks are useful for characters who have both low stats and low levels in games that normally account for those factors in dealing damage. Plus, they ignore the defense of the target (although the formula could be easily reworked to fit in defense if you so desired).

alternativly, if your looking for a very simple formula, Do the following:

(Note that this is my idea for a formula,)

First, for a simple attack formula, you will only need a few stats. THe player's Attack stat (this could be Strength, or Magic, depending on the type of move.)

Then, create a variable, called MovePower. This will depend on the move, and better moves would have a better MovePower. For my formula's, general "Attack" commands have a MovePower of 5.

Then, make the defence a percent based stat, (and, of course, make it inpossible to achieve 100% defence on damage)

Then, during the attack phase, simply multiply the attack stat by the move power, and remove damage based on the foes defence! simple!

You can also opt to have other modifyers, like if the move will hit (Accuracy), if the move has another added effect (Bio, inflicting poison,) and opt for that to hit, (Accuracy again,) have damage upgrading/downgrading moves that change stats, ect. Have fun with it!

• Another option that avoids the armor as a percentile issue (thus allowing its values to look the same) is to calculate damage vs armor as a comparison that becomes a multiplier. Something like Ln(atk/def) as a base. This allows defensive armor stats to scale as time goes on in the same fashion. Figure out how to get your basic desired damage range for when the damage and armor stats are the same and extrapolate from there. This does make "armor avoidance" attacks require a trick to create, but that's part of what creativity is for. – Aviose Jul 10 '15 at 15:14

In essence, you need to figure out two things.

1. How to properly preform computation with large numbers.
2. How you want and expect attack damage to behave against weaker and strong opponents.

# 1

You can either user double or a big number library. Doing computations with large numbers (like in clicking / idle games often relies on such big number libraries). In your case, the numbers are relatively small so using 64-bit floating point will allow the needed flexibility.

# 2

How do you want the game to behave? some examples:

• One approach is to use ATK to decide if you hit or not and roll a die with a known damage rating depending on the weapon: for instance long sword 1d8, two handed sword 1d10, dagger 1d4. This will not scale amazingly well if the hp can grow on and on. If you use ATK to determine if the characters hit or miss, you can do another throw after a successful hit with ATK * 80% to determine crits.
• If you want to use a damage formula, the damage formula can be as simple as (ATK - DEF) +/- 20% as it's done in World's End (an RPG strategy game). This will mean that attacks against an opponent with strong DEF could do no damage at all. For instace ATK = 10, ENEMY DEF = 12, (ATK - DEF) = -2 and it also means that high attack vs slightly lower def, could do little damage, potentially making battles longer with increasing HP. For instance with ATK = 1010, ENEMY DEF = 1005, the damage would be 5. The damage will also increase dramatically now if the ATK is increased by a small percentage. For instance ATK = 1055, will do 900% more damage with only a %5 increase in ATK value.
• To avoid this, you can do something like ATK / DEF * WEAPON_DAMAGE This will scale more gradually when ATK or DEF are increased and allow a weak attacker to damage a creature with strong DEF.

tl;dr You need to treat your numbers responsibly and figure out how you want the game to behave in different situations. Some questions to ask yourself:

1. How many attacks (turns), should it take to defeat that boss / minion?
2. How should different skills, buffs, debuffs affect x battle? Should it be hopeless, should winning be y% less / more likely?