feat(hud): add shots fired counter and fix kill tracking

- Add shots_fired counter to HUDStats
- Display SHOTS in HUD next to DAMAGE DEALT/TAKEN
- Track 1 shot per damage event
- Fix kills: count when non-Shrapnel loot is received
- Shrapnel excluded from kill count (every mob drops it)
This commit is contained in:
LemonNexus 2026-02-08 23:43:37 +00:00
parent 3a3e389f05
commit 647728a1d4
2 changed files with 35 additions and 2 deletions

View File

@ -61,6 +61,7 @@ class HUDStats:
# Combat stats
damage_dealt: int = 0
damage_taken: int = 0
shots_fired: int = 0 # NEW: Track shots fired
kills: int = 0
globals_count: int = 0
hofs_count: int = 0
@ -80,6 +81,7 @@ class HUDStats:
'profit_loss': str(self.profit_loss),
'damage_dealt': self.damage_dealt,
'damage_taken': self.damage_taken,
'shots_fired': self.shots_fired,
'kills': self.kills,
'globals_count': self.globals_count,
'hofs_count': self.hofs_count,
@ -99,6 +101,7 @@ class HUDStats:
profit_loss=Decimal(data.get('profit_loss', '0.0')),
damage_dealt=data.get('damage_dealt', 0),
damage_taken=data.get('damage_taken', 0),
shots_fired=data.get('shots_fired', 0),
kills=data.get('kills', 0),
globals_count=data.get('globals_count', 0),
hofs_count=data.get('hofs_count', 0),
@ -358,9 +361,22 @@ class HUDOverlay(QWidget):
layout.addLayout(row1)
# Row 2: Damage
# Row 2: Shots, Damage Dealt, Damage Taken
row2 = QHBoxLayout()
# Shots Fired
shots_layout = QVBoxLayout()
shots_label = QLabel("🔫 SHOTS")
shots_label.setStyleSheet("font-size: 10px; color: #888888;")
shots_layout.addWidget(shots_label)
self.shots_value_label = QLabel("0")
self.shots_value_label.setStyleSheet("font-size: 13px; font-weight: bold; color: #FFD700;")
shots_layout.addWidget(self.shots_value_label)
row2.addLayout(shots_layout)
row2.addStretch()
# Damage Dealt
dealt_layout = QVBoxLayout()
dealt_label = QLabel("⚔️ DEALT")
@ -856,6 +872,12 @@ class HUDOverlay(QWidget):
elif 'damage_taken_add' in stats:
self._stats.damage_taken += int(stats['damage_taken_add'])
# Shots fired
if 'shots_fired' in stats:
self._stats.shots_fired = int(stats['shots_fired'])
elif 'shots_add' in stats:
self._stats.shots_fired += int(stats['shots_add'])
# Kills
if 'kills' in stats:
self._stats.kills = int(stats['kills'])
@ -914,6 +936,9 @@ class HUDOverlay(QWidget):
f"{self._stats.globals_count} / {self._stats.hofs_count}"
)
# Shots Fired
self.shots_value_label.setText(str(self._stats.shots_fired))
# Damage
self.dealt_value_label.setText(str(self._stats.damage_dealt))
self.taken_value_label.setText(str(self._stats.damage_taken))

View File

@ -958,6 +958,11 @@ class MainWindow(QMainWindow):
if item_name == 'Universal Ammo':
return
# Count kills (excluding Shrapnel which is from every mob)
# Real loot items indicate a kill
if item_name != 'Shrapnel':
self.hud.update_stats({'kills_add': 1})
# Queue database write for main thread (SQLite thread safety)
if self._current_db_session_id:
self._event_queue.put({
@ -1002,10 +1007,13 @@ class MainWindow(QMainWindow):
self.log_info("Skill", f"{skill_name} +{gained}")
def on_damage_dealt(event):
"""Handle damage dealt - also track weapon cost."""
"""Handle damage dealt - also track weapon cost and shots fired."""
damage = event.data.get('damage', 0)
self.hud.on_damage_dealt(float(damage))
# Track shots fired (1 shot per damage event)
self.hud.update_stats({'shots_add': 1})
# Track weapon decay cost per shot
# Only count as one shot fired per damage event
if self._selected_weapon_stats: