Damage Formulas 101
A comprehensive guide for RPG Maker MV & MZ
Damage formulas in RPG Maker are plain JavaScript expressions.
They follow normal math order of operations (PEMDAS):
- Parentheses
- Exponents
- Multiplication & Division (left to right)
- Addition & Subtraction (left to right)
Because of this, a.atk * 4 - b.def * 2 is not the same as (a.atk * 4 - b.def) * 2.
Always use parentheses when you need to control the order.
The Two Most Important Variables
a = the user (attacker)
b = the target (defender)
You can access almost any parameter from them:
a.atk, a.def, a.mat, a.mdf, a.agi, a.luk
a.hp, a.mp, a.tp, a.mhp, a.mmp
a.level, a.hpRate(), a.mpRate(), a.tpRate()
Same options exist for b.
Basic Operators
-
Addition → a.atk + 50
-
Subtraction → a.atk - b.def
-
Multiplication → a.atk * 4
/ Division → a.atk / 2
% Modulo → a.hp % 10
** Exponent → a.atk ** 2
Useful Math Functions
Math.max(x, y) // higher value
Math.min(x, y) // lower value
Math.floor(x) // round down
Math.ceil(x) // round up
Math.round(x) // normal rounding
Math.random() // 0 to 1
Math.randomInt(n) // 0 to n-1
Essential Formula Building Blocks
-
Classic Physical
a.atk * 4 - b.def * 2 -
Classic Magical
a.mat * 4 - b.mdf * 2 -
Percentage of Max HP
b.mhp * 0.25 -
Current / Missing HP
b.hp * 0.3
(b.mhp - b.hp) * 0.5 -
Level Scaling
a.atk * 2 + a.level * 5 -
Minimum Damage Guarantee
Math.max(a.atk * 4 - b.def * 2, 1) -
Using Variables
a.atk * 4 - b.def * 2 + v[10] -
Conditional (ternary)
a.hpRate() < 0.3 ? a.atk * 6 : a.atk * 4 -
Element Rate
(a.atk * 4 - b.def * 2) * b.elementRate(2)
Practical Full Examples
Balanced Physical Skill
Math.max(a.atk * 4 - b.def * 2, a.atk)
Magic with Level Scaling
a.mat * 3 + a.level * 8 - b.mdf * 1.5
True Damage (ignores defense)
a.atk * 3
Execute (stronger under 25% HP)
b.hpRate() < 0.25 ? a.atk * 8 : a.atk * 3
Important Notes & Common Pitfalls
- Variance is applied after the formula.
- Critical hits multiply the final result (default ×3) after formula + variance.
- Guard halves damage after everything else.
- Division by zero will crash the game. Always protect it:
a.atk / Math.max(b.def, 1) - Very large numbers can cause issues. Prefer keeping values reasonable or using Math.floor().
Quick Reference Cheat Sheet
a.atk * 4 - b.def * 2 // Basic physical
a.mat * 4 - b.mdf * 2 // Basic magical
Math.max(a.atk * 4 - b.def * 2, 1) // Minimum 1 damage
b.mhp * 0.2 // 20% max HP
a.level * 10 + a.atk * 2 // Level scaling
a.hpRate() < 0.5 ? a.atk * 5 : a.atk * 3 // Conditional
Feel free to ask questions or share your own formulas below.
Happy formula crafting!