From 59e3373716a46c57241fdcfa9e197bfb69fa17ec Mon Sep 17 00:00:00 2001 From: Florian Stinglmayr Date: Fri, 11 Feb 2022 13:26:10 +0100 Subject: [PATCH] improve murder detection --- BGS/Report.cs | 50 +++++++++++++++++++++++++++++++++++++++----------- README.md | 7 ++++++- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/BGS/Report.cs b/BGS/Report.cs index 3b47678..3f488b7 100644 --- a/BGS/Report.cs +++ b/BGS/Report.cs @@ -29,22 +29,23 @@ namespace EliteBGS.BGS { } private bool IsRelevant(Entry e) { - return e.Is(Events.MissionCompleted) || - e.Is(Events.MissionFailed) || - e.Is(Events.MissionAccepted) || + return e.Is(Events.CommitCrime) || e.Is(Events.Docked) || + e.Is(Events.FactionKillBond) || e.Is(Events.FSDJump) || e.Is(Events.Location) || + e.Is(Events.MarketBuy) || + e.Is(Events.MarketSell) || + e.Is(Events.MissionAccepted) || + e.Is(Events.MissionFailed) || e.Is(Events.MultiSellExplorationData) || + e.Is(Events.RedeemVoucher) || e.Is(Events.SearchAndRescue) || e.Is(Events.SellExplorationData) || e.Is(Events.SellMicroResources) || e.Is(Events.SellOrganicData) || - e.Is(Events.RedeemVoucher) || - e.Is(Events.FactionKillBond) || - e.Is(Events.MarketBuy) || - e.Is(Events.MarketSell) || - e.Is(Events.CommitCrime) + e.Is(Events.ShipTargeted) || + e.Is(Events.MissionCompleted) ; } @@ -61,10 +62,15 @@ namespace EliteBGS.BGS { return; } - List relevant = entries.Where(x => IsRelevant(x)).ToList(); + List relevant = entries + .Where(x => IsRelevant(x)) + .ToList() + ; + Dictionary acceptedMissions = new Dictionary(); Dictionary buyCost = new Dictionary(); Dictionary systems = new Dictionary(); + Dictionary npcfactions = new Dictionary(); string current_system = null; ulong current_system_address = 0; @@ -73,7 +79,7 @@ namespace EliteBGS.BGS { objectives.ForEach(x => x.Clear()); - foreach (var e in relevant) { + foreach (Entry e in relevant) { List results = new List(); bool collate = false; @@ -118,17 +124,39 @@ namespace EliteBGS.BGS { if (!string.IsNullOrEmpty(location.StationName)) { current_station = location.StationName; } + } else if (e.Is(Events.ShipTargeted)) { + ShipTargetedEntry targeted = e as ShipTargetedEntry; + + if (string.IsNullOrEmpty(targeted.PilotName) || + string.IsNullOrEmpty(targeted.Faction)) { + continue; + } + + npcfactions.Add(targeted.PilotName, targeted.Faction); } else if (e.Is(Events.CommitCrime)) { CommitCrimeEntry crime = e as CommitCrimeEntry; + string faction = crime.Faction; if (!crime.IsMurder) { /* we don't care about anything but murder for now */ continue; } + if (!npcfactions.ContainsKey(crime.Victim)) { + /* The faction in the crime report is the faction that issues the bounty, + * and not the faction of the victim. + */ + OnLog?.Invoke(string.Format( + "No faction found for victim \"{0}\", using faction that issued the bounty instead.", + crime.Victim, crime.Faction + )); + } else { + faction = npcfactions[crime.Victim]; + } + results.Add(new FoulMurder(crime) { System = current_system, - Faction = crime.Faction, + Faction = faction, }); collate = true; } else if (e.Is(Events.MissionCompleted)) { diff --git a/README.md b/README.md index 1960591..d55956f 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Selling cargo attempts to discern the profit and/or loss, which is helpful to ga impact. But the player journal does not tell the amount of profit in the sell message. So the tool looks for a buy a message related to the same commodity, and calculates loss and/or profit from that. If the buy of the commodity is not within the time and date range, -or some other shenanigans happen that the tool does not yet support the profit/loss could +or some other shenanigans happen that the tool does not yet support, the profit/loss could be wrong. You can use the "Adjust Trade Profit" button to manually adjust the trade profit, or you could simply edit the discord log manually. @@ -63,6 +63,11 @@ it, if the day you accepted the mission is outside of the given date range. It n entry where you accept the mission to connect the mission to a faction, system and station. The tool will warn you if this happens, with a message in the error log in the fourth tab. +When committing murder, the journal entry contains the faction information of the faction that gave +you the bounty. And not the faction of the victim. The tool will look for an event in which you +scanned your victim, and gleem the victim's faction from that. If you did not scan your victim, then +sadly the tool cannot connect the victim's faction to the victim. + ![Main Window with entries](main-entries.png) The window will then list all the journal entries it has found, and group them by objectives. You