Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod("betterkeybum", 1)
- local game = Game()
- -- BumsKeys = 0 -- gobal variable which keeps track on how many keys Key Bum picked up
- local BumsKeys = 0
- local DadsKey = nil
- local KBumExtra = 0
- function Mod:onInit(player)
- if game:GetFrameCount() == 1 then
- -- spawn in if you want to
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_COLLECTIBLE, 17, Vector(100, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_COLLECTIBLE, 175, Vector(150, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_COLLECTIBLE, 199, Vector(200, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_COLLECTIBLE, 343, Vector(250, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_COLLECTIBLE, 388, Vector(300, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_COLLECTIBLE, 416, Vector(350, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_COLLECTIBLE, 286, Vector(400, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_TRINKET, 19, Vector(450, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_TRINKET, 36, Vector(500, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_TRINKET, 83, Vector(100, 150), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_CARD, Card.RUNE_JERA, Vector(150, 150), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_CARD, Card.RUNE_BLACK, Vector(200, 150), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupType.PICKUP_COLLECTIBLE, 139, Vector(250, 150), Vector(0,0), player)
- -- check for Dads Key
- DadsKey = false
- BumsKeys = 0
- Mod:SaveData(BumsKeys)
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onInit)
- local function SkeletonKey(KBum, keyone)
- local player = Isaac.GetPlayer(0)
- -- tables which contain the items Key Bum can pull from
- -- Item tables
- local SkeItemPool = {175,199,343} -- 175 = Dads Key, 199 = Moms Key, 343 = Latch Key
- local BackItemPool = {175,199,343}
- -- Trinket tables
- local SkeTrinketPool = {19,36,83} -- 19 = Paper Clip, 36 = Rusted Key, 83 = Store Key
- local BackTrinketPool = {19,36,83}
- local trinketCounter = 0 -- keeps track on how many key themed trinkets you have
- if player:HasCollectible(17) then -- 17 = Skeleton Key
- if keyone < 5 then
- -- check if the player has an item and remove it from the table. It is removed from the "pool"
- if player:HasCollectible(343) then
- table.remove(SkeItemPool, 3)
- end
- if player:HasCollectible(199) then
- table.remove(SkeItemPool, 2)
- end
- if DadsKey == true then
- table.remove(SkeItemPool, 1)
- end
- -- make sure the table is not empty
- if SkeItemPool[1] ~= 175
- and SkeItemPool[1] ~= 199
- and SkeItemPool[1] ~= 343 then
- -- Breakfasting, if the table is empty
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- local pickitem = math.random(#SkeItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, SkeItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if SkeItemPool[pickitem] == 175 then
- DadsKey = true
- end
- -- after spawning the Item you have to reset the table
- SkeItemPool = BackItemPool
- end
- else
- -- check if the player has a trinket and remove it from the table. It is removed from the "pool"
- if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
- table.remove(SkeTrinketPool, 3)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
- table.remove(SkeTrinketPool, 2)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
- or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
- table.remove(SkeTrinketPool, 1)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- -- make sure that the player doesn't have two key themend trinkets
- if trinketCounter >= 2 then
- -- if the player has two key trinkets, then Key Bum will spawn an item
- if player:HasCollectible(343) then
- table.remove(SkeItemPool, 3)
- end
- if player:HasCollectible(199) then
- table.remove(SkeItemPool, 2)
- end
- if player:HasCollectible(175) then
- table.remove(SkeItemPool, 1)
- end
- if SkeItemPool[1] ~= 175
- and SkeItemPool[1] ~= 199
- and SkeItemPool[1] ~= 343 then
- -- Breakfasting
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- local pickitem = math.random(#SkeItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, SkeItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if SkeItemPool[pickitem] == 175 then
- DadsKey = true
- end
- -- reset the item pool
- SkeItemPool = BackItemPool
- -- reset the trinket "pool"
- SkeTrinketPool = BackTrinketPool
- end
- else
- local picktrinket = math.random(#SkeTrinketPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, SkeTrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
- -- reset the Trinket "pool"
- SkeTrinketPool = BackTrinketPool
- end
- end
- else
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_SKELETON_KEY, KBum.Position, Vector(0,0), KBum)
- end
- end
- local function MomKey(KBum, keytwo)
- local player = Isaac.GetPlayer(0)
- -- tables which contain the items Key Bum can pull from
- -- Item tables
- local MomItemPool = {17,175,343} -- 17 = Skeleton Key, 175 = Dads Key, 343 = Latch Key
- local BackMomItemPool = {17,175,343}
- -- Trinket tables
- local MomTrinketPool = {19,36,83} -- 19 = Paper Clip, 36 = Rusted Key, 83 = Store Key
- local BackMomTrinketPool = {19,36,83}
- local trinketCounter = 0
- if player:HasCollectible(199) then -- 199 = Moms Key
- if keytwo < 50 then
- if player:HasCollectible(343) then
- table.remove(MomItemPool, 3)
- end
- if DadsKey == true then
- table.remove(MomItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(MomItemPool, 1)
- end
- if MomItemPool[1] ~= 17
- and MomItemPool[1] ~= 175
- and MomItemPool[1] ~= 343 then
- -- Breakfasting
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- local pickitem = math.random(#MomItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, MomItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if MomItemPool[pickitem] == 175 then
- DadsKey = true
- end
- MomItemPool = BackMomItemPool
- end
- else
- if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
- table.remove(MomTrinketPool, 3)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
- table.remove(MomTrinketPool, 2)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
- or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
- table.remove(MomTrinketPool, 1)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- -- make sure that the player has two key themend trinkets
- if trinketCounter >= 2 then
- if player:HasCollectible(343) then
- table.remove(MomItemPool, 3)
- end
- if DadsKey == true then
- table.remove(MomItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(MomItemPool, 1)
- end
- if MomItemPool[1] ~= 17
- and MomItemPool[1] ~= 175
- and MomItemPool[1] ~= 343 then
- -- Breakfasting
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- local pickitem = math.random(#MomItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, MomItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if MomItemPool[pickitem] == 175 then
- DadsKey = true
- end
- MomItemPool = BackMomItemPool
- MomTrinketPool = BackMomTrinketPool
- end
- else
- local picktrinket = math.random(#MomTrinketPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, MomTrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
- MomTrinketPool = BackMomTrinketPool
- end
- end
- else
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_MOMS_KEY, KBum.Position, Vector(0,0), KBum)
- end
- end
- -- !!
- local function DadKey(KBum, keythree)
- local player = Isaac.GetPlayer(0)
- -- tables which contain the items Key Bum can pull from
- -- Item tables
- local DadItemPool = {17,199,343} -- 17 = Skeleton Key, 199 = Moms Key, 343 = Latch Key
- local BackDadItemPool = {17,199,343}
- -- Trinket tables
- local DadTrinketPool = {19,36,83} -- 19 = Paper Clip, 36 = Rusted Key, 83 = Store Key
- local BackDadTrinketPool = {19,36,83}
- local trinketCounter = 0
- if DadsKey == true then
- if keythree < 50 then
- if player:HasCollectible(343) then
- table.remove(DadItemPool, 3)
- end
- if player:HasCollectible(199) then
- table.remove(DadItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(DadItemPool, 1)
- end
- if DadItemPool[1] ~= 17
- and DadItemPool[1] ~= 199
- and DadItemPool[1] ~= 343 then
- -- Breakfasting
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- local pickitem = math.random(#DadItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, DadItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- DadItemPool = BackDadItemPool
- end
- else
- if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
- table.remove(DadTrinketPool, 3)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
- table.remove(DadTrinketPool, 2)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
- or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
- table.remove(DadTrinketPool, 1)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- -- make sure that the player has two key themend trinkets
- if trinketCounter >= 2 then
- if player:HasCollectible(343) then
- table.remove(DadItemPool, 3)
- end
- if DadsKey == true then
- table.remove(DadItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(DadItemPool, 1)
- end
- if DadItemPool[1] ~= 17
- and DadItemPool[1] ~= 199
- and DadItemPool[1] ~= 343 then
- -- Breakfasting
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- local pickitem = math.random(#DadItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, DadItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- DadItemPool = BackDadItemPool
- DadTrinketPool = BackDadTrinketPool
- end
- else
- local picktrinket = math.random(#DadTrinketPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET,DadTrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
- DadTrinketPool = BackDadTrinketPool
- end
- end
- else
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_DADS_KEY, KBum.Position, Vector(0,0), KBum)
- DadsKey = true
- end
- end
- local function LatchKey(KBum, keyfour)
- local player = Isaac.GetPlayer(0)
- -- tables which contain the items Key Bum can pull from
- -- Item tables
- local LatchItemPool = {17,175,199} -- 17 = Skeleton Key, 175 = Dads Key, 199 = Moms Key
- local BackLatchItemPool = {17,175,199}
- -- Trinket tables
- local LatchTrinketPool = {19,36,83} -- 19 = Paper Clip, 36 = Rusted Key, 83 = Store Key
- local BackLatchTrinketPool = {19,36,83}
- local trinketCounter = 0
- if player:HasCollectible(343) then -- 343 = Latch Key
- if keyfour < 50 then
- if player:HasCollectible(199) then
- table.remove(LatchItemPool, 3)
- end
- if DadsKey == true then
- table.remove(LatchItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(LatchItemPool, 1)
- end
- if LatchItemPool[1] ~= 17
- and LatchItemPool[1] ~= 175
- and LatchItemPool[1] ~= 199 then
- -- Breakfasting
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- local pickitem = math.random(#LatchItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, LatchItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if LatchItemPool[pickitem] == 175 then
- DadsKey = true
- end
- LatchItemPool = BackLatchItemPool
- end
- else
- if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
- table.remove(LatchTrinketPool, 3)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
- table.remove(LatchTrinketPool, 2)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
- or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
- table.remove(LatchTrinketPool, 1)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- end
- -- make sure that the player has two key themend trinkets
- if trinketCounter >= 2 then
- if player:HasCollectible(199) then
- table.remove(LatchItemPool, 3)
- end
- if DadsKey == true then
- table.remove(LatchItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(LatchItemPool, 1)
- end
- if LatchItemPool[1] ~= 17
- and LatchItemPool[1] ~= 175
- and LatchItemPool[1] ~= 199 then
- -- Breakfasting
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- local pickitem = math.random(#LatchItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, LatchItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if LatchItemPool[pickitem] == 175 then
- DadsKey = true
- end
- LatchItemPool = BackLatchItemPool
- LatchTrinketPool = BackLatchTrinketPool
- end
- else
- local picktrinket = math.random(#LatchTrinketPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, LatchTrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
- LatchTrinketPool = BackLatchTrinketPool
- end
- end
- else
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_LATCH_KEY, KBum.Position, Vector(0,0), KBum)
- end
- end
- local function PaperKey(KBum, keytrinket)
- local player = Isaac.GetPlayer(0)
- -- the "keytrinket" variable stores the rng for the different trinket.
- -- item & trinket pools
- local TrinketItemPool = {17,175,199,343}
- local BackTrinketItemPool = {17,175,199,343}
- local TrinketPool = {19,36,83}
- local BackTrinketPool = {19,36,83}
- -- counter & variables to keep track of the trinkets
- local trinketCounter = 0
- local paperKey = false
- local rustKey = false
- local storeKey = false
- if paperKey == true
- or rustKey == true
- or storeKey == true then
- paperKey = false
- rustKey = false
- storeKey = false
- end
- -- first we check if the player has two trinkets
- if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
- table.remove(TrinketPool, 3)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- storeKey = true
- Isaac.ConsoleOutput("Store Key = true")
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
- or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
- table.remove(TrinketPool, 2)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- rustKey = true
- Isaac.ConsoleOutput("Rusted Key = true")
- end
- if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
- or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
- table.remove(TrinketPool, 1)
- trinketCounter = trinketCounter + 1
- Mod:SaveData(trinketCounter)
- paperKey = true
- Isaac.ConsoleOutput("Paper Clip = true")
- end
- if trinketCounter >= 2 then
- -- if the player has two key themed trinkets then we spawn an item
- -- we check what items the player has
- if player:HasCollectible(343) then
- table.remove(TrinketItemPool, 4)
- end
- if player:HasCollectible(199) then
- table.remove(TrinketItemPool, 3)
- end
- if DadsKey == true then
- table.remove(TrinketItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(TrinketItemPool, 1)
- end
- --now we check if the pool is empty
- if TrinketItemPool[1] ~= 17
- and TrinketItemPool[2] ~= 175
- and TrinketItemPool[3] ~= 199
- and TrinketItemPool[4] ~= 343 then
- -- if the item pool is empty then we "Breakfast"
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- -- we spawn an item from the pool
- local pickitem = math.random(#TrinketItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if TrinketItemPool[pickitem] == 175 then
- DadsKey = true
- end
- -- we reset the items pools
- TrinketItemPool = BackTrinketItemPool
- TrinketPool = BackTrinketPool
- end
- paperKey = false
- rustKey = false
- storeKey = false
- else
- -- if the player doesn't have two key themed trinkets, then we check if he has a key themed trinket at all
- -- does the player have the Paper Clip?
- if paperKey == true then
- if keytrinket < 50 then
- if player:HasCollectible(343) then
- table.remove(TrinketItemPool, 4)
- end
- if player:HasCollectible(199) then
- table.remove(TrinketItemPool, 3)
- end
- if DadsKey == true then
- table.remove(TrinketItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(TrinketItemPool, 1)
- end
- --now we check if the pool is empty
- if TrinketItemPool[1] ~= 17
- and TrinketItemPool[2] ~= 175
- and TrinketItemPool[3] ~= 199
- and TrinketItemPool[4] ~= 343 then
- -- if the item pool is empty then we "Breakfast"
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- -- we spawn an item from the pool
- local pickitem = math.random(#TrinketItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if TrinketItemPool[pickitem] == 175 then
- DadsKey = true
- end
- -- we reset the items pools
- TrinketItemPool = BackTrinketItemPool
- TrinketPool = BackTrinketPool
- end
- else
- -- 50% to spawn an other key themed trinket
- local picktrinket = math.random(#TrinketPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
- TrinketPool = BackTrinketPool
- end
- else
- -- spawn the Paper Clip trinket
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_PAPER_CLIP, KBum.Position, Vector(0,0), KBum)
- Isaac.ConsoleOutput("Paper Clip")
- end
- -- does the player have the Rusted Key trinket?
- if rustKey == true then
- if keytrinket < 50 then
- if player:HasCollectible(343) then
- table.remove(TrinketItemPool, 4)
- end
- if player:HasCollectible(199) then
- table.remove(TrinketItemPool, 3)
- end
- if DadsKey == true then
- table.remove(TrinketItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(TrinketItemPool, 1)
- end
- --now we check if the pool is empty
- if TrinketItemPool[1] ~= 17
- and TrinketItemPool[2] ~= 175
- and TrinketItemPool[3] ~= 199
- and TrinketItemPool[4] ~= 343 then
- -- if the item pool is empty then we "Breakfast"
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- -- we spawn an item from the pool
- local pickitem = math.random(#TrinketItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if TrinketItemPool[pickitem] == 175 then
- DadsKey = true
- end
- -- we reset the items pools
- TrinketItemPool = BackTrinketItemPool
- TrinketPool = BackTrinketPool
- end
- else
- -- 50% to spawn an other key themed trinket
- local picktrinket = math.random(#TrinketPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
- TrinketPool = BackTrinketPool
- end
- else
- -- spawn the Rusted Key trinket
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_RUSTED_KEY, KBum.Position, Vector(0,0), KBum)
- Isaac.ConsoleOutput("Rusted Key")
- end
- -- does the player have the Store Key trinket?
- if storeKey == true then
- if keytrinket < 50 then
- if player:HasCollectible(343) then
- table.remove(TrinketItemPool, 4)
- end
- if player:HasCollectible(199) then
- table.remove(TrinketItemPool, 3)
- end
- if DadsKey == true then
- table.remove(TrinketItemPool, 2)
- end
- if player:HasCollectible(17) then
- table.remove(TrinketItemPool, 1)
- end
- --now we check if the pool is empty
- if TrinketItemPool[1] ~= 17
- and TrinketItemPool[2] ~= 175
- and TrinketItemPool[3] ~= 199
- and TrinketItemPool[4] ~= 343 then
- -- if the item pool is empty then we "Breakfast"
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- else
- -- we spawn an item from the pool
- local pickitem = math.random(#TrinketItemPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
- if TrinketItemPool[pickitem] == 175 then
- DadsKey = true
- end
- -- we reset the items pools
- TrinketItemPool = BackTrinketItemPool
- TrinketPool = BackTrinketPool
- end
- else
- -- 50% to spawn an other key themed trinket
- local picktrinket = math.random(#TrinketPool)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
- TrinketPool = BackTrinketPool
- end
- else
- -- spawn the Store Key trinket
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_STORE_KEY, KBum.Position, Vector(0,0), KBum)
- Isaac.ConsoleOutput("Store Key")
- end
- end
- end
- function Mod:onPickup(KBum)
- local player = Isaac.GetPlayer(0)
- local entities = Isaac.GetRoomEntities()
- local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_KEY_BUM)
- local roll = rng:RandomInt(100)
- if player:HasCollectible(CollectibleType.COLLECTIBLE_KEY_BUM) then
- -- we check all entities in the room
- for j = 1, #entities do
- -- collision detection
- if entities[j].Type == EntityType.ENTITY_PICKUP
- and KBum.Position:Distance(entities[j].Position) <= 10
- and (not (player.Position:Distance(entities[j].Position) <= 40))
- then
- if entities[j]:GetSprite():IsPlaying("Collect")
- and entities[j]:GetData().Picked == nil then
- entities[j]:GetData().Picked = true
- -- pickup specific action
- if entities[j].Variant == PickupVariant.PICKUP_KEY then
- if entities[j].SubType == KeySubType.KEY_NORMAL
- or entities[j].SubType == KeySubType.KEY_CHARGED then
- -- key counter
- BumsKeys = BumsKeys + 1
- Mod:SaveData(BumsKeys)
- -- if BumsKeys == 1 then
- -- Isaac.ConsoleOutput("Save BumsKey")
- -- depending on how high the key counter Key Bum can spawn different things
- if BumsKeys == 7 then
- if player:HasCollectible(CollectibleType.COLLECTIBLE_SKELETON_KEY)
- and player:HasCollectible(CollectibleType.COLLECTIBLE_MOMS_KEY)
- and player:HasCollectible(CollectibleType.COLLECTIBLE_LATCH_KEY)
- and DadsKey == true then
- if roll < 98 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_KEY, KeySubType.KEY_GOLDEN, entities[j].Position, Vector(0,0), KBum)
- BumsKeys = 0 -- reset the counter to 0
- Mod:SaveData(BumsKeys)
- else
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_LOCKEDCHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
- BumsKeys = 0 -- reset the counter to 0
- Mod:SaveData(BumsKeys)
- end
- else
- if roll < 50 then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_KEY, KeySubType.KEY_GOLDEN, entities[j].Position, Vector(0,0), KBum)
- BumsKeys = 0 -- reset the counter to 0
- Mod:SaveData(BumsKeys)
- end
- end
- elseif BumsKeys >= 12 then
- -- the chance to drop something increases with every key picked up
- if BumsKeys == 12 then
- KBumExtra = 0
- elseif BumsKeys == 13 then
- KBumExtra = KBumExtra + 10
- Mod:SaveData(KBumExtra)
- -- Isaac.ConsoleOutput("Save BumExtra") -- testing
- elseif BumsKeys == 14 then
- KBumExtra = KBumExtra + 10
- Mod:SaveData(KBumExtra)
- -- Isaac.ConsoleOutput("Save BumExtra") -- testing
- elseif BumsKeys == 15 then
- KBumExtra = KBumExtra + 15
- Mod:SaveData(KBumExtra)
- -- Isaac.ConsoleOutput("Save BumExtra") -- testing
- elseif BumsKeys == 16 then
- KBumExtra = KBumExtra + 15
- Mod:SaveData(KBumExtra)
- -- Isaac.ConsoleOutput("Save BumExtra") -- testing
- elseif BumsKeys == 17 then
- KBumExtra = KBumExtra + 15
- Mod:SaveData(KBumExtra)
- -- Isaac.ConsoleOutput("Save BumExtra two") -- testing
- end
- if roll < (35 + KBumExtra) then
- local rolltwo = rng:RandomInt(120)
- if rolltwo < 1 then
- local rngone = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_SKELETON_KEY)
- local keyone = rngone:RandomInt(100)
- SkeletonKey(KBum, keyone)
- BumsKeys = 0
- Mod:SaveData(BumsKeys)
- elseif rolltwo < 3 then
- local rngtwo = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_MOMS_KEY)
- local keytwo = rngtwo:RandomInt(100)
- MomKey(KBum, keytwo)
- BumsKeys = 0
- Mod:SaveData(BumsKeys)
- elseif rolltwo < 5 then
- local rngthree = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_DADS_KEY)
- local keythree = rngthree:RandomInt(100)
- DadKey(KBum, keythree)
- BumsKeys = 0
- Mod:SaveData(BumsKeys)
- DadsKey = true
- elseif rolltwo < 7 then
- local rngfour = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_LATCH_KEY)
- local keyfour = rngfour:RandomInt(100)
- LatchKey(KBum, keyfour)
- BumsKeys = 0
- Mod:SaveData(BumsKeys)
- elseif rolltwo < 38 then --87
- local rngfive = player:GetCollectibleRNG(TrinketType.TRINKET_PAPER_CLIP)
- local keytrinket = rngfive:RandomInt(100)
- PaperKey(KBum, keytrinket)
- BumsKeys = 0
- Mod:SaveData(BumsKeys)
- elseif rolltwo < 74 then --104
- local rngsix = player:GetCollectibleRNG(TrinketType.TRINKET_STORE_KEY)
- local keytrinket = rngsix:RandomInt(100)
- PaperKey(KBum, keytrinket)
- BumsKeys = 0
- Mod:SaveData(BumsKeys)
- else
- local rngseven = player:GetCollectibleRNG(TrinketType.TRINKET_RUSTED_KEY)
- local keytrinket = rngseven:RandomInt(100)
- PaperKey(KBum, keytrinket)
- BumsKeys = 0
- Mod:SaveData(BumsKeys)
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_FAMILIAR_UPDATE, Mod.onPickup, FamiliarVariant.KEY_BUM)
Advertisement
Add Comment
Please, Sign In to add comment