Josh64

Poop Tears

Apr 12th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.67 KB | None | 0 0
  1. local Mod = RegisterMod("Miserere", 1);
  2. local game = Game()
  3.  
  4. local pooptear = {
  5. BASE_CHANCE = 15,
  6. MAX_LUCK = 10,
  7. STONE_BONUS = 1.5,
  8. SCALE = -1,
  9. TurnChance = 0
  10. }
  11. local Dir = {
  12. [Direction.UP] = Vector(0,-1),
  13. [Direction.DOWN] = Vector(0,1),
  14. [Direction.LEFT] = Vector(-1,0),
  15. [Direction.RIGHT] = Vector(1,0)
  16. }
  17.  
  18. CollectibleType.COLLECTIBLE_MISERERE = Isaac.GetItemIdByName("Miserere")
  19. TearVariant.POOPTEAR = Isaac.GetEntityVariantByName("POOPTEAR")
  20.  
  21. -- on post peffect update
  22. function Mod:onUpdate(player)
  23.  
  24. local FireDir = player:GetFireDirection()
  25.  
  26. if game:GetFrameCount() == 1 then
  27. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_MISERERE, Vector(250, 250), Vector(0,0), nil)
  28. end
  29.  
  30. if player:HasCollectible(CollectibleType.COLLECTIBLE_MISERERE) then
  31. for _, entity in pairs(Isaac.GetRoomEntities()) do
  32. local tearData = entity:GetData()
  33. local sprite = entity:GetSprite()
  34. if entity.Type == EntityType.ENTITY_TEAR then
  35. local tear = entity:ToTear()
  36. if entity.Variant ~= TearVariant.POOPTEAR then --TearVariant.PoopTear then
  37. tear:ChangeVariant(TearVariant.POOPTEAR)
  38. -- Isaac.ConsoleOutput("Poop Tear!")
  39. if tearData.Animation == nil then
  40. if FireDir == Direction.DOWN then
  41. tearData.Animation = true
  42. tear:GetSprite():Play("ShotDown", true)
  43. elseif FireDir == Direction.RIGHT then
  44. tearData.Animation = true
  45. tear:GetSprite():Play("ShotRight", true)
  46. elseif FireDir == Direction.UP then
  47. tearData.Animation = true
  48. tear:GetSprite():Play("ShotUp", true)
  49. elseif FireDir == Direction.LEFT then
  50. tearData.Animation = true
  51. tear:GetSprite():Play("ShotLeft", true)
  52. end
  53. end
  54. -- add first flags?
  55. else
  56. if tearData.PoopType == nil then
  57. Isaac.ConsoleOutput("A new Tear!")
  58. -- check if the tear can be a variant
  59. if player:HasTrinket(TrinketType.TRINKET_PINKY_EYE)
  60. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PINKY_EYE)
  61. or player:HasCollectible(CollectibleType.COLLECTIBLE_BOZO)
  62. or player:HasCollectible(CollectibleType.COLLECTIBLE_MIDAS_TOUCH)
  63. or player:HasTrinket(TrinketType.TRINKET_MECONIUM)
  64. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_MECONIUM)
  65. or player:HasCollectible(CollectibleType.COLLECTIBLE_HALLOWED_GROUND) then
  66. -- get rng
  67. local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_MISERERE)
  68. local roll = rng:RandomInt(100)
  69. -- will the tear be a variant
  70. if roll <= ((100 - pooptear.BASE_CHANCE) * player.Luck / pooptear.MAX_LUCK) + pooptear.BASE_CHANCE then
  71. -- which variants are possible
  72. local poopVariant = {1, 2, 3, 4, 5} -- 1=holy, 2=dank, 3=golden, 4=rainbow, 5=red
  73. if not (player:HasTrinket(TrinketType.TRINKET_PINKY_EYE)
  74. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PINKY_EYE)) then
  75. table.remove(poopVariant, 5)
  76. end
  77. if not (player:HasCollectible(CollectibleType.COLLECTIBLE_BOZO)) then
  78. table.remove(poopVariant, 4)
  79. end
  80. if not (player:HasCollectible(CollectibleType.COLLECTIBLE_MIDAS_TOUCH)) then
  81. table.remove(poopVariant, 3)
  82. end
  83. if not (player:HasTrinket(TrinketType.TRINKET_MECONIUM)
  84. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_MECONIUM)) then
  85. table.remove(poopVariant, 2)
  86. end
  87. if not (player:HasCollectible(CollectibleType.COLLECTIBLE_HALLOWED_GROUND)) then
  88. table.remove(poopVariant, 1)
  89. end
  90.  
  91. -- saftey check
  92. if poopVariant[1] == nil then -- somehow the poop got emptied
  93. tearData.PoopType = 0 -- a normal poop tear
  94. else -- should happen normaly
  95.  
  96. local pickPoop = math.random(#poopVariant)
  97. if poopVariant[pickPoop] == 1 then
  98. tearData.PoopType = 1 -- Holy Poop
  99. elseif poopVariant[pickPoop] == 2 then
  100. tearData.PoopType = 2 -- Dank Poop
  101. elseif poopVariant[pickPoop] == 3 then
  102. tearData.PoopType = 3 -- Golden Poop
  103. elseif poopVariant[pickPoop] == 4 then
  104. tearData.PoopType = 4 -- Rainbow Poop
  105. elseif poopVariant[pickPoop] == 5 then
  106. tearData.PoopType = 5 -- Red Poop
  107. end
  108. end
  109. if tearData.PoopType == 1 then -- Holy Poop
  110. if tearData.HasCostume == nil then
  111. if tear:TearFlags() == TearFlags.TEAR_PIERCING then
  112. tearData.HasCostume = true
  113. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_holy_piercing.png")
  114. sprite:LoadGraphics()
  115. else
  116. tearData.HasCostume = true
  117. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_holy.png")
  118. sprite:LoadGraphics()
  119. end
  120. end
  121. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  122. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  123. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  124. end
  125. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  126. elseif tearData.PoopType == 2 then -- Dank
  127. if tearData.HasCostume == nil then
  128. if tear:TearFlags() == TearFlags.TEAR_PIERCING then
  129. tearData.HasCostume = true
  130. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_dank_piercing.png")
  131. sprite:LoadGraphics()
  132. else
  133. tearData.HasCostume = true
  134. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_dank.png")
  135. sprite:LoadGraphics()
  136. end
  137. end
  138. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  139. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  140. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  141. end
  142. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  143. elseif tearData.PoopType == 3 then -- Golden
  144. if tearData.HasCostume == nil then
  145. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  146. tearData.HasCostume = true
  147. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_golden_piercing.png")
  148. sprite:LoadGraphics()
  149. else
  150. tearData.HasCostume = true
  151. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_golden.png")
  152. sprite:LoadGraphics()
  153. end
  154. end
  155. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  156. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  157. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  158. end
  159. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  160. elseif tearData.PoopType == 4 then -- Rainbow
  161. if tearData.HasCostume == nil then
  162. if tear:TearFlags() == TearFlags.TEAR_PIERCING then
  163. tearData.HasCostume = true
  164. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_rainbow_piercing.png")
  165. sprite:LoadGraphics()
  166. else
  167. tearData.HasCostume = true
  168. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_rainbow.png")
  169. sprite:LoadGraphics()
  170. end
  171. end
  172. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  173. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  174. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  175. end
  176. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  177. elseif tearData.PoopType == 5 then -- Red
  178. if tearData.HasCostume == nil then
  179. if tear:TearFlags() == TearFlags.TEAR_PIERCING then
  180. tearData.HasCostume = true
  181. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_red_piercing.png")
  182. sprite:LoadGraphics()
  183. else
  184. tearData.HasCostume = true
  185. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_red.png")
  186. sprite:LoadGraphics()
  187. end
  188. end
  189. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  190. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  191. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  192. end
  193. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  194. end
  195. else
  196. tearData.PoopType = 0
  197. end
  198. else
  199. tearData.PoopType = 0
  200. end
  201. -- do stuff for tearData.PoopType 0
  202. if tearData.PoopType == 0 then
  203. if tearData.HasCostume == nil then
  204. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  205. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  206. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  207. tearData.HasCostume = true
  208. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_petrified_piercing.png")
  209. sprite:LoadGraphics()
  210. else
  211. tearData.HasCostume = true
  212. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_normal_piercing.png")
  213. sprite:LoadGraphics()
  214. end
  215. elseif player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  216. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  217. tearData.HasCostume = true
  218. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_petrified.png")
  219. sprite:LoadGraphics()
  220. end
  221. end
  222. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  223. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  224. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  225. end
  226. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  227.  
  228. end
  229. end
  230. end
  231. end
  232. end
  233. end
  234. end
  235. Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onUpdate)
  236.  
  237.  
  238. function Mod:onDamage(entity, amt, flag, source, countdown)
  239.  
  240. if source.Type == EntityType.ENTITY_TEAR
  241. and source.Variant == TearVariant.POOPTEAR then
  242. if entity:IsActiveEnemy() then
  243. entity:Remove()
  244. Isaac.ConsoleOutput("Poop!")
  245. Isaac.GridSpawn(GridEntityType.GRID_POOP, 0, entity.Position, true)
  246. end
  247. end
  248. end
  249. Mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, Mod.onDamage)
Advertisement
Add Comment
Please, Sign In to add comment