Damage calculation

Notation
The and  notation is used to mean the Floor and ceiling functions in these formulae. For example, and.

The $$\operatorname{trunc}$$ notation is used to mean truncation in these formulae. This means that $$\operatorname{trunc}(-1.6) = -1$$, it is effectively dropping all numbers after the decimal point. To make the formulae more readable, this notation will only be used when floor is not sufficient to provide a visual shorthand for truncation.

The positive part of Positive and negative parts notation $$x^+$$ is used to set a number to 0 if it is negative.

Damage is calculated in these steps:
 * 1) Base Damage
 * 2) Adjusted Damage
 * 3) Final Damage

Simple hit
The damage calculation for a simple hit is:


 * Note: Damage is never negative.

Weapon-triangle advantage
Here the formula adds in weapon-triangle advantage ("Atk+20%"):

Important is that although weapon-triangle advantage is "Atk+20%" and Triangle Adept 3 will "boost Atk by 20%", these modifiers all affect the same component and do not act independently, thus, $$Atk + \operatorname{trunc}(Atk \times 0.2) + \operatorname{trunc}(Atk \times 0.2)$$ is incorrect while $$Atk + \operatorname{trunc}(Atk \times 0.4)$$ is correct.

To illustrate this point, take the example of a red unit with 54 Atk attacking a green unit with a Mitigation of 34.

Note: Affinity does not stack. Triangle Adept does not stack with the gemstone weapons. Only the highest value is applied.

Effectiveness
The formula including the weapon-triangle and factoring effective damage in is
 * $$(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor + \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) - \mathit{Mit})^+$$

Note that effectiveness is first instead of weapon-triangle advantage. To illustrate this, take a look at the following example. Note that the formula cannot be simplified to $$\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor + \lfloor \mathit{Atk} \times \mathit{Eff} \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})\rfloor - \mathit{Mit}$$. This can be proven with the next example:

Boosted Damage
Some Specials can also add boosted damage. When a Special is capable of doing so, its description will say that it boosts damage. This boosted damage is also referred to as "special damage bonus" (奥義ダメージ). The formula looks like this:
 * $$(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor + \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) + BoostedDamage - \mathit{Mit})^+$$

Currently only Specials use boosted damage in the game. Other extra damage skills use dealt damage instead, described later. Note that BoostedDamage is added within the first set of parentheses that have positive part applied to them. This means, unlike the calculations that come afterwards, boosted damage from specials will need to "make up" negative damage.

Calculating Boosted Damage
This section describes how to calculate the boosted damage for various Specials. Some specials, like, tell the amount directly in the skill description.

Stat-based Specials
$$BoostedDamage = \lfloor \mathit{Stat} \times 0.5\rfloor$$

Luna

 * $$BoostedDamage = \lfloor \mathit{Mit} \times 0.5\rfloor$$

The formula above applies for similar skills such as Moonbow or Aether, simply replace 0.5 with the appropriate value.

Note that despite Luna stating that it treats foe’s Def/Res "as if reduced by 50% during combat", it does not actually do this, because the activation of Luna also does not change whether or not the condition "If foe's Def ≥ foe's Res+5" for or  is true or not. In addition, the activation of Luna on a foe does not change the amount added to damage dealt for.

It is currently mathematically accurate to say adding 50% of foe's Def/Res to damage is identical to reducing foe's Def/Res by 50%, but only for the purpose of Base Damage calculation:
 * 1) $$\mathit{Atk} + \mathit{BoostedDamage} - \mathit{Mit} = \mathit{Atk} - (\mathit{Mit} - \lfloor \mathit{Mit} \times 0.5\rfloor)$$
 * 2) $$\mathit{Atk} + \lfloor \mathit{Mit} \times 0.5\rfloor - \mathit{Mit} = \mathit{Atk} - (\mathit{Mit} - \lfloor \mathit{Mit} \times 0.5\rfloor)$$
 * 3) $$\mathit{Atk} + \lfloor \mathit{Mit} \times 0.5\rfloor - \mathit{Mit} = \mathit{Atk} - \mathit{Mit} + \lfloor \mathit{Mit} \times 0.5\rfloor$$
 * 4) $$\mathit{Atk} + \lfloor \mathit{Mit} \times 0.5\rfloor - \mathit{Mit} = \mathit{Atk} + \lfloor \mathit{Mit} \times 0.5\rfloor - \mathit{Mit}$$

Astra
Astra does not use boosted damage.

Final Damage calculation
<!-- old text:

Flat damage (weapon-based)
Flat damage is additional damage from skills such as, or.
 * $$((\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) - \mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+ + WpnFlatAdd)^+$$

Flat Damage (Special-based)
Flat added or reduced damage, such as that from the, is factored in after their potential respective multipliers like Glimmer, or Pavise. That means the added damage is not affected by advantage, effectiveness, or other offensive specials like Night Sky, but is affected by defensive skills like Buckler, while flat reduced damage like that from Shield Pulse applies after the damage has already been reduced by Buckler, or similar.
 * $$\mathit{Damage1} = (\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) + \lfloor \mathit{SpcStat} \times \mathit{SpcMod}\rfloor - (\mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{MoonMod}\rfloor) - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+$$
 * $$\mathit{Damage2} = \mathit{Damage1} + trunc(\mathit{Damage1} \times \mathit{StarMod}) + \mathit{SpcFlatAdd} + \mathit{WpnFlatAdd}$$
 * $$\mathit{Damage3} = (\mathit{Damage2} - trunc(\mathit{Damage2} \times \mathit{ShieldMod}) - \mathit{SpcFlatSubtract})^+$$

Class Modifier
Staves have a special property which makes them deal half the damage that other weapons would do. The ClassMod variable will be used to represent this. The skills and  can be used to negate this. This can be expressed by:
 * $$(\operatorname{trunc}\big((\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) - \mathit{Mit}) \times \mathit{ClassMod}\big))^+$$

Note: ClassMod will be omitted from the examples on this page, as it only currently affects attacking healers.

Offensive and defensive multipliers
Let's consider offensive special skills which grant a percentage increase to the damage dealt (e.g. Night Sky or Glimmer), and defensive special skills, which reduce the damage taken by a certain percent (e.g. Pavise or Urvan):
 * $$\mathit{Damage1} = (\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) + \lfloor \mathit{SpcStat} \times \mathit{SpcMod}\rfloor - (\mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{MoonMod}\rfloor) - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+$$
 * $$\mathit{Damage2} = \mathit{Damage1} + trunc(\mathit{Damage1} \times \mathit{StarMod}) + \mathit{WpnFlatAdd}$$
 * $$\mathit{Damage3} = (\mathit{Damage2} - trunc(\mathit{Damage2} \times \mathit{ShieldMod}))^+$$

Skill interactions
This section contains notes clarifying how certain skills factor into the damage formula.


 * Skills like increase the raw Atk value, and the added attack power is therefore also modified by Eff and Aff.
 * This also applies to the damage added from buffs on a (or similar) wielder. The in-combat Atk value used for calculations includes all added "damage" from the -blade tome.
 * Special skills that are based off a certain stat, such as Bonfire are calculated using the in-combat stat value, which makes them benefit from in-combat effects such as Spur, or in the case of Dragon Fang and similar skills, the increased Atk value from sources like Gronnblade
 * Special skills that deal damage before combat, like Rising Thunder or Growing Thunder, do not take into consideration any in-combat boosts like Spur, or even any weapon-triangle advantages since the formula for damage for each one is specified in its description, they do however take into account any buffs or debuffs, from sources such as Rally or Threaten.
 * Special skills that modify the damage by a flat value, like Wo Dao+'s +10, or Shield Pulse 3's -5, are applied after all other respective multipliers have been considered. This means that Glimmer and similar skills cannot increase the 10 extra damage Wo Dao brings, while Pavise and other damage reduction multipliers do help mitigate the added damage. Shield Pulse's reduced damage is calculated after skills like Pavise.

Summarized formulas
$$((\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) - \mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+ + WpnFlatAdd)^+$$

With no consideration for Special skills, this is the complete damage formula, per hit, as we understand it.


 * $$\mathit{Damage1} = (\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) + \lfloor \mathit{SpcStat} \times \mathit{SpcMod}\rfloor - (\mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{MoonMod}\rfloor) - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+$$
 * $$\mathit{Damage2} = \mathit{Damage1} + trunc(\mathit{Damage1} \times \mathit{StarMod}) + \mathit{SpcFlatAdd} + \mathit{WpnFlatAdd}$$
 * $$\mathit{Damage3} = (\mathit{Damage2} - trunc(\mathit{Damage2} \times \mathit{ShieldMod}) - \mathit{SpcFlatSubtract})^+$$

These are the complete damage formulas, per hit, including special skills, as we understand it. The use of three different variables Damage1, Damage2, Damage3 is intended to simplify the formula. Without using them, the formula would be:
 * $$((\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) + \lfloor \mathit{SpcStat} \times \mathit{SpcMod}\rfloor - (\mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{MoonMod}\rfloor) - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+ + trunc((\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) + \lfloor \mathit{SpcStat} \times \mathit{SpcMod}\rfloor - (\mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{MoonMod}\rfloor) - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+ \times \mathit{StarMod}) + \mathit{SpcFlatAdd} + \mathit{WpnFlatAdd} - trunc(((\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) + \lfloor \mathit{SpcStat} \times \mathit{SpcMod}\rfloor - (\mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{MoonMod}\rfloor) - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+ + trunc((\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \pm \operatorname{trunc}(\lfloor \mathit{Atk} \times \mathit{Eff}\rfloor \times (\mathit{Adv} \times \frac{\mathit{Aff} + 20}{20})) + \lfloor \mathit{SpcStat} \times \mathit{SpcMod}\rfloor - (\mathit{Mit} - \lfloor \mathit{Mit} \times \mathit{MoonMod}\rfloor) - \lfloor \mathit{Mit} \times \mathit{DefTileMod}\rfloor)^+ \times \mathit{StarMod}) + \mathit{SpcFlatAdd} + \mathit{WpnFlatAdd}) \times \mathit{ShieldMod}) - \mathit{SpcFlatSubtract})^+$$

-->