oasis-b

Wiki / Database

Damage formulas

How the damage of a skill or item is calculated and how to write your own formula.

Every skill and item with damage has a formula in the Damage section. It is JavaScript and is calculated for each target.

aThe user of the skill.
bThe target.
v[n]The value of variable number n.
a.atk, b.def, a.mat, b.mdf, a.agi, a.lukAttack, defense, magic attack, magic defense, agility, luck.
a.hp, a.mhp, a.mp, a.levelCurrent and maximum HP, MP and, for actors, the level.

Examples

a.atk * 4 - b.def * 2          the default Attack skill
a.mat * 2 - b.mdf               a simple magic spell
200 + a.mat                     healing (type HP Recover)
b.mhp * 0.25                    a quarter of the target's max HP
Math.max(a.atk - b.def, 1) * 3  never below 3 damage

What happens after the formula

The result is changed by the element rate of the target, by Variance (a random spread, 20% by default), by a critical hit (three times the damage by default) and by guarding. Negative results count as 0 for damage types.

Tip: keep formulas short. A formula with a typo does not show an error; the skill simply does 0 damage. Test new formulas in a test battle.