Skip to content

Commit

Permalink
Keep dict of all previously targeted ships for checking murdered ship…
Browse files Browse the repository at this point in the history
… faction. Closes #136.
  • Loading branch information
aussig committed Sep 8, 2023
1 parent 640cab5 commit ed7ecf0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

* Some Orthrus kills were not being tallied because the bond value logged was 40m instead of the previous 25m. We can only detect the type of Thargoid via the bond value logged by the game, so BGS-Tally will now tally an Orthrus for both kill values.
* Trade purchase, sale and profit was not being logged if you previously disembarked from your ship on foot, took a taxi or dropship somewhere, returned to your ship and then traded.
* Forcing a tick (via the settings panel), though still not advised unless automatic tick detection has **definitely** missed a tick, should now be much more reliable:
* It would cause your previously logged activity for the current tick to be lost and replaced by activity after the forced tick. Now, a 'proper' new tick is created so your earlier activity should be kept and available in the previous tick.
* Forcing a tick (via the settings panel), though still not recommended unless automatic tick detection has **definitely** missed a tick, should now be much more reliable:
* It would cause your previously logged activity for the current tick to be lost and replaced by activity after the forced tick. Now, a 'proper' new tick is created so your earlier activity should be kept and available in the previous ticks dropdown menu.
* If an automatic tick arrived with an earlier tick time than your forced tick, this could cause BGS-Tally to get confused. We now ignore any incoming ticks that have an older tick time than your forced tick.
* Forced ticks are now handled more elegantly when sending data via the BGS-Tally API, as we generate a fake `tickid` for the forced tick.
* Due to a game bug, some illegal massacre and assassination missions were not logging negative INF correctly against the target faction. Implemented a workaround for this.
* Due to a game bug, some illegal massacre and assassination missions were not tallying negative INF correctly against the target faction. Implemented a workaround for this.
* Due to a game bug, some ship murders were not being tallied against the target ship faction. Implemented a workaround for this.

### API Changes ([v1.2](https://studio-ws.apicur.io/sharing/281a84ad-dca9-42da-a08b-84e4b9af1b7e)):

Expand Down
14 changes: 9 additions & 5 deletions bgstally/activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def ship_targeted(self, journal_entry: Dict, state: State):
"""
if 'Faction' in journal_entry and 'PilotName_Localised' in journal_entry:
self.dirty = True
state.last_ship_targeted = {'Faction': journal_entry['Faction'], 'PilotName_Localised': journal_entry['PilotName_Localised']}
state.last_ships_targeted[journal_entry['PilotName_Localised']] = {'Faction': journal_entry['Faction'], 'PilotName_Localised': journal_entry['PilotName_Localised']}


def crime_committed(self, journal_entry: Dict, state: State):
Expand All @@ -580,14 +580,18 @@ def crime_committed(self, journal_entry: Dict, state: State):
self.dirty = True

# For in-space murders, the faction logged in the CommitCrime event is the system faction,
# not the ship faction. We need to log the murder against the ship faction, so we store the
# it from the previous ShipTargeted event in last_ship_targeted.
# not the ship faction. We need to log the murder against the ship faction, so we store
# it from the previous ShipTargeted event in last_ships_targeted. Need to keep a dict of all
# previously targeted ships because of a game bug where the logged murdered ship may not be the
# last target logged.

match journal_entry['CrimeType']:
case 'murder':
# For ship murders, if we didn't get a previous scan containing ship faction, don't log
if journal_entry.get('Victim') != state.last_ship_targeted.get('PilotName_Localised'): return
faction = current_system['Factions'].get(state.last_ship_targeted.get('Faction'))
ship_target_info:dict = state.last_ships_targeted.pop(journal_entry.get('Victim'), None)
if ship_target_info is None: return
faction = current_system['Factions'].get(ship_target_info.get('Faction'))

if faction:
faction['Murdered'] += 1
self.recalculate_zero_activity()
Expand Down
2 changes: 1 addition & 1 deletion bgstally/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def load(self):
# Non-persistent values
self.last_settlement_approached:Dict = {}
self.last_spacecz_approached:Dict = {}
self.last_ship_targeted:Dict = {}
self.last_ships_targeted:Dict = {}
self.system_tw_status = None

self.refresh()
Expand Down

0 comments on commit ed7ecf0

Please sign in to comment.