Josh64

A Better Dark Bum (for Keeper & Lost) v 1.4

Sep 23rd, 2018
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.93 KB | None | 0 0
  1.  
  2. local Mod = RegisterMod("betterdarkbum", 1)
  3. local game = Game()
  4.  
  5. local HeartCount = 0 -- counts the hearts Dark Bum steals
  6. local DarkBum = {
  7. Alt = false, -- allows the player to switch between the two steal animaions
  8. INIT = true, -- prevent Super Bum functionality
  9. SPAWNED = false, -- checks if Dark Bum can spawn something
  10. PAYOUT = nil, -- checks if Dark Bum should spawn something
  11. BUM = nil -- registers Dark Bum
  12. }
  13. local steal = "AltSteal"
  14.  
  15. function Mod:onInit(player)
  16. local player = Isaac.GetPlayer(0)
  17. if game:GetFrameCount() == 1 then
  18. -- spawn in if you want
  19. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_DARK_BUM, Vector(250, 250), Vector(0,0), player) -- testing
  20. end
  21. end
  22. Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onInit)
  23.  
  24. -- let the player set the animation with the debug conosle
  25. function Mod:setAnimation(consol,para)
  26. if consol == "setanimation" then
  27. if DarkBum.Alt == false then
  28. DarkBum.Alt = true
  29. steal = "AltSteal"
  30. Isaac.ConsoleOutput("animation updated. Use alt animation")
  31. else
  32. DarkBum.Alt = false
  33. steal = "Steal"
  34. Isaac.ConsoleOutput("animation updated. Use default animation")
  35. end
  36. end
  37. end
  38. Mod:AddCallback(ModCallbacks.MC_EXECUTE_CMD, Mod.setAnimation)
  39.  
  40. function Mod:onNewEvent(player)
  41. local entities = Isaac.GetRoomEntities()
  42. local entity = DarkBum.BUM
  43.  
  44. -- makes sure that the code doesn't work for Super Bum
  45.  
  46. if player:GetPlayerType() == PlayerType.PLAYER_KEEPER
  47. and player:HasCollectible(CollectibleType.COLLECTIBLE_DARK_BUM)
  48. and player:HasCollectible(CollectibleType.COLLECTIBLE_KEY_BUM)
  49. and player:HasCollectible(CollectibleType.COLLECTIBLE_BUM_FRIEND) then
  50. DarkBum.INIT = false
  51. end
  52.  
  53. -- Dark Bum functionality. He steals Keeper's red hearts
  54.  
  55. if player:GetPlayerType() == PlayerType.PLAYER_KEEPER
  56. and player:HasCollectible(CollectibleType.COLLECTIBLE_DARK_BUM)
  57. and DarkBum.INIT == true then
  58. for o = 1, #entities do
  59. local bum = entities[o]
  60. if bum.Type == EntityType.ENTITY_FAMILIAR then
  61. if bum.Variant == FamiliarVariant.DARK_BUM then
  62. entity = bum
  63. end
  64. end
  65. end
  66.  
  67. local Sprite = entity:GetSprite()
  68.  
  69. -- we are looking for red hearts
  70.  
  71. for m = 1, #entities do -- we go through every entity in the room
  72. local toSteal = entities[m] -- toSteal are the pickups we want to steal from the Keeper
  73. if toSteal.Type == EntityType.ENTITY_PICKUP
  74. and toSteal.Variant == PickupVariant.PICKUP_HEART then
  75. -- we are looking for all kinds of red hearts
  76. if toSteal.SubType == HeartSubType.HEART_HALF -- first half red hearts
  77. and not toSteal:ToPickup():IsShopItem() then
  78. toSteal:Remove()
  79. Sprite:Play(steal, true) -- Play costume animation
  80. if Sprite:IsPlaying(steal) then
  81. HeartCount = HeartCount + 1 -- half a heart increases the counter by 1
  82. Mod:SaveData(HeartCount)
  83. if HeartCount >= 5 then -- pays out at 2,5 hearts
  84. DarkBum.PAYOUT = true
  85. end
  86. end
  87. end
  88. if toSteal.SubType == HeartSubType.HEART_FULL -- normal red hearts
  89. and not toSteal:ToPickup():IsShopItem() then
  90. toSteal:Remove()
  91. Sprite:Play(steal, true) -- Play costume animation
  92. if Sprite:IsPlaying(steal) then
  93. HeartCount = HeartCount + 2 -- a full heart increases the counter by 2
  94. Mod:SaveData(HeartCount)
  95. if HeartCount >= 5 then -- pays out at 2,5 hearts
  96. DarkBum.PAYOUT = true
  97. end
  98. end
  99. end
  100. if toSteal.SubType == HeartSubType.HEART_SCARED -- scared red hearts
  101. and not toSteal:ToPickup():IsShopItem() then
  102. toSteal:Remove()
  103. Sprite:Play(steal, true) -- Play costume animation
  104. if Sprite:IsPlaying(steal) then
  105. HeartCount = HeartCount + 2 -- a sacred heart increases the counter by 2
  106. Mod:SaveData(HeartCount)
  107. if HeartCount >= 5 then -- pays out at 2,5 hearts
  108. DarkBum.PAYOUT = true
  109. end
  110. end
  111. end
  112. if toSteal.SubType == HeartSubType.HEART_DOUBLEPACK -- double red hearts
  113. and not toSteal:ToPickup():IsShopItem() then
  114. toSteal:Remove()
  115. Sprite:Play(steal, true) -- Play costume animation
  116. if Sprite:IsPlaying(steal) then
  117. HeartCount = HeartCount + 4 -- a double red heart increases the counter by 4
  118. Mod:SaveData(HeartCount)
  119. if HeartCount >= 5 then -- pays out at 2,5 hearts
  120. DarkBum.PAYOUT = true
  121. end
  122. end
  123. end
  124. end
  125. end
  126. if entity.Position:Distance(player.Position) <= 95 then -- distance from the player
  127. if DarkBum.SPAWNED == false
  128. and DarkBum.PAYOUT == true then -- 95
  129. DarkBum.SPAWNED = true
  130. Sprite:Play("PreCoin", true)
  131. end
  132. end
  133.  
  134. end
  135. end
  136. Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onNewEvent)
  137.  
  138.  
  139. function Mod:onPickup(DaBum)
  140. local player = Isaac.GetPlayer(0)
  141. local entities = Isaac.GetRoomEntities() -- all entities in the room
  142. local entity = DaBum
  143. local Sprite = entity:GetSprite()
  144. local rng = player:GetCollectibleRNG(278) -- 278 = Dark Bum
  145. local numCoins = (rng:RandomInt(2)) + 2 -- number of coins Dark Bum spawns if you play as the Keeper
  146.  
  147. if player:HasCollectible(CollectibleType.COLLECTIBLE_DARK_BUM) then
  148.  
  149. -- if you play as the Lost
  150. if player:GetPlayerType() == PlayerType.PLAYER_THELOST then
  151. if Sprite:IsPlaying("Spawn") then
  152. if Sprite:GetFrame() == 1 then
  153. for j = 1, #entities do
  154. local entitis = entities[j]
  155. if entitis.Type == EntityType.ENTITY_PICKUP
  156. and entitis.Variant == PickupVariant.PICKUP_HEART
  157. and entitis.SubType == HeartSubType.HEART_SOUL then
  158. if entitis.SpawnerType == EntityType.ENTITY_FAMILIAR
  159. and entitis.SpawnerVariant == FamiliarVariant.DARK_BUM then
  160. entitis:Remove()
  161. local numBlueSpider = 2 -- number of spiders Dark Bum will spawn
  162. for k = 1, numBlueSpider do
  163. player:ThrowBlueSpider(entity.Position, player.Position)
  164. end
  165. end
  166. end
  167. end
  168. end
  169. end
  170. end
  171.  
  172. -- if you play as the Keeper
  173. if Sprite:IsFinished("PreCoin") then
  174. HeartCount = HeartCount - 5
  175. Mod:SaveData(HeartCount)
  176. Sprite:Play("SpawnCoin", true)
  177. for i = 1, numCoins do
  178. angle = math.random(math.floor(360/numCoins)) -- get the angle
  179. angleVector = Vector.FromAngle(angle + (i-1)*(math.floor(360/numCoins))) -- this distributes the coins equally around Dark Bum
  180. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COIN, CoinSubType.COIN_PENNY, entity.Position, angleVector, entity)
  181. end
  182. end
  183. if Sprite:IsFinished("SpawnCoin") then
  184. if HeartCount < 5 then
  185. DarkBum.PAYOUT = false
  186. DarkBum.SPAWNED = false
  187. else
  188. DarkBum.PAYOUT = true
  189. DarkBum.SPAWNED = false
  190. end
  191. end
  192.  
  193. if Sprite:IsFinished("SpawnCoin") or Sprite:IsFinished("Steal") or Sprite:IsFinished("AltSteal") then
  194. Sprite:Play("FloatDown", true)
  195. end
  196. end
  197. end
  198. Mod:AddCallback(ModCallbacks.MC_FAMILIAR_UPDATE, Mod.onPickup, FamiliarVariant.DARK_BUM)
Advertisement
Add Comment
Please, Sign In to add comment