track Pill Color, not Pill Effect

This commit is contained in:
Buurazu authored and GitHub committed 2022-09-30 02:17:23 -04:00
1 parent 0cb84ba7f6
commit af44c92d9c
1 file changed
+16 -14
+16 -14
View File
@@ -37,6 +37,7 @@ EID.CollectedItems = {}
EID.IgnoredEntities = {} EID.IgnoredEntities = {}
EID.CurrentRoomGridEntities = {} EID.CurrentRoomGridEntities = {}
EID.UnidentifyablePillEffects = {} -- List of pilleffects that are always unidentifyable EID.UnidentifyablePillEffects = {} -- List of pilleffects that are always unidentifyable
EID.UsedPillColors = {} -- Colors of pills that have been eaten during this game
local pathsChecked = {} local pathsChecked = {}
local altPathItemChecked = {} local altPathItemChecked = {}
local alwaysUseLocalMode = false -- set to true after drawing a non-local mode description this frame local alwaysUseLocalMode = false -- set to true after drawing a non-local mode description this frame
@@ -1474,7 +1475,7 @@ local function onRender(t)
local identified = pool:IsPillIdentified(pillColor) and not EID.Config["OnlyShowPillWhenUsedAtLeastOnce"] local identified = pool:IsPillIdentified(pillColor) and not EID.Config["OnlyShowPillWhenUsedAtLeastOnce"]
if REPENTANCE and pillColor % PillColor.PILL_GIANT_FLAG == PillColor.PILL_GOLD then identified = true end if REPENTANCE and pillColor % PillColor.PILL_GIANT_FLAG == PillColor.PILL_GOLD then identified = true end
local pillEffectID = EID:getAdjustedSubtype(closest.Type, closest.Variant, pillColor) local pillEffectID = EID:getAdjustedSubtype(closest.Type, closest.Variant, pillColor)
local wasUsed = EID:WasPillUsed(pillEffectID, player) local wasUsed = EID:WasPillUsed(pillColor)
if (identified or wasUsed or EID.Config["ShowUnidentifiedPillDescriptions"]) and not EID.UnidentifyablePillEffects[pillEffectID] then if (identified or wasUsed or EID.Config["ShowUnidentifiedPillDescriptions"]) and not EID.UnidentifyablePillEffects[pillEffectID] then
local descEntry = EID:getDescriptionObj(closest.Type, closest.Variant, pillColor, closest) local descEntry = EID:getDescriptionObj(closest.Type, closest.Variant, pillColor, closest)
@@ -1581,22 +1582,17 @@ if REPENTANCE then
end end
function EID:OnUsePill(pillEffectID, player, useFlags) function EID:OnUsePill(pillEffectID, player, useFlags)
if (REPENTANCE and player:GetPill(0) % PillColor.PILL_GIANT_FLAG == PillColor.PILL_GOLD) then return end
player = player or EID.player --AB+ doesn't receive player in callback arguments! player = player or EID.player --AB+ doesn't receive player in callback arguments!
local playerID = EID:getPlayerID(player) -- get the pill color by checking the player's pocket (not accurate for Temperance? and such, but useFlags will help us ignore those)
-- Dead Tainted Lazarus exceptions local pillColor = player:GetPill(0)
local pillsTable = EID.PlayerItemInteractions[playerID].pills if pillColor == 0 then return end -- ignore if no pill found in pocket
EID:AddPickupToHistory("pill", pillEffectID+1, player, useFlags, pillColor) -- Echo Chamber tracking
if player:GetPlayerType() == 38 then -- for tracking used pills, ignore gold pills and noannouncer flag pills
pillsTable = EID.PlayerItemInteractions[playerID].altPills or pillsTable -- (not using a bitmask, because Placebo is mimic+noannouncer, and we want to count those)
end if REPENTANCE and (pillColor % PillColor.PILL_GIANT_FLAG == PillColor.PILL_GOLD or useFlags == UseFlag.USE_NOANNOUNCER) then return end
local effectID = tostring(pillEffectID+1) EID.UsedPillColors[tostring(pillColor)] = true
if not pillsTable[effectID] then
pillsTable[effectID] = 0
end
pillsTable[effectID] = pillsTable[effectID] + 1
EID:AddPickupToHistory("pill", pillEffectID+1, player, useFlags)
end end
EID:AddCallback(ModCallbacks.MC_USE_PILL, EID.OnUsePill) EID:AddCallback(ModCallbacks.MC_USE_PILL, EID.OnUsePill)
@@ -1617,6 +1613,7 @@ if EID.MCMLoaded or REPENTANCE then
["AbsorbedItems"] = true, ["AbsorbedItems"] = true,
["CollectedItems"] = true, ["CollectedItems"] = true,
["PlayerItemInteractions"] = true, ["PlayerItemInteractions"] = true,
["UsedPillColors"] = true,
} }
-------------------------------- --------------------------------
--------Handle Savadata--------- --------Handle Savadata---------
@@ -1648,6 +1645,10 @@ if EID.MCMLoaded or REPENTANCE then
-- check for the players' starting active items -- check for the players' starting active items
CheckAllActiveItemProgress() CheckAllActiveItemProgress()
end end
EID.UsedPillColors = {}
if isSave then
EID.UsedPillColors = savedEIDConfig["UsedPillColors"] or {}
end
if REPENTANCE then if REPENTANCE then
EID.BoC.BagItems = {} EID.BoC.BagItems = {}
@@ -1735,6 +1736,7 @@ if EID.MCMLoaded or REPENTANCE then
end end
EID.Config["CollectedItems"] = EID.CollectedItems EID.Config["CollectedItems"] = EID.CollectedItems
EID.Config["PlayerItemInteractions"] = EID.PlayerItemInteractions or {} EID.Config["PlayerItemInteractions"] = EID.PlayerItemInteractions or {}
EID.Config["UsedPillColors"] = EID.UsedPillColors
EID.SaveData(EID, json.encode(EID.Config)) EID.SaveData(EID, json.encode(EID.Config))
EID:hidePermanentText() EID:hidePermanentText()