Merge pull request #517 from Buurazu/master
Pill Color tracking, Echo fixes, AB+ save fix
This commit is contained in:
4 files changed
+49
-51
No files matched your search
+10
-15
@@ -717,12 +717,12 @@ function EID:createItemIconObject(str)
|
||||
end
|
||||
local cardID,numReplace3 = string.gsub(str, "Card", "")
|
||||
if numReplace3 > 0 and cardID ~= "" and tonumber(cardID) ~= nil then
|
||||
if tonumber(cardID) > maxCardID then return EID.InlineIcons[str] or EID.InlineIcons["Blank"] end
|
||||
if tonumber(cardID) > maxCardID then return EID.InlineIcons[str] or EID.InlineIcons["Card"] end
|
||||
return {"Cards", tonumber(cardID)-1, 8, 8, 0, 1, EID.CardPillSprite}
|
||||
end
|
||||
local pillID,numReplace4 = string.gsub(str, "Pill", "")
|
||||
if numReplace4 > 0 and pillID ~= "" and tonumber(pillID) ~= nil then
|
||||
if tonumber(pillID) > maxPillID then return EID.InlineIcons[str] or EID.InlineIcons["Blank"] end
|
||||
if tonumber(pillID) > maxPillID then return EID.InlineIcons[str] or EID.InlineIcons["Pill"] end
|
||||
return {"Pills", tonumber(pillID)-1, 9, 8, 0, 1, EID.CardPillSprite}
|
||||
end
|
||||
if item == nil then
|
||||
@@ -1769,8 +1769,9 @@ function EID:SetPillEffectUnidentifyable(pillEffectID, isUnidentifyable)
|
||||
end
|
||||
|
||||
-- Add pickup usage to history of pickups used by the player
|
||||
function EID:AddPickupToHistory(pickupType, effectID, player, useFlags)
|
||||
if REPENTANCE and useFlags & UseFlag.USE_MIMIC == UseFlag.USE_MIMIC then return end -- dont add mimic pills to history
|
||||
function EID:AddPickupToHistory(pickupType, effectID, player, useFlags, pillColorID)
|
||||
-- don't add mimiced or noannouncer cards/pills to history
|
||||
if REPENTANCE and (useFlags & UseFlag.USE_MIMIC == UseFlag.USE_MIMIC or useFlags & UseFlag.USE_NOANNOUNCER == UseFlag.USE_NOANNOUNCER) then return end
|
||||
local playerID = EID:getPlayerID(player)
|
||||
EID:InitItemInteractionIfAbsent(playerID)
|
||||
|
||||
@@ -1780,8 +1781,8 @@ function EID:AddPickupToHistory(pickupType, effectID, player, useFlags)
|
||||
historyTable = EID.PlayerItemInteractions[playerID].altPickupHistory or historyTable
|
||||
end
|
||||
|
||||
-- pickupType = ["pill","card"], playerTypeID, effectID, hadEchoChamberWhenUsed
|
||||
table.insert(historyTable, 1, {pickupType, player:GetPlayerType(), effectID, REPENTANCE and player:HasCollectible(700)})
|
||||
-- pickupType = ["pill","card"], pillColorID, effectID, hadEchoChamberWhenUsed
|
||||
table.insert(historyTable, 1, {pickupType, pillColorID, effectID, REPENTANCE and player:HasCollectible(700)})
|
||||
end
|
||||
|
||||
-- Render a sprite of an entity
|
||||
@@ -1809,13 +1810,7 @@ function EID:IsGridEntity(entity)
|
||||
return entity.Type == nil
|
||||
end
|
||||
|
||||
-- returns true if the given pilleffect id was used at least once by the current player
|
||||
function EID:WasPillUsed(pillEffectID, player)
|
||||
local playerID = EID:getPlayerID(player)
|
||||
local pillsTable = EID.PlayerItemInteractions[playerID].pills
|
||||
-- Dead Tainted Lazarus exception
|
||||
if player:GetPlayerType() == 38 then
|
||||
pillsTable = EID.PlayerItemInteractions[playerID].altPills or pillsTable
|
||||
end
|
||||
return pillsTable[tostring(pillEffectID)] ~= nil
|
||||
-- returns true if the given pill color was used at least once in this game
|
||||
function EID:WasPillUsed(pillColor)
|
||||
return EID.UsedPillColors[tostring(pillColor)] ~= nil
|
||||
end
|
||||
+1
-1
@@ -91,7 +91,7 @@ function EID:getHoldMapDescription(player, checkingTwin)
|
||||
if pickupHistory[i][4] then -- Echo chamber was owned before this card/pill was used
|
||||
if pickupHistory[i][1] == "pill" then
|
||||
local name = EID:getPillName(pickupHistory[i][3], false)
|
||||
pickupNames = pickupNames .. "{{Pill}} " .. name .. "#"
|
||||
pickupNames = pickupNames .. "{{Pill" .. pickupHistory[i][2] .. "}} " .. name .. "#"
|
||||
else
|
||||
local name = EID:getObjectName(5, 300, pickupHistory[i][3])
|
||||
pickupNames = pickupNames .. "{{Card" .. pickupHistory[i][3] .. "}} " .. name .. "#"
|
||||
|
||||
@@ -173,3 +173,10 @@ local function GameEndTMTRAINER()
|
||||
Isaac.DebugString("[EID] Game ended; ignore previous glitched items in the log!")
|
||||
end
|
||||
EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, GameEndTMTRAINER)
|
||||
|
||||
|
||||
-- shh. it's a non-obtrusive april fools joke for the 1% of people with luadebug
|
||||
-- https://www.youtube.com/watch?v=msDuNZyYAIQ
|
||||
if (os.date("%m/%d") == "04/01") then
|
||||
EID.descriptions["en_us"].sacrifice[1][3] = "{{Coin}} 50% chance of winning 1 coin at Sacrifice#75% chance if you're a genetic freak#!!! If you add Kurt Angle to the mix, your chances of winning drastically go down"
|
||||
end
|
||||
@@ -18,6 +18,7 @@ EID.coopMainPlayers = {} -- The primary Player Entity for each controller being
|
||||
EID.coopAllPlayers = {} -- Every Player Entity (includes Esau, T.Forgotten)
|
||||
EID.controllerIndexes = {} -- A table to map each controller index to their player number for coloring indicators
|
||||
EID.isMultiplayer = false -- Used to color P1's highlight/outline indicators (single player just uses white)
|
||||
EID.BoC = {}
|
||||
|
||||
-- general variables
|
||||
EID.PositionModifiers = {}
|
||||
@@ -37,6 +38,7 @@ EID.CollectedItems = {}
|
||||
EID.IgnoredEntities = {}
|
||||
EID.CurrentRoomGridEntities = {}
|
||||
EID.UnidentifyablePillEffects = {} -- List of pilleffects that are always unidentifyable
|
||||
EID.UsedPillColors = {} -- Colors of pills that have been eaten during this game
|
||||
local pathsChecked = {}
|
||||
local altPathItemChecked = {}
|
||||
local alwaysUseLocalMode = false -- set to true after drawing a non-local mode description this frame
|
||||
@@ -1474,7 +1476,7 @@ local function onRender(t)
|
||||
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
|
||||
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
|
||||
local descEntry = EID:getDescriptionObj(closest.Type, closest.Variant, pillColor, closest)
|
||||
@@ -1581,22 +1583,17 @@ if REPENTANCE then
|
||||
end
|
||||
|
||||
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!
|
||||
local playerID = EID:getPlayerID(player)
|
||||
-- Dead Tainted Lazarus exceptions
|
||||
local pillsTable = EID.PlayerItemInteractions[playerID].pills
|
||||
-- get the pill color by checking the player's pocket (not accurate for Temperance? and such, but useFlags will help us ignore those)
|
||||
local pillColor = player:GetPill(0)
|
||||
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
|
||||
pillsTable = EID.PlayerItemInteractions[playerID].altPills or pillsTable
|
||||
end
|
||||
local effectID = tostring(pillEffectID+1)
|
||||
if not pillsTable[effectID] then
|
||||
pillsTable[effectID] = 0
|
||||
end
|
||||
pillsTable[effectID] = pillsTable[effectID] + 1
|
||||
-- for tracking used pills, ignore gold pills and noannouncer flag pills
|
||||
-- (not using a bitmask, because Placebo is mimic+noannouncer, and we want to count those)
|
||||
if REPENTANCE and (pillColor % PillColor.PILL_GIANT_FLAG == PillColor.PILL_GOLD or useFlags == UseFlag.USE_NOANNOUNCER) then return end
|
||||
EID.UsedPillColors[tostring(pillColor)] = true
|
||||
|
||||
EID:AddPickupToHistory("pill", pillEffectID+1, player, useFlags)
|
||||
end
|
||||
EID:AddCallback(ModCallbacks.MC_USE_PILL, EID.OnUsePill)
|
||||
|
||||
@@ -1606,10 +1603,8 @@ function EID:OnUseCard(cardID, player, useFlags)
|
||||
end
|
||||
EID:AddCallback(ModCallbacks.MC_USE_CARD, EID.OnUseCard)
|
||||
|
||||
-- only save and load configs when using MCM. Otherwise Config file changes arent valid
|
||||
if EID.MCMLoaded or REPENTANCE then
|
||||
local json = require("json")
|
||||
local configIgnoreList = {
|
||||
local json = require("json")
|
||||
local configIgnoreList = {
|
||||
["BagContent"] = true,
|
||||
["BagFloorContent"] = true,
|
||||
["CraneItemType"] = true,
|
||||
@@ -1617,11 +1612,12 @@ if EID.MCMLoaded or REPENTANCE then
|
||||
["AbsorbedItems"] = true,
|
||||
["CollectedItems"] = true,
|
||||
["PlayerItemInteractions"] = true,
|
||||
}
|
||||
--------------------------------
|
||||
--------Handle Savadata---------
|
||||
--------------------------------
|
||||
function OnGameStart(_,isSave)
|
||||
["UsedPillColors"] = true,
|
||||
}
|
||||
--------------------------------
|
||||
--------Handle Savadata---------
|
||||
--------------------------------
|
||||
function OnGameStart(_,isSave)
|
||||
--Loading Moddata--
|
||||
|
||||
if EID:HasData() then
|
||||
@@ -1648,6 +1644,10 @@ if EID.MCMLoaded or REPENTANCE then
|
||||
-- check for the players' starting active items
|
||||
CheckAllActiveItemProgress()
|
||||
end
|
||||
EID.UsedPillColors = {}
|
||||
if isSave then
|
||||
EID.UsedPillColors = savedEIDConfig["UsedPillColors"] or {}
|
||||
end
|
||||
|
||||
if REPENTANCE then
|
||||
EID.BoC.BagItems = {}
|
||||
@@ -1679,7 +1679,8 @@ if EID.MCMLoaded or REPENTANCE then
|
||||
end
|
||||
end
|
||||
|
||||
-- Only copy Saved config entries that exist in the save
|
||||
-- Check if eid_config.lua is in its default state (like if an EID update occurred)
|
||||
-- If it is, or MCM is loaded, load the config from savedata instead of eid_config.lua
|
||||
if savedEIDConfig.Version == EID.Config.Version then
|
||||
local isDefaultConfig = true
|
||||
for key, value in pairs(EID.Config) do
|
||||
@@ -1698,11 +1699,7 @@ if EID.MCMLoaded or REPENTANCE then
|
||||
end
|
||||
end
|
||||
end
|
||||
-- DisableAchievementCheck has been renamed, convert the setting to the new one (this can be removed in a few updates)
|
||||
if savedEIDConfig["DisableAchievementCheck"] then
|
||||
EID.Config["DisableStartOfRunWarnings"] = savedEIDConfig["DisableAchievementCheck"]
|
||||
end
|
||||
|
||||
EID.isHidden = EID.Config["InitiallyHidden"]
|
||||
EID.UsedPosition = Vector(EID.Config["XPosition"], EID.Config["YPosition"])
|
||||
EID.Scale = EID.Config["Size"]
|
||||
@@ -1710,12 +1707,11 @@ if EID.MCMLoaded or REPENTANCE then
|
||||
EID:fixDefinedFont()
|
||||
EID:loadFont(EID.modPath .. "resources/font/eid_"..EID.Config["FontType"]..".fnt")
|
||||
end
|
||||
end
|
||||
end
|
||||
EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, OnGameStart)
|
||||
end
|
||||
EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, OnGameStart)
|
||||
|
||||
--Saving Moddata--
|
||||
function SaveGame()
|
||||
--Saving Moddata--
|
||||
function SaveGame()
|
||||
if REPENTANCE then
|
||||
EID.Config["BagContent"] = EID.BoC.BagItems or {}
|
||||
EID.Config["BagFloorContent"] = EID.BoC.RoomQueries or {}
|
||||
@@ -1735,14 +1731,14 @@ if EID.MCMLoaded or REPENTANCE then
|
||||
end
|
||||
EID.Config["CollectedItems"] = EID.CollectedItems
|
||||
EID.Config["PlayerItemInteractions"] = EID.PlayerItemInteractions or {}
|
||||
EID.Config["UsedPillColors"] = EID.UsedPillColors
|
||||
|
||||
EID.SaveData(EID, json.encode(EID.Config))
|
||||
EID:hidePermanentText()
|
||||
EID.itemUnlockStates[CollectibleType.COLLECTIBLE_CUBE_OF_MEAT] = nil
|
||||
EID.itemUnlockStates[CollectibleType.COLLECTIBLE_BOOK_OF_REVELATIONS or CollectibleType.COLLECTIBLE_BOOK_REVELATIONS] = nil
|
||||
end
|
||||
EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame)
|
||||
end
|
||||
EID:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, SaveGame)
|
||||
|
||||
if EID.enableDebug then
|
||||
require("eid_debugging")
|
||||
|
||||
Reference in new issue
Block a user