Table of Contents

Class DamageMitigationCalculator

Namespace
ElectricDrill.AstraHealth.Damage.CalculationPipeline
Assembly
com.electricdrill.astra-health.Runtime.dll

Pure, stateless helpers that compute damage after defensive and damage reduction functions are applied. Callers are responsible for validating their DamageTypeSO configuration (for example, the consistency warnings in ApplyDefenseStep).

public static class DamageMitigationCalculator
Inheritance
object
DamageMitigationCalculator

Methods

ApplyDamageMitigation(long, double, DamageMitigationFnSO, RoundingMode)

Applies damageMitigationFn and rounds fractional results with roundingMode.

public static long ApplyDamageMitigation(long amount, double reducedDefensiveStatValue, DamageMitigationFnSO damageMitigationFn, RoundingMode roundingMode)

Parameters

amount long

The damage amount to reduce.

reducedDefensiveStatValue double

The defensive stat value after defense penetration was applied.

damageMitigationFn DamageMitigationFnSO

The damage mitigation function. May be null, in which case amount is returned unchanged.

roundingMode RoundingMode

Rounding mode applied by mitigation functions with fractional output.

Returns

long

The reduced damage amount.

CalculatePiercedDefense(long, long, DefensePenetrationFnSO, StatSO, bool)

Calculates the effective defensive stat value after the attacker's piercing has been applied through defensePenetrationFn.

public static double CalculatePiercedDefense(long piercingStatValue, long defensiveStatValue, DefensePenetrationFnSO defensePenetrationFn, StatSO defensiveStat, bool applyClamp = true)

Parameters

piercingStatValue long

The attacker's piercing stat value.

defensiveStatValue long

The defender's defensive stat value.

defensePenetrationFn DefensePenetrationFnSO

The penetration function. May be null, in which case defensiveStatValue is returned unchanged.

defensiveStat StatSO

The defensive ElectricDrill.AstraRpgFramework.Stats.StatSO definition. May be null when defensePenetrationFn is null.

applyClamp bool

Whether to apply stat clamping. Defaults to true.

Returns

double

The reduced defensive stat value.

CalculateReducedDmg(long, long, DefensePenetrationFnSO, long, StatSO, DamageMitigationFnSO, HealthRoundingSettings, bool)

Calculates the reduced damage amount using explicit rounding settings for defense penetration and damage mitigation.

public static long CalculateReducedDmg(long amount, long piercingStatValue, DefensePenetrationFnSO defensePenetrationFn, long defensiveStatValue, StatSO defensiveStat, DamageMitigationFnSO damageMitigationFn, HealthRoundingSettings roundingSettings, bool applyClamp = true)

Parameters

amount long

The base damage amount.

piercingStatValue long

The attacker's piercing stat value.

defensePenetrationFn DefensePenetrationFnSO

Function used to reduce the defensive stat with the piercing value. May be null, in which case the defensive stat is passed through unchanged.

defensiveStatValue long

The defender's defensive stat value.

defensiveStat StatSO

The defensive ElectricDrill.AstraRpgFramework.Stats.StatSO definition. May be null when defensePenetrationFn is null.

damageMitigationFn DamageMitigationFnSO

Function used to reduce the damage based on the (possibly reduced) defensive stat. May be null, in which case amount is returned unchanged.

roundingSettings HealthRoundingSettings

Rounding policy used for fractional penetration and mitigation values.

applyClamp bool

Whether to apply stat clamping in defense penetration. Defaults to true for gameplay; pass false for analysis tools that want to visualize the unclamped formula.

Returns

long

The damage amount after defense and damage reduction have been applied.

CalculateReducedDmg(long, long, long, DamageTypeSO, HealthRoundingSettings, bool)

Convenience overload that reads reduction functions from damageType and uses explicit rounding settings.

public static long CalculateReducedDmg(long amount, long piercingStatValue, long defensiveStatValue, DamageTypeSO damageType, HealthRoundingSettings roundingSettings, bool applyClamp = true)

Parameters

amount long

The base damage amount.

piercingStatValue long

The attacker's piercing stat value.

defensiveStatValue long

The defender's defensive stat value.

damageType DamageTypeSO

The damage type asset that supplies the reduction functions and defensive stat.

roundingSettings HealthRoundingSettings

Rounding policy used for fractional penetration and mitigation values.

applyClamp bool

Whether to apply stat clamping in defense penetration. Defaults to true for gameplay.

Returns

long

The damage amount after defense and damage reduction have been applied.