Josh64

KeyBum trinket functionality

Nov 2nd, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.11 KB | None | 0 0
  1. local function PaperKey(KBum, keytrinket)
  2. local player = Isaac.GetPlayer(0)
  3. -- the "keytrinket" variable stores the rng for the different trinket.
  4. -- item & trinket pools
  5. local TrinketItemPool = {17,175,199,343}
  6. local BackTrinketItemPool = {17,175,199,343}
  7. local TrinketPool = {19,36,83}
  8. local BackTrinketPool = {19,36,83}
  9. -- counter & variables to keep track of the trinkets
  10. local trinketCounter = 0
  11. local paperKey = false
  12. local rustKey = false
  13. local storeKey = false
  14.  
  15. -- first we check if the player has two trinkets
  16. if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
  17. or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
  18. table.remove(TrinketPool, 3)
  19. trinketCounter = trinketCounter + 1
  20. Mod:SaveData(trinketCounter)
  21. storeKey = true
  22. end
  23. if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
  24. or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
  25. table.remove(TrinketPool, 2)
  26. trinketCounter = trinketCounter + 1
  27. Mod:SaveData(trinketCounter)
  28. rustKey = true
  29. end
  30. if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
  31. or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
  32. table.remove(TrinketPool, 1)
  33. trinketCounter = trinketCounter + 1
  34. Mod:SaveData(trinketCounter)
  35. paperKey = true
  36. end
  37.  
  38. if trinketCounter >= 2 then
  39. -- if the player has two key themed trinkets then we spawn an item
  40. -- we check what items the player has
  41. if player:HasCollectible(343) then
  42. table.remove(TrinketItemPool, 4)
  43. end
  44. if player:HasCollectible(199) then
  45. table.remove(TrinketItemPool, 3)
  46. end
  47. if DadsKey == true then
  48. table.remove(TrinketItemPool, 2)
  49. end
  50. if player:HasCollectible(17) then
  51. table.remove(TrinketItemPool, 1)
  52. end
  53. --now we check if the pool is empty
  54. if TrinketItemPool[1] ~= 17
  55. and TrinketItemPool[2] ~= 175
  56. and TrinketItemPool[3] ~= 199
  57. and TrinketItemPool[4] ~= 343 then
  58. -- if the item pool is empty then we "Breakfast"
  59. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubtype.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  60. else
  61. -- we spawn an item from the pool
  62. local pickitem = math.random(#TrinketItemPool)
  63. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  64. if TrinketItemPool[pickitem] == 175 then
  65. DadsKey = true
  66. end
  67. -- we reset the items pools
  68. TrinketItemPool = BackTrinketItemPool
  69. TrinketPool = BackTrinketPool
  70. end
  71. else
  72. -- if the player doesn't have two key themed trinkets, then we check if he has a key themed trinket at all
  73. -- does the player have the Paper Clip?
  74. if paperKey == true then
  75. if keytrinket < 50 then
  76. -- item spawn code
  77. else
  78. -- 50% to spawn an other key themed trinket
  79. local picktrinket = math.random(#TrinketPool)
  80. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  81. TrinketPool = BackTrinketPool
  82. end
  83. else
  84. -- spawn the Paper Clip trinket
  85. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_PAPER_CLIP, KBum.Position, Vector(0,0), KBum)
  86. end
  87.  
  88. -- does the player have the Rusted Key trinket?
  89. if rustKey == true then
  90. if keytrinket < 50 then
  91. -- item spawn code
  92. else
  93. -- 50% to spawn an other key themed trinket
  94. local picktrinket = math.random(#TrinketPool)
  95. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  96. TrinketPool = BackTrinketPool
  97. end
  98. else
  99. -- spawn the Rusted Key trinket
  100. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_RUSTED_KEY, KBum.Position, Vector(0,0), KBum)
  101. end
  102.  
  103. -- does the player have the Store Key trinket?
  104. if storeKey == true then
  105. if keytrinket < 50 then
  106. -- item spawn code
  107. else
  108. -- 50% to spawn an other key themed trinket
  109. local picktrinket = math.random(#TrinketPool)
  110. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  111. TrinketPool = BackTrinketPool
  112. end
  113. else
  114. -- spawn the Store Key trinket
  115. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_STORE_KEY, KBum.Position, Vector(0,0), KBum)
  116. end
  117. end
  118.  
  119. end
Add Comment
Please, Sign In to add comment