Josh64

Untitled

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