Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Bombbugs = RegisterMod("BombBugs", 1)
- local game = Game()
- -- reference item, bomb, costume and timer
- local bombBugs = Isaac.GetItemIdByName("Bomb Bugs")
- local bombs = {} -- empty array of bombs
- epictimer = 0 -- variable 2
- epictimercheck = 0 -- variable 1
- -- loacl BombCostume = Isaac.GetCostumeIdByPath("gfx/charaters/YOUR NAME FOR THE ANIMATION.anm2")
- -- on player init
- function Bombbugs:onInit()
- local player = Isaac.GetPlayer(0);
- if game:GetFrameCount() == 1 then
- HasBugs = false
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, bombBugs, Vector(320, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_TAROTCARD, Card.CARD_TOWER, Vector(270, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_DR_FETUS, Vector(370, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_HIVE_MIND, Vector(470, 250), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_BURSTING_SACK, Vector(370, 350), Vector(0,0), player)
- Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_BOMB, BombSubType.BOMB_SUPERTROLL, Vector(120, 150), Vector(0,0), player)
- end
- if not HasBugs and player:HasCollectible(bombBugs) then
- -- player:AddNullCostume(BombCostume)
- HasBugs = true
- 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 -- should be a bomb
- and entities[j].Variant ~= BombVariant.BOMB_SUPERTROLL
- and entities[j].Variant ~= BombVariant.BOMB_TROLL then
- if entities[j].SpawnerType == EntityType.ENTITY_PLAYER then
- 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
- 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
- -- now we spawn something!
- local rng = player:GetCollectibleRNG(bombBugs)
- local roll = rng:RandomInt(100)
- local diceroll = math.random(4)
- if player:HasCollectible(377) then -- 377 is Bursting Sack
- if roll < 85 then
- if player:HasCollectible(248) then
- for a = 1, diceroll do
- local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
- spider:AddCharmed(-1)
- spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
- end
- else
- for b = 1, diceroll do
- Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
- --bombs[j].ThrowBlueSpider(bombs[j].Position, Vector(math.random(30),math.random(35)))
- end
- end
- 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
- if player:HasCollectible(248) then
- for c = 1, diceroll do
- local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
- spider:AddCharmed(-1)
- spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
- end
- else
- for d = 1, diceroll do
- Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
- end
- end
- end
- else
- if player:HasCollectible(248) then -- 248 is Hive Mind
- Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
- else
- for e = 1, diceroll do
- local smallspider = Isaac.Spawn(EntityType.ENTITY_SPIDER, 2, 1, bombs[j].Position, Vector(0,0), player)
- smallspider:AddCharmed(-1)
- smallspider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
- end
- end
- end
- else
- if roll < 85 then
- if player:HasCollectible(248) then
- local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
- spider:AddCharmed(-1)
- spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
- else
- Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
- end
- 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
- player:DropTrinket(player.Position, false)
- player:AddTrinket(TrinketType.TRINKET_TICK)
- else
- Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, bombs[j].Position, Vector(0,0), player)
- end
- else
- -- spawns a Big or normal red spider with a 5% chance
- if player:HasCollectible(248) then -- 248 is Hive Mind
- local spider = Isaac.Spawn(EntityType.ENTITY_BIGSPIDER, 1, 1, bombs[j].Position, Vector(0,0), player)
- spider:AddCharmed(-1)
- spider:AddEntityFlags(EntityFlag.FLAG_FRIENDLY)
- else
- Isaac.Spawn(EntityType.ENTITY_SPIDER, 2, 1, bombs[j].Position, Vector(0,0), player)
- end
- end
- 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
- --Epic Fetus functionality
- if player:HasCollectible(168) then -- 168 = Epic Fetus
- for _, entity in pairs(entities) do -- we check each entity in the room.
- epictimercheck = game:GetFrameCount()
- if entity.Type == EntityType.ENTITY_EFFECT
- and entity.Variant == EffectVariant.ROCKET then
- if epictimercheck >= epictimer + 10
- and entity.FrameCount >= 9 then
- Isaac.Spawn(EntityType.ENTITY_FAMILIAR, FamiliarVariant.BLUE_SPIDER, 0, entity.Position, Vector(0,0), player)
- epictimer = game:GetFrameCount()
- end
- end
- end
- end
- if not player:HasCollectible(168) then
- epictimercheck = 0
- epictimer = 0
- end
- end
- end
- Bombbugs:AddCallback(ModCallbacks.MC_POST_UPDATE, Bombbugs.onExplosion)
Advertisement
Add Comment
Please, Sign In to add comment