feat(combat): add critical hit tracking and filter Universal Ammo
- Add English critical hit pattern: 'Critical hit - Additional damage! You inflicted X'
- Display 💀 CRITICAL notifications with damage
- Filter out Universal Ammo from loot (converted shrapnel, not real loot)
- Critical hits count toward damage_dealt stats
Fixes loot inflation from shrapnel conversion and tracks critical strikes.
This commit is contained in:
parent
0f19155dd8
commit
b28b3915fd
|
|
@ -123,12 +123,19 @@ class LogWatcher:
|
|||
|
||||
# CRITICAL HIT
|
||||
# Swedish: "Kritisk träff - Extra skada! Du orsakade 44.4 poäng skada"
|
||||
# English: "Critical hit - Additional damage! You inflicted 49.6 points of damage"
|
||||
PATTERN_CRITICAL_SV = re.compile(
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+'
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+\[?\]?\s*'
|
||||
r'Kritisk\s+träff.*?Du\s+orsakade\s+(\d+(?:\.\d+)?)\s+poäng\s+skada',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
PATTERN_CRITICAL_EN = re.compile(
|
||||
r'^(\d{4}-\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2})\s+\[System\]\s+\[?\]?\s*'
|
||||
r'Critical\s+hit.*?You\s+inflicted\s+(\d+(?:\.\d+)?)\s+points?\s+of\s+damage',
|
||||
re.IGNORECASE
|
||||
)
|
||||
|
||||
# DAMAGE TAKEN
|
||||
# Swedish: "Du tog 31.5 poäng skada"
|
||||
# English: "You took 7.4 points of damage"
|
||||
|
|
@ -407,14 +414,24 @@ class LogWatcher:
|
|||
data={'damage': Decimal(match.group(2)), 'language': 'english'}
|
||||
)
|
||||
|
||||
# CRITICAL HIT
|
||||
# CRITICAL HIT - Swedish
|
||||
match = self.PATTERN_CRITICAL_SV.match(line)
|
||||
if match:
|
||||
return LogEvent(
|
||||
timestamp=self._parse_timestamp(match.group(1)),
|
||||
event_type='critical_hit',
|
||||
raw_line=line,
|
||||
data={'damage': Decimal(match.group(2))}
|
||||
data={'damage': Decimal(match.group(2)), 'language': 'swedish'}
|
||||
)
|
||||
|
||||
# CRITICAL HIT - English
|
||||
match = self.PATTERN_CRITICAL_EN.match(line)
|
||||
if match:
|
||||
return LogEvent(
|
||||
timestamp=self._parse_timestamp(match.group(1)),
|
||||
event_type='critical_hit',
|
||||
raw_line=line,
|
||||
data={'damage': Decimal(match.group(2)), 'language': 'english'}
|
||||
)
|
||||
|
||||
# DAMAGE TAKEN - Swedish
|
||||
|
|
|
|||
11
main.py
11
main.py
|
|
@ -212,8 +212,12 @@ class LemontropiaApp:
|
|||
def on_event(event):
|
||||
"""Handle log events."""
|
||||
if event.event_type == 'loot':
|
||||
item_name = event.data.get('item_name', 'Unknown')
|
||||
# Skip Universal Ammo - it's converted shrapnel, not loot
|
||||
if item_name == 'Universal Ammo':
|
||||
return
|
||||
loot = LootEvent(
|
||||
item_name=event.data.get('item_name', 'Unknown'),
|
||||
item_name=item_name,
|
||||
quantity=event.data.get('quantity', 1),
|
||||
value_ped=event.data.get('value_ped', Decimal('0.0')),
|
||||
event_type='regular',
|
||||
|
|
@ -248,6 +252,10 @@ class LemontropiaApp:
|
|||
stats['damage_dealt'] += 1
|
||||
print(f" 💥 Damage Dealt: {event.data.get('damage')} pts")
|
||||
|
||||
elif event.event_type == 'critical_hit':
|
||||
stats['damage_dealt'] += 1 # Count as damage dealt too
|
||||
print(f" 💀 CRITICAL: {event.data.get('damage')} pts")
|
||||
|
||||
elif event.event_type == 'damage_taken':
|
||||
stats['damage_taken'] += 1
|
||||
print(f" 🛡️ Damage Taken: {event.data.get('damage')} pts")
|
||||
|
|
@ -264,6 +272,7 @@ class LemontropiaApp:
|
|||
self.watcher.subscribe('level_up', on_event)
|
||||
self.watcher.subscribe('weapon_tier', on_event)
|
||||
self.watcher.subscribe('damage_dealt', on_event)
|
||||
self.watcher.subscribe('critical_hit', on_event)
|
||||
self.watcher.subscribe('damage_taken', on_event)
|
||||
self.watcher.subscribe('evade', on_event)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue