fix: calculate armor decay based on actual damage absorbed
- Use formula: Decay (PED) = damage * 0.0005 (approx 0.05 PEC per damage) - This matches EU armor decay formula better than flat cost per hit - 1966 damage would give ~0.98 PED decay (not 22 PED) - Falls back to cost_per_hit if armor stats not available
This commit is contained in:
parent
6d8f710244
commit
a216afde2d
|
|
@ -1187,13 +1187,25 @@ class MainWindow(QMainWindow):
|
|||
logger.debug(f"[HUD] on_damage_taken({damage})")
|
||||
self.hud.on_damage_taken(Decimal(str(damage)))
|
||||
|
||||
# Track armor cost per hit
|
||||
logger.debug(f"[DEBUG] _session_costs={self._session_costs}")
|
||||
if self._session_costs:
|
||||
# Calculate armor decay based on actual damage absorbed
|
||||
# Formula: Decay (PEC) = damage_absorbed * 0.05 * (1 - durability/100000)
|
||||
# Approximate: ~0.05 PEC per damage point for non-L armor
|
||||
# For simplicity: 0.0005 PED per damage point (0.05 PEC = 0.0005 PED)
|
||||
if self._selected_armor_stats and 'decay' in self._selected_armor_stats:
|
||||
# Use decay per hit from armor stats if available
|
||||
armor_decay_pec = Decimal(str(self._selected_armor_stats.get('decay', 0)))
|
||||
# Approximate: decay scales with damage
|
||||
# Most armor has ~0.05 PEC decay per damage point
|
||||
decay_per_damage = Decimal('0.0005') # 0.05 PEC = 0.0005 PED
|
||||
cost_ped = Decimal(str(damage)) * decay_per_damage
|
||||
if cost_ped > 0:
|
||||
logger.debug(f"[HUD] update_armor_cost({cost_ped:.4f}) based on damage {damage}")
|
||||
self.hud.update_armor_cost(cost_ped)
|
||||
else:
|
||||
# Fallback to simple calculation
|
||||
cost_per_hit = self._session_costs.get('cost_per_hit', Decimal('0'))
|
||||
logger.debug(f"[DEBUG] cost_per_hit={cost_per_hit}")
|
||||
if cost_per_hit > 0:
|
||||
logger.debug(f"[HUD] update_armor_cost({cost_per_hit})")
|
||||
logger.debug(f"[HUD] update_armor_cost({cost_per_hit}) [fallback]")
|
||||
self.hud.update_armor_cost(cost_per_hit)
|
||||
except Exception as e:
|
||||
logger.error(f"[ERROR] Error in on_damage_taken: {e}")
|
||||
|
|
|
|||
Loading…
Reference in New Issue