fix: correct kill counting logic

- Remove separate update_kills() call from on_loot handler
- Let update_loot() handle kill counting internally
- Only increment kills when >2 second gap since last loot
- Add is_new_kill flag to track new mobs vs multi-item drops
- Add debug logging for kill counting
This commit is contained in:
LemonNexus 2026-02-10 14:37:46 +00:00
parent 4db34c2c2c
commit fe0858ebfa
2 changed files with 11 additions and 7 deletions

View File

@ -854,6 +854,7 @@ class HUDOverlay(QWidget):
logger.debug(f"[HUD] update_loot called: value={value_ped}, is_shrapnel={is_shrapnel}, session_active={self.session_active}")
if self.session_active:
now = datetime.now()
is_new_kill = False
# Check if this is a new kill (gap of >2 seconds since last loot)
if self._stats._last_loot_time is not None:
@ -864,15 +865,22 @@ class HUDOverlay(QWidget):
self._stats.highest_loot = self._stats._current_kill_loot
# Start new kill
self._stats._current_kill_loot = value_ped
is_new_kill = True
else:
# Same kill, add to current
self._stats._current_kill_loot += value_ped
else:
# First loot of session
# First loot of session - this is a new kill
self._stats._current_kill_loot = value_ped
is_new_kill = True
self._stats._last_loot_time = now
# Only count kill if it's a new mob
if is_new_kill:
self._stats.kills += 1
logger.debug(f"[HUD] New kill counted! Total kills: {self._stats.kills}")
# Add to totals
if is_shrapnel:
self._stats.shrapnel_total += value_ped
@ -880,8 +888,8 @@ class HUDOverlay(QWidget):
self._stats.loot_other += value_ped
self._stats.recalculate()
# Emit signal to refresh on main thread instead of calling directly
self._request_refresh()
logger.debug(f"[HUD] update_loot complete: kills={self._stats.kills}, shrapnel={self._stats.shrapnel_total}, other={self._stats.loot_other}")
logger.debug(f"[HUD] update_loot complete: shrapnel={self._stats.shrapnel_total}, other={self._stats.loot_other}")
def update_shrapnel(self, amount: Decimal):

View File

@ -1075,11 +1075,7 @@ class MainWindow(QMainWindow):
return
try:
# Update kill count (each loot event = 1 kill)
logger.debug(f"[HUD] update_kills(1)")
self.hud.update_kills(1)
# Update loot value
# Update loot value - this also handles kill counting internally
is_shrapnel = 'shrapnel' in item_name.lower()
logger.debug(f"[HUD] update_loot({value_ped}, is_shrapnel={is_shrapnel})")
self.hud.update_loot(value_ped, is_shrapnel=is_shrapnel)