Fixed Pills not being considered for Transformation progression
This commit is contained in:
1 parent
fd6507bac7
commit
0f714135f1
2 files changed
+38
-23
No files matched your search
+16
-12
@@ -1474,13 +1474,17 @@ function EID:evaluateTransformationProgress(transformation)
|
|||||||
local eType, eVariant, eSubType = entityString:match("([^.]+).([^.]+).([^.]+)")
|
local eType, eVariant, eSubType = entityString:match("([^.]+).([^.]+).([^.]+)")
|
||||||
if tonumber(eType) == EntityType.ENTITY_PICKUP then
|
if tonumber(eType) == EntityType.ENTITY_PICKUP then
|
||||||
if tonumber(eVariant) == PickupVariant.PICKUP_COLLECTIBLE then
|
if tonumber(eVariant) == PickupVariant.PICKUP_COLLECTIBLE then
|
||||||
if EID.TouchedActiveItems[i][tonumber(eSubType)] then
|
if EID.PlayerItemInteractions[i].actives[tostring(eSubType)] then
|
||||||
EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + EID.TouchedActiveItems[i][tonumber(eSubType)]
|
EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + EID.PlayerItemInteractions[i].actives[tostring(eSubType)]
|
||||||
else
|
else
|
||||||
EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + player:GetCollectibleNum(eSubType, true)
|
EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + player:GetCollectibleNum(eSubType, true)
|
||||||
end
|
end
|
||||||
elseif tonumber(eVariant) == PickupVariant.PICKUP_TRINKET and player:HasTrinket(eSubType) then
|
elseif tonumber(eVariant) == PickupVariant.PICKUP_TRINKET and player:HasTrinket(eSubType) then
|
||||||
EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + 1
|
EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + 1
|
||||||
|
elseif tonumber(eVariant) == PickupVariant.PICKUP_PILL then
|
||||||
|
if EID.PlayerItemInteractions[i].pills[tostring(eSubType)] then
|
||||||
|
EID.TransformationProgress[i][transformation] = EID.TransformationProgress[i][transformation] + EID.PlayerItemInteractions[i].pills[tostring(eSubType)]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -1489,27 +1493,27 @@ function EID:evaluateTransformationProgress(transformation)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Given a transformation identifier, itterate over every player and count the number of items they have which count towards that transformation
|
-- Given a transformation identifier, itterate over every player and count the number of items they have which count towards that transformation
|
||||||
EID.TouchedActiveItems = {}
|
EID.PlayerItemInteractions = {}
|
||||||
function EID:evaluateQueuedItems()
|
function EID:evaluateQueuedItems()
|
||||||
for i = 0, game:GetNumPlayers() - 1 do
|
for i = 0, game:GetNumPlayers() - 1 do
|
||||||
local player = Isaac.GetPlayer(i)
|
local player = Isaac.GetPlayer(i)
|
||||||
if player.QueuedItem then
|
if player.QueuedItem then
|
||||||
if not EID.TouchedActiveItems[i] then
|
if not EID.PlayerItemInteractions[i] then
|
||||||
EID.TouchedActiveItems[i] = {LastTouch = 0}
|
EID.PlayerItemInteractions[i] = {LastTouch = 0, actives = {}, pills = {}}
|
||||||
end
|
end
|
||||||
if EID.TouchedActiveItems[i].LastTouch + 45 >= game:GetFrameCount() and player.QueuedItem.Item then
|
if EID.PlayerItemInteractions[i].LastTouch + 45 >= game:GetFrameCount() and player.QueuedItem.Item then
|
||||||
return
|
return
|
||||||
else
|
else
|
||||||
EID.TouchedActiveItems[i].LastTouch = 0
|
EID.PlayerItemInteractions[i].LastTouch = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
if not player.QueuedItem.Touched and player.QueuedItem.Item and player.QueuedItem.Item.Type == ItemType.ITEM_ACTIVE then
|
if not player.QueuedItem.Touched and player.QueuedItem.Item and player.QueuedItem.Item.Type == ItemType.ITEM_ACTIVE then
|
||||||
local itemID = player.QueuedItem.Item.ID
|
local itemID = tostring(player.QueuedItem.Item.ID)
|
||||||
if not EID.TouchedActiveItems[i][itemID] then
|
if not EID.PlayerItemInteractions[i].actives[itemID] then
|
||||||
EID.TouchedActiveItems[i][itemID] = 0
|
EID.PlayerItemInteractions[i].actives[itemID] = 0
|
||||||
end
|
end
|
||||||
EID.TouchedActiveItems[i][itemID] = EID.TouchedActiveItems[i][itemID] + 1
|
EID.PlayerItemInteractions[i].actives[itemID] = EID.PlayerItemInteractions[i].actives[itemID] + 1
|
||||||
EID.TouchedActiveItems[i].LastTouch = game:GetFrameCount()
|
EID.PlayerItemInteractions[i].LastTouch = game:GetFrameCount()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1473,7 +1473,7 @@ EID:AddCallback(ModCallbacks.MC_POST_RENDER, onRender)
|
|||||||
local function OnGameStartGeneral(_,isSave)
|
local function OnGameStartGeneral(_,isSave)
|
||||||
EID:buildTransformationTables()
|
EID:buildTransformationTables()
|
||||||
if not isSave then
|
if not isSave then
|
||||||
EID.TouchedActiveItems = {}
|
EID.PlayerItemInteractions = {}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, OnGameStartGeneral)
|
EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, OnGameStartGeneral)
|
||||||
@@ -1482,17 +1482,28 @@ EID:AddCallback(ModCallbacks.MC_POST_GAME_STARTED, OnGameStartGeneral)
|
|||||||
local function OnUseD4(_, _, _, player)
|
local function OnUseD4(_, _, _, player)
|
||||||
local playerID = EID:getPlayerID(player)
|
local playerID = EID:getPlayerID(player)
|
||||||
for i = 0, 3 do
|
for i = 0, 3 do
|
||||||
local itemID = player:GetActiveItem(i)
|
local itemID = tostring(player:GetActiveItem(i))
|
||||||
if itemID ~= 0 then
|
if itemID ~= "0" then
|
||||||
if not EID.TouchedActiveItems[playerID][itemID] then
|
if not EID.PlayerItemInteractions[playerID].actives[itemID] then
|
||||||
EID.TouchedActiveItems[playerID][itemID] = 0
|
EID.PlayerItemInteractions[playerID].actives[itemID] = 0
|
||||||
end
|
end
|
||||||
EID.TouchedActiveItems[playerID][itemID] = EID.TouchedActiveItems[playerID][itemID] + 1
|
EID.PlayerItemInteractions[playerID].actives[itemID] = EID.PlayerItemInteractions[playerID].actives[itemID] + 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
EID:AddCallback(ModCallbacks.MC_USE_ITEM, OnUseD4, CollectibleType.COLLECTIBLE_D4)
|
EID:AddCallback(ModCallbacks.MC_USE_ITEM, OnUseD4, CollectibleType.COLLECTIBLE_D4)
|
||||||
|
|
||||||
|
function EID:OnUsePill(pillEffectID, player)
|
||||||
|
local playerID = EID:getPlayerID(player)
|
||||||
|
local effectID = tostring(pillEffectID+1)
|
||||||
|
if not EID.PlayerItemInteractions[playerID].pills[effectID] then
|
||||||
|
EID.PlayerItemInteractions[playerID].pills[effectID] = 0
|
||||||
|
end
|
||||||
|
EID.PlayerItemInteractions[playerID].pills[effectID] = EID.PlayerItemInteractions[playerID].pills[effectID] + 1
|
||||||
|
end
|
||||||
|
EID:AddCallback(ModCallbacks.MC_USE_PILL, EID.OnUsePill)
|
||||||
|
|
||||||
|
|
||||||
-- only save and load configs when using MCM. Otherwise Config file changes arent valid
|
-- only save and load configs when using MCM. Otherwise Config file changes arent valid
|
||||||
if EID.MCMLoaded or REPENTANCE then
|
if EID.MCMLoaded or REPENTANCE then
|
||||||
local json = require("json")
|
local json = require("json")
|
||||||
@@ -1503,7 +1514,7 @@ if EID.MCMLoaded or REPENTANCE then
|
|||||||
["FlipItemPositions"] = true,
|
["FlipItemPositions"] = true,
|
||||||
["AbsorbedItems"] = true,
|
["AbsorbedItems"] = true,
|
||||||
["CollectedItems"] = true,
|
["CollectedItems"] = true,
|
||||||
["TouchedActiveItems"] = true,
|
["PlayerItemInteractions"] = true,
|
||||||
}
|
}
|
||||||
--------------------------------
|
--------------------------------
|
||||||
--------Handle Savadata---------
|
--------Handle Savadata---------
|
||||||
@@ -1521,15 +1532,15 @@ if EID.MCMLoaded or REPENTANCE then
|
|||||||
EID.SaveGame[EID.Config["SaveGameNumber"]].ItemNeedsPickup[id] = nil
|
EID.SaveGame[EID.Config["SaveGameNumber"]].ItemNeedsPickup[id] = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
EID.TouchedActiveItems = {}
|
EID.PlayerItemInteractions = {}
|
||||||
if isSave then
|
if isSave then
|
||||||
-- JSON saves integer table keys as strings. we need to transform them back...
|
-- JSON saves integer table keys as strings. we need to transform them back...
|
||||||
for playerID, data in pairs(savedEIDConfig["TouchedActiveItems"] or {}) do
|
for playerID, data in pairs(savedEIDConfig["PlayerItemInteractions"] or {}) do
|
||||||
local convertedData = {}
|
local convertedData = {}
|
||||||
for key, value in pairs(data) do
|
for key, value in pairs(data) do
|
||||||
convertedData[tonumber(key) or key] = value
|
convertedData[tonumber(key) or key] = value
|
||||||
end
|
end
|
||||||
EID.TouchedActiveItems[tonumber(playerID)] = convertedData
|
EID.PlayerItemInteractions[tonumber(playerID)] = convertedData
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1618,7 +1629,7 @@ if EID.MCMLoaded or REPENTANCE then
|
|||||||
EID.Config["FlipItemPositions"] = flipItemTable or {}
|
EID.Config["FlipItemPositions"] = flipItemTable or {}
|
||||||
end
|
end
|
||||||
EID.Config["CollectedItems"] = EID.CollectedItems
|
EID.Config["CollectedItems"] = EID.CollectedItems
|
||||||
EID.Config["TouchedActiveItems"] = EID.TouchedActiveItems or {}
|
EID.Config["PlayerItemInteractions"] = EID.PlayerItemInteractions or {}
|
||||||
|
|
||||||
EID.SaveData(EID, json.encode(EID.Config))
|
EID.SaveData(EID, json.encode(EID.Config))
|
||||||
EID:hidePermanentText()
|
EID:hidePermanentText()
|
||||||
|
|||||||
Reference in new issue
Block a user