Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local MawMod = RegisterMod("Your Mod", 1);
- local game = Game()
- local specialTear = {
- BASE_CHANCE = 10, -- chance for tear to turn into a special one
- MAX_LUCK = 10, -- max luck requiered to turn every tear into a special one
- }
- function MawsMod:onUpdate(player)
- for _, entity in pairs(Isaac.GetRoomEntities()) do -- go through every entity in the room
- if entity.Type == EntityType.ENTITY_TEAR -- its a tear!
- and entity.SpawnerType == EntityType.ENTITY_PLAYER then
- local tear = entity:ToTear()
- local tearData = tear:GetData()
- local sprite = tear:GetSprite()
- if tearData.NewTear == nil then -- has no data applied to it yet
- -- get rng
- local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_YOUR_ITEM)
- local roll = rng:RandomInt(100)
- -- will the tear be a variant (based on luck)
- if roll <= ((100 - specialTear.BASE_CHANCE) * player.Luck / specialTear.MAX_LUCK) + specialTear.BASE_CHANCE then
- -- make sure it's not choas card or bobs rotten head before changing the variant
- if tear.Variant ~= TearVariant.CHAOS_CARD
- and tear.Variant ~= TearVariant.BOBS_ROTTEN_HEAD then
- -- change tear variant
- -- make sure the tear doesn't is the same variant as the variant you would like to change it to (if you do the tear gets invisible)
- if tear.Variant ~= TearVariant.BLUE
- and tear.Variant ~= TearVariant.BLOOD then
- tearData.NewTear = 1
- -- change tear variant
- tear:ChangeVariant(TearVariant.BLUE)
- -- give it your new spritesheet
- sprite:ReplaceSpritesheet(0, "gfx/effects/your_new_spritesheet.png")
- sprite:LoadGraphics()
- else
- -- it's already the variant you need
- tearData.NewTear = 1 -- now your special tear
- -- give it your new spritesheet
- sprite:ReplaceSpritesheet(0, "gfx/effects/your_new_spritesheet.png")
- sprite:LoadGraphics()
- end
- end
- end
- elseif tearData.NewTear == 1 then -- your new special tear
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities:IsActiveEnemy()
- and not (entities:IsBoss()) then
- local enemy = entities
- -- check collision
- if (enemy.Position:Distance(tear.Position) < 30) then
- -- if (enemy.Position - tear.Position):Length() <= enemy.Size + tear.Size then
- -- inflict bleeding
- enemy:AddEntityFlags(EntityFlag.FLAG_BLEEDING)
- end
- end
- end
- end
- end
- end
- end
- MawMod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, MawMod.onUpdate)
Advertisement
Add Comment
Please, Sign In to add comment