# What damage formulas do you use?

#### FoxIt

##### Villager
I kinda just felt like talking about damage formulas for once so...
Damage formulas tend to be something most RM developpers seem to not focus on until it's either too late or don't put any effort into designing it and just using the default formula.
So, in short, what formulas do some of you guys use?
Here's an overview of a few formulas:
a*p-d
The above is the default RPG maker formula.
a here is the relevant attacking stat of the attacker.
p is the value that makes the power of each attack fluctuate
d being the relevant defending stat of the defender.
Multiple a, p and d values can be present on a formula (so if you have an attack that calculates damage based on attack and AGI for example then they'd be both "a values", though it may be easier to combine that all as one a value in this instance)
This formula is... fine, but it definitely has shortcomings for a lot of projects tbh.
Pros:
Good for making small actions and attack increases feel impactful. The first few points of attack can really make a big difference with this formula. Especially good with low numbers games.
Cons:
Kinda annoying to balance. If your numbers are way off, the most common problem, at least I find, is for the defense stat to become kinda useless to the player because the enemy's attack is so much higher than your defence that stacking defence just effectively does nothing. Other problems include stacking player defense becoming overpowered on the other end of the spectrum since every point of defence is, percentage-wise anyways, worth more than the last as well as certain attack types becoming useless if not balanced correctly relative to the others.
Low numbers games remedy these issues somewhat by making the math simpler and thus easier to manage for the developper as well as making each point of damage much more impactful and enhancing the upsides so I feel like in low numbers games is where this formula shines the most.
Other formula:
p*(a/d)
This formula is kind of the opposite of the default one.
Pros:
If an effect increases your attack by 25%, then it effectively increases your damage by 25% which is pretty easy to understand.
Even if your defence is 4 times higher than the attack stats constantly it's still totally balanced since both stats will always remain relevant.
Very easy to make guarantee every stat in your damage formula is useful.
Cons:
Can get kinda janky if you're throwing a lot of tools at the player with the player being able to potentially deal much more damage than you intended since everything about this formula is multiplicative.
Defence reduction effects can be unintuitive to calculate and get really swingy. DEF-25%=33% damage increase to the target. DEF-50%=100% damage increase to the target. DEF-100%=Game crash since you don't divide by 0 in math.
Awful for low numbers games. Going from 1 defence point to 2 defence points means suddenly taking -50% compared to before for example.

#### kirbwarrior

##### Veteran
My default is a.atk - b.def. It's not always what I use, but it's simple to develop, simple to the player, and makes it really clear to the player what the enemy defense is (in fact, I'd love to be able to set def to 0).
Low numbers games remedy these issues somewhat by making the math simpler and thus easier to manage for the developper as well as making each point of damage much more impactful and enhancing the upsides so I feel like in low numbers games is where this formula shines the most.
This, but there's also something really nice about small numbers. Like, in Paper Mario you feel incredibly powerful when you hit two digits of damage. Having 1 more defense can make you feel tanky.

I also really like the feel of being immune to damage, plus I dislike how defense as divisor largely just feels like an hp multiplier. So even when I don't use the above, I still tend to make defense a subtraction. I do like elemental resistances doing it, though, largely because they are much more narrow in scope.

Note this is 'baseline'. Multiplying the whole thing by a number helps for 'big' skills. Silly things like a.def-b.atk can make for a bizarre slam. I even had a skill called 'Overwhelm' where it uses the total of your stats minus the total of their stats for damage.

As for less common ones I've used; a.Level + (a.atk-b.def) * a.atk - b.spd * (b.hp/b.mhp)
...yeah, I can't remember why I did that.

#### lianderson

##### Veteran
All my formulas are displayed in the skill description itself, and almost every element has its own formulas! (like earth magic using some defense stat for its damage and wind magic using some agility, or lightning incorporating both spirit and magic stats into its defense with gravity incorporating the enemy's defense)

Steal all my ideas! Steal everything!

Good day humans.

#### FoxIt

##### Villager
My default is a.atk - b.def. It's not always what I use, but it's simple to develop, simple to the player, and makes it really clear to the player what the enemy defense is (in fact, I'd love to be able to set def to 0).

This, but there's also something really nice about small numbers. Like, in Paper Mario you feel incredibly powerful when you hit two digits of damage. Having 1 more defense can make you feel tanky.

I also really like the feel of being immune to damage, plus I dislike how defense as divisor largely just feels like an hp multiplier. So even when I don't use the above, I still tend to make defense a subtraction. I do like elemental resistances doing it, though, largely because they are much more narrow in scope.

Note this is 'baseline'. Multiplying the whole thing by a number helps for 'big' skills. Silly things like a.def-b.atk can make for a bizarre slam. I even had a skill called 'Overwhelm' where it uses the total of your stats minus the total of their stats for damage.

As for less common ones I've used; a.Level + (a.atk-b.def) * a.atk - b.spd * (b.hp/b.mhp)
...yeah, I can't remember why I did that.
Yeah, a.atk-b.def really shines when numbers are low since every point of damage just feels like it has so much impact.
Though overall defense as a divisor only really makes sense if there are multiple defense stats and they're important. Otherwise may as well just use HP and no defense stat at all tbh.
Though in my case for the small for fun projects I make I tend to build stuff that involves way too many interactions going off at once with attack and defense multipliers going off everywhere on both sides at basically all times in combat.
a.atk-b.def stops being a useful formula when so many things are going off at once since the formula becomes impossible to balance as mentionned in my downsides section for the formula.

#### TheoAllen

##### Self-proclaimed jack of all trades
Code:
``a.atk * skill_power``
That's all.

It is simply a percentage damage reduction. If I put 20 as my DEF, then it means -20% damage taken.
It is hardcoded in the script so it works for all kinds of damage. Easier to balance.

My game complexity is on something else rather than on the damage formula itself.

Last edited:

#### Milennin

##### "With a bang and a boom!"
Code:
``a.atk*v[x]/100``
For the player's basic attack. It's just their attack stat, and then an extra percentage added on top of that, based on a variable that can be increased through the use of various Skills. The variable, by default, is set to 100.

Code:
``a.atk*v[x]*2.5/100``
This is for a relatively cheap single-target Skill, which just adds a 2.5 multiplier, so spending MP will make you feel the difference. A hit-all Skill for the same MP cost would have an 1.5 multiplier instead.

Code:
``Math.max(a.atk*2.25-b.def*0.67,1)``
For the enemy's base attack, it's a bit more complex, with also taking the target's defence into account.

My game complexity is on something else rather than on the damage formula itself.

Looks like we're taking a similar approach.

Last edited:

#### kirbwarrior

##### Veteran
Otherwise may as well just use HP and no defense stat at all tbh.
I've actually had games like that where there isn't a 'defense' stat at all. Final Fantasy Tactics has (weapon damage) * (strength) and armor gives flat HP boosts (among other non defense things).

so many things are going off at once since the formula becomes impossible to balance
That's more its own problem and not necessarily related to the damage formula. In fact, I find the simple atk*4-def*2 formula really easy to balance around and multiplicative formulas harder. In every game I've played with multiplier juggling, it always gets out of hand in the player's favor and often really easily.

#### Tiamat-86

##### old jrpg gamer
atk*p-def*5+atk*%
at minimum p=5 ('stat'100%).
this formula makes you have a minimum damage = to your attack stat * the skill's multiplier.
a skill listing ('stat'120%) would be p=6. the enemy would need 20% more def then your attack stat to make you deal minimum damage, and the minimum damage is now stat+20%

the simplicity of a low numbers game designed for the grinders that keep up with new gear,
yet also doesn't roadblock speedrunners that only get enough to survive and rely on strategy/rng while being under leveled.

also when using enemy levels, my (closest thing to fast travel) world map travel which doesn't cap enemy level like all the field/dungeon maps, doesn't get completely broken when you over level the party but your equipment is under leveled.

Last edited:

#### D.L. Yomegami

##### Sanely Insane
At the moment, I find myself preferring additive formulas, usually some variation of atk - def / 2. It's simple enough for both me and the player to understand, and can work with both big and small numbers. It also allows defense and physical/magical reduction (PDR/MDR) to have two different roles, whereas with a formula like atk * atk / def the distinction between the two becomes blurrier and can even make the latter outright redundant.

The problem with a formula like this is that I'm very fond of buffs/debuffs, and it's really easy for buffs/debuffs to break this formula. Assuming RPG Maker's default buff/debuff formula of +/- 0.25 per stack, defense can only be a third at most of attack without two attack debuffs completely crippling the attacker on their own with no defense buffs necessary, and when defense is that low defense buffs might not even be worth it. To get around this I've tried adding a flat base power that can't be buffed or debuffed, or adding a multiplier to defense that lowers its effect, but neither is a perfect solution (especially for normal attacks).

My ideal formula would be something that values both attack and defense equally, but with diminishing returns for both as well. That is, investing in attack past a certain point lowers the effectiveness of each individual point in that stat, and likewise for defense. Alas, my math skills are just too lacking to figure this out. The closest I've gotten on the defensive end is attack * attack / (attack + defense), but that benefits higher attack more than higher defense. On the offensive end I've had no luck at all.

#### kirbwarrior

##### Veteran
The problem with a formula like this is that I'm very fond of buffs/debuffs, and it's really easy for buffs/debuffs to break this formula. Assuming RPG Maker's default buff/debuff formula of +/- 0.25 per stack, defense can only be a third at most of attack without two attack debuffs completely crippling the attacker on their own with no defense buffs necessary, and when defense is that low defense buffs might not even be worth it. To get around this I've tried adding a flat base power that can't be buffed or debuffed, or adding a multiplier to defense that lowers its effect, but neither is a perfect solution (especially for normal attacks).
The best solution I've come up with is to use flat bonuses and penalties to stats. So, instead of +25% to attack, you add +3 to attack. You don't even need it to scale depending on how numbers work out elsewhere in the game, but if you wanted it to scale it can be based on something (for instance, the buffer can increase someone's attack or defense by a quarter of the buffer's magic, or it gives +X and costs 3x MP and you choose X).

#### ScorchedGround

##### Blizzards most disappointed fan (More than ever)
My base damage formula looks like this:

((6 * USER STATS) - (2 * TARGET STATS)) * MODIFIER

My base healing formula looks like this:

(4 * USER STATS) * MODIFIER

So basically, the real strength of any given skill is based on the modifier and which stats are used.
Healing formulas only take 4*User Stats because I basically just subtracted the missing 2*Target Stats.

Some examples:

((6 * a.atk) - (2 * b.def)) * 1.25
((3 * a.atk + 3 * a.agi) - (1 * b.def + 1 * b.agi)) * 1.5
((2 * a.atk + 2 * a.mat + 2 * a.luk) - (2 * b.mdf)) * 1.25

(3 * a.luk + 1 * a.mat) * 1.25
(4 * a.luk) * 1.25

I know doing it like this seems primitive or lazy, but it works really well to ensure that you always deal some damage and fully stacking armor is not as prevalent as defense scales worse than offense.

#### Frostorm

##### []D[][]V[][]D aka "Staf00"
Basic/normal attack:
(offensive component)
`(a.atk ** (1 + a.agi / 1000) + a.equips()[0]._weaponDamage) * (a.equips()[1] ? 0.8 : 1)`

(defensive component)
`value /= 2 ** (armor/ user.atk)`

...where "armor" is:
`(this.getItemElements().contains(4) || this.getItemElements().contains(5) || this.getItemElements().contains(6) || this.getItemElements().contains(7) || this.getItemElements().contains(8)) ? (target.def + target.mdf) / 2 : target.def`

(off hand component)
`(a.atk ** (1 + a.agi / 1000) + a.equips()[1]._weaponDamage) * 0.6`

Explanation
Offensive Component:
Damage is mostly derived from the ATK (Strength) stat but gains a synergistic effect if the user has a high AGI (Dexterity) stat as well. That's why it's in exponential form, albeit a mild one. Next, it adds a flat amount based on the weapon damage of the item in the Main Hand slot. Then it checks if there's anything equipped in the Off Hand slot. If so, the whole thing is reduced a bit, which is for Dual Wielding balancing purposes, which I'll get to later.

Defensive Component:
The result from the offensive component is then multiplied by a factor that depends on the ratio between the attacker's ATK and the defender's DEF. The formula I listed is for Physical attacks specifically. Magical attacks use the same formula but swap ATK for MAT and DEF for MDF, w/ some caveats which I'll explain next. But for now, I'll use the term "Armor" to refer to DEF/MDF. Note that if the defender has 0 Armor, the attack does full damage. If the defender's Armor stat equals the attacker's ATK stat, then the attack deals half damage.

Armor Caveat:
As far as the messy javascript goes... That basically just checks the element(s) of the attack in question. If it contains any elements 4-8 (Fire, Frost, Shock, Radiant, Necrotic) then the formula will use the average of the defender's DEF & MDF, otherwise it will just use DEF. The reason for the average instead of pure MDF is because this is for Physical attacks, so it is assumed that physical damage is being dealt regardless.

Off Hand Component:
This formula is for an off-hand swing that automatically triggers w/o the user's input if the user is Dual Wielding. It is similar to the Main Hand formula except it adds the weapon damage from the Off Hand and uses a lower multiplier.

Simple magical attack: (e.g. Fireball)
(offensive component)
`a.mat ** (1 + a.mdf / 1000) * 1.5`

(defensive component)
`value /= 2 ** (armor/ user.mat)`

...where "armor" is:
`if ((this.getItemElements().contains(1) || this.getItemElements().contains(2) || this.getItemElements().contains(3)) && (this.getItemElements().contains(4) || this.getItemElements().contains(5) || this.getItemElements().contains(6) || this.getItemElements().contains(7) || this.getItemElements().contains(8))) {(target.def + target.mdf) / 2;} else if (!this.getItemElements().contains(4) && !this.getItemElements().contains(5) && !this.getItemElements().contains(6) && !this.getItemElements().contains(7) && !this.getItemElements().contains(8)) {target.def;} else {target.mdf;}`

Explanation
Offensive Component:
Similar to the physical formula except damage is derived from MAT (Intellect) instead of ATK (Strength). MDF (Willpower) is used as a synergistic boost in the same way AGI (Dexterity) does for the physical formula. I use MDF because Willpower also increases MaxMP so pure casters (who usually invest in both MAT & MDF) will have stronger magical attacks than hybrid characters even if their MAT is the same. Note how the magical formula doesn't have a weapon damage component but instead relies on a multiplier that varies from spell to spell.

Defensive Component:
Same as the physical one except ATK is swapped for MAT.

Messy Armor Code:
The magical formula has a slightly more complex conditional to determine what stat is used for "Armor". This is because a spell can either deal purely physical damage (e.g. Wind Blade, Earthquake, etc...), purely magical damage (e.g. Fireball, Lightning Bolt, etc...), or hybrid damage (e.g. Ice Lance, etc...). Thus it will either use DEF, MDF, or the average of the two in place of "Armor" for its calculations. Also, I wasn't sure how to do "else if" statements in a ternary format so it's written in regular form. If anyone can help me translate that chunk, that'd be great.

Edit: I wanted to mention that the player doesn't need to do any of these calculations in their head or anything since the skill descriptions and tooltips incorporate the formulas and will show the exact damage being dealt w/ the user's stats accounted for.

Last edited:

#### RachelTheSeeker

##### Suddenly, a summer breeze...
Is it bad that I use variants of the default RM2k/3 forumlae? Like ATK * 2 - DEF, or MAT * 2 - MAT? Because I don't think so. Occasionally some moves might add a smaller modifier to damage or healing (because the basic numbers seemed underwhelming compared to the raw equation). I might do weirder stuff like a.hp for a White Wind, but eh.

#### LightBorneX

##### Veteran
Other formula:
p*(a/d)
Awful for low numbers games. Going from 1 defence point to 2 defence points means suddenly taking -50% compared to before for example.
p* (100+a/100+d). The only time you would divide by 0 is if somehow an enemy lowered your defense by an additional 100, but that can be blocked. It also means it's still easy to follow, because 1 point in a or d is a 1% increase. If you balance your game right, it also stays balanced as the game goes on, as if enemies are getting the same amount of stats, even if you hit 100+10,000/100+10,000 later, it will still run the same. (Also, assume the extra parantheses are in there if you are trying to do that math literally like a computer would do.)

Of course, some games do both additive and multiplicative effects, and while I understand the idea, it gets wonky if executed poorly.

I have a feeling someone has tried to create a game with far more advanced math calculations, and I'd love to see it just for the kicks and giggles. Let's get those tangents and cosines in there. That would likely get so horrible.

#### TheGentlemanLoser

##### "And when we fall, we will fall together..."
My base damage formula looks like this:

((6 * USER STATS) - (2 * TARGET STATS)) * MODIFIER

My base healing formula looks like this:

(4 * USER STATS) * MODIFIER

So basically, the real strength of any given skill is based on the modifier and which stats are used.
Healing formulas only take 4*User Stats because I basically just subtracted the missing 2*Target Stats.

Some examples:

((6 * a.atk) - (2 * b.def)) * 1.25
((3 * a.atk + 3 * a.agi) - (1 * b.def + 1 * b.agi)) * 1.5
((2 * a.atk + 2 * a.mat + 2 * a.luk) - (2 * b.mdf)) * 1.25

(3 * a.luk + 1 * a.mat) * 1.25
(4 * a.luk) * 1.25

I know doing it like this seems primitive or lazy, but it works really well to ensure that you always deal some damage and fully stacking armor is not as prevalent as defense scales worse than offense.

The damage formulas I've used in my last five or so projects, or for the last four years or so, look a lot like this (sans the * 1.25 constant). So I don't think it's primitive or crazy at all even if it is close to the default. I wish OP would use some formatting like this because (maybe I'm just being lazy/dumb, idk) w/o formatting it's very hard to pick out what the damage formulae actually are in the original post. I have in the past thought about how incredibly simple the damage formulae I use which are as mentioned very close to the default in the program are with the damage formulae in even early Final Fantasy games which look more like this:

I am perennially fascinated by the use of 255/256 and 512 as magic numbers by the Final Fantasy series although the FF games are really far from alone in this, coders/programmers/hackers in general really like to use these magic numbers.

Everything in my games can crit by default, including healing abilities, though some area/all enemies/multi-hits attacks can't crit as a tradeoff. I like having agi help reduce damage from area attacks as one "trick", I like the idea of including b.def in healing formula (although I haven't actually tried it because I'm not sure of the code that gives base b.def w/o armor and I do not like the idea of heavier armor making you heal more), and only occasionally I get a little cute or clever like in Reclaimer there's an overload skill that deals damage based on b.mp, the more POW (mp) the target has the more damage they take, and I've done "Vengeance" skills that scale damage based on how much HP the user is missing from their max.
In Spirit of '76 my damage formulae are even simpler, basically:

Gun Damage - b.def * armor penetration multiplier.

Armor penetration multiplier:
Normal Bullet Attacks: Armor x1
Shotgun/Flechette/Electrical Attacks: Armor x2 or Armor x3
Armor-Piercing Ammo Calibers like 5.7x28mm or 4.6x30mm: Armor/2 (Armor * 0.5)
Hypersonic Railguns & Laser Weapons: Armor/4 (Armor * 0.25)

Melee weapons/attacks are the exception not the rule in that game but usually wind up STR (ATK) * 2 - Armor x 1 for brute force weapons and AGI * 2 - Armor x 1 for finesse based weapons. I'm using "Armor" here but armor is just "def" in RM engine terms.

I try to vary my damage formulae between projects but I'm realizing more and more that I'm honestly really bad at that. Since I figured out (at least in theory) how do use math.rand(int) or w/e it is to add die rolls to damage I've wanted to work on something that's more dice based but it's gonna have to be a conversion to one of my 3-4 WIPs because I absolutely cannot even consider a new project at this point (honestly doing A.L.E.X. for Touch The Stars Jam was probably a huge mistake but I couldn't help myself!).

Frostorm's formulae are so fancy they hurts my brain meats lol. Frosty, where in the JS code do you define armor? I'm curious how that works. I'm assuming you're not copy pasting some version of

Code:
``if ((this.getItemElements().contains(1) || this.getItemElements().contains(2) || this.getItemElements().contains(3)) && (this.getItemElements().contains(4) || this.getItemElements().contains(5) || this.getItemElements().contains(6) || this.getItemElements().contains(7) || this.getItemElements().contains(8))) {(target.def + target.mdf) / 2;} else if (!this.getItemElements().contains(4) && !this.getItemElements().contains(5) && !this.getItemElements().contains(6) && !this.getItemElements().contains(7) && !this.getItemElements().contains(8)) {target.def;} else {target.mdf;}``

into every damage formula bar, but maybe I shouldn't make assumptions about other people's masochism potential.

Last edited:

#### Frostorm

##### []D[][]V[][]D aka "Staf00"
Frostorm's formulae are so fancy they hurts my brain meats lol. Frosty, where in the JS code do you define armor? I'm curious how that works. I'm assuming you're not copy pasting some version of
Yanfly's Armor Penetration plugin has a place to put the formula for "armor". It lets you put 3 versions (physical, magical, & certain).

The negative formulas are blank because I only recently changed to the current formula I'm using so I haven't figured that part out yet, heh.

Last edited:

#### kirbwarrior

##### Veteran
I have a feeling someone has tried to create a game with far more advanced math calculations, and I'd love to see it just for the kicks and giggles. Let's get those tangents and cosines in there. That would likely get so horrible.
Not quite there, but check out Pokemon's damage calculation at some point. It's unnecessarily complicated, especially for a game that refuses to let you know how much damage you do (Or really clarity in battle at all).

One of the Final Fantasies uses something like str*3 as a base and decreases things from there. I couldn't tell you what decreases it.

And I don't see why the damage formula should be so obfuscated like these. If the player doesn't understand how much damage they will do, then that's the developer taking that part of the strategy away from them.

#### G-G-Games

##### Villager
I'm thinking for my next project I might use:

a.atk * 2 ^ ( (a.atk - b.def) / N ) -or in javascript- a.atk * Math.pow( 2 , (a.atk - b.def) / N )

This makes damage tend to be close to a.atk when a.atk and b.def are close. Previously I had N = a.atk, but I may switch to N = 100 or something.

#### ATT_Turan

##### Forewarner of the Black Wind
And I don't see why the damage formula should be so obfuscated like these. If the player doesn't understand how much damage they will do, then that's the developer taking that part of the strategy away from them.
It's not usually supposed to be a part of the strategy in games of this genre. Skill and gear progression in JRPGs is typically linear - Fire 2 is better than Fire 1; the longsword is better than the wooden practice sword; so they're better and you use them as soon as you can.

I get away from this within my skills by making damage formulae that scale with my stats, so a given spell is viable at all levels. That means the strategy is in choosing between different damage-per-mana efficiency (which is easily described without showing the formula), or in whether you need a particular element or effect.

What you're describing is really only applicable when you're choosing between equivalent but different things, which is atypical. And when I've seen that, the difference is usually in extra effects, not in the damage formula (fire spells have a chance to inflict a burn DoT, where as ice will slow the enemy down; swords get a bonus from Dexterity where hammers benefit from Strength).

I've only ever seen damage formulae in-game in some of the D&D games. That doesn't diminish my ability to understand how much damage I'll do, nor to formulate strategy.

For the record, per the OP, my default formula is:
atk * Math.log10(atk) * Math.log(1 + Math.pow((atk / def), 2)) / Math.log(2)

#### Silenity

##### Veteran
Lately I've been testing this one:

WPN * (A.ATK / B.DEF + 1) / 2 + MODS

Debating on keeping the /2 in there. I give each weapon a damage value (WPN).
Early level example of a weapon with 10 damage, a player with 15 attack vs an enemy with 8 defence.

10 * (15 / 8 + 1) / 2

14 damage total

If I removed the /2 it'd be 28 damage. I kinda like the lower numbers though. Modifiers (MODS) is a flat bonus damage addition that can be based on needs.

Last edited:

### Latest Profile Posts

Worked on some face-sets. Need to finish up the lot and cut some out of the game. She's looking pretty cute.
Even though I'm not going for the first time in...ten years or something...ordered my Gen Con dice!
Will be focusing on map making today and adding locked chests
It's hard to stay consistent for at least a week
new enemies for the game I'm working on...