Josh64

Better Key Bum 2.0

Oct 17th, 2018
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.31 KB | None | 0 0
  1. local Mod = RegisterMod("betterkeybum", 1)
  2. local game = Game()
  3.  
  4. local BumsKeys = 0 -- gobal variable which keeps track on how many keys Key Bum picked up
  5. local DadsKey = nil
  6. local paperKey = nil
  7. local rustKey = nil
  8. local storeKey = nil
  9. local KBumExtra = 0
  10.  
  11. function Mod:onInit(player)
  12. if game:GetFrameCount() == 1 then
  13. -- spawn in if you want to
  14. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 17, Vector(100, 250), Vector(0,0), player)
  15. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 175, Vector(150, 250), Vector(0,0), player)
  16. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 199, Vector(200, 250), Vector(0,0), player)
  17. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 343, Vector(250, 250), Vector(0,0), player)
  18. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 388, Vector(300, 250), Vector(0,0), player)
  19. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 416, Vector(350, 250), Vector(0,0), player)
  20. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 286, Vector(400, 250), Vector(0,0), player)
  21. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, 19, Vector(450, 250), Vector(0,0), player)
  22. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, 36, Vector(500, 250), Vector(0,0), player)
  23. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, 83, Vector(100, 150), Vector(0,0), player)
  24. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_JERA, Vector(150, 150), Vector(0,0), player)
  25. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.RUNE_BLACK, Vector(200, 150), Vector(0,0), player)
  26. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, 139, Vector(250, 150), Vector(0,0), player)
  27.  
  28. -- check for Dads Key
  29. DadsKey = false
  30. Isaac.ConsoleOutput("Dads Key = false")
  31. paperKey = false
  32. Isaac.ConsoleOutput("Paper Key = false")
  33. rustKey = false
  34. Isaac.ConsoleOutput("Rusted Key = false")
  35. storeKey = false
  36. Isaac.ConsoleOutput("Store Key = false")
  37. BumsKeys = 0
  38. Mod:SaveData(BumsKeys)
  39. end
  40. end
  41. Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onInit)
  42.  
  43.  
  44. local function SkeletonKey(KBum, keyone)
  45. local player = Isaac.GetPlayer(0)
  46. -- tables which contain the items Key Bum can pull from
  47. -- Item tables
  48. local SkeItemPool = {175,199,343} -- 175 = Dads Key, 199 = Moms Key, 343 = Latch Key
  49. local BackItemPool = {175,199,343}
  50. -- Trinket tables
  51. local SkeTrinketPool = {19,36,83} -- 19 = Paper Clip, 36 = Rusted Key, 83 = Store Key
  52. local BackTrinketPool = {19,36,83}
  53. local trinketCounter = 0 -- keeps track on how many key themed trinkets you have
  54. if player:HasCollectible(17) then -- 17 = Skeleton Key
  55. if keyone < 5 then
  56. -- check if the player has an item and remove it from the table. It is removed from the "pool"
  57. if player:HasCollectible(343) then
  58. table.remove(SkeItemPool, 3)
  59. end
  60. if player:HasCollectible(199) then
  61. table.remove(SkeItemPool, 2)
  62. end
  63. if DadsKey == true then
  64. table.remove(SkeItemPool, 1)
  65. end
  66. -- make sure the table is not empty
  67. if SkeItemPool[1] ~= 175
  68. and SkeItemPool[1] ~= 199
  69. and SkeItemPool[1] ~= 343 then
  70. -- Breakfasting, if the table is empty
  71. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  72. else
  73. local pickitem = math.random(#SkeItemPool)
  74. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, SkeItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  75. if SkeItemPool[pickitem] == 175 then
  76. DadsKey = true
  77. end
  78. -- after spawning the Item you have to reset the table
  79. SkeItemPool = BackItemPool
  80. end
  81. else
  82. -- check if the player has a trinket and remove it from the table. It is removed from the "pool"
  83. if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
  84. or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
  85. table.remove(SkeTrinketPool, 3)
  86. trinketCounter = trinketCounter + 1
  87. Mod:SaveData(trinketCounter)
  88. end
  89. if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
  90. or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
  91. table.remove(SkeTrinketPool, 2)
  92. trinketCounter = trinketCounter + 1
  93. Mod:SaveData(trinketCounter)
  94. end
  95. if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
  96. or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
  97. table.remove(SkeTrinketPool, 1)
  98. trinketCounter = trinketCounter + 1
  99. Mod:SaveData(trinketCounter)
  100. end
  101. -- make sure that the player doesn't have two key themend trinkets
  102.  
  103. if trinketCounter >= 2 then
  104.  
  105. -- if the player has two key trinkets, then Key Bum will spawn an item
  106. if player:HasCollectible(343) then
  107. table.remove(SkeItemPool, 3)
  108. end
  109. if player:HasCollectible(199) then
  110. table.remove(SkeItemPool, 2)
  111. end
  112. if player:HasCollectible(175) then
  113. table.remove(SkeItemPool, 1)
  114. end
  115. if SkeItemPool[1] ~= 175
  116. and SkeItemPool[1] ~= 199
  117. and SkeItemPool[1] ~= 343 then
  118.  
  119. -- Breakfasting
  120. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  121. else
  122. local pickitem = math.random(#SkeItemPool)
  123. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, SkeItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  124. if SkeItemPool[pickitem] == 175 then
  125. DadsKey = true
  126. end
  127.  
  128. -- reset the item pool
  129. SkeItemPool = BackItemPool
  130. -- reset the trinket "pool"
  131. SkeTrinketPool = BackTrinketPool
  132. end
  133. else
  134. local picktrinket = math.random(#SkeTrinketPool)
  135. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, SkeTrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  136. -- reset the Trinket "pool"
  137. SkeTrinketPool = BackTrinketPool
  138. end
  139. end
  140. else
  141. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_SKELETON_KEY, KBum.Position, Vector(0,0), KBum)
  142. end
  143. end
  144.  
  145. local function MomKey(KBum, keytwo)
  146. local player = Isaac.GetPlayer(0)
  147. -- tables which contain the items Key Bum can pull from
  148. -- Item tables
  149. local MomItemPool = {17,175,343} -- 17 = Skeleton Key, 175 = Dads Key, 343 = Latch Key
  150. local BackMomItemPool = {17,175,343}
  151. -- Trinket tables
  152. local MomTrinketPool = {19,36,83} -- 19 = Paper Clip, 36 = Rusted Key, 83 = Store Key
  153. local BackMomTrinketPool = {19,36,83}
  154. local trinketCounter = 0
  155.  
  156. if player:HasCollectible(199) then -- 199 = Moms Key
  157. if keytwo < 50 then
  158. if player:HasCollectible(343) then
  159. table.remove(MomItemPool, 3)
  160. end
  161. if DadsKey == true then
  162. table.remove(MomItemPool, 2)
  163. end
  164. if player:HasCollectible(17) then
  165. table.remove(MomItemPool, 1)
  166. end
  167. if MomItemPool[1] ~= 17
  168. and MomItemPool[1] ~= 175
  169. and MomItemPool[1] ~= 343 then
  170. -- Breakfasting
  171. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  172. else
  173. local pickitem = math.random(#MomItemPool)
  174. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, MomItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  175. if MomItemPool[pickitem] == 175 then
  176. DadsKey = true
  177. end
  178. MomItemPool = BackMomItemPool
  179. end
  180. else
  181. if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
  182. or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
  183. table.remove(MomTrinketPool, 3)
  184. trinketCounter = trinketCounter + 1
  185. Mod:SaveData(trinketCounter)
  186. end
  187. if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
  188. or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
  189. table.remove(MomTrinketPool, 2)
  190. trinketCounter = trinketCounter + 1
  191. Mod:SaveData(trinketCounter)
  192. end
  193. if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
  194. or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
  195. table.remove(MomTrinketPool, 1)
  196. trinketCounter = trinketCounter + 1
  197. Mod:SaveData(trinketCounter)
  198. end
  199. -- make sure that the player has two key themend trinkets
  200.  
  201. if trinketCounter >= 2 then
  202.  
  203. if player:HasCollectible(343) then
  204. table.remove(MomItemPool, 3)
  205. end
  206. if DadsKey == true then
  207. table.remove(MomItemPool, 2)
  208. end
  209. if player:HasCollectible(17) then
  210. table.remove(MomItemPool, 1)
  211. end
  212. if MomItemPool[1] ~= 17
  213. and MomItemPool[1] ~= 175
  214. and MomItemPool[1] ~= 343 then
  215. -- Breakfasting
  216. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  217. else
  218. local pickitem = math.random(#MomItemPool)
  219. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, MomItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  220. if MomItemPool[pickitem] == 175 then
  221. DadsKey = true
  222. end
  223. MomItemPool = BackMomItemPool
  224. MomTrinketPool = BackMomTrinketPool
  225. end
  226. else
  227. local picktrinket = math.random(#MomTrinketPool)
  228. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, MomTrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  229. MomTrinketPool = BackMomTrinketPool
  230. end
  231. end
  232. else
  233. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_MOMS_KEY, KBum.Position, Vector(0,0), KBum)
  234. end
  235. end
  236.  
  237. -- !!
  238. local function DadKey(KBum, keythree)
  239. local player = Isaac.GetPlayer(0)
  240. -- tables which contain the items Key Bum can pull from
  241. -- Item tables
  242. local DadItemPool = {17,199,343} -- 17 = Skeleton Key, 199 = Moms Key, 343 = Latch Key
  243. local BackDadItemPool = {17,199,343}
  244. -- Trinket tables
  245. local DadTrinketPool = {19,36,83} -- 19 = Paper Clip, 36 = Rusted Key, 83 = Store Key
  246. local BackDadTrinketPool = {19,36,83}
  247. local trinketCounter = 0
  248.  
  249. if DadsKey == true then
  250. if keythree < 50 then
  251. if player:HasCollectible(343) then
  252. table.remove(DadItemPool, 3)
  253. end
  254. if player:HasCollectible(199) then
  255. table.remove(DadItemPool, 2)
  256. end
  257. if player:HasCollectible(17) then
  258. table.remove(DadItemPool, 1)
  259. end
  260. if DadItemPool[1] ~= 17
  261. and DadItemPool[1] ~= 199
  262. and DadItemPool[1] ~= 343 then
  263. -- Breakfasting
  264. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  265. else
  266. local pickitem = math.random(#DadItemPool)
  267. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, DadItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  268. DadItemPool = BackDadItemPool
  269. end
  270. else
  271. if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
  272. or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
  273. table.remove(DadTrinketPool, 3)
  274. trinketCounter = trinketCounter + 1
  275. Mod:SaveData(trinketCounter)
  276. end
  277. if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
  278. or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
  279. table.remove(DadTrinketPool, 2)
  280. trinketCounter = trinketCounter + 1
  281. Mod:SaveData(trinketCounter)
  282. end
  283. if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
  284. or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
  285. table.remove(DadTrinketPool, 1)
  286. trinketCounter = trinketCounter + 1
  287. Mod:SaveData(trinketCounter)
  288. end
  289. -- make sure that the player has two key themend trinkets
  290.  
  291. if trinketCounter >= 2 then
  292.  
  293. if player:HasCollectible(343) then
  294. table.remove(DadItemPool, 3)
  295. end
  296. if DadsKey == true then
  297. table.remove(DadItemPool, 2)
  298. end
  299. if player:HasCollectible(17) then
  300. table.remove(DadItemPool, 1)
  301. end
  302. if DadItemPool[1] ~= 17
  303. and DadItemPool[1] ~= 199
  304. and DadItemPool[1] ~= 343 then
  305. -- Breakfasting
  306. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  307. else
  308. local pickitem = math.random(#DadItemPool)
  309. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, DadItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  310. DadItemPool = BackDadItemPool
  311. DadTrinketPool = BackDadTrinketPool
  312. end
  313. else
  314. local picktrinket = math.random(#DadTrinketPool)
  315. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET,DadTrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  316. DadTrinketPool = BackDadTrinketPool
  317. end
  318. end
  319. else
  320. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_DADS_KEY, KBum.Position, Vector(0,0), KBum)
  321. DadsKey = true
  322. end
  323. end
  324.  
  325. local function LatchKey(KBum, keyfour)
  326. local player = Isaac.GetPlayer(0)
  327. -- tables which contain the items Key Bum can pull from
  328. -- Item tables
  329. local LatchItemPool = {17,175,199} -- 17 = Skeleton Key, 175 = Dads Key, 199 = Moms Key
  330. local BackLatchItemPool = {17,175,199}
  331. -- Trinket tables
  332. local LatchTrinketPool = {19,36,83} -- 19 = Paper Clip, 36 = Rusted Key, 83 = Store Key
  333. local BackLatchTrinketPool = {19,36,83}
  334. local trinketCounter = 0
  335.  
  336. if player:HasCollectible(343) then -- 343 = Latch Key
  337. if keyfour < 50 then
  338. if player:HasCollectible(199) then
  339. table.remove(LatchItemPool, 3)
  340. end
  341. if DadsKey == true then
  342. table.remove(LatchItemPool, 2)
  343. end
  344. if player:HasCollectible(17) then
  345. table.remove(LatchItemPool, 1)
  346. end
  347. if LatchItemPool[1] ~= 17
  348. and LatchItemPool[1] ~= 175
  349. and LatchItemPool[1] ~= 199 then
  350. -- Breakfasting
  351. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  352. else
  353. local pickitem = math.random(#LatchItemPool)
  354. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, LatchItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  355. if LatchItemPool[pickitem] == 175 then
  356. DadsKey = true
  357. end
  358. LatchItemPool = BackLatchItemPool
  359. end
  360. else
  361. if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
  362. or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
  363. table.remove(LatchTrinketPool, 3)
  364. trinketCounter = trinketCounter + 1
  365. Mod:SaveData(trinketCounter)
  366. end
  367. if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
  368. or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
  369. table.remove(LatchTrinketPool, 2)
  370. trinketCounter = trinketCounter + 1
  371. Mod:SaveData(trinketCounter)
  372. end
  373. if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
  374. or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
  375. table.remove(LatchTrinketPool, 1)
  376. trinketCounter = trinketCounter + 1
  377. Mod:SaveData(trinketCounter)
  378. end
  379. -- make sure that the player has two key themend trinkets
  380.  
  381. if trinketCounter >= 2 then
  382.  
  383. if player:HasCollectible(199) then
  384. table.remove(LatchItemPool, 3)
  385. end
  386. if DadsKey == true then
  387. table.remove(LatchItemPool, 2)
  388. end
  389. if player:HasCollectible(17) then
  390. table.remove(LatchItemPool, 1)
  391. end
  392. if LatchItemPool[1] ~= 17
  393. and LatchItemPool[1] ~= 175
  394. and LatchItemPool[1] ~= 199 then
  395. -- Breakfasting
  396. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  397. else
  398. local pickitem = math.random(#LatchItemPool)
  399. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, LatchItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  400. if LatchItemPool[pickitem] == 175 then
  401. DadsKey = true
  402. end
  403. LatchItemPool = BackLatchItemPool
  404. LatchTrinketPool = BackLatchTrinketPool
  405. end
  406. else
  407. local picktrinket = math.random(#LatchTrinketPool)
  408. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, LatchTrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  409. LatchTrinketPool = BackLatchTrinketPool
  410. end
  411. end
  412. else
  413. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_LATCH_KEY, KBum.Position, Vector(0,0), KBum)
  414. end
  415. end
  416.  
  417. local function PaperKey(KBum)
  418. local player = Isaac.GetPlayer(0)
  419. -- the "keytrinket" variable stores the rng for the different trinket.
  420. -- item & trinket pools
  421. local TrinketItemPool = {17,175,199,343}
  422. local BackTrinketItemPool = {17,175,199,343}
  423. local TrinketPool = {19,36,83}
  424. local BackTrinketPool = {19,36,83}
  425. -- counter & variables to keep track of the trinkets
  426. local trinketCounter = 0
  427. local spawned = false
  428.  
  429.  
  430. -- first we check if the player has two trinkets
  431. if player:GetTrinket(0) == TrinketType.TRINKET_STORE_KEY
  432. or player:GetTrinket(1) == TrinketType.TRINKET_STORE_KEY then
  433. table.remove(TrinketPool, 3)
  434. trinketCounter = trinketCounter + 1
  435. Mod:SaveData(trinketCounter)
  436. storeKey = true
  437. -- Isaac.ConsoleOutput("Store Key = true")
  438. else
  439. storeKey = false
  440. end
  441. if player:GetTrinket(0) == TrinketType.TRINKET_RUSTED_KEY
  442. or player:GetTrinket(1) == TrinketType.TRINKET_RUSTED_KEY then
  443. table.remove(TrinketPool, 2)
  444. trinketCounter = trinketCounter + 1
  445. Mod:SaveData(trinketCounter)
  446. rustKey = true
  447. -- Isaac.ConsoleOutput("Rusted Key = true")
  448. else
  449. rustKey = false
  450. end
  451. if player:GetTrinket(0) == TrinketType.TRINKET_PAPER_CLIP
  452. or player:GetTrinket(1) == TrinketType.TRINKET_PAPER_CLIP then
  453. table.remove(TrinketPool, 1)
  454. trinketCounter = trinketCounter + 1
  455. Mod:SaveData(trinketCounter)
  456. paperKey = true
  457. -- Isaac.ConsoleOutput("Paper Clip = true")
  458. else
  459. paperKey = false
  460. end
  461.  
  462. if trinketCounter >= 2 then
  463. -- if the player has two key themed trinkets then we spawn an item
  464. -- we check what items the player has
  465. if player:HasCollectible(343) then
  466. table.remove(TrinketItemPool, 4)
  467. end
  468. if player:HasCollectible(199) then
  469. table.remove(TrinketItemPool, 3)
  470. end
  471. if DadsKey == true then
  472. table.remove(TrinketItemPool, 2)
  473. end
  474. if player:HasCollectible(17) then
  475. table.remove(TrinketItemPool, 1)
  476. end
  477. --now we check if the pool is empty
  478. if TrinketItemPool[1] ~= 17
  479. and TrinketItemPool[1] ~= 175
  480. and TrinketItemPool[1] ~= 199
  481. and TrinketItemPool[1] ~= 343 then
  482. -- if the item pool is empty then we "Breakfast"
  483. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  484. else
  485. -- we spawn an item from the pool
  486. local pickitem = math.random(#TrinketItemPool)
  487. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  488. if TrinketItemPool[pickitem] == 175 then
  489. DadsKey = true
  490. end
  491. -- we reset the items pools
  492. TrinketItemPool = BackTrinketItemPool
  493. TrinketPool = BackTrinketPool
  494. end
  495. paperKey = false
  496. rustKey = false
  497. storeKey = false
  498. spawned = true
  499. end
  500. if trinketCounter == 1 then
  501. -- if the player doesn't have two key themed trinkets, then we check if he has a key themed trinket at all
  502. -- does the player have the Paper Clip?
  503. if paperKey == true then
  504. local rngfive = player:GetCollectibleRNG(TrinketType.TRINKET_PAPER_CLIP)
  505. local keyfive = rngfive:RandomInt(100)
  506. if keyfive < 50 then
  507. if player:HasCollectible(343) then
  508. table.remove(TrinketItemPool, 4)
  509. end
  510. if player:HasCollectible(199) then
  511. table.remove(TrinketItemPool, 3)
  512. end
  513. if DadsKey == true then
  514. table.remove(TrinketItemPool, 2)
  515. end
  516. if player:HasCollectible(17) then
  517. table.remove(TrinketItemPool, 1)
  518. end
  519. --now we check if the pool is empty
  520. if TrinketItemPool[1] ~= 17
  521. and TrinketItemPool[1] ~= 175
  522. and TrinketItemPool[1] ~= 199
  523. and TrinketItemPool[1] ~= 343 then
  524. -- if the item pool is empty then we "Breakfast"
  525. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  526. else
  527. -- we spawn an item from the pool
  528. local pickitem = math.random(#TrinketItemPool)
  529. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  530. if TrinketItemPool[pickitem] == 175 then
  531. DadsKey = true
  532. end
  533. -- we reset the items pools
  534. TrinketItemPool = BackTrinketItemPool
  535. TrinketPool = BackTrinketPool
  536. end
  537. else
  538. -- 50% to spawn an other key themed trinket
  539. local picktrinket = math.random(#TrinketPool)
  540. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  541. TrinketPool = BackTrinketPool
  542. Isaac.ConsoleOutput("Trinket 3")
  543. end
  544. spawned = true
  545.  
  546. -- does the player have the Rusted Key trinket?
  547. elseif rustKey == true then
  548. local rngseven = player:GetCollectibleRNG(TrinketType.TRINKET_RUSTED_KEY)
  549. local keyseven = rngseven:RandomInt(100)
  550. if keyseven < 50 then
  551. if player:HasCollectible(343) then
  552. table.remove(TrinketItemPool, 4)
  553. end
  554. if player:HasCollectible(199) then
  555. table.remove(TrinketItemPool, 3)
  556. end
  557. if DadsKey == true then
  558. table.remove(TrinketItemPool, 2)
  559. end
  560. if player:HasCollectible(17) then
  561. table.remove(TrinketItemPool, 1)
  562. end
  563. --now we check if the pool is empty
  564. if TrinketItemPool[1] ~= 17
  565. and TrinketItemPool[1] ~= 175
  566. and TrinketItemPool[1] ~= 199
  567. and TrinketItemPool[1] ~= 343 then
  568. -- if the item pool is empty then we "Breakfast"
  569. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  570. else
  571. -- we spawn an item from the pool
  572. local pickitem = math.random(#TrinketItemPool)
  573. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  574. if TrinketItemPool[pickitem] == 175 then
  575. DadsKey = true
  576. end
  577. -- we reset the items pools
  578. TrinketItemPool = BackTrinketItemPool
  579. TrinketPool = BackTrinketPool
  580. end
  581. else
  582. -- 50% to spawn an other key themed trinket
  583. local picktrinket = math.random(#TrinketPool)
  584. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  585. TrinketPool = BackTrinketPool
  586. Isaac.ConsoleOutput("Trinket 2")
  587. end
  588. spawned = true
  589.  
  590. -- does the player have the Store Key trinket?
  591. elseif storeKey == true then
  592. local rngsix = player:GetCollectibleRNG(TrinketType.TRINKET_STORE_KEY)
  593. local keysix = rngsix:RandomInt(100)
  594. if keysix < 50 then
  595. if player:HasCollectible(343) then
  596. table.remove(TrinketItemPool, 4)
  597. end
  598. if player:HasCollectible(199) then
  599. table.remove(TrinketItemPool, 3)
  600. end
  601. if DadsKey == true then
  602. table.remove(TrinketItemPool, 2)
  603. end
  604. if player:HasCollectible(17) then
  605. table.remove(TrinketItemPool, 1)
  606. end
  607. --now we check if the pool is empty
  608. if TrinketItemPool[1] ~= 17
  609. and TrinketItemPool[1] ~= 175
  610. and TrinketItemPool[1] ~= 199
  611. and TrinketItemPool[1] ~= 343 then
  612. -- if the item pool is empty then we "Breakfast"
  613. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_CHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  614. else
  615. -- we spawn an item from the pool
  616. local pickitem = math.random(#TrinketItemPool)
  617. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, TrinketItemPool[pickitem], KBum.Position, Vector(0,0), KBum)
  618. if TrinketItemPool[pickitem] == 175 then
  619. DadsKey = true
  620. end
  621. -- we reset the items pools
  622. TrinketItemPool = BackTrinketItemPool
  623. TrinketPool = BackTrinketPool
  624. end
  625. else
  626. -- 50% to spawn an other key themed trinket
  627. local picktrinket = math.random(#TrinketPool)
  628. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  629. TrinketPool = BackTrinketPool
  630. Isaac.ConsoleOutput("Trinket 1")
  631. end
  632. spawned = true
  633. end
  634. else
  635. if spawned == false then
  636. local picktrinket = math.random(#TrinketPool)
  637. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketPool[picktrinket], KBum.Position, Vector(0,0), KBum)
  638. TrinketPool = BackTrinketPool
  639. Isaac.ConsoleOutput("Spawn Trinket")
  640. spawned = true
  641. end
  642. end
  643. spawned = false
  644. end
  645.  
  646.  
  647.  
  648. function Mod:onPickup(KBum)
  649. local player = Isaac.GetPlayer(0)
  650. local entities = Isaac.GetRoomEntities()
  651. local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_KEY_BUM)
  652. local roll = rng:RandomInt(100)
  653.  
  654. if player:HasCollectible(CollectibleType.COLLECTIBLE_KEY_BUM) then
  655. -- we check all entities in the room
  656. for j = 1, #entities do
  657. -- collision detection
  658. if entities[j].Type == EntityType.ENTITY_PICKUP
  659. and KBum.Position:Distance(entities[j].Position) <= 10
  660. and (not (player.Position:Distance(entities[j].Position) <= 40))
  661. then
  662. if entities[j]:GetSprite():IsPlaying("Collect")
  663. and entities[j]:GetData().Picked == nil then
  664. entities[j]:GetData().Picked = true
  665. -- pickup specific action
  666. if entities[j].Variant == PickupVariant.PICKUP_KEY then
  667. if entities[j].SubType == KeySubType.KEY_NORMAL then
  668. -- key counter
  669. BumsKeys = BumsKeys + 1
  670. Mod:SaveData(BumsKeys)
  671. -- if BumsKeys == 1 then
  672. Isaac.ConsoleOutput("Save BumsKey")
  673. end
  674. if entities[j].SubType == KeySubType.KEY_CHARGED then
  675. -- key counter
  676. BumsKeys = BumsKeys + 1
  677. Mod:SaveData(BumsKeys)
  678. Isaac.ConsoleOutput("Save Charged Key")
  679.  
  680. -- we charge the active item
  681. if player:NeedsCharge() then
  682. -- dont forget Mega Blast
  683. if player:GetActiveItem() == CollectibleType.COLLECTIBLE_MEGA_SATANS_BREATH then
  684. player:FullCharge(3)
  685. else
  686. player:FullCharge(12)
  687. end
  688. end
  689. end
  690.  
  691. -- depending on how high the key counter Key Bum can spawn different things
  692. if BumsKeys == 7 then
  693. if player:HasCollectible(CollectibleType.COLLECTIBLE_SKELETON_KEY)
  694. and player:HasCollectible(CollectibleType.COLLECTIBLE_MOMS_KEY)
  695. and player:HasCollectible(CollectibleType.COLLECTIBLE_LATCH_KEY)
  696. and DadsKey == true then
  697. if roll < 98 then
  698. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_KEY, KeySubType.KEY_GOLDEN, entities[j].Position, Vector(0,0), KBum)
  699. BumsKeys = 0 -- reset the counter to 0
  700. Mod:SaveData(BumsKeys)
  701. else
  702. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_LOCKEDCHEST, ChestSubType.CHEST_CLOSED, KBum.Position, Vector(0,0), KBum)
  703. BumsKeys = 0 -- reset the counter to 0
  704. Mod:SaveData(BumsKeys)
  705. end
  706. else
  707. if roll < 50 then
  708. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_KEY, KeySubType.KEY_GOLDEN, entities[j].Position, Vector(0,0), KBum)
  709. BumsKeys = 0 -- reset the counter to 0
  710. Mod:SaveData(BumsKeys)
  711. end
  712. end
  713. elseif BumsKeys >= 12 then
  714. -- the chance to drop something increases with every key picked up
  715. if BumsKeys == 12 then
  716. KBumExtra = 0
  717. elseif BumsKeys == 13 then
  718. KBumExtra = KBumExtra + 10
  719. Mod:SaveData(KBumExtra)
  720. -- Isaac.ConsoleOutput("Save BumExtra") -- testing
  721. elseif BumsKeys == 14 then
  722. KBumExtra = KBumExtra + 10
  723. Mod:SaveData(KBumExtra)
  724. -- Isaac.ConsoleOutput("Save BumExtra") -- testing
  725. elseif BumsKeys == 15 then
  726. KBumExtra = KBumExtra + 15
  727. Mod:SaveData(KBumExtra)
  728. -- Isaac.ConsoleOutput("Save BumExtra") -- testing
  729. elseif BumsKeys == 16 then
  730. KBumExtra = KBumExtra + 15
  731. Mod:SaveData(KBumExtra)
  732. -- Isaac.ConsoleOutput("Save BumExtra") -- testing
  733. elseif BumsKeys == 17 then
  734. KBumExtra = KBumExtra + 15
  735. Mod:SaveData(KBumExtra)
  736. -- Isaac.ConsoleOutput("Save BumExtra two") -- testing
  737. end
  738. if roll < (35 + KBumExtra) then
  739. local rolltwo = rng:RandomInt(120)
  740. if rolltwo < 1 then
  741. local rngone = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_SKELETON_KEY)
  742. local keyone = rngone:RandomInt(100)
  743. SkeletonKey(KBum, keyone)
  744. BumsKeys = 0
  745. Mod:SaveData(BumsKeys)
  746. elseif rolltwo < 3 then
  747. local rngtwo = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_MOMS_KEY)
  748. local keytwo = rngtwo:RandomInt(100)
  749. MomKey(KBum, keytwo)
  750. BumsKeys = 0
  751. Mod:SaveData(BumsKeys)
  752. elseif rolltwo < 5 then
  753. local rngthree = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_DADS_KEY)
  754. local keythree = rngthree:RandomInt(100)
  755. DadKey(KBum, keythree)
  756. BumsKeys = 0
  757. Mod:SaveData(BumsKeys)
  758. DadsKey = true
  759. elseif rolltwo < 7 then
  760. local rngfour = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_LATCH_KEY)
  761. local keyfour = rngfour:RandomInt(100)
  762. LatchKey(KBum, keyfour)
  763. BumsKeys = 0
  764. Mod:SaveData(BumsKeys)
  765. elseif rolltwo < 35 then --87
  766. -- local rngfive = player:GetCollectibleRNG(TrinketType.TRINKET_PAPER_CLIP)
  767. -- local keyfive = rngfive:RandomInt(100)
  768. PaperKey(KBum, keytrinket)
  769. BumsKeys = 0
  770. Mod:SaveData(BumsKeys)
  771. elseif rolltwo < 80 then --104
  772. -- local rngsix = player:GetCollectibleRNG(TrinketType.TRINKET_STORE_KEY)
  773. -- local keysix = rngsix:RandomInt(100)
  774. PaperKey(KBum, keytrinket)
  775. BumsKeys = 0
  776. Mod:SaveData(BumsKeys)
  777. else
  778. -- local rngseven = player:GetCollectibleRNG(TrinketType.TRINKET_RUSTED_KEY)
  779. -- local keyseven = rngseven:RandomInt(100)
  780. PaperKey(KBum, keytrinket)
  781. BumsKeys = 0
  782. Mod:SaveData(BumsKeys)
  783. end
  784. end
  785. end
  786. end
  787. end
  788. end
  789. end
  790. end
  791. end
  792. Mod:AddCallback(ModCallbacks.MC_FAMILIAR_UPDATE, Mod.onPickup, FamiliarVariant.KEY_BUM)
Advertisement
Add Comment
Please, Sign In to add comment