Damage Calculation
The complete damage formula reverse-engineered from the IL2CPP runtime. Covers NumberUnit math, BasicShipStatus, BasicSkillData, DamageInfo structs, and the full 28+ modifier category chain.
NumberUnit Math
All large numbers in Darkstar use the NumberUnit encoding to handle values that exceed standard floating-point precision. A NumberUnit stores two components:
value = quotient * 10^exponent
For example, a ship with fPowerQuotient = 3.45 and iPowerExponent = 12
has a base ATK of 3.45 × 1012 (3.45 trillion).
All arithmetic in the damage pipeline operates on NumberUnit values.
NumberUnit arithmetic normalizes after each operation: the quotient is kept in [1.0, 10.0) and the exponent is adjusted accordingly. This prevents precision loss during the multi-step damage calculation.
Core Structs
3 structsBasicShipStatus
The resolved runtime stats for a ship after all modifiers are applied. Built during battle initialization from the ship's base stats plus all equipment, admiral, memory card, gemstone, and building bonuses.
| Field | Type | Notes |
|---|---|---|
MaxHP | NumberUnit | Total hit points after all bonuses |
ATK | NumberUnit | Total attack power after all bonuses |
DEF | NumberUnit | Physical defense rating |
MDEF | NumberUnit | Magical defense rating |
CritChance | float | Critical hit probability (0.0 - 1.0) |
CritDamage | float | Critical damage multiplier (e.g., 1.5 = 150%) |
AttackSpeed | float | Attacks per second (final value) |
BasicSkillData
The resolved skill parameters for the current attack action.
| Field | Type | Notes |
|---|---|---|
SkillPower | float | fPower + (level × fPowerPerLevel) |
SkillCritChance | float | Skill-specific crit override (0 = use ship default) |
SkillCritDamage | float | Skill-specific crit multiplier override |
DamageType | AttackDamageType | Physical or Magical |
TargetCount | int | Number of targets hit |
DamageInfo
The output structure produced by the damage calculation pipeline. Passed to the target for HP reduction.
| Field | Type | Notes |
|---|---|---|
FinalDamage | NumberUnit | The actual damage dealt after all modifiers |
IsCritical | bool | Whether this hit was a critical strike |
DamageType | AttackDamageType | Physical or Magical (determines DEF vs MDEF) |
SourceShipID | int | The attacking ship |
SkillID | int | The skill that produced this damage |
Damage Calculation Chain
The damage formula is a multi-step pipeline executed by BattleManager. Each step
applies a category of modifiers. The chain proceeds in this order:
Step 1: Base Damage
BaseDamage = ATK * SkillPower
The attacker's total ATK (from BasicShipStatus) is multiplied by the skill's power coefficient. Both are NumberUnit values.
Step 2: Defense Reduction
// Physical damage: PostDefense = BaseDamage * (1 - DEF / (DEF + ScalingConstant)) // Magical damage: PostDefense = BaseDamage * (1 - MDEF / (MDEF + ScalingConstant))
Defense reduces damage using a diminishing-returns formula. The ScalingConstant
determines how quickly defense effectiveness falls off.
Step 3: Critical Hit
if (random() < CritChance):
PostCrit = PostDefense * CritDamage
else:
PostCrit = PostDefense
Crit chance is checked per hit. If the skill has a non-zero SkillCritChance,
it overrides the ship's base crit rate. Same for SkillCritDamage.
Step 4: Modifier Categories (28+)
After the base/defense/crit calculation, the engine applies 28+ categories of multiplicative and additive modifiers. These come from equipment, admirals, memory cards, gemstones, buildings, buffs, debuffs, and mode-specific effects.
| # | Category | Source | Type |
|---|---|---|---|
| 1 | Weapon ATK% | Equipped weapon | Multiplicative |
| 2 | Armor DEF% | Equipped armor | Multiplicative |
| 3 | Accessory Bonus | Equipped accessory | Multiplicative |
| 4 | Admiral Equip Effects | Equipped admiral (up to 35 slots) | Additive within, multiplicative across |
| 5 | Admiral Owned Effects | All owned admirals | Additive |
| 6 | Ship Owned Effects | All owned ships | Additive |
| 7 | Memory Card Equip | Equipped memory cards | Additive within category |
| 8 | Memory Card Hold | All owned memory cards | Additive |
| 9 | Gemstone Effects | Socketed gemstones | Additive |
| 10 | Gemstone Set Bonus | Gemstone collection completion | Multiplicative |
| 11 | Building Bonuses | Base buildings | Additive |
| 12 | Artifact Passive | Equipped artifacts | Varies |
| 13 | Skill Damage% | Skill-specific damage bonus | Multiplicative |
| 14 | Elemental Bonus | Damage type advantage | Multiplicative |
| 15 | Target Type Bonus | Bonus vs. specific eMainType | Multiplicative |
| 16 | Boss Damage% | Extra damage to boss targets | Multiplicative |
| 17 | Normal Damage% | Extra damage to non-boss targets | Multiplicative |
| 18 | Physical Damage% | Bonus to physical attacks | Multiplicative |
| 19 | Magical Damage% | Bonus to magical attacks | Multiplicative |
| 20 | Active Skill Damage% | Bonus to active (non-basic) skills | Multiplicative |
| 21 | Basic Attack Damage% | Bonus to basic attacks only | Multiplicative |
| 22 | Crit Damage% Bonus | Additive to crit multiplier | Additive to CritDamage |
| 23 | All Damage% | Universal damage multiplier | Multiplicative |
| 24 | Damage Reduction (target) | Target's damage reduction stat | Multiplicative (inverse) |
| 25 | Buff: ATK Up | Temporary combat buff | Multiplicative |
| 26 | Debuff: DEF Down | Target debuff reducing defense | Multiplicative |
| 27 | Mode-Specific Multiplier | Chronos bonus, Raid multiplier, etc. | Multiplicative |
| 28 | Awakening Bonus | Ship/equipment awakening tier bonus | Multiplicative |
The exact order of modifier application affects the final result due to multiplicative vs. additive stacking. Categories that are additive within themselves but multiplicative with other categories must be summed first, then multiplied. The engine processes them in the order shown above.
Simplified Formula
FinalDamage =
ATK
* SkillPower
* DefenseReduction(DEF_or_MDEF)
* CritMultiplier
* ProductOf(All Multiplicative Modifiers)
* (1 + SumOf(All Additive Modifiers))
In practice, the formula is more nuanced because some modifier categories stack additively
within their group before being multiplied with other groups. The exact behavior for each
PropertyType is defined in BattleManager.CalculateDamage().
DPS Estimation
EffectiveDPS =
FinalDamage
* AttackSpeed
* (1 + CritChance * (CritDamage - 1))
* TargetCount
This gives the expected damage per second accounting for crit probability.
For AoE skills with iMaxTargetCount = -1, multiply by the average
number of targets present.
- What is the exact value of the defense
ScalingConstant? Is it level-dependent? - Are there damage floors or ceilings (minimum 1 damage, max damage caps)?
- How do damage-over-time (DoT) effects interact with the modifier chain?
- Is there a separate formula for healing, or does it reuse the damage pipeline with inverted sign?
- How does the "Damage Reduction" stat on targets interact with the defense formula — before or after?
- Are there any hidden rounding steps in NumberUnit arithmetic that affect edge cases?