Josh64

COT beggar code

Aug 20th, 2020
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.17 KB | None | 0 0
  1. if entities.Variant == 3 then -- fortune teller
  2. -- get rng
  3. local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_SMELTER)
  4. local roll = rng:RandomInt(100)
  5.  
  6. -- remove slot
  7. entities:Remove()
  8.  
  9. -- replace it with a soul heart or Fragmented Card
  10. if roll >= 15 then
  11. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_HEART, HeartSubType.HEART_SOUL, entities.Position, Vector(0,0), entities)
  12. else
  13. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_FRAGMENTED_CARD, entities.Position, Vector(0,0), entities)
  14. end
  15. elseif entities.Variant == 4 then -- normal beggar
  16. if entities:GetSprite():IsEventTriggered("Prize") then
  17. -- Isaac.ConsoleOutput("Pay Prize")
  18. waitForBeggar = true
  19. collectible.Beggar = true
  20. end
  21. elseif entities.Variant == 5 then -- demon beggar
  22. if entities:GetSprite():IsEventTriggered("Prize") then
  23. -- Isaac.ConsoleOutput("Pay Prize")
  24. waitForBeggar = true
  25. collectible.DemonBeggar = true
  26. end
  27. elseif entities.Variant == 6 then -- shell game
  28. if entities:GetSprite():IsEventTriggered("Prize") then
  29. -- Isaac.ConsoleOutput("Pay Prize")
  30. waitForBeggar = true
  31. collectible.ShellGame = true
  32. end
  33. elseif entities.Variant == 7 then -- key beggar
  34. if entities:GetSprite():IsEventTriggered("Prize") then
  35. -- Isaac.ConsoleOutput("Pay Prize")
  36. waitForBeggar = true
  37. collectible.KeyBeggar = true
  38. end
  39. elseif entities.Variant == 9 then -- bomb beggar
  40. if entities:GetSprite():IsEventTriggered("Prize") then
  41. -- Isaac.ConsoleOutput("Pay Prize")
  42. waitForBeggar = true
  43. collectible.BombBeggar = true
  44. end
  45. elseif entities.Variant == 10 then -- reroll maschine
  46. local restock = entities
  47. local sprite = restock:GetSprite()
  48. local numTrinkets = 0 -- keeps track of the number of trinkets in the room
  49.  
  50. -- First check if the player inserted a coin
  51. if sprite:IsOverlayPlaying("CoinInsert") then
  52. if sprite:GetOverlayFrame() == 7 then
  53. local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_SMELTER)
  54. local roll = rng:RandomInt(100)
  55. if roll < 50 then
  56. -- check for the room the restock machine is in
  57. if roomType == RoomType.ROOM_TREASURE then
  58. -- Isaac.ConsoleOutput("Yess!")
  59. -- get the pool first
  60. local poolBase = {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} -- used to determine pool and poolBackwards
  61.  
  62. -- reroll stuff!
  63. TrinketReroll(poolBase)
  64.  
  65. -- check how many times the machine rerolled the trinkets
  66. rerollItemRo = rerollItemRo + 1
  67.  
  68. elseif roomType == RoomType.ROOM_SECRET then
  69. -- get the pool first
  70. local poolBase = {15,28,32,83,84,91} -- used to determine pool and poolBackwards
  71.  
  72. -- reroll stuff!
  73. TrinketReroll(poolBase)
  74.  
  75. -- check how many times the machine rerolled the trinkets
  76. rerollSecretRo = rerollSecretRo + 1
  77. end
  78. end
  79. end
  80. end
  81.  
  82. -- check for explosions close to the machine and trigger the reroll if necessary
  83. for _, entitiis in pairs(Isaac.GetRoomEntities()) do
  84. -- Isaac.ConsoleOutput("Yess!")
  85. if entitiis.Type == EntityType.ENTITY_EFFECT then
  86. local effect = entitiis
  87. local reRoll = false
  88. if effect.Variant == EffectVariant.BOMB_EXPLOSION
  89. or effect.Variant == EffectVariant.MOM_FOOT_STOMP
  90. or effect.Variant == EffectVariant.SHOCKWAVE then
  91. if effect:GetData().Exploded == nil then
  92. -- if (restock.Position - effect.Position):Length() <= restock.Size + effect.Size then
  93. if (restock.Position:Distance(effect.Position) < 83) then
  94. -- set the data for the effect
  95. effect:GetData().Exploded = true
  96.  
  97. -- Isaac.ConsoleOutput("Uhh?")
  98. if restock:GetData().OutOfStock == nil
  99. or restock:GetData().OutOfStock == false then -- the restock machine isn't supposed to be out of stock
  100. if roomType == RoomType.ROOM_TREASURE
  101. and reRoll == false then
  102. -- Isaac.ConsoleOutput("Yess!")
  103. -- get the pool first
  104. local poolBase = {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} -- used to determine pool and poolBackwards
  105.  
  106. -- reroll stuff!
  107. TrinketReroll(poolBase)
  108.  
  109. -- check how many times the machine rerolled the trinkets
  110. rerollItemRo = rerollItemRo + 1
  111.  
  112. reRoll = true
  113.  
  114. elseif roomType == RoomType.ROOM_SECRET
  115. and reRoll == false then
  116. -- get the pool first
  117. local poolBase = {15,28,32,83,84,91} -- used to determine pool and poolBackwards
  118.  
  119. -- reroll stuff!
  120. TrinketReroll(poolBase)
  121.  
  122. -- check how many times the machine rerolled the trinkets
  123. rerollSecretRo = rerollSecretRo + 1
  124.  
  125. reRoll = true
  126. end
  127. end
  128. end
  129. end
  130. end
  131. end
  132. end
  133.  
  134. -- check for trinkets in the room and block the restock machine if too much are in there
  135. for _, entiti in pairs(Isaac.FindInRadius(player.Position, 1500, EntityPartition.PICKUP)) do
  136. if entiti.Variant == PickupVariant.PICKUP_TRINKET then
  137. numTrinkets = numTrinkets + 1
  138. end
  139. end
  140.  
  141. if numTrinkets >= 7 then
  142. if restock:GetData().OutOfStock == nil
  143. or restock:GetData().OutOfStock == false then
  144. sprite:ReplaceSpritesheet(0, "gfx/items/slots/custom/slot_010_out_of_stock.png")
  145. sprite:LoadGraphics()
  146.  
  147. -- make it intengable to other entities
  148. restock.EntityCollisionClass = EntityCollisionClass.ENTCOLL_NONE
  149.  
  150. -- set the data
  151. restock:GetData().OutOfStock = true
  152. end
  153. else
  154. if restock:GetData().OutOfStock == true then -- the spritesheet got replaced before
  155. sprite:ReplaceSpritesheet(0, "gfx/items/slots/custom/slot_010_restockmachine.png")
  156. sprite:LoadGraphics()
  157.  
  158. -- make it tengable to the player and bombs again
  159. restock.EntityCollisionClass = EntityCollisionClass.ENTCOLL_ALL -- | EntityCollisionClass.ENTCOLL_PLAYEROBJECTS
  160.  
  161. -- set the data so that it can trigger again
  162. restock:GetData().OutOfStock = false
  163. end
  164. end
  165.  
  166. -- destroy the restock machine once it is used to many times
  167. if rerollItemRo >= 6 then
  168. if roomType == RoomType.ROOM_TREASURE
  169. and restock:GetData().IsBroken == nil then
  170. -- let it play the death animation
  171. sprite:Play("Death", false)
  172. -- then kill it off
  173. restock:Die()
  174. restock:GetData().IsBroken = true
  175. end
  176. end
  177. if rerollSecretRo >= 6 then
  178. if roomType == RoomType.ROOM_SECRET
  179. and restock:GetData().IsBroken == nil then
  180. -- let it play the death animation
  181. sprite:Play("Death", false)
  182. -- then kill it off
  183. restock:Die()
  184. restock:GetData().IsBroken = true
  185. end
  186. end
  187. end
  188. end
Advertisement
Add Comment
Please, Sign In to add comment