Josh64

We put bugs in your bombs!!

Jun 17th, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.36 KB | None | 0 0
  1. local Bombbugs = RegisterMod("BombBugs", 1)
  2. local game = Game()
  3.  
  4. -- reference item and bomb
  5.  
  6. local bombBugs = Isaac.GetItemIdByName("Bomb Bugs")
  7. local bombs = {} -- empty array of bombs
  8. timer = 0 -- variable 2
  9. timercheck = 0 -- variable 1
  10.  
  11. -- on player init
  12.  
  13. function Bombbugs:onInit()
  14. local player = Isaac.GetPlayer(0);
  15. if game:GetFrameCount() == 1 then
  16. if ((Game():GetLevel():GetStage() == 1) and (Game():IsGreedMode() == false)) then
  17. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, bombBugs, Vector(320, 250), Vector(0,0), player)
  18. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.CARD_TOWER, Vector(270, 250), Vector(0,0), player)
  19. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_DR_FETUS, Vector(370, 250), Vector(0,0), player)
  20. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_BOMB, BombSubType.BOMB_SUPERTROLL, Vector(120, 150), Vector(0,0), player)
  21. end
  22. end
  23. end
  24. Bombbugs:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Bombbugs.onInit)
  25.  
  26. -- getting a bug on a bomb explosion
  27.  
  28.  
  29. function Bombbugs:onExplosion()
  30.  
  31. local player = Isaac.GetPlayer(0) -- reference player
  32. local entities = Isaac.GetRoomEntities() -- reference all room entities
  33.  
  34. -- detect an explosion
  35.  
  36. if player:HasCollectible(bombBugs) then
  37. for j = 1, #entities do -- we check all entities in the room
  38. if(entities[j].Type == EntityType.ENTITY_BOMBDROP and entities[j].Variant ~= BombVariant.BOMB_SUPERTROLL and entities[j].Variant ~= BombVariant.BOMB_TROLL) then -- should be a bomb
  39. if(entities[j].SpawnerType == EntityType.ENTITY_PLAYER) then
  40. if(entities[j]:GetData().Exploded == nil) then -- a fresh bomb
  41. entities[j]:GetData().Exploded = false -- property that the bomb hasn“t exploded yet
  42. table.insert(bombs, entities[j]) -- insert the found bomb into the array
  43. end
  44. end
  45. end
  46. end
  47. for j= 1, #bombs do -- iterate through every bomb
  48. if(bombs[j]:IsDead() and bombs[j]:GetData().Exploded == false) then -- if bomb is dead(has exploded)
  49. bombs[j]:GetData().Exploded = true -- property that the bomb exploded
  50.  
  51. -- now we spawn something!
  52.  
  53. local rng = player:GetCollectibleRNG(bombBugs)
  54. local roll = rng:RandomInt(100)
  55. if roll < 85 then
  56. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  57.  
  58. elseif roll < 95 then
  59. if(player:GetTrinket(0) ~= TrinketType.TRINKET_TICK and player:GetTrinket(1) ~= TrinketType.TRINKET_TICK and player:GetTrinket(0) ~= TrinketType.TRINKET_MATCH_STICK and player:GetTrinket(1) ~= TrinketType.TRINKET_MATCH_STICK) then -- the game tries to give the player the Tick
  60. player:DropTrinket(player.Position, false) -- if the player has a trinket it will be dropped
  61. player:AddTrinket(TrinketType.TRINKET_TICK) -- add the tick to the player
  62. else
  63. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  64. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_MATCH_STICK, bombs[j].Position, Vector(0,0), player)
  65. end
  66. else
  67. Isaac.Spawn(EntityType.ENTITY_SPIDER, 2, 1, bombs[j].Position, Vector(0,0), player) -- spawns a red spider at a 5% chance
  68. end
  69. end
  70. end
  71. for j = 1, #entities do
  72. if(entities[j].Type == EntityType.ENTITY_BOMBDROP) then
  73. if(entities[j]:GetData().Exploded == true) then -- the bomb, which is exploded
  74. entities[j]:Remove() -- remove the original bomb
  75. end
  76. end
  77. end
  78.  
  79. --Epic Fetus functionality
  80.  
  81. if player:HasCollectible(168) then -- 168 = Epic Fetus
  82.  
  83. for _, entity in pairs(entities) do -- we check each entity in the room.
  84. timercheck = game:GetFrameCount()
  85.  
  86. if entity.Type == EntityType.ENTITY_EFFECT
  87. and entity.Variant == EffectVariant.ROCKET then
  88. if timercheck >= timer + 10
  89. and entity.FrameCount >= 9 then
  90. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, entity.Position, Vector(0,0), player)
  91. timer = game:GetFrameCount()
  92. end
  93. end
  94. end
  95. end
  96. if not player:HasCollectible(168) then
  97. timercheck = 0
  98. timer = 0
  99. end
  100. end
  101. end
  102. Bombbugs:AddCallback(ModCallbacks.MC_POST_UPDATE, Bombbugs.onExplosion)
Advertisement
Add Comment
Please, Sign In to add comment