Josh64

Fix 1.04

Jun 20th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.45 KB | None | 0 0
  1. local Bombbugs = RegisterMod("BombBugs", 1)
  2. local game = Game()
  3.  
  4. -- reference item, bomb, costume and timer
  5.  
  6. local bombBugs = Isaac.GetItemIdByName("Bomb Bugs")
  7. local bombs = {} -- empty array of bombs
  8. epictimer = 0 -- variable 2
  9. epictimercheck = 0 -- variable 1
  10. -- loacl BombCostume = Isaac.GetCostumeIdByPath("gfx/charaters/YOUR NAME FOR THE ANIMATION.anm2")
  11.  
  12. -- on player init
  13.  
  14. function Bombbugs:onInit()
  15. local player = Isaac.GetPlayer(0);
  16. if game:GetFrameCount() == 1 then
  17. HasBugs = false
  18. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, bombBugs, Vector(320, 250), Vector(0,0), player)
  19. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.CARD_TOWER, Vector(270, 250), Vector(0,0), player)
  20. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_DR_FETUS, Vector(370, 250), Vector(0,0), player)
  21. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_HIVE_MIND, Vector(470, 250), Vector(0,0), player)
  22. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_BURSTING_SACK, Vector(370, 350), Vector(0,0), player)
  23. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_BOMB, BombSubType.BOMB_SUPERTROLL, Vector(120, 150), Vector(0,0), player)
  24. end
  25. if not HasBugs and player:HasCollectible(bombBugs) then
  26. -- player:AddNullCostume(BombCostume)
  27. HasBugs = true
  28. end
  29. end
  30. Bombbugs:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Bombbugs.onInit)
  31.  
  32. -- getting a bug on a bomb explosion
  33.  
  34.  
  35. function Bombbugs:onExplosion()
  36.  
  37. local player = Isaac.GetPlayer(0) -- reference player
  38. local entities = Isaac.GetRoomEntities() -- reference all room entities
  39.  
  40. -- detect an explosion
  41.  
  42. if player:HasCollectible(bombBugs) then
  43. for j = 1, #entities do -- we check all entities in the room
  44. if entities[j].Type == EntityType.ENTITY_BOMBDROP -- should be a bomb
  45. and entities[j].Variant ~= BombVariant.BOMB_SUPERTROLL
  46. and entities[j].Variant ~= BombVariant.BOMB_TROLL then
  47. if entities[j].SpawnerType == EntityType.ENTITY_PLAYER then
  48. if entities[j]:GetData().Exploded == nil then -- a fresh bomb
  49. entities[j]:GetData().Exploded = false -- property that the bomb hasn´t exploded yet
  50. table.insert(bombs, entities[j]) -- insert the found bomb into the array
  51. end
  52. end
  53. end
  54. end
  55. for j= 1, #bombs do -- iterate through every bomb
  56. if bombs[j]:IsDead() and bombs[j]:GetData().Exploded == false then -- if bomb is dead(has exploded)
  57. bombs[j]:GetData().Exploded = true -- property that the bomb exploded
  58.  
  59. -- now we spawn something!
  60.  
  61. local rng = player:GetCollectibleRNG(bombBugs)
  62. local roll = rng:RandomInt(100)
  63. local diceroll = math.random(4)
  64. if player:HasCollectible(377) then -- 377 is Bursting Sack
  65. if roll < 85 then
  66. if player:HasCollectible(248) then
  67. for a = 1, diceroll do
  68. local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
  69. spider:AddCharmed(-1)
  70. spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
  71. end
  72. else
  73. for b = 1, diceroll do
  74.  
  75. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  76.  
  77. --bombs[j].ThrowBlueSpider(bombs[j].Position, Vector(math.random(30),math.random(35)))
  78. end
  79. end
  80. elseif roll < 95 then
  81. if player:GetTrinket(0) ~= TrinketType.TRINKET_TICK
  82. and player:GetTrinket(1) ~= TrinketType.TRINKET_TICK
  83. and player:GetTrinket(0) ~= TrinketType.TRINKET_MATCH_STICK
  84. and player:GetTrinket(1) ~= TrinketType.TRINKET_MATCH_STICK then -- the game tries to give the player the Tick
  85. player:DropTrinket(player.Position, false) -- if the player has a trinket it will be dropped
  86. player:AddTrinket(TrinketType.TRINKET_TICK) -- add the tick to the player
  87. else
  88. if player:HasCollectible(248) then
  89. for c = 1, diceroll do
  90. local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
  91. spider:AddCharmed(-1)
  92. spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
  93. end
  94. else
  95. for d = 1, diceroll do
  96.  
  97. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  98. end
  99. end
  100. end
  101. else
  102. if player:HasCollectible(248) then -- 248 is Hive Mind
  103. Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
  104. else
  105. for e = 1, diceroll do
  106. local smallspider = Isaac.Spawn(EntityType.ENTITY_SPIDER, 2, 1, bombs[j].Position, Vector(0,0), player)
  107. smallspider:AddCharmed(-1)
  108. smallspider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
  109. end
  110. end
  111. end
  112. else
  113. if roll < 85 then
  114. if player:HasCollectible(248) then
  115. local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
  116. spider:AddCharmed(-1)
  117. spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
  118. else
  119. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  120. end
  121. elseif roll < 95 then
  122. if player:GetTrinket(0) ~= TrinketType.TRINKET_TICK
  123. and player:GetTrinket(1) ~= TrinketType.TRINKET_TICK
  124. and player:GetTrinket(0) ~= TrinketType.TRINKET_MATCH_STICK
  125. and player:GetTrinket(1) ~= TrinketType.TRINKET_MATCH_STICK then
  126. player:DropTrinket(player.Position, false)
  127. player:AddTrinket(TrinketType.TRINKET_TICK)
  128. else
  129. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  130. end
  131. else
  132. -- spawns a Big or normal red spider with a 5% chance
  133. if player:HasCollectible(248) then -- 248 is Hive Mind
  134. local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
  135. spider:AddCharmed(-1)
  136. spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
  137. else
  138. Isaac.Spawn(EntityType.ENTITY_SPIDER, 2, 1, bombs[j].Position, Vector(0,0), player)
  139. end
  140. end
  141. end
  142. end
  143. end
  144. for j = 1, #entities do
  145. if entities[j].Type == EntityType.ENTITY_BOMBDROP then
  146. if entities[j]:GetData().Exploded == true then -- the bomb, which is exploded
  147. entities[j]:Remove() -- remove the original bomb
  148. end
  149. end
  150. end
  151.  
  152. --Epic Fetus functionality
  153.  
  154. if player:HasCollectible(168) then -- 168 = Epic Fetus
  155.  
  156. for _, entity in pairs(entities) do -- we check each entity in the room.
  157. epictimercheck = game:GetFrameCount()
  158.  
  159. if entity.Type == EntityType.ENTITY_EFFECT
  160. and entity.Variant == EffectVariant.ROCKET then
  161. if epictimercheck >= epictimer + 10
  162. and entity.FrameCount >= 9 then
  163. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, entity.Position, Vector(0,0), player)
  164. epictimer = game:GetFrameCount()
  165. end
  166. end
  167. end
  168. end
  169. if not player:HasCollectible(168) then
  170. epictimercheck = 0
  171. epictimer = 0
  172. end
  173. end
  174. end
  175. Bombbugs:AddCallback(ModCallbacks.MC_POST_UPDATE, Bombbugs.onExplosion)
Advertisement
Add Comment
Please, Sign In to add comment