local Mod = RegisterMod("Miserere", 1); local game = Game() local pooptear = { BASE_CHANCE = 15, MAX_LUCK = 10, STONE_BONUS = 1.5, SCALE = -1, TurnChance = 0 } local Dir = { [Direction.UP] = Vector(0,-1), [Direction.DOWN] = Vector(0,1), [Direction.LEFT] = Vector(-1,0), [Direction.RIGHT] = Vector(1,0) } CollectibleType.COLLECTIBLE_MISERERE = Isaac.GetItemIdByName("Miserere") TearVariant.POOPTEAR = Isaac.GetEntityVariantByName("POOPTEAR") -- on post peffect update function Mod:onUpdate(player) local FireDir = player:GetFireDirection() if game:GetFrameCount() == 1 then Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_MISERERE, Vector(250, 250), Vector(0,0), nil) end if player:HasCollectible(CollectibleType.COLLECTIBLE_MISERERE) then for _, entity in pairs(Isaac.GetRoomEntities()) do local tearData = entity:GetData() local sprite = entity:GetSprite() if entity.Type == EntityType.ENTITY_TEAR then local tear = entity:ToTear() if entity.Variant ~= TearVariant.POOPTEAR then --TearVariant.PoopTear then tear:ChangeVariant(TearVariant.POOPTEAR) -- Isaac.ConsoleOutput("Poop Tear!") if tearData.Animation == nil then if FireDir == Direction.DOWN then tearData.Animation = true tear:GetSprite():Play("ShotDown", true) elseif FireDir == Direction.RIGHT then tearData.Animation = true tear:GetSprite():Play("ShotRight", true) elseif FireDir == Direction.UP then tearData.Animation = true tear:GetSprite():Play("ShotUp", true) elseif FireDir == Direction.LEFT then tearData.Animation = true tear:GetSprite():Play("ShotLeft", true) end end -- add first flags? else if tearData.PoopType == nil then Isaac.ConsoleOutput("A new Tear!") -- check if the tear can be a variant if player:HasTrinket(TrinketType.TRINKET_PINKY_EYE) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PINKY_EYE) or player:HasCollectible(CollectibleType.COLLECTIBLE_BOZO) or player:HasCollectible(CollectibleType.COLLECTIBLE_MIDAS_TOUCH) or player:HasTrinket(TrinketType.TRINKET_MECONIUM) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_MECONIUM) or player:HasCollectible(CollectibleType.COLLECTIBLE_HALLOWED_GROUND) then -- get rng local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_MISERERE) local roll = rng:RandomInt(100) -- will the tear be a variant if roll <= ((100 - pooptear.BASE_CHANCE) * player.Luck / pooptear.MAX_LUCK) + pooptear.BASE_CHANCE then -- which variants are possible local poopVariant = {1, 2, 3, 4, 5} -- 1=holy, 2=dank, 3=golden, 4=rainbow, 5=red if not (player:HasTrinket(TrinketType.TRINKET_PINKY_EYE) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PINKY_EYE)) then table.remove(poopVariant, 5) end if not (player:HasCollectible(CollectibleType.COLLECTIBLE_BOZO)) then table.remove(poopVariant, 4) end if not (player:HasCollectible(CollectibleType.COLLECTIBLE_MIDAS_TOUCH)) then table.remove(poopVariant, 3) end if not (player:HasTrinket(TrinketType.TRINKET_MECONIUM) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_MECONIUM)) then table.remove(poopVariant, 2) end if not (player:HasCollectible(CollectibleType.COLLECTIBLE_HALLOWED_GROUND)) then table.remove(poopVariant, 1) end -- saftey check if poopVariant[1] == nil then -- somehow the poop got emptied tearData.PoopType = 0 -- a normal poop tear else -- should happen normaly local pickPoop = math.random(#poopVariant) if poopVariant[pickPoop] == 1 then tearData.PoopType = 1 -- Holy Poop elseif poopVariant[pickPoop] == 2 then tearData.PoopType = 2 -- Dank Poop elseif poopVariant[pickPoop] == 3 then tearData.PoopType = 3 -- Golden Poop elseif poopVariant[pickPoop] == 4 then tearData.PoopType = 4 -- Rainbow Poop elseif poopVariant[pickPoop] == 5 then tearData.PoopType = 5 -- Red Poop end end if tearData.PoopType == 1 then -- Holy Poop if tearData.HasCostume == nil then if tear:TearFlags() == TearFlags.TEAR_PIERCING then tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_holy_piercing.png") sprite:LoadGraphics() else tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_holy.png") sprite:LoadGraphics() end end if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS end tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8) elseif tearData.PoopType == 2 then -- Dank if tearData.HasCostume == nil then if tear:TearFlags() == TearFlags.TEAR_PIERCING then tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_dank_piercing.png") sprite:LoadGraphics() else tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_dank.png") sprite:LoadGraphics() end end if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS end tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8) elseif tearData.PoopType == 3 then -- Golden if tearData.HasCostume == nil then if tear.TearFlags == TearFlags.TEAR_PIERCING then tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_golden_piercing.png") sprite:LoadGraphics() else tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_golden.png") sprite:LoadGraphics() end end if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS end tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8) elseif tearData.PoopType == 4 then -- Rainbow if tearData.HasCostume == nil then if tear:TearFlags() == TearFlags.TEAR_PIERCING then tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_rainbow_piercing.png") sprite:LoadGraphics() else tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_rainbow.png") sprite:LoadGraphics() end end if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS end tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8) elseif tearData.PoopType == 5 then -- Red if tearData.HasCostume == nil then if tear:TearFlags() == TearFlags.TEAR_PIERCING then tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_red_piercing.png") sprite:LoadGraphics() else tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_red.png") sprite:LoadGraphics() end end if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS end tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8) end else tearData.PoopType = 0 end else tearData.PoopType = 0 end -- do stuff for tearData.PoopType 0 if tearData.PoopType == 0 then if tearData.HasCostume == nil then if tear.TearFlags == TearFlags.TEAR_PIERCING then if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_petrified_piercing.png") sprite:LoadGraphics() else tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_normal_piercing.png") sprite:LoadGraphics() end elseif player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then tearData.HasCostume = true sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_petrified.png") sprite:LoadGraphics() end end if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP) or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS end tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8) end end end end end end end Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onUpdate) function Mod:onDamage(entity, amt, flag, source, countdown) if source.Type == EntityType.ENTITY_TEAR and source.Variant == TearVariant.POOPTEAR then if entity:IsActiveEnemy() then entity:Remove() Isaac.ConsoleOutput("Poop!") Isaac.GridSpawn(GridEntityType.GRID_POOP, 0, entity.Position, true) end end end Mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, Mod.onDamage)