Josh64

Final BombBugs

Jun 20th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.40 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. -- now we spawn something
  62.  
  63. local rng = player:GetCollectibleRNG(bombBugs)
  64. local roll = rng:RandomInt(100)
  65. if player:HasCollectible(377) then -- 377 is Bursting Sack
  66. if roll < 85 then
  67. for e = 1, 4 do
  68. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  69. end
  70. elseif roll < 95 then
  71. if(player:GetTrinket(0) ~= TrinketType.TRINKET_TICK
  72. and player:GetTrinket(1) ~= TrinketType.TRINKET_TICK
  73. and player:GetTrinket(0) ~= TrinketType.TRINKET_MATCH_STICK
  74. and player:GetTrinket(1) ~= TrinketType.TRINKET_MATCH_STICK) then -- the game tries to give the player the Tick
  75. player:DropTrinket(player.Position, false) -- if the player has a trinket it will be dropped
  76. player:AddTrinket(TrinketType.TRINKET_TICK) -- add the tick to the player
  77. else
  78. for f = 1, 4 do
  79. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  80. end
  81. end
  82. else
  83. if player:HasCollectible(248) then -- 248 is Hive Mind
  84. local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
  85. spider:AddCharmed(-1)
  86. spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
  87. else
  88. for g = 1, 4 do
  89. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  90. end
  91. end
  92. end
  93. else
  94. if roll < 85 then
  95. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  96. elseif roll < 95 then
  97. if(player:GetTrinket(0) ~= TrinketType.TRINKET_TICK
  98. and player:GetTrinket(1) ~= TrinketType.TRINKET_TICK
  99. and player:GetTrinket(0) ~= TrinketType.TRINKET_MATCH_STICK
  100. and player:GetTrinket(1) ~= TrinketType.TRINKET_MATCH_STICK) then player:DropTrinket(player.Position, false)
  101. player:AddTrinket(TrinketType.TRINKET_TICK)
  102. else
  103. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  104. end
  105. else
  106. -- spawns a Big or normal red spider with a 5% chance
  107. if player:HasCollectible(248) then -- 248 is Hive Mind
  108. Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
  109. else
  110. Isaac.Spawn(EntityType.ENTITY_SPIDER, 2, 1, bombs[j].Position, Vector(0,0), player)
  111. end
  112. end
  113. end
  114. end
  115. end
  116. for j = 1, #entities do
  117. if entities[j].Type == EntityType.ENTITY_BOMBDROP then
  118. if entities[j]:GetData().Exploded == true then -- the bomb, which is exploded
  119. entities[j]:Remove() -- remove the original bomb
  120. end
  121. end
  122. end
  123.  
  124. --Epic Fetus functionality
  125.  
  126. if player:HasCollectible(168) then -- 168 = Epic Fetus
  127.  
  128. for _, entity in pairs(entities) do -- we check each entity in the room.
  129. epictimercheck = game:GetFrameCount()
  130.  
  131. if entity.Type == EntityType.ENTITY_EFFECT
  132. and entity.Variant == EffectVariant.ROCKET then
  133. if epictimercheck >= epictimer + 10
  134. and entity.FrameCount >= 9 then
  135. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, entity.Position, Vector(0,0), player)
  136. epictimer = game:GetFrameCount()
  137. end
  138. end
  139. end
  140. end
  141. if not player:HasCollectible(168) then
  142. epictimercheck = 0
  143. epictimer = 0
  144. end
  145. end
  146. end
  147. Bombbugs:AddCallback(ModCallbacks.MC_POST_UPDATE, Bombbugs.onExplosion)
Advertisement
Add Comment
Please, Sign In to add comment