Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod("Miserere", 1);
- local game = Game()
- local pooptear = {
- BASE_CHANCE = 100,
- MAX_LUCK = 10,
- STONE_BONUS = 1.5,
- SCALE = 1, -- (-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)
- }
- local hasCostume = false -- keeps track if the player has the costume
- CollectibleType.COLLECTIBLE_MISERERE = Isaac.GetItemIdByName("Miserere") -- item
- Mod.COSTUME_MISERERE = Isaac.GetCostumeIdByPath("gfx/characters/miserere.anm2") -- costume
- TearVariant.POOPTEAR = Isaac.GetEntityVariantByName("POOPTEAR") -- tear variant
- -- 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
- -- costume stuff
- if player:HasCollectible(CollectibleType.COLLECTIBLE_MISERERE)
- and hasCostume == false then
- player:AddNullCostume(Mod.COSTUME_MISERERE)
- hasCostume = true
- end
- if not (player:HasCollectible(CollectibleType.COLLECTIBLE_MISERERE))
- and hasCostume == true then
- player:TryRemoveNullCostume(Mod.COSTUME_MISERERE)
- hasCostume = false
- end
- -- tear stuff
- if player:HasCollectible(CollectibleType.COLLECTIBLE_MISERERE) then
- -- costume stuff
- if hasCostume == false then
- player:AddNullCostume(Mod.COSTUME_MISERERE)
- hasCostume = true
- end
- for _, entity in pairs(Isaac.GetRoomEntities()) do -- go through every entity in the room
- local tearData = entity:GetData()
- local sprite = entity:GetSprite()
- if entity.Type == EntityType.ENTITY_TEAR then -- its a tear!
- local tear = entity:ToTear()
- -- change tear variant
- 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("ShootDown", true)
- elseif FireDir == Direction.RIGHT then
- tearData.Animation = true
- tear:GetSprite():Play("ShootRight", true)
- elseif FireDir == Direction.UP then
- tearData.Animation = true
- tear:GetSprite():Play("ShootUp", true)
- elseif FireDir == Direction.LEFT then
- tearData.Animation = true
- tear:GetSprite():Play("ShootLeft", 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
- end
- 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)
- -- check if the tear collids with an enemy
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities:IsActiveEnemy()
- and not (entities:IsBoss()) then
- local enemy = entities
- if (enemy.Position:Distance(tear.Position) < 30) then
- enemy:GetData().NormalPoop = true
- end
- end
- end
- elseif tearData.PoopType == 1 then -- Holy
- -- check if the tear collids with an enemy
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities:IsActiveEnemy()
- and not (entities:IsBoss()) then
- local enemy = entities
- if (enemy.Position:Distance(tear.Position) < 30) then
- enemy:GetData().HolyPoop = true
- end
- end
- end
- elseif tearData.PoopType == 2 then -- Dank
- -- check if the tear collids with an enemy
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities:IsActiveEnemy()
- and not (entities:IsBoss()) then
- local enemy = entities
- if (enemy.Position:Distance(tear.Position) < 30) then
- enemy:GetData().DankPoop = true
- end
- end
- end
- elseif tearData.PoopType == 3 then -- Golden
- -- check if the tear collids with an enemy
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities:IsActiveEnemy()
- and not (entities:IsBoss()) then
- local enemy = entities
- if (enemy.Position:Distance(tear.Position) < 30) then
- enemy:GetData().GoldenPoop = true
- end
- end
- end
- elseif tearData.PoopType == 4 then -- Rainbow
- -- check if the tear collids with an enemy
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities:IsActiveEnemy()
- and not (entities:IsBoss()) then
- local enemy = entities
- if (enemy.Position:Distance(tear.Position) < 30) then
- enemy:GetData().RainbowPoop = true
- end
- end
- end
- elseif tearData.PoopType == 5 then -- Red
- -- check if the tear collids with an enemy
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities:IsActiveEnemy()
- and not (entities:IsBoss()) then
- local enemy = entities
- if (enemy.Position:Distance(tear.Position) < 30) then
- enemy:GetData().RedPoop = true
- end
- end
- end
- end
- end
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onUpdate)
- function Mod:onDamage(entity, amt, flag, source, countdown)
- -- local tearData = source:GetData()
- if source.Type == EntityType.ENTITY_TEAR
- and source.Variant == TearVariant.POOPTEAR then
- if entity:IsActiveEnemy()
- and not (entity:IsBoss()) then
- if entity:GetData().NormalPoop == true then
- entity:Remove()
- Isaac.ConsoleOutput(" Poop!")
- Isaac.GridSpawn(GridEntityType.GRID_POOP, 0, entity.Position, true)
- elseif entity:GetData().HolyPoop == true then
- entity:Remove()
- Isaac.ConsoleOutput("Holy Poop!")
- Isaac.GridSpawn(GridEntityType.GRID_POOP, 6, entity.Position, true)
- elseif entity:GetData().DankPoop == true then
- entity:Remove()
- Isaac.ConsoleOutput("Dank Poop!")
- Isaac.GridSpawn(GridEntityType.GRID_POOP, 5, entity.Position, true)
- elseif entity:GetData().GoldenPoop == true then
- entity:Remove()
- Isaac.ConsoleOutput("Golden Poop!")
- Isaac.GridSpawn(GridEntityType.GRID_POOP, 3, entity.Position, true)
- elseif entity:GetData().RainbowPoop == true then
- entity:Remove()
- Isaac.ConsoleOutput("Rainbow Poop!")
- Isaac.GridSpawn(GridEntityType.GRID_POOP, 4, entity.Position, true)
- elseif entity:GetData().RedPoop == true then
- entity:Remove()
- Isaac.ConsoleOutput("Red Poop!")
- Isaac.GridSpawn(GridEntityType.GRID_POOP, 1, entity.Position, true)
- end
- end
- end
- end
- Mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, Mod.onDamage)
Advertisement
Add Comment
Please, Sign In to add comment