fix(hud): correct cost calculation using weapon decay from Nexus API

- Use actual weapon decay (PEC) from API instead of broken DPP calculation
- Add decay and ammo_burn to weapon stats passed from Gear Selector
- Cost per shot = decay (in PEC) / 100 = PED
This commit is contained in:
LemonNexus 2026-02-08 23:34:02 +00:00
parent 0a12b22498
commit 3a3e389f05
2 changed files with 14 additions and 11 deletions

View File

@ -292,8 +292,13 @@ class GearSelectorDialog(QDialog):
if self.gear_type == "weapon":
w = self.selected_gear
self.gear_selected.emit("weapon", w.name, {
'id': w.id, 'item_id': w.item_id, 'dpp': float(w.dpp),
'cost_per_hour': float(w.cost_per_hour), 'total_damage': float(w.total_damage),
'id': w.id,
'item_id': w.item_id,
'dpp': float(w.dpp),
'cost_per_hour': float(w.cost_per_hour),
'total_damage': float(w.total_damage),
'decay': float(w.decay) if w.decay else 0,
'ammo_burn': w.ammo_burn or 0,
})
elif self.gear_type == "armor":
a = self.selected_gear

View File

@ -1006,17 +1006,15 @@ class MainWindow(QMainWindow):
damage = event.data.get('damage', 0)
self.hud.on_damage_dealt(float(damage))
# Estimate cost per shot based on weapon stats
# Track weapon decay cost per shot
# Only count as one shot fired per damage event
if self._selected_weapon_stats:
dpp = self._selected_weapon_stats.get('dpp', 0)
if dpp and dpp > 0:
# Cost per shot in PEC = damage / DPP
# Convert to Decimal for precision
# Get decay per shot from weapon stats (in PEC)
decay = self._selected_weapon_stats.get('decay', 0)
if decay:
from decimal import Decimal
damage_dec = Decimal(str(damage))
dpp_dec = Decimal(str(dpp))
cost_pec = damage_dec / dpp_dec
cost_ped = cost_pec / Decimal('100') # Convert to PED
# Convert PEC to PED
cost_ped = Decimal(str(decay)) / Decimal('100')
self.hud.update_cost(cost_ped)
def on_critical_hit(event):