use sprite color to detect hidden items in alt path

This commit is contained in:
frto027 committed 2021-05-30 18:31:21 +08:00
1 parent 125445bcc1
commit 942ff386d7
1 file changed
+53 -24
+53 -24
View File
@@ -129,8 +129,6 @@ end
-------------------------Handle Sacrifice Room----------------------------- -------------------------Handle Sacrifice Room-----------------------------
function EID:onNewFloor() function EID:onNewFloor()
EID.sacrificeCounter = {} EID.sacrificeCounter = {}
EID.altPathItemCounter = {}
EID.lastHidePosition = {}
end end
EID:AddCallback(ModCallbacks.MC_POST_NEW_LEVEL, EID.onNewFloor) EID:AddCallback(ModCallbacks.MC_POST_NEW_LEVEL, EID.onNewFloor)
@@ -151,31 +149,62 @@ end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
------------------------Handle ALT FLOOR CHOICE---------------------------- ------------------------Handle ALT FLOOR CHOICE----------------------------
if REPENTANCE then
EID.altPathItemCounter = {}
EID.lastHidePosition = {} -- stores lastHide position to store Hide between Morphs / rerolls
function EID:onCollectibleInit(pickup) local questionMarkSprite = Sprite()
if pickup:GetData()["EID_IsAltChoise"] ~= nil then questionMarkSprite:Load("gfx/005.100_collectible.anm2",true)
return questionMarkSprite:ReplaceSpritesheet(1,"gfx/items/collectibles/questionmark.png")
end questionMarkSprite:LoadGraphics()
pickup:GetData()["EID_IsAltChoise"] = false
local player = Isaac.GetPlayer(0) function EID:IsAltChoise(pickup)
local hasBrokenGrasses = player:HasTrinket(TrinketType.TRINKET_BROKEN_GLASSES) local data = pickup:GetData()
local isRepStage = game:GetLevel():GetStageType() >= StageType.STAGETYPE_REPENTANCE if data["EID_IsAltChoise"] ~= nil then
if game:GetRoom():GetType() == RoomType.ROOM_TREASURE and (isRepStage or hasBrokenGrasses) then return data["EID_IsAltChoise"]
local curRoomIndex = game:GetLevel():GetCurrentRoomIndex() end
local lastHidepos = EID.lastHidePosition[curRoomIndex] or nullVector
local curCounter = EID.altPathItemCounter[curRoomIndex] or 0 if not REPENTANCE then
if curCounter == 1 and not player:HasCollectible(CollectibleType.COLLECTIBLE_DADS_NOTE) and ((isRepStage and not hasBrokenGrasses) or (not isRepStage and hasBrokenGrasses)) or (pickup.Position - lastHidepos):Length() < 0.1 then data["EID_IsAltChoise"] = false
pickup:GetData()["EID_IsAltChoise"] = true return false
EID.lastHidePosition[curRoomIndex] = pickup.Position end
end
EID.altPathItemCounter[curRoomIndex] = curCounter + 1 local entitySprite = pickup:GetSprite()
local name
if entitySprite:IsPlaying("Idle") then
name = "Idle"
elseif entitySprite:IsFinished("ShopIdle") then
-- for tainted keeper or shop items
name = "ShopIdle"
else
-- I don't know other animation names, so just ignore them
data["EID_IsAltChoise"] = false
return false
end
questionMarkSprite:SetFrame(name,entitySprite:GetFrame())
-- check some point in entitySprite
for i = -70,0,2 do
local qcolor = questionMarkSprite:GetTexel(Vector(0,i),nullVector,1,1)
local ecolor = entitySprite:GetTexel(Vector(0,i),nullVector,1,1)
if qcolor.Red ~= ecolor.Red or qcolor.Green ~= ecolor.Green or qcolor.Blue ~= ecolor.Blue then
-- it is not same with question mark sprite
data["EID_IsAltChoise"] = false
return false
end end
end end
EID:AddCallback(ModCallbacks.MC_POST_PICKUP_UPDATE, EID.onCollectibleInit, PickupVariant.PICKUP_COLLECTIBLE)
--this may be a question mark, however, we will check it again to ensure it
for j = -3,3,2 do
for i = -71,0,2 do
local qcolor = questionMarkSprite:GetTexel(Vector(j,i),nullVector,1,1)
local ecolor = entitySprite:GetTexel(Vector(j,i),nullVector,1,1)
if qcolor.Red ~= ecolor.Red or qcolor.Green ~= ecolor.Green or qcolor.Blue ~= ecolor.Blue then
data["EID_IsAltChoise"] = false
return false
end
end
end
data["EID_IsAltChoise"] = true
return true
end end
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
@@ -543,7 +572,7 @@ local function onRender(t)
EID:printDescription(descriptionObj) EID:printDescription(descriptionObj)
elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then elseif closest.Variant == PickupVariant.PICKUP_COLLECTIBLE then
--Handle Collectibles --Handle Collectibles
if (EID:hasCurseBlind() and EID.Config["DisableOnCurse"]) or (closest:GetData()["EID_IsAltChoise"] and EID.Config["DisableOnAltPath"] and not closest:ToPickup().Touched) or (game.Challenge == Challenge.CHALLENGE_APRILS_FOOL and EID.Config["DisableOnAprilFoolsChallenge"]) then if (EID:hasCurseBlind() and EID.Config["DisableOnCurse"]) or (EID:IsAltChoise(closest) and EID.Config["DisableOnAltPath"] and not closest:ToPickup().Touched) or (game.Challenge == Challenge.CHALLENGE_APRILS_FOOL and EID.Config["DisableOnAprilFoolsChallenge"]) then
EID:renderQuestionMark() EID:renderQuestionMark()
return return
end end