Class DamageMitigationCalculator
- 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
-
objectDamageMitigationCalculator
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
amountlongThe damage amount to reduce.
reducedDefensiveStatValuedoubleThe defensive stat value after defense penetration was applied.
damageMitigationFnDamageMitigationFnSOThe damage mitigation function. May be
null, in which caseamountis returned unchanged.roundingModeRoundingModeRounding 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
piercingStatValuelongThe attacker's piercing stat value.
defensiveStatValuelongThe defender's defensive stat value.
defensePenetrationFnDefensePenetrationFnSOThe penetration function. May be
null, in which casedefensiveStatValueis returned unchanged.defensiveStatStatSOThe defensive ElectricDrill.AstraRpgFramework.Stats.StatSO definition. May be
nullwhendefensePenetrationFnisnull.applyClampboolWhether 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
amountlongThe base damage amount.
piercingStatValuelongThe attacker's piercing stat value.
defensePenetrationFnDefensePenetrationFnSOFunction used to reduce the defensive stat with the piercing value. May be
null, in which case the defensive stat is passed through unchanged.defensiveStatValuelongThe defender's defensive stat value.
defensiveStatStatSOThe defensive ElectricDrill.AstraRpgFramework.Stats.StatSO definition. May be
nullwhendefensePenetrationFnisnull.damageMitigationFnDamageMitigationFnSOFunction used to reduce the damage based on the (possibly reduced) defensive stat. May be
null, in which caseamountis returned unchanged.roundingSettingsHealthRoundingSettingsRounding policy used for fractional penetration and mitigation values.
applyClampboolWhether to apply stat clamping in defense penetration. Defaults to
truefor gameplay; passfalsefor 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
amountlongThe base damage amount.
piercingStatValuelongThe attacker's piercing stat value.
defensiveStatValuelongThe defender's defensive stat value.
damageTypeDamageTypeSOThe damage type asset that supplies the reduction functions and defensive stat.
roundingSettingsHealthRoundingSettingsRounding policy used for fractional penetration and mitigation values.
applyClampboolWhether to apply stat clamping in defense penetration. Defaults to
truefor gameplay.
Returns
- long
The damage amount after defense and damage reduction have been applied.