# Damage Formula

Explanation on how damage is calculated in Tower of Fantasy (WIP).

## Datamined Damage Formula

This is the formula found in the game files by Afrodiy#9769 and Sova#0618, but it isn't fully understood.
"GMExecutionInfo": "Skill ID: {0}, Current Stat Conversion: {1}, Target's Current HP: {2}, Target's HP Left: {16}, Attacker: {18}, Target: {19}
Formula: Max (Base ATK {7} × Skill Ratio {3} + Fixed Skill Value {4}) ×0.1, Base ATK {7} × revised Skill Ratio {5} + revised Fixed Skill Value {6}), Max Sum ({8}) × Crit Damage Ratio {11} × True DEF Conversion {9} × Module Ratio {10} × (1 + Damage Fluctuation {12}) × Headshot Ratio {14} × Final Module Ratio {15} = {17}",

This still stays questionable as this is a topic yet to be properly understood.
​​
$Damage=BaseDamage×Crit×EnemyDefMult× DamageBonus$
$×(1+DamageFluctuation)×HeadshotMult$

## Base Damage

$BaseDamage = ATK × SkillPercent + FlatSkill$
$ATK = FlatATK × (1 + ATKBonus)$
Formula Variable
Explanation
SkillPercent
The scaling percentage-based number of a specific attack.
FlatSkill
The scaling non-percentage-based number of a specific attack.
FlatATK
Sum of all non-percentage-based attack from character, suppressor, weapons, equipment, matrices.
ATKBonus
Sum off all percentage-based attack from buffs and other sources.
DamageBonus
All percentage-based damage buffs multiplied to each other.

## Critical Hits

$Crit =\begin{cases}1 + CritDamage\\1\end{cases}$
first option if Critical Hit, second otherwise
$AverageCrit = 1 + TotalCritRate × CritDamage$

### ​Crit Rate

$TotalCritRate = \frac{FlatCrit}{CritLevelMultiplier} + CritRate$
$CritLevelMultiplier = a×Level^{2}+b×Level+c$
Level Range
a
b
c
1 - 9
0
150
0
10 - 40
-4
408
-2078
41 - 100
-0.163
285
-3215
Formula Variable
Explanation
TotalCritRate
The total Crit Rate from all possible sources.
FlatCrit
Sum of non-percentage-based Crit from suppressor, weapons, equipment, matrices.
CritRate
Percentage-based Crit Rate already present before Flat Crit conversion.

## Enemy Defense Multiplier

Complete formula is currently unknown.
$DefLevelMultiplier = a×Level^{2}+b×Level+c$
Text
a
b
c
1 - 9
0
75
0
10 - 40
-2
204
-1039
41 - 100
-0.0815
142.5
-1607.5

## Damage Fluctuation

Random multiplier which ranges between -0.05 and 0.05. This changes the damage slightly resulting in seeing minor differences in damage numbers despite having the same stats.