From 0fd2264d5388a4c21d519cc1267e8ec4376d40e1 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Thu, 20 May 2021 11:26:04 +0100 Subject: [PATCH] UseConsumable: Rely on `BackpackChange` instead, to avoid double-accounting --- monitor.py | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/monitor.py b/monitor.py index 9787f192..0890b680 100644 --- a/monitor.py +++ b/monitor.py @@ -1019,24 +1019,28 @@ class EDLogs(FileSystemEventHandler): # type: ignore # See below self.state['BackPack'][entry['Type']][i] = 0 elif event_type == 'UseConsumable': - # alpha4 - # When using an item from the player’s inventory (backpack) - # - # Parameters: - # • Name - # • Type - # TODO: XXX: From v31 doc # 12.2 BackpackChange # This is written when there is any change to the contents of the # suit backpack – note this can be written at the same time as other # events like UseConsumable - for c in self.state['BackPack']['Consumable']: - if c == entry['Name']: - self.state['BackPack']['Consumable'][c] -= 1 - # Paranoia in case we lost track - if self.state['BackPack']['Consumable'][c] < 0: - self.state['BackPack']['Consumable'][c] = 0 + + # In 4.0.0.100 it is observed that: + # + # 1. Throw of any grenade type *only* causes a BackpackChange event, no + # accompanying 'UseConsumable'. + # 2. Using an Energy Cell causes both UseConsumable and BackpackChange, + # in that order. + # 3. Medkit acts the same as Energy Cell. + # + # Thus we'll just ignore 'UseConsumable' for now. + # for c in self.state['BackPack']['Consumable']: + # if c == entry['Name']: + # self.state['BackPack']['Consumable'][c] -= 1 + # # Paranoia in case we lost track + # if self.state['BackPack']['Consumable'][c] < 0: + # self.state['BackPack']['Consumable'][c] = 0 + ... # TODO: #