diff --git a/eid_api.lua b/eid_api.lua index 430c7c68..e1faf76b 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -1695,7 +1695,9 @@ function EID:evaluateTransformationProgress(transformation) if activesTable[tostring(eSubType)] then EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + activesTable[tostring(eSubType)] else - EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + player:GetCollectibleNum(eSubType, true) + local collCount = player:GetCollectibleNum(eSubType, true) - (EID.PlayerItemInteractions[i].rerollItems[tostring(eSubType)] or 0) + EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + collCount + -- Undo the Book of Virtues active item getting counted here if tonumber(eSubType) == 584 and player:GetActiveItem() == 584 then EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] - 1 @@ -1767,7 +1769,7 @@ end function EID:InitItemInteractionIfAbsent(playerID) if not EID.PlayerItemInteractions[playerID] then EID.PlayerItemInteractions[playerID] = { LastTouch = 0, actives = {}, pills = {}, altActives = {}, altPills = {}, - pickupHistory = {}, altPickupHistory = {} } + pickupHistory = {}, altPickupHistory = {}, rerollItems = {} } end EID.RecentlyTouchedItems[playerID] = EID.RecentlyTouchedItems[playerID] or {} end @@ -1851,6 +1853,20 @@ function EID:GetTransformationsOfModdedItems() end end +-- Collects items that the player got after using D4 item +function EID:CollectRerolledItemsOfPlayer(player) + if maxCollectibleID == nil then maxCollectibleID = EID:GetMaxCollectibleID() end + local playerID = EID:getPlayerID(player) + EID.PlayerItemInteractions[playerID].rerollItems = {} + for i = 1, maxCollectibleID do + local count = player:GetCollectibleNum(i, true) + if count > 0 then + EID.PlayerItemInteractions[playerID].rerollItems[tostring(i)] = count + end + end +end + + -- Returns true if a given entity is a grid entity function EID:IsGridEntity(entity) return entity.Type == nil diff --git a/main.lua b/main.lua index b6da7098..1dc438c1 100644 --- a/main.lua +++ b/main.lua @@ -1560,6 +1560,7 @@ EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, OnGameStartGeneral) local function OnUseD4(_, _, _, player) -- in AB+, USE_ITEM doesn't provide a player AddActiveItemProgress(player or EID.player, true) + EID:CollectRerolledItemsOfPlayer(player or EID.player) end EID:AddCallback(ModCallbacks.MC_USE_ITEM, OnUseD4, CollectibleType.COLLECTIBLE_D4)