Josh64

Untitled

Jan 6th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.23 KB | None | 0 0
  1. local MawMod = RegisterMod("Your Mod", 1);
  2. local game = Game()
  3.  
  4. local specialTear = {
  5. BASE_CHANCE = 10, -- chance for tear to turn into a special one
  6. MAX_LUCK = 10, -- max luck requiered to turn every tear into a special one
  7. }
  8.  
  9. function MawsMod:onUpdate(player)
  10. for _, entity in pairs(Isaac.GetRoomEntities()) do -- go through every entity in the room
  11. if entity.Type == EntityType.ENTITY_TEAR -- its a tear!
  12. and entity.SpawnerType == EntityType.ENTITY_PLAYER then
  13. local tear = entity:ToTear()
  14. local tearData = tear:GetData()
  15. local sprite = tear:GetSprite()
  16. if tearData.NewTear == nil then -- has no data applied to it yet
  17. -- get rng
  18. local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_YOUR_ITEM)
  19. local roll = rng:RandomInt(100)
  20. -- will the tear be a variant (based on luck)
  21. if roll <= ((100 - specialTear.BASE_CHANCE) * player.Luck / specialTear.MAX_LUCK) + specialTear.BASE_CHANCE then
  22. -- make sure it's not choas card or bobs rotten head before changing the variant
  23. if tear.Variant ~= TearVariant.CHAOS_CARD
  24. and tear.Variant ~= TearVariant.BOBS_ROTTEN_HEAD then
  25. -- change tear variant
  26. -- 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)
  27. if tear.Variant ~= TearVariant.BLUE
  28. and tear.Variant ~= TearVariant.BLOOD then
  29. tearData.NewTear = 1
  30. -- change tear variant
  31. tear:ChangeVariant(TearVariant.BLUE)
  32. -- give it your new spritesheet
  33. sprite:ReplaceSpritesheet(0, "gfx/effects/your_new_spritesheet.png")
  34. sprite:LoadGraphics()
  35. else
  36. -- it's already the variant you need
  37. tearData.NewTear = 1 -- now your special tear
  38. -- give it your new spritesheet
  39. sprite:ReplaceSpritesheet(0, "gfx/effects/your_new_spritesheet.png")
  40. sprite:LoadGraphics()
  41. end
  42. end
  43. end
  44. elseif tearData.NewTear == 1 then -- your new special tear
  45. for _, entities in pairs(Isaac.GetRoomEntities()) do
  46. if entities:IsActiveEnemy()
  47. and not (entities:IsBoss()) then
  48. local enemy = entities
  49. -- check collision
  50. if (enemy.Position:Distance(tear.Position) < 30) then
  51. -- if (enemy.Position - tear.Position):Length() <= enemy.Size + tear.Size then
  52. -- inflict bleeding
  53. enemy:AddEntityFlags(EntityFlag.FLAG_BLEEDING)
  54. end
  55. end
  56. end
  57. end
  58. end
  59. end
  60. end
  61. MawMod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, MawMod.onUpdate)
Advertisement
Add Comment
Please, Sign In to add comment