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.

28+ modifiers BattleManager DamageInfo v1.1.79

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.

Implementation

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 structs

BasicShipStatus

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.

FieldTypeNotes
MaxHPNumberUnitTotal hit points after all bonuses
ATKNumberUnitTotal attack power after all bonuses
DEFNumberUnitPhysical defense rating
MDEFNumberUnitMagical defense rating
CritChancefloatCritical hit probability (0.0 - 1.0)
CritDamagefloatCritical damage multiplier (e.g., 1.5 = 150%)
AttackSpeedfloatAttacks per second (final value)

BasicSkillData

The resolved skill parameters for the current attack action.

FieldTypeNotes
SkillPowerfloatfPower + (level × fPowerPerLevel)
SkillCritChancefloatSkill-specific crit override (0 = use ship default)
SkillCritDamagefloatSkill-specific crit multiplier override
DamageTypeAttackDamageTypePhysical or Magical
TargetCountintNumber of targets hit

DamageInfo

The output structure produced by the damage calculation pipeline. Passed to the target for HP reduction.

FieldTypeNotes
FinalDamageNumberUnitThe actual damage dealt after all modifiers
IsCriticalboolWhether this hit was a critical strike
DamageTypeAttackDamageTypePhysical or Magical (determines DEF vs MDEF)
SourceShipIDintThe attacking ship
SkillIDintThe 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.

#CategorySourceType
1Weapon ATK%Equipped weaponMultiplicative
2Armor DEF%Equipped armorMultiplicative
3Accessory BonusEquipped accessoryMultiplicative
4Admiral Equip EffectsEquipped admiral (up to 35 slots)Additive within, multiplicative across
5Admiral Owned EffectsAll owned admiralsAdditive
6Ship Owned EffectsAll owned shipsAdditive
7Memory Card EquipEquipped memory cardsAdditive within category
8Memory Card HoldAll owned memory cardsAdditive
9Gemstone EffectsSocketed gemstonesAdditive
10Gemstone Set BonusGemstone collection completionMultiplicative
11Building BonusesBase buildingsAdditive
12Artifact PassiveEquipped artifactsVaries
13Skill Damage%Skill-specific damage bonusMultiplicative
14Elemental BonusDamage type advantageMultiplicative
15Target Type BonusBonus vs. specific eMainTypeMultiplicative
16Boss Damage%Extra damage to boss targetsMultiplicative
17Normal Damage%Extra damage to non-boss targetsMultiplicative
18Physical Damage%Bonus to physical attacksMultiplicative
19Magical Damage%Bonus to magical attacksMultiplicative
20Active Skill Damage%Bonus to active (non-basic) skillsMultiplicative
21Basic Attack Damage%Bonus to basic attacks onlyMultiplicative
22Crit Damage% BonusAdditive to crit multiplierAdditive to CritDamage
23All Damage%Universal damage multiplierMultiplicative
24Damage Reduction (target)Target's damage reduction statMultiplicative (inverse)
25Buff: ATK UpTemporary combat buffMultiplicative
26Debuff: DEF DownTarget debuff reducing defenseMultiplicative
27Mode-Specific MultiplierChronos bonus, Raid multiplier, etc.Multiplicative
28Awakening BonusShip/equipment awakening tier bonusMultiplicative
Ordering Matters

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.

Open Questions
  • 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?