diff --git a/eid_api.lua b/eid_api.lua index 32297da9..3b3d22d4 100644 --- a/eid_api.lua +++ b/eid_api.lua @@ -510,14 +510,7 @@ function EID:getObjectName(Type, Variant, SubType) return name or (not string.find(vanillaName, "^#") and vanillaName) or EID.descriptions["en_us"][tableName][SubType][2] or vanillaName elseif tableName == "pills" or tableName == "horsepills" then local adjustedSubtype = EID:getAdjustedSubtype(Type, Variant, SubType) - local vanillaName = "" - if adjustedSubtype == 9999 then - vanillaName = "Golden Pill" -- only used for languages that haven't defined a Golden Pill name - else - vanillaName = EID.itemConfig:GetPillEffect(adjustedSubtype - 1).Name - end - name = name or (not string.find(vanillaName, "^#") and vanillaName) or EID.descriptions["en_us"][tableName][adjustedSubtype][2] or vanillaName - return string.gsub(name,"I'm Excited!!!","I'm Excited!!") -- prevent markup trigger + return EID:getPillName(adjustedSubtype, tableName == "horsepills") elseif tableName == "sacrifice" then return EID:getDescriptionEntry("sacrificeHeader") elseif tableName == "dice" then @@ -528,6 +521,25 @@ function EID:getObjectName(Type, Variant, SubType) return Type.."."..Variant.."."..SubType end +-- returns the name of a pill based on the pilleffect id +function EID:getPillName(pillID, isHorsepill) + local moddedDesc = EID:getDescriptionEntry("custom", "5.70."..pillID) + local legacyModdedDescription = EID:getLegacyModDescription(5, 70, pillID) + local tableName = isHorsepill and "horsepills" or "pills" + local defaultDesc = EID:getDescriptionEntry(tableName, pillID) + + local name = moddedDesc or legacyModdedDescription or defaultDesc + + local vanillaName = "" + if pillID == 9999 then + vanillaName = "Golden Pill" -- only used for languages that haven't defined a Golden Pill name + else + vanillaName = EID.itemConfig:GetPillEffect(pillID - 1).Name + end + name = name and name[2] or (not string.find(vanillaName, "^#") and vanillaName) or EID.descriptions["en_us"][tableName][pillID][2] or vanillaName + return string.gsub(name,"I'm Excited!!!","I'm Excited!!") -- prevent markup trigger +end + -- tries to get the ingame description of an object, based on their description in the XML files function EID:getXMLDescription(Type, Variant, SubType) local tableName = EID:getTableName(Type, Variant, SubType) @@ -1563,7 +1575,7 @@ function EID:evaluateQueuedItems() for i = 0, game:GetNumPlayers() - 1 do local player = Isaac.GetPlayer(i) if not EID.PlayerItemInteractions[i] then - EID.PlayerItemInteractions[i] = {LastTouch = 0, actives = {}, pills = {}, altActives = {}, altPills = {}} + EID.PlayerItemInteractions[i] = {LastTouch = 0, actives = {}, pills = {}, altActives = {}, altPills = {}, history = {pills = {},altPills = {}}} end EID.RecentlyTouchedItems[i] = EID.RecentlyTouchedItems[i] or {} end diff --git a/eid_holdmapdesc.lua b/eid_holdmapdesc.lua index 39e34ef0..32a4a7e6 100644 --- a/eid_holdmapdesc.lua +++ b/eid_holdmapdesc.lua @@ -40,6 +40,7 @@ local rainbowWormEffects = { [0] = 9, 11, 65, 27, 10, 12, 26, 66, 96, 144 } -- Mysterious Paper does not play well with displaying Error 404's effect local mysteriousPaperBlacklist = { [23] = true, [48] = true } + function EID:getHoldMapDescription(player, checkingTwin) EID.InsideItemReminder = true -- Starting Blacklist: Recall, Hold @@ -65,6 +66,27 @@ function EID:getHoldMapDescription(player, checkingTwin) append("{{PoopSpell" .. nextPoop .. "}}", poopInfo[nextPoop][1], poopInfo[nextPoop][2]) end end + + -- Echo Chamber Description + if REPENTANCE and player:HasCollectible(700) then + local playerID = player:GetPlayerType() + if EID.PlayerItemInteractions[playerID].history then + local pillHistoryTable = EID.PlayerItemInteractions[playerID].history.pills + -- Dead Tainted Lazarus + if playerID == 38 then + pillHistoryTable = EID.PlayerItemInteractions[playerID].history.altPills or pillHistoryTable + end + local pillNames = "" + for i = 1, math.min(3,#pillHistoryTable) do + if pillHistoryTable[i][2] then -- Echo chamber is owned + local lastUsedPill = tonumber(pillHistoryTable[i][1]) + local name = EID:getPillName(lastUsedPill, false) + pillNames = pillNames..name.."#" + end + end + append("{{Collectible700}}", EID:getObjectName(5,100,700), pillNames) + end + end -- Recently Acquired Item Descriptions if EID.Config["ItemReminderShowRecentItem"] > 0 then diff --git a/eid_modifiers.lua b/eid_modifiers.lua index 4a1dca14..4323f944 100644 --- a/eid_modifiers.lua +++ b/eid_modifiers.lua @@ -462,6 +462,38 @@ if REPENTANCE then return descObj end + -- Handle VURP description addition + local function VurpCallback(descObj) + local adjustedID = EID:getAdjustedSubtype(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType) + if adjustedID - 1 ~= PillEffect.PILLEFFECT_VURP then return descObj end + + local playerID = EID.player:GetPlayerType() + if EID.PlayerItemInteractions[playerID].history then + local pillHistoryTable = EID.PlayerItemInteractions[playerID].history.pills + -- Dead Tainted Lazarus + if playerID == 38 then + pillHistoryTable = EID.PlayerItemInteractions[playerID].history.altPills or pillHistoryTable + end + + local lastUsedPill = nil + local i = 1 + while(i <= #pillHistoryTable) do + if tonumber(pillHistoryTable[i][1]) ~= PillEffect.PILLEFFECT_VURP + 1 then + lastUsedPill = tonumber(pillHistoryTable[i][1]) + break + end + i = i +1 + end + + if lastUsedPill then + local tableName = EID:getTableName(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType) + local name = EID:getPillName(lastUsedPill, tableName == "horsepills") + EID:appendToDescription(descObj, "#{{Pill}} {{ColorSilver}}"..name) + end + end + return descObj + end + -- Handle False PHD description addition local function FalsePHDCallback(descObj) local adjustedID = EID:getAdjustedSubtype(descObj.ObjType, descObj.ObjVariant, descObj.ObjSubType) @@ -578,6 +610,7 @@ if REPENTANCE then elseif descObj.ObjVariant == PickupVariant.PICKUP_PILL then if EID.collectiblesOwned[654] then table.insert(callbacks, FalsePHDCallback) end if EID.collectiblesOwned[348] then table.insert(callbacks, PlaceboCallback) end + table.insert(callbacks, VurpCallback) if EID.pillPlayer == nil and #EID.coopAllPlayers > 1 then table.insert(callbacks, CoopPillCallback) diff --git a/main.lua b/main.lua index a3c93b10..54607520 100644 --- a/main.lua +++ b/main.lua @@ -1551,7 +1551,7 @@ local function AddActiveItemProgress(player, isD4) EID.ForceRefreshCache = true local playerID = EID:getPlayerID(player) if not EID.PlayerItemInteractions[playerID] then - EID.PlayerItemInteractions[playerID] = {LastTouch = 0, actives = {}, pills = {}, altActives = {}, altPills = {}} + EID.PlayerItemInteractions[playerID] = {LastTouch = 0, actives = {}, pills = {}, altActives = {}, altPills = {}, history = {pills = {},altPills = {}}} end -- Dead Tainted Lazarus exceptions local activesTable = EID.PlayerItemInteractions[playerID].actives @@ -1604,19 +1604,31 @@ if REPENTANCE then EID:AddCallback(ModCallbacks.MC_USE_ITEM, OnUseGenesis, CollectibleType.COLLECTIBLE_GENESIS) end -function EID:OnUsePill(pillEffectID, player) +function EID:OnUsePill(pillEffectID, player, useFlags) player = player or EID.player --AB+ doesn't receive player in callback arguments! local playerID = EID:getPlayerID(player) -- Dead Tainted Lazarus exceptions local pillsTable = EID.PlayerItemInteractions[playerID].pills + + if not EID.PlayerItemInteractions[playerID].history then + EID.PlayerItemInteractions[playerID].history = {pills = {},altPills = {}} + end + local pillHistoryTable = EID.PlayerItemInteractions[playerID].history.pills if player:GetPlayerType() == 38 then pillsTable = EID.PlayerItemInteractions[playerID].altPills or pillsTable + pillHistoryTable = EID.PlayerItemInteractions[playerID].history.altPills or pillHistoryTable end local effectID = tostring(pillEffectID+1) if not pillsTable[effectID] then pillsTable[effectID] = 0 end pillsTable[effectID] = pillsTable[effectID] + 1 + + if REPENTANCE and useFlags & UseFlag.USE_MIMIC == UseFlag.USE_MIMIC then return end -- dont add mimic pills to history + table.insert(pillHistoryTable, 1, {effectID, REPENTANCE and player:HasCollectible(700)}) + for k,v in ipairs(pillHistoryTable) do + print(k,v[1]) + end end EID:AddCallback(ModCallbacks.MC_USE_PILL, EID.OnUsePill)