Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod("Challenge Only Trinkets", 1)
- local game = Game()
- -- save data & custom achievement stuff --
- local json = require("json")
- local GameState = {
- HeartKill = 0,
- SatanKill = 0,
- LambKill = 0,
- Trophy = 0
- }
- local reevaluateCustomAchievements = false -- keeps track if custom achievements should be reevaluated (true if the endboss of the challenge is killed)
- -- effect variants/ achievement papers
- EffectVariant.COSTUM_ACHIEVEMENT_PAPER = Isaac.GetEntityVariantByName("Costum Achievement Paper")
- EffectVariant.COSTUM_ACHIEVEMENT_PAPER_4 = Isaac.GetEntityVariantByName("Costum Achievement Paper 4")
- EffectVariant.COSTUM_ACHIEVEMENT_PAPER_5 = Isaac.GetEntityVariantByName("Costum Achievement Paper 5")
- local Challenges = {
- CHALLENGE_ONLY_TRINKETS = Isaac.GetChallengeIdByName("Trinkets Only!")
- }
- local roomContains = {
- Famine = false,
- Pestilence = false,
- Death = false,
- War = false,
- Conquest = false,
- Fallen = false
- }
- local waitForBeggar = false -- is "true" if a beggar spawned an item
- local collectible ={ -- keeps track which beggar type spawned an item
- Beggar = false,
- DemonBeggar = false,
- KeyBeggar = false,
- BombBeggar = false,
- ShellGame = false
- }
- local morphItem = false -- keeps rtack if an item is already morphed once
- -- trinket pool
- function TrinketPools (item, pool, poolBackwards)
- if pool == nil then
- Isaac.ConsoleOutput("That works")
- end
- -- item = the current item
- -- pool = the current main pool.
- -- poolBackwards = the mirrored version of the current main pool. It is used to check which trinkets the player has
- local maxNum = 0 -- keeps track of the max number of trinkets in the current main table/pool
- local curNum = 0 -- used to count down the places in the current main table/pool
- local player = Isaac.GetPlayer(0)
- local hasEffect = player:GetEffects()
- local roomType = game:GetRoom():GetType()
- -- get maxNum first of the main table/pool
- for a = 1, #pool do
- maxNum = maxNum + 1
- end
- -- now go through very entity in the backwards table
- for b = 1, #poolBackwards do
- -- check if the player has a trinket or a trinket effect from the table
- if player:HasTrinket(poolBackwards[b])
- or hasEffect:HasTrinketEffect(poolBackwards[b]) then
- -- remove it from the main Table
- table.remove(pool, (maxNum - curNum))
- end
- -- increase curNum so that the position to remove gets moved by 1 in the next cycle
- curNum = curNum +1
- end
- -- spawn trinket
- if pool[1] ~= nil then -- the table which got check isn't empty yet
- local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_SMELTER)
- local pickTrinket = rng:RandomInt(#pool)
- -- morph the item to the picked trinket
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, pool[pickTrinket], false)
- else
- -- the table is already empty. Spawn the error trinket
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_ERROR, false)
- Isaac.ConsoleOutput("That's an error for you")
- end
- end
- function Mod:onStart()
- GameState = json.decode(Isaac.LoadModData(Mod)) -- decodes the data from the savefile (returns a lua table)
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PLAYER_INIT, Mod.onStart)
- function Mod:OnUpdate(player)
- local roomType = game:GetRoom():GetType()
- -- do possible trophy spawning
- -- costum achievements
- if reevaluateCustomAchievements == true then
- if game.Challenge == Challenges.CHALLENGE_ONLY_TRINKETS then
- -- first the achievements gained through Mom's Heart
- -- check for current gamestates
- if GameState.HeartKill == 2 then -- this should only proc once
- -- Isaac.ConsoleOutput("Yeeah")
- -- spawn the achievement paper
- local achievement = Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.COSTUM_ACHIEVEMENT_PAPER, 0, Vector(325, 275), Vector(0,0), player):ToEffect()
- -- achievement:GetSprite():ReplaceSpritesheet(3, "gfx/effects/first_challenge_won.png")
- -- increase the trophy counter
- GameState.Trophy = GameState.Trophy + 1
- -- check if the trophy should be spawned
- if GameState.Trophy == 2 then -- the 2 challenges have been beaten
- -- spawn the achievement paper
- -- Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.COSTUM_ACHIEVEMENT_PAPER, 0, Vector(325, 275), Vector(0,0), player)
- end
- reevaluateCustomAchievements = false
- elseif GameState.HeartKill == 10 then -- procs after 5 kills
- -- spawn the achievement paper
- -- Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.COSTUM_ACHIEVEMENT_PAPER_4, 0, Vector(325, 275), Vector(0,0),, player)
- reevaluateCustomAchievements = false
- end
- -- check if the player has beaten the Lamb during the challenge
- if GameState.LambKill == 2 then -- this should only proc once
- -- spawn the achievement paper
- -- Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.COSTUM_ACHIEVEMENT_PAPER_5, 0, Vector(325, 275), Vector(0,0), player):ToEffect()
- reevaluateCustomAchievements = false
- end
- elseif game.Challenge == Challenges.CHALLENGE_ONLY_TRINKETS then -- hard mode!... later
- -- check for current gamestates
- -- achievement gained through Satan
- if GameState.SatanKill == 1 then
- -- spawn the achievement paper
- -- Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.COSTUM_ACHIEVEMENT_PAPER, 0, Vector(325, 275), Vector(0,0), player)
- -- increase the trophy counter
- GameState.Trophy = GameState.Trophy + 1
- -- check if the trophy should be spawned
- if GameState.Trophy == 2 then -- the 2 challenges have been beaten
- -- spawn the achievement paper
- -- Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.COSTUM_ACHIEVEMENT_PAPER, 0, Vector(325, 275), Vector(0,0), player)
- end
- end
- reevaluateCustomAchievements = false
- Isaac.ConsoleOutput("Stop it!!! ")
- end
- end
- -- check if the player plays the challenge
- if game.Challenge == Challenges.CHALLENGE_ONLY_TRINKETS then
- -- go through all room entities
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities.Type == EntityType.ENTITY_SLOT then
- if entities.Variant == 4 then -- normal beggar
- if entities:GetSprite():IsEventTriggered("Prize") then
- Isaac.ConsoleOutput("Pay Prize")
- waitForBeggar = true
- collectible.Beggar = true
- end
- elseif entities.Variant == 5 then -- demon beggar
- if entities:GetSprite():IsEventTriggered("Prize") then
- Isaac.ConsoleOutput("Pay Prize")
- waitForBeggar = true
- collectible.DemonBeggar = true
- end
- elseif entities.Variant == 6 then -- shell game
- if entities:GetSprite():IsEventTriggered("Prize") then
- Isaac.ConsoleOutput("Pay Prize")
- waitForBeggar = true
- collectible.ShellGame = true
- end
- elseif entities.Variant == 7 then -- key beggar
- if entities:GetSprite():IsEventTriggered("Prize") then
- Isaac.ConsoleOutput("Pay Prize")
- waitForBeggar = true
- collectible.KeyBeggar = true
- end
- elseif entities.Variant == 9 then -- bomb beggar
- if entities:GetSprite():IsEventTriggered("Prize") then
- Isaac.ConsoleOutput("Pay Prize")
- waitForBeggar = true
- collectible.BombBeggar = true
- end
- end
- end
- if entities.Type == EntityType.ENTITY_PICKUP then
- if entities.Variant == PickupVariant.PICKUP_COLLECTIBLE then -- look for items
- local item = entities
- -- check if a beggar spawned an item
- if waitForBeggar == true -- a beggar spawned an item
- and morphItem == false then -- item hasn't morphed yet
- if collectible.Beggar == true then
- -- get the beggar trinket "pool"
- local pool = {1,24,49,50,51,52,126} -- mostly the penny trinkets
- local poolBackwards = {126,52,51,50,49,24,1}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- waitForBeggar = false
- collectible.Beggar = false
- morphItem = true -- the item is already morphed
- elseif collectible.DemonBeggar == true then
- -- get the devil beggar trinket "pool"
- local pool = {61,111} -- Left Hand, Bloody Crown
- local poolBackwards = {111,61}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- waitForBeggar = false
- collectible.DemonBeggar = false
- morphItem = true -- the item is already morphed
- elseif collectible.ShellGame == true then
- Isaac.ConsoleOutput("Shell Game")
- -- get the shell game trinket "pool"
- local pool = {2,93} -- Petrified Poop, Used Diaper
- local poolBackwards = {93,2}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- waitForBeggar = false
- collectible.ShellGame = false
- morphItem = true -- the item is already morphed
- elseif collectible.KeyBeggar == true then
- -- get the key master trinket "pool"
- local pool = {19,36,83,124} -- key related trinkets
- local poolBackwards = {124,83,36,19}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- waitForBeggar = false
- collectible.KeyBeggar = false
- morphItem = true -- the item is already morphed
- elseif collectible.BombBeggar == true then
- -- get the bomb beggar trinket "pool"
- local pool = {71} -- Bob's Bladder / bomb related trinkets
- -- morph the item to the picked trinket
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, pool, false)
- waitForBeggar = false
- collectible.KeyBeggar = false
- morphItem = true -- the item is already morphed
- end
- end
- -- check for the SpawnerType (if possible) for stuff like beggars, slots, the player etc.
- if item.SpawnerType == EntityType.ENTITY_SLOT then
- -- check for the spawner variant (to differ between the slots)
- if item.SpawnerVariant == 1 then -- Slot Machine (doesn't work)
- -- get the slot machine trinket "pool"
- local pool = {121} -- while it makes no sense for one trinket [...]
- local poolBackwards = {121} -- [...] it allows to extend the trinket pool more easily
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards) -- gives the item itself and the both pools into the pool function
- elseif item.SpawnerVariant == 2 then -- Blood Donation Machine
- -- get the blood donation machine trinket "pool"
- local pool = {34} -- Child's Heart
- local poolBackwards = {34}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif item.SpawnerVariant == 3 then -- Fortune Teller
- -- get the fortune teller trinket "pool"
- local pool = {102} -- Fragmented Card
- local poolBackwards = {102}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- -- elseif item.SpawnerVariant == 5 then -- Devil Beggar
- -- elseif item.SpawnerVariant == 6 then -- Shell Game
- -- elseif item.SpawnerVariant == 7 then -- Key Master (Key Beggar)
- -- nothing for SpawnerVariant 8
- -- elseif item.SpawnerVariant == 9 then -- Bomb Beggar
- -- nothing for SpawnerVariant 10
- -- nothing for SpawnerVariant 11
- elseif item.SpawnerVariant == 12 then -- Dressing Table
- -- get the dressing table trinket "pool"
- local pool = {16,17,44}
- local poolBackwards = {44,17,16}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- end
- elseif item.SpawnerType == EntityType.ENTITY_PICKUP then
- if item.SpawnerVariant == PickupVariant.PICKUP_LOCKEDCHEST then -- Golden Chest
- -- get the golden chest trinket "pool"
- local pool = {29,54,57}
- local poolBackwards = {57,54,29}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- morphItem = true -- the item is already morphed
- elseif item.SpawnerVariant == PickupVariant.PICKUP_REDCHEST then
- -- get the red chest trinket "pool"
- local pool = {40,43,80,107,128}
- local poolBackwards = {128,107,80,43,40}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- morphItem = true -- the item is already morphed
- elseif item.SpawnerVariant == PickupVariant.PICKUP_ETERNALCHEST then
- -- get the eternal/holy chest trinket "pool"
- local pool = {7,18,38,85,87,92,100,110,121} -- pool is shared with the angel room
- local poolBackwards = {121,110,100,92,87,85,38,18,7}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- morphItem = true -- the item is already morphed
- end
- elseif item.SpawnerType == EntityType.ENTITY_PLAYER then
- -- for item spawning trinkets/effects (inlucdes Lunch Bag and Wish Bone)
- -- needs thought tho
- end
- -- Look for spcific items via the CollectibleType
- if (item.SubType == CollectibleType.COLLECTIBLE_LUMP_OF_COAL -- spawned from the Krampus fight
- or item.SubType == CollectibleType.COLLECTIBLE_KRAMPUS_HEAD) then
- -- possible needs room type?
- -- get krampu's trinket pool
- local pool = {35,95}
- local poolBackwards = {95,35}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- morphItem = true -- the item is already morphed
- elseif (item.SubType == CollectibleType.COLLECTIBLE_CUBE_OF_MEAT -- spawned by the horesman fight
- or item.SubType == CollectibleType.COLLECTIBLE_BALL_OF_BANDAGES
- or item.SubType == CollectibleType.COLLECTIBLE_WHITE_PONY) then -- spawned by Conquest
- -- get room data to see which horseman room it is
- if roomType == RoomType.ROOM_BOSS then -- first check the room type
- -- if roomData.IsFaminesRoom == true then
- if roomContains.Famine == true then
- -- morph the item into a locust. This will always happen regardless if the player has it or not
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_FAMINE, false)
- -- elseif roomData.IsPestilencesRoom == true then
- elseif roomContains.Pestilence == true then
- -- morph the item into a locust. This will always happen regardless if the player has it or not
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_PESTILENCE, false)
- -- elseif roomData.IsDeathsRoom == true then
- elseif roomContains.Death == true then
- -- morph the item into a locust. This will always happen regardless if the player has it or not
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_DEATH, false)
- -- elseif roomData.IsWarsRoom == true then
- elseif roomContains.War == true then
- -- morph the item into a locust. This will always happen regardless if the player has it or not
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_WRATH, false)
- -- elseif roomData.IsConquestsRoom == true then
- elseif roomContains.Conquest == true then
- -- morph the item into a locust. This will always happen regardless if the player has it or not
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_CONQUEST, false)
- end
- end
- morphItem = true -- the item is already morphed
- elseif (item.SubType == CollectibleType.COLLECTIBLE_POLARIOD -- spawned from the Krampus fight
- or item.SubType == CollectibleType.COLLECTIBLE_NEGATIVE) then
- -- get mom's "pool"
- local pool = {69} -- Faded Polariod
- -- morph the item to the picked trinket
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, pool, false)
- morphItem = true -- the item is already morphed
- -- elseif item.SubType == CollectibleType.COLLECTIBLE_SKATOLE then -- shell game
- -- get the shell game trinket "pool"
- -- local pool = {2,93} -- Petrified Poop, Used Diaper
- -- local poolBackwards = {93,2}
- -- trinket pool stuff
- -- TrinketPools(item, pool, poolBackwards)
- elseif item.SubType == CollectibleType.COLLECTIBLE_DOLLAR then -- slot machine
- -- get the slot machine trinket "pool"
- local pool = {121}
- -- morph the item to the picked trinket
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, pool, false)
- morphItem = true -- the item is already morphed
- elseif item.SubType == CollectibleType.COLLECTIBLE_CRYSTAL_BALL then -- fortune teeler
- -- get the fortune teller trinket "pool"
- local pool = {102} -- Fragmented Card
- -- morph the item to the picked trinket
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, pool, false)
- morphItem = true -- the item is already morphed
- end
- if waitForBeggar == false -- the item wasn't spawned by a beggar
- and morphItem == false then -- item hasn't morphed yet
- -- go through the different room types
- if roomType == RoomType.ROOM_TREASURE
- or roomType == RoomType.ROOM_DUNGEON then
- -- get the treasure room pool
- local pool = {5,8,14,16,25,30,31,33,53,54,55,57,60,68,70,71,77,81,86,90,93,95,97,98,99,127}
- local poolBackwards = {127,99,98,97,95,93,90,86,81,77,71,70,68,60,57,55,54,53,33,31,30,25,16,14,8,5}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- -- if item:GetData().ThereIsOptions == nil then
- -- item:GetData().ThereIsOptions = true
- -- end
- elseif roomType == RoomType.ROOM_SHOP
- or roomType == RoomType.ROOM_BLACK_MARKET then
- -- get the shop room pool
- local pool = {3,29,34,36,41,44,59,62,63,72,73,74,76,78,82,89,94,103,106,109,120,125}
- local poolBackwards = {125,120,109,106,103,94,89,82,78,76,74,73,72,63,62,59,44,41,36,34,29,3}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- -- asign data to the entity to make it a shop item later down the line
- item:GetData().ShopTrinket = true
- item:GetData().NeedsNewPrize = true
- elseif roomType == RoomType.ROOM_LIBRARY then
- -- get the library room pool
- local pool = {9,10,11,12,21,23,26,27,45,48,64,65,66,96,102}
- local poolBackwards = {102,96,66,65,64,48,45,27,26,23,21,12,11,10,9}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif roomType == RoomType.ROOM_BOSS
- or roomType == RoomType.ROOM_MINIBOSS then
- if roomContains.Famine == true then -- the boss room contains the Fallen
- -- get the devil room pool
- local pool = {13,17,20,22,35,80,111,118}
- local poolBackwards = {118,111,80,35,22,20,17,13}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- else
- -- get the boss room pool
- local pool = {37,39,42,46,58,101,104,105,108,119}
- local poolBackwards = {119,108,105,104,101,58,46,42,39,37}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- end
- elseif roomType == RoomType.ROOM_SECRET
- or roomType == RoomType.ROOM_SUPERSECRET then
- -- get the secret room pool
- local pool = {15,28,32,83,84,91}
- local poolBackwards = {91,84,83,32,28,15}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif roomType == RoomType.ROOM_DEVIL then
- -- get the secret room pool
- local pool = {13,17,20,22,35,80,111,118}
- local poolBackwards = {118,111,80,35,22,20,17,13}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif roomType == RoomType.ROOM_ANGEL
- or roomType == RoomType.ROOM_SACRIFICE then
- -- get the secret room pool
- local pool = {7,18,38,85,87,92,100,110,121}
- local poolBackwards = {121,110,100,92,87,85,38,18,7}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif roomType == RoomType.ROOM_CURSE then
- -- get the secret room pool
- local pool = {40,43,61,107,128}
- local poolBackwards = {128,107,61,43,40}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif roomType == RoomType.ROOM_ISAACS
- or roomType == RoomType.ROOM_BARREN then
- -- get the secret room pool
- local pool = {8,46,54,63,67,99}
- local poolBackwards = {99,67,63,54,46,8}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif roomType == RoomType.ROOM_CHALLENGE then
- -- get the secret room pool
- local pool = {6,40,58}
- local poolBackwards = {58,40,6}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif roomType == RoomType.ROOM_ERROR then
- -- get the secret room pool
- local pool = {4,6,67,75,79,92}
- local poolBackwards = {92,79,75,67,6,4}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif roomType == RoomType.ROOM_BOSSRUSH
- or roomType == RoomType.ROOM_DEFAULT then
- Isaac.ConsoleOutput("s,rjzgqp")
- -- morph the item into a random trinket. This will always happen regardless if the player has it or not
- item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_NULL, false)
- end
- end
- morphItem = false
- elseif entities.Variant == PickupVariant.PICKUP_TRINKET then -- look for trinkets
- local trinket = entities
- local sprite = trinket:GetSprite()
- local data = trinket:GetData()
- -- check for There's Options trinkets
- if roomType == RoomType.ROOM_TREASURE then
- if (player.Position - trinket.Position):Length() < player.Size + trinket.Size then
- -- Isaac.ConsoleOutput("Collect") -- gets collected
- if data.Picked == nil -- hasn't been picked up yet
- and data.ThereIsOptions == nil then -- one of the trinkets where you have a choice
- -- Isaac.ConsoleOutput("Yeahhh")
- data.Picked = true
- data.ThereIsOptions = false
- -- look for the other There Is Options trinket
- for _, entitis in pairs(Isaac.GetRoomEntities()) do
- if entitis.Type == EntityType.ENTITY_PICKUP
- and entitis.Variant == PickupVariant.PICKUP_TRINKET
- and entitis.SpawnerType ~= EntityType.ENTITY_PLAYER -- the trinket isn't the one dropped by the player
- and entitis:GetData().Picked == nil
- and entitis ~= trinket then -- isn't the trinket which is picked up
- entitis:Remove() -- remove the other trinket
- end
- end
- end
- end
- -- check if the trinket is in the shop
- elseif roomType == RoomType.ROOM_SHOP then
- local price = 10
- if data.ShopTrinket == true then -- it's a shop trinket
- if data.NeedsNewPrize == true then -- is just spawned
- -- give it a new cost/price
- trinket:ToPickup().Price = price
- data.Price = price
- -- doesn't need a new price anymore
- data.NeedsNewPrize = false
- end
- end
- elseif roomType == RoomType.ROOM_DEVIL then
- if (player.Position - trinket.Position):Length() < player.Size + trinket.Size then
- -- if sprite:IsPlaying("Collect") -- gets collected
- if data.Picked == nil
- and trinket.SpawnerType ~= EntityType.ENTITY_PLAYER then -- the trinket isn't the one dropped by the player -- hasn't been picked up yet
- player:TakeDamage(1, 0, EntityRef(player), 1)
- -- Isaac.ConsoleOutput("Yeahhh")
- data.Picked = true
- end
- end
- end
- end
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.OnUpdate)
- function Mod:onAchievementPopup(effect)
- local sprite = effect:GetSprite()
- effect.RenderZOffset = 4900 -- 1300 is enough for most obstacles, but not for the player
- if not sprite:Play("Appear")
- and effect:GetData().Init == nil then
- -- Isaac.ConsoleOutput("Appear ")
- sprite:Play("Appear")
- effect:GetData().Init = true
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_EFFECT_INIT, Mod.onAchievementPopup, EffectVariant.COSTUM_ACHIEVEMENT_PAPER)
- function Mod:onAchievementUpdate(effect)
- local sprite = effect:GetSprite()
- local data = effect:GetData()
- effect.RenderZOffset = 4900
- -- sprite:ReplaceSpritesheet(3, "gfx/effects/first_challenge_won.png")
- if sprite:IsFinished("Appear") then
- -- Isaac.ConsoleOutput("Idle ")
- sprite:Play("Idle", true)
- end
- if sprite:IsFinished("Idle") then
- -- Isaac.ConsoleOutput("Go away ")
- sprite:Play("Dissapear", false)
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_EFFECT_UPDATE, Mod.onAchievementUpdate, EffectVariant.COSTUM_ACHIEVEMENT_PAPER)
- function Mod.onNewRoom(_)
- local player = Isaac.GetPlayer(0)
- local roomType = game:GetRoom():GetType()
- -- check if the player plays the challenge
- if game.Challenge == Challenges.CHALLENGE_ONLY_TRINKETS then
- if game:GetRoom():IsFirstVisit() == true then
- -- Isaac.ConsoleOutput("Roooom")
- if roomType == RoomType.ROOM_TREASURE then
- -- check for items
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities.Type == EntityType.ENTITY_PICKUP then
- if entities.Variant == PickupVariant.PICKUP_COLLECTIBLE then -- it's an item!
- local item = entities
- -- get the treasure room pool
- local pool = {5,8,14,16,25,30,31,33,53,54,55,57,60,68,70,71,77,81,86,90,93,95,97,98,99,127}
- local poolBackwards = {127,99,98,97,95,93,90,86,81,77,71,70,68,60,57,55,54,53,33,31,30,25,16,14,8,5}
- -- trinket pool stuff
- TrinketPools(item, pool, poolBackwards)
- elseif entities.Variant == PickupVariant.PICKUP_TRINKET then -- it's a trinket!
- end
- end
- end
- elseif roomType == RoomType.ROOM_BOSS then
- -- look for the boss in the boss room
- for _, entitis in pairs(Isaac.GetRoomEntities()) do
- if entitis.Type == EntityType.ENTITY_FAMINE then
- if roomContains.Famine == false then
- roomContains.Famine = true
- end
- elseif entitis.Type == EntityType.ENTITY_PESTILENCE then
- if roomContains.Pestilence == false then
- roomContains.Pestilence = true
- end
- elseif entitis.Type == EntityType.ENTITY_WAR then
- if entitis.Variant == 1 then -- it's Conquest
- if roomContains.Conquest == false then
- roomContains.Conquest = true
- end
- else -- it's War
- if roomContains.War == false then
- roomContains.War = true
- end
- end
- elseif entitis.Type == EntityType.ENTITY_DEATH then
- if roomContains.Death == false then
- roomContains.Death = true
- end
- elseif entitis.Type == EntityType.ENTITY_FALLEN then
- if roomContains.Fallen == false then
- roomContains.Fallen = true
- end
- else
- -- it is none of them so the variables should be reset to false
- roomContains.Famine = false
- roomContains.Pestilence = false
- roomContains.War = false
- roomContains.Death = false
- roomContains.Conquest = false
- roomContains.Fallen = false
- end
- end
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_NEW_ROOM, Mod.onNewRoom)
- function Mod:onHeartKill(entity)
- -- Isaac.ConsoleOutput("Heart?")
- local data = entity:GetData()
- if entity:IsDead() -- is it dead?
- and data.Died == nil then -- did it already die?
- data.Died = true -- well now it is dead
- if game.Challenge == Challenges.CHALLENGE_ONLY_TRINKETS then
- -- increase the kill counter
- if data.CounterUpdate == nil then
- GameState.HeartKill = GameState.HeartKill + 1
- -- reevaluate the custom achievements
- reevaluateCustomAchievements = true
- -- Isaac.ConsoleOutput("Diiiiie!!")
- Isaac.SaveModData(Mod, json.encode(GameState)) -- encodes the data
- data.CounterUpdate = true
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_NPC_UPDATE, Mod.onHeartKill, EntityType.ENTITY_MOMS_HEART)
- -- Mod:AddCallback(ModCallbacks.MC_NPC_UPDATE, Mod.onHeartKill, EntityType.ENTITY_IT_LIVES)
- function Mod:onSatanKill(entity)
- local data = entity:GetData()
- if entity:IsDead() -- is it dead?
- and not data.Died then -- did it already die?
- data.Died = true -- well now it is dead
- if game.Challenge == Challenges.CHALLENGE_ONLY_TRINKETS then -- will be replaced with hard
- -- increase the kill counter
- GameState.HeartKill = GameState.HeartKill + 1 -- in case the player skips the second womb floor
- -- reevaluate the custom achievements
- reevaluateCustomAchievements = true
- Isaac.SaveModData(Mod, json.encode(GameState)) -- encodes the data
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_NPC_UPDATE, Mod.onSatanKill, EntityType.ENTITY_SATAN)
- function Mod:onExit(save)
- Isaac.SaveModData(Mod, json.encode(GameState)) -- encodes the data
- end
- Mod:AddCallback(ModCallbacks.MC_POST_NEW_LEVEL, Mod.onExit)
- Mod:AddCallback(ModCallbacks.MC_PRE_GAME_EXIT, Mod.onExit)
- Mod:AddCallback(ModCallbacks.MC_POST_GAME_END, Mod.onExit)
Advertisement
Add Comment
Please, Sign In to add comment