パッケージ mechanics.formula

クラス DamageCalculator

java.lang.Object
mechanics.formula.DamageCalculator

public class DamageCalculator extends Object
Computes outgoing damage for a single attack action.

Two independent code paths are implemented inside calculateDamage(model.entity.Character, model.entity.Enemy, simulation.action.AttackAction, java.util.List<mechanics.buff.Buff>, double, double, simulation.CombatSimulator):

  1. Lunar path – entered when action.isLunarConsidered() is true. Uses the custom Lunar formula: 3 * (Stat * MV) * (1 + BaseBonus + UniqueBonus) * (1 + ReactionBonus + GearBonus) * Crit * Res * ColumbinaMultiplier
  2. Standard path – follows the official Genshin Impact formula: (Stat * MV + FlatDmg) * (1 + DmgBonus%) * Crit * ReactionMulti * Def * Res
  • コンストラクタの詳細

    • DamageCalculator

      public DamageCalculator()
  • メソッドの詳細

    • calculateDamage

      public static double calculateDamage(Character attacker, Enemy target, AttackAction action, List<Buff> activeBuffs, double currentTime, double reactionMultiplier, CombatSimulator sim)
      Calculates the final damage dealt by action. Lunar path (action.isLunarConsidered() == true)
      1. Resolve stats – snapshot or live, then apply active buffs.
      2. Base section: 3 * (statVal * MV) * (1 + LUNAR_BASE_BONUS) * (1 + LUNAR_UNIQUE_BONUS)
      3. Reaction multiplier: 1 + (6*EM)/(EM+2000) + GearBonuses where gear covers LUNAR_CHARGED_DMG_BONUS, LUNAR_REACTION_DMG_BONUS_ALL, and LUNAR_MOONSIGN_BONUS.
      4. Crit: 1 + min(CR,1) * CD
      5. Res: via calculateResMulti(double, double).
      6. Columbina multiplier: 1 + LUNAR_MULTIPLIER – applied last as an independent final multiplier, scaling with (EM / 2000) * 1.5.
      Standard path
      1. Resolve stats – snapshot or live, then apply active buffs.
      2. Base damage: (scalingStat * MV) + FLAT_DMG_BONUS
      3. DMG Bonus%: sum of DMG_BONUS_ALL, element-specific bonus, action bonus stat, and any extra bonuses attached to the action.
      4. Crit: 1 + min(CR,1) * CD; burst/skill crit-rate overrides are added before clamping.
      5. Reaction multiplier passed in from CombatSimulator.
      6. Defense: via calculateDefMulti(int, int, double) at attacker level 90.
      7. Resistance: via calculateResMulti(double, double) after accumulating element-specific shred.

      After computing damage on either path, weapon and artifact onDamage hooks are fired so stacking/proc mechanics can update their internal state.

      パラメータ:
      attacker - the attacking character
      target - the enemy being hit
      action - the attack action containing MV, element, scaling stat, etc.
      activeBuffs - team and self buffs currently active (may be null)
      currentTime - simulation time in seconds at the moment of the hit
      reactionMultiplier - amplifying reaction multiplier pre-computed by the simulator (1.0 if no amplifying reaction)
      sim - the running CombatSimulator instance
      戻り値:
      final damage value after all multipliers
    • calculateResMulti

      public static double calculateResMulti(double baseRes, double resShred)
      Computes the resistance damage multiplier after applying resistance shred.

      The three-region piecewise function mirrors the official game:

      • finalRes < 0: 1 - finalRes / 2
      • 0 <= finalRes < 0.75: 1 - finalRes
      • finalRes >= 0.75: 1 / (1 + 4 * finalRes)
      パラメータ:
      baseRes - enemy base resistance for the relevant element (e.g. 0.10 for 10%)
      resShred - total resistance shred accumulated from all sources
      戻り値:
      resistance multiplier to apply to outgoing damage