Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
- -- 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
- 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
- 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
- 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
- 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
- -- item spawn code
- 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)
- end
- -- does the player have the Rusted Key trinket?
- if rustKey == true then
- if keytrinket < 50 then
- -- item spawn code
- 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)
- end
- -- does the player have the Store Key trinket?
- if storeKey == true then
- if keytrinket < 50 then
- -- item spawn code
- 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)
- end
- end
- end
Add Comment
Please, Sign In to add comment