Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Bombbugs = RegisterMod("BombBugs", 1)
- local game = Game()
- -- reference item and bomb
- local bombBugs = Isaac.GetItemIdByName("Bomb Bugs")
- local bombs = {} -- empty array of bombs
- -- on player init
- function Bombbugs:onInit()
- local player = Isaac.GetPlayer(0);
- if game:GetFrameCount() == 1 then
- if ((Game():GetLevel():GetStage() == 1) and (Game():IsGreedMode() == false)) then
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, bombBugs, Vector(320, 250), Vector(0,0), player)
- -- spawn in test subjects
- -- 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
- -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_FAST_BOMBS, Vector(370, 250), Vector(0,0), player) -- Fast Bombs for fast testing
- -- 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
- end
- end
- end
- Bombbugs:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Bombbugs.onInit)
- -- getting a bug on a bomb explosion
- function Bombbugs:onExplosion()
- local player = Isaac.GetPlayer(0) -- reference player
- local entities = Isaac.GetRoomEntities() -- reference all room entities
- -- detect an explosion
- if player:HasCollectible(bombBugs) then
- for j = 1, #entities do -- we check all entities in the room
- 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
- if(entities[j]:GetData().Exploded == nil) then -- a fresh bomb
- entities[j]:GetData().Exploded = false -- property that the bomb hasn´t exploded yet
- table.insert(bombs, entities[j]) -- insert the found bomb into the array
- end
- end
- end
- for j= 1, #bombs do -- iterate through every bomb
- if(bombs[j]:IsDead() and bombs[j]:GetData().Exploded == false) then -- if bomb is dead(has exploded)
- bombs[j]:GetData().Exploded = true -- property that the bomb exploded
- local rng = player:GetCollectibleRNG(bombBugs)
- local roll = rng:RandomInt(100)
- if roll < 85 then
- Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
- elseif roll < 95 then
- 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
- player:DropTrinket(player.Position, false) -- if the player has a trinket it will be dropped
- player:AddTrinket(TrinketType.TRINKET_TICK) -- add the tick to the player
- else
- Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
- -- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TRINKET, TrinketType.TRINKET_MATCH_STICK, bombs[j].Position, Vector(0,0), player)
- end
- else
- Isaac.Spawn(EntityType.ENTITY_SPIDER, 2, 1, bombs[j].Position, Vector(0,0), player) -- spawns a red spider at a 5% chance
- end
- end
- end
- for j = 1, #entities do
- if(entities[j].Type == EntityType.ENTITY_BOMBDROP) then
- if(entities[j]:GetData().Exploded == true) then -- the bomb, which is exploded
- entities[j]:Remove() -- remove the original bomb
- end
- end
- end
- end
- end
- Bombbugs:AddCallback(ModCallbacks.MC_POST_UPDATE, Bombbugs.onExplosion)
Advertisement
Add Comment
Please, Sign In to add comment