Josh64

onCollectibleSpawn

Aug 13th, 2020
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.87 KB | None | 0 0
  1.  
  2. function Mod:onCollectibleSpawn(pickup)
  3. local player = Isaac.GetPlayer(0)
  4. local roomType = game:GetRoom():GetType()
  5. local hasEffect = player:GetEffects()
  6.  
  7. -- check if the player plays the challenge
  8. if game.Challenge == Challenges.CHALLENGE_ONLY_TRINKETS then
  9. if pickup.Variant == PickupVariant.PICKUP_COLLECTIBLE then -- look for items
  10. -- Isaac.ConsoleOutput("Yeahhh")
  11. local item = pickup
  12. -- check if a beggar spawned an item
  13. if waitForBeggar == true -- a beggar spawned an item
  14. and morphItem == false then -- item hasn't morphed yet
  15. -- Isaac.ConsoleOutput("Wait!! ")
  16. if collectible.Beggar == true then
  17. -- get the beggar trinket "pool"
  18. local pool = {1,24,49,50,51,52,126} -- mostly the penny trinkets
  19. local poolBackwards = {126,52,51,50,49,24,1}
  20.  
  21. -- trinket pool stuff
  22. TrinketPools(item, pool, poolBackwards)
  23.  
  24. collectible.Beggar = false
  25. Isaac.ConsoleOutput("Please? ")
  26.  
  27. elseif collectible.DemonBeggar == true then
  28. -- get the devil beggar trinket "pool"
  29. local pool = {61,111} -- Left Hand, Bloody Crown
  30. local poolBackwards = {111,61}
  31.  
  32. -- trinket pool stuff
  33. TrinketPools(item, pool, poolBackwards)
  34.  
  35. collectible.DemonBeggar = false
  36.  
  37. elseif collectible.ShellGame == true then
  38. -- get the shell game trinket "pool"
  39. local pool = {2,93} -- Petrified Poop, Used Diaper
  40. local poolBackwards = {93,2}
  41.  
  42. -- trinket pool stuff
  43. TrinketPools(item, pool, poolBackwards)
  44.  
  45. collectible.ShellGame = false
  46.  
  47. -- Isaac.ConsoleOutput("Shell Game")
  48.  
  49. elseif collectible.KeyBeggar == true then
  50. -- get the key master trinket "pool"
  51. local pool = {19,36,83,124} -- key related trinkets
  52. local poolBackwards = {124,83,36,19}
  53.  
  54. -- trinket pool stuff
  55. TrinketPools(item, pool, poolBackwards)
  56.  
  57. collectible.KeyBeggar = false
  58.  
  59. elseif collectible.BombBeggar == true then
  60. -- get the bomb beggar trinket "pool"
  61. local pool = {63,71,73} -- Bob's Bladder / bomb related trinkets
  62. local poolBackwards = {73,71,63}
  63.  
  64. -- trinket pool stuff
  65. TrinketPools(item, pool, poolBackwards)
  66.  
  67. collectible.BombBeggar = false
  68. -- Isaac.ConsoleOutput("Kaboooom")
  69. end
  70. -- set waitForBeggar and morphItem
  71. waitForBeggar = false
  72. morphItem = true -- the item is already morphed
  73. end
  74.  
  75. if morphItem == true then
  76. -- break
  77. -- morphItem = false
  78. end
  79.  
  80. -- Look for specific items via the CollectibleType
  81. if (item.SubType == CollectibleType.COLLECTIBLE_LUMP_OF_COAL -- spawned from the Krampus fight
  82. or item.SubType == CollectibleType.COLLECTIBLE_KRAMPUS_HEAD) then
  83. -- possible needs room type?
  84. -- get krampu's trinket pool
  85. local pool = {35,95}
  86. local poolBackwards = {95,35}
  87.  
  88. -- trinket pool stuff
  89. TrinketPools(item, pool, poolBackwards)
  90.  
  91. morphItem = true -- the item is already morphed
  92.  
  93. elseif (item.SubType == CollectibleType.COLLECTIBLE_CUBE_OF_MEAT -- spawned by the horesman fight
  94. or item.SubType == CollectibleType.COLLECTIBLE_BALL_OF_BANDAGES
  95. or item.SubType == CollectibleType.COLLECTIBLE_WHITE_PONY) then -- spawned by Conquest
  96. -- get room data to see which horseman room it is
  97. if roomType == RoomType.ROOM_BOSS then -- first check the room type
  98. if roomContains.Famine == true then
  99. -- morph the item into a locust. This will always happen regardless if the player has it or not
  100. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_FAMINE, false)
  101. -- reset the roomContains
  102. roomContains.Famine = false
  103.  
  104. elseif roomContains.Pestilence == true then
  105. -- morph the item into a locust. This will always happen regardless if the player has it or not
  106. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_PESTILENCE, false)
  107. -- reset the roomContains
  108. roomContains.Pestilence = false
  109.  
  110. elseif roomContains.Death == true then
  111. -- morph the item into a locust. This will always happen regardless if the player has it or not
  112. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_DEATH, false)
  113. -- reset the roomContains
  114. roomContains.Death = false
  115.  
  116. elseif roomContains.War == true then
  117. -- morph the item into a locust. This will always happen regardless if the player has it or not
  118. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_WRATH, false)
  119. -- reset the roomContains
  120. roomContains.War = false
  121.  
  122. elseif roomContains.Conquest == true then
  123. -- morph the item into a locust. This will always happen regardless if the player has it or not
  124. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_LOCUST_OF_CONQUEST, false)
  125. -- reset the roomContains
  126. roomContains.Conquest = false
  127. end
  128. end
  129. morphItem = true -- the item is already morphed
  130.  
  131. elseif (item.SubType == CollectibleType.COLLECTIBLE_POLAROID -- spawned from the Krampus fight
  132. or item.SubType == CollectibleType.COLLECTIBLE_NEGATIVE) then
  133. -- get mom's "pool"
  134. -- local pool = {69} -- Faded Polariod
  135.  
  136. -- morph the item to the picked trinket
  137. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_FADED_POLAROID, false)
  138.  
  139. morphItem = true -- the item is already morphed
  140.  
  141. elseif item.SubType == CollectibleType.COLLECTIBLE_SKATOLE then -- shell game
  142. -- get the shell game trinket "pool"
  143. local pool = {2,93} -- Petrified Poop, Used Diaper
  144. local poolBackwards = {93,2}
  145.  
  146. -- trinket pool stuff
  147. TrinketPools(item, pool, poolBackwards)
  148.  
  149. morphItem = true -- the item is already morphed
  150.  
  151. elseif item.SubType == CollectibleType.COLLECTIBLE_DOLLAR then -- slot machine
  152. -- get the slot machine trinket "pool"
  153. -- local pool = 121
  154. -- morph the item to the picked trinket
  155. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_SILVER_DOLLAR, false)
  156.  
  157. morphItem = true -- the item is already morphed
  158.  
  159. elseif item.SubType == CollectibleType.COLLECTIBLE_BLOOD_BAG -- blood donation machine
  160. or item.SubType == CollectibleType.COLLECTIBLE_IV_BAG then
  161. -- get the blood donation trinket "pool"
  162. local pool = {34,40,87}
  163. local poolBackwards = {87,40,34}
  164. -- trinket pool stuff
  165. TrinketPools(item, pool, poolBackwards)
  166.  
  167. morphItem = true -- the item is already morphed
  168.  
  169. elseif item.SubType == CollectibleType.COLLECTIBLE_CRYSTAL_BALL then -- fortune teller
  170. -- get the fortune teller trinket "pool"
  171. -- local pool = 102 -- Fragmented Card
  172. -- morph the item to the picked trinket
  173. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_FRAGMENTED_CARD, false)
  174.  
  175. morphItem = true -- the item is already morphed
  176.  
  177. elseif item.SubType == CollectibleType.COLLECTIBLE_PONY then
  178. -- get the headless trinket "pool"
  179. -- local pool = 54 -- Isaac's Head
  180. -- morph the item to the picked trinket
  181. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_ISAACS_HEAD, false)
  182.  
  183. morphItem = true -- the item is already morphed
  184.  
  185. elseif item.SubType == CollectibleType.COLLECTIBLE_KEY_PIECE_1
  186. or item.SubType == CollectibleType.COLLECTIBLE_KEY_PIECE_2 then
  187. local droppedFeather = false -- keeps track if the Filigree Feather is already in the room
  188. -- look for the feather
  189. for _, entity in pairs(Isaac.GetRoomEntities()) do
  190. if entity.Type == EntityType.ENTITY_PICKUP
  191. and entity.Variant == PickupVariant.PICKUP_TRINKET
  192. and entity.SubType == TrinketType.TRINKET_FILIGREE_FEATHERS then
  193. if droppedFeather == false then
  194. droppedFeather = true
  195. -- Isaac.ConsoleOutput("Kaboooom")
  196. end
  197. end
  198. end
  199.  
  200. -- after searching decide in what the item is going to be morped
  201. if droppedFeather == true
  202. or player:HasTrinket(TrinketType.TRINKET_FILIGREE_FEATHERS)
  203. or hasEffect:HasTrinketEffect(TrinketType.TRINKET_FILIGREE_FEATHERS) then
  204. -- a random trinket from the angel trinket room pool
  205. -- get the angel room pool
  206. local pool = {7,18,38,85,87,92,100,110,121}
  207. local poolBackwards = {121,110,100,92,87,85,38,18,7}
  208.  
  209. -- trinket pool stuff
  210. TrinketPools(item, pool, poolBackwards)
  211. else
  212. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_FILIGREE_FEATHERS, false)
  213. end
  214.  
  215. morphItem = true -- the item is already morphed
  216. end
  217.  
  218. if morphItem == true then
  219. -- Isaac.ConsoleOutput("Kaboooom")
  220. end
  221.  
  222. -- check the room pools
  223. if waitForBeggar == false -- the item wasn't spawned by a beggar
  224. and morphItem == false then -- item hasn't morphed yet
  225.  
  226. -- go through the different room types
  227. if roomType == RoomType.ROOM_TREASURE
  228. or roomType == RoomType.ROOM_DUNGEON then
  229. -- get the treasure room pool
  230. local pool = {5,8,14,16,25,30,31,33,53,54,55,57,60,68,70,71,77,81,86,90,93,95,97,98,99,127}
  231. local poolBackwards = {127,99,98,97,95,93,90,86,81,77,71,70,68,60,57,55,54,53,33,31,30,25,16,14,8,5}
  232.  
  233. -- trinket pool stuff
  234. TrinketPools(item, pool, poolBackwards)
  235.  
  236. elseif roomType == RoomType.ROOM_SHOP
  237. or roomType == RoomType.ROOM_BLACK_MARKET then
  238. -- get the shop room pool
  239. local pool = {3,29,34,36,41,44,59,62,63,72,73,74,76,78,82,89,94,103,106,109,120,125}
  240. local poolBackwards = {125,120,109,106,103,94,89,82,78,76,74,73,72,63,62,59,44,41,36,34,29,3}
  241.  
  242. -- trinket pool stuff
  243. TrinketPools(item, pool, poolBackwards)
  244.  
  245. -- assign data to the entity to make it a shop item later down the line
  246. item:GetData().ShopTrinket = true
  247. item:GetData().NeedsNewPrize = true
  248.  
  249.  
  250. elseif roomType == RoomType.ROOM_LIBRARY then
  251. -- get the library room pool
  252. local pool = {9,10,11,12,21,23,26,27,45,48,64,65,66,96,102}
  253. local poolBackwards = {102,96,66,65,64,48,45,27,26,23,21,12,11,10,9}
  254.  
  255. -- trinket pool stuff
  256. TrinketPools(item, pool, poolBackwards)
  257.  
  258. elseif roomType == RoomType.ROOM_BOSS
  259. or roomType == RoomType.ROOM_MINIBOSS then
  260. if roomContains.Fallen == true then -- the boss room contains the Fallen
  261. -- get the devil room pool
  262. local pool = {13,17,20,22,35,80,111,118}
  263. local poolBackwards = {118,111,80,35,22,20,17,13}
  264.  
  265. -- trinket pool stuff
  266. TrinketPools(item, pool, poolBackwards)
  267.  
  268. roomContains.Fallen = false
  269. else
  270. -- get the boss room pool
  271. local pool = {37,39,42,46,58,101,104,105,108,119}
  272. local poolBackwards = {119,108,105,104,101,58,46,42,39,37}
  273.  
  274. -- trinket pool stuff
  275. TrinketPools(item, pool, poolBackwards)
  276. end
  277.  
  278. elseif roomType == RoomType.ROOM_SECRET
  279. or roomType == RoomType.ROOM_SUPERSECRET then
  280. -- get the secret room pool
  281. local pool = {15,28,32,83,84,91}
  282. local poolBackwards = {91,84,83,32,28,15}
  283.  
  284. -- trinket pool stuff
  285. TrinketPools(item, pool, poolBackwards)
  286.  
  287. elseif roomType == RoomType.ROOM_DEVIL then
  288. -- get the secret room pool
  289. local pool = {13,17,20,22,35,80,111,118}
  290. local poolBackwards = {118,111,80,35,22,20,17,13}
  291.  
  292. -- trinket pool stuff
  293. TrinketPools(item, pool, poolBackwards)
  294.  
  295. elseif roomType == RoomType.ROOM_ANGEL
  296. or roomType == RoomType.ROOM_SACRIFICE then
  297. -- get the secret room pool
  298. local pool = {7,18,38,87,92,100,110,121}
  299. local poolBackwards = {121,110,100,92,87,38,18,7}
  300.  
  301. -- trinket pool stuff
  302. TrinketPools(item, pool, poolBackwards)
  303.  
  304. elseif roomType == RoomType.ROOM_CURSE then
  305. -- get the secret room pool
  306. local pool = {40,43,61,107,128}
  307. local poolBackwards = {128,107,61,43,40}
  308.  
  309. -- trinket pool stuff
  310. TrinketPools(item, pool, poolBackwards)
  311.  
  312. elseif roomType == RoomType.ROOM_ISAACS
  313. or roomType == RoomType.ROOM_BARREN then
  314. -- get the secret room pool
  315. local pool = {8,46,54,63,67,99}
  316. local poolBackwards = {99,67,63,54,46,8}
  317.  
  318. -- trinket pool stuff
  319. TrinketPools(item, pool, poolBackwards)
  320.  
  321. elseif roomType == RoomType.ROOM_CHALLENGE then
  322. -- get the secret room pool
  323. local pool = {6,40,58}
  324. local poolBackwards = {58,40,6}
  325.  
  326. -- trinket pool stuff
  327. TrinketPools(item, pool, poolBackwards)
  328.  
  329. elseif roomType == RoomType.ROOM_CHEST then
  330. -- get the secret room pool
  331. local pool = {29,54,55,56,57,58,59,60}
  332. local poolBackwards = {60,59,58,57,56,55,54,29}
  333.  
  334. -- trinket pool stuff
  335. TrinketPools(item, pool, poolBackwards)
  336.  
  337. elseif roomType == RoomType.ROOM_ARCADE then
  338. -- get the secret room pool
  339. local pool = {8,45,67,76,112}
  340. local poolBackwards = {112,76,67,45,8}
  341.  
  342. -- trinket pool stuff
  343. TrinketPools(item, pool, poolBackwards)
  344.  
  345. elseif roomType == RoomType.ROOM_ERROR then
  346. -- get the secret room pool
  347. local pool = {4,6,67,75,79,92}
  348. local poolBackwards = {92,79,75,67,6,4}
  349.  
  350. -- trinket pool stuff
  351. TrinketPools(item, pool, poolBackwards)
  352.  
  353. elseif roomType == RoomType.ROOM_BOSSRUSH
  354. or roomType == RoomType.ROOM_DEFAULT then
  355. -- Isaac.ConsoleOutput("s,rjzgqp")
  356. -- morph the item into a random trinket. This will always happen regardless if the player has it or not
  357. item:ToPickup():Morph(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_NULL, false)
  358. end
  359. end
  360.  
  361. if morphItem == true then
  362. morphItem = false
  363. end
  364. end
  365. end
  366.  
  367. end
  368. Mod:AddCallback(ModCallbacks.MC_POST_PICKUP_UPDATE, Mod.onCollectibleSpawn)
Advertisement
Add Comment
Please, Sign In to add comment