Josh64

final version without synergies

May 20th, 2018
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 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.  
  9. -- on player init
  10.  
  11. function Bombbugs:onInit()
  12. local player = Isaac.GetPlayer(0);
  13. if game:GetFrameCount() == 1 then
  14. if ((Game():GetLevel():GetStage() == 1) and (Game():IsGreedMode() == false)) then
  15. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, bombBugs, Vector(320, 250), Vector(0,0), player)
  16.  
  17. -- spawn in test subjects
  18.  
  19. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.CARD_TOWER, Vector(270, 250), Vector(0,0), player) -- Tarotcard the tower, to check if the mod ignores normal troll bombs
  20. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_FAST_BOMBS, Vector(370, 250), Vector(0,0), player) -- Fast Bombs for fast testing
  21. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_BOMB, BombSubType.BOMB_SUPERTROLL, Vector(120, 150), Vector(0,0), player) -- to check if the mod ignores Supertroll bombs
  22. end
  23. end
  24. end
  25. Bombbugs:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Bombbugs.onInit)
  26.  
  27. -- getting a bug on a bomb explosion
  28.  
  29.  
  30. function Bombbugs:onExplosion()
  31.  
  32. local player = Isaac.GetPlayer(0) -- reference player
  33. local entities = Isaac.GetRoomEntities() -- reference all room entities
  34.  
  35. -- detect an explosion
  36.  
  37. if player:HasCollectible(bombBugs) then
  38. for j = 1, #entities do -- we check all entities in the room
  39. 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
  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. for j= 1, #bombs do -- iterate through every bomb
  47. if(bombs[j]:IsDead() and bombs[j]:GetData().Exploded == false) then -- if bomb is dead(has exploded)
  48. bombs[j]:GetData().Exploded = true -- property that the bomb exploded
  49. local rng = player:GetCollectibleRNG(bombBugs)
  50. local roll = rng:RandomInt(100)
  51. if roll < 85 then
  52. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  53.  
  54. elseif roll < 95 then
  55. 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
  56. player:DropTrinket(player.Position, false) -- if the player has a trinket it will be dropped
  57. player:AddTrinket(TrinketType.TRINKET_TICK) -- add the tick to the player
  58. else
  59. Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
  60. -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_MATCH_STICK, bombs[j].Position, Vector(0,0), player)
  61. end
  62. else
  63. Isaac.Spawn(EntityType.ENTITY_SPIDER, 2, 1, bombs[j].Position, Vector(0,0), player) -- spawns a red spider at a 5% chance
  64. end
  65. end
  66. end
  67. for j = 1, #entities do
  68. if(entities[j].Type == EntityType.ENTITY_BOMBDROP) then
  69. if(entities[j]:GetData().Exploded == true) then -- the bomb, which is exploded
  70. entities[j]:Remove() -- remove the original bomb
  71. end
  72. end
  73. end
  74. end
  75. end
  76. Bombbugs:AddCallback(ModCallbacks.MC_POST_UPDATE, Bombbugs.onExplosion)
Advertisement
Add Comment
Please, Sign In to add comment