Josh64

Poop Tear 2

Jul 27th, 2019
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.68 KB | None | 0 0
  1. local Mod = RegisterMod("Miserere", 1);
  2. local game = Game()
  3.  
  4. local pooptear = {
  5. BASE_CHANCE = 100,
  6. MAX_LUCK = 10,
  7. STONE_BONUS = 1.5,
  8. SCALE = 1, -- (-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. local hasCostume = false -- keeps track if the player has the costume
  19.  
  20.  
  21. CollectibleType.COLLECTIBLE_MISERERE = Isaac.GetItemIdByName("Miserere") -- item
  22. Mod.COSTUME_MISERERE = Isaac.GetCostumeIdByPath("gfx/characters/miserere.anm2") -- costume
  23. TearVariant.POOPTEAR = Isaac.GetEntityVariantByName("POOPTEAR") -- tear variant
  24.  
  25. -- on post peffect update
  26. function Mod:onUpdate(player)
  27.  
  28. local FireDir = player:GetFireDirection()
  29.  
  30. if game:GetFrameCount() == 1 then
  31. Isaac.Spawn(EntityType.ENTITY_PICKUP, PickupVariant.PICKUP_COLLECTIBLE, CollectibleType.COLLECTIBLE_MISERERE, Vector(250, 250), Vector(0,0), nil)
  32. end
  33.  
  34. -- costume stuff
  35. if player:HasCollectible(CollectibleType.COLLECTIBLE_MISERERE)
  36. and hasCostume == false then
  37. player:AddNullCostume(Mod.COSTUME_MISERERE)
  38. hasCostume = true
  39. end
  40. if not (player:HasCollectible(CollectibleType.COLLECTIBLE_MISERERE))
  41. and hasCostume == true then
  42. player:TryRemoveNullCostume(Mod.COSTUME_MISERERE)
  43. hasCostume = false
  44. end
  45.  
  46. -- tear stuff
  47. if player:HasCollectible(CollectibleType.COLLECTIBLE_MISERERE) then
  48.  
  49. -- costume stuff
  50. if hasCostume == false then
  51. player:AddNullCostume(Mod.COSTUME_MISERERE)
  52. hasCostume = true
  53. end
  54. for _, entity in pairs(Isaac.GetRoomEntities()) do -- go through every entity in the room
  55. local tearData = entity:GetData()
  56. local sprite = entity:GetSprite()
  57. if entity.Type == EntityType.ENTITY_TEAR then -- its a tear!
  58. local tear = entity:ToTear()
  59. -- change tear variant
  60. if entity.Variant ~= TearVariant.POOPTEAR then --TearVariant.PoopTear then
  61. tear:ChangeVariant(TearVariant.POOPTEAR)
  62. -- Isaac.ConsoleOutput("Poop Tear!")
  63. if tearData.Animation == nil then
  64. if FireDir == Direction.DOWN then
  65. tearData.Animation = true
  66. tear:GetSprite():Play("ShootDown", true)
  67. elseif FireDir == Direction.RIGHT then
  68. tearData.Animation = true
  69. tear:GetSprite():Play("ShootRight", true)
  70. elseif FireDir == Direction.UP then
  71. tearData.Animation = true
  72. tear:GetSprite():Play("ShootUp", true)
  73. elseif FireDir == Direction.LEFT then
  74. tearData.Animation = true
  75. tear:GetSprite():Play("ShootLeft", true)
  76. end
  77. end
  78. -- add first flags?
  79. else
  80. if tearData.PoopType == nil then
  81. Isaac.ConsoleOutput("A new Tear!")
  82. -- check if the tear can be a variant
  83. if player:HasTrinket(TrinketType.TRINKET_PINKY_EYE)
  84. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PINKY_EYE)
  85. or player:HasCollectible(CollectibleType.COLLECTIBLE_BOZO)
  86. or player:HasCollectible(CollectibleType.COLLECTIBLE_MIDAS_TOUCH)
  87. or player:HasTrinket(TrinketType.TRINKET_MECONIUM)
  88. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_MECONIUM)
  89. or player:HasCollectible(CollectibleType.COLLECTIBLE_HALLOWED_GROUND) then
  90. -- get rng
  91. local rng = player:GetCollectibleRNG(CollectibleType.COLLECTIBLE_MISERERE)
  92. local roll = rng:RandomInt(100)
  93. -- will the tear be a variant
  94. if roll <= ((100 - pooptear.BASE_CHANCE) * player.Luck / pooptear.MAX_LUCK) + pooptear.BASE_CHANCE then
  95. -- which variants are possible
  96. local poopVariant = {1, 2, 3, 4, 5} -- 1=holy, 2=dank, 3=golden, 4=rainbow, 5=red
  97. if not (player:HasTrinket(TrinketType.TRINKET_PINKY_EYE)
  98. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PINKY_EYE)) then
  99. table.remove(poopVariant, 5)
  100. end
  101. if not (player:HasCollectible(CollectibleType.COLLECTIBLE_BOZO)) then
  102. table.remove(poopVariant, 4)
  103. end
  104. if not (player:HasCollectible(CollectibleType.COLLECTIBLE_MIDAS_TOUCH)) then
  105. table.remove(poopVariant, 3)
  106. end
  107. if not (player:HasTrinket(TrinketType.TRINKET_MECONIUM)
  108. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_MECONIUM)) then
  109. table.remove(poopVariant, 2)
  110. end
  111. if not (player:HasCollectible(CollectibleType.COLLECTIBLE_HALLOWED_GROUND)) then
  112. table.remove(poopVariant, 1)
  113. end
  114.  
  115. -- saftey check
  116. if poopVariant[1] == nil then -- somehow the poop got emptied
  117. tearData.PoopType = 0 -- a normal poop tear
  118. else -- should happen normaly
  119.  
  120. local pickPoop = math.random(#poopVariant)
  121. if poopVariant[pickPoop] == 1 then
  122. tearData.PoopType = 1 -- Holy Poop
  123. elseif poopVariant[pickPoop] == 2 then
  124. tearData.PoopType = 2 -- Dank Poop
  125. elseif poopVariant[pickPoop] == 3 then
  126. tearData.PoopType = 3 -- Golden Poop
  127. elseif poopVariant[pickPoop] == 4 then
  128. tearData.PoopType = 4 -- Rainbow Poop
  129. elseif poopVariant[pickPoop] == 5 then
  130. tearData.PoopType = 5 -- Red Poop
  131. end
  132. end
  133. if tearData.PoopType == 1 then -- Holy Poop
  134. if tearData.HasCostume == nil then
  135. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  136. tearData.HasCostume = true
  137. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_holy_piercing.png")
  138. sprite:LoadGraphics()
  139. else
  140. tearData.HasCostume = true
  141. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_holy.png")
  142. sprite:LoadGraphics()
  143. end
  144. end
  145. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  146. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  147. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  148. end
  149. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  150.  
  151. elseif tearData.PoopType == 2 then -- Dank
  152. if tearData.HasCostume == nil then
  153. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  154. tearData.HasCostume = true
  155. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_dank_piercing.png")
  156. sprite:LoadGraphics()
  157. else
  158. tearData.HasCostume = true
  159. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_dank.png")
  160. sprite:LoadGraphics()
  161. end
  162. end
  163. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  164. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  165. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  166. end
  167. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  168.  
  169. elseif tearData.PoopType == 3 then -- Golden
  170. if tearData.HasCostume == nil then
  171. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  172. tearData.HasCostume = true
  173. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_golden_piercing.png")
  174. sprite:LoadGraphics()
  175. else
  176. tearData.HasCostume = true
  177. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_golden.png")
  178. sprite:LoadGraphics()
  179. end
  180. end
  181. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  182. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  183. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  184. end
  185. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  186.  
  187. elseif tearData.PoopType == 4 then -- Rainbow
  188. if tearData.HasCostume == nil then
  189. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  190. tearData.HasCostume = true
  191. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_rainbow_piercing.png")
  192. sprite:LoadGraphics()
  193. else
  194. tearData.HasCostume = true
  195. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_rainbow.png")
  196. sprite:LoadGraphics()
  197. end
  198. end
  199. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  200. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  201. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  202. end
  203. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  204.  
  205. elseif tearData.PoopType == 5 then -- Red
  206. if tearData.HasCostume == nil then
  207. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  208. tearData.HasCostume = true
  209. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_red_piercing.png")
  210. sprite:LoadGraphics()
  211. else
  212. tearData.HasCostume = true
  213. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_red.png")
  214. sprite:LoadGraphics()
  215. end
  216. end
  217. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  218. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  219. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  220. end
  221. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  222. end
  223. else
  224. tearData.PoopType = 0
  225. end
  226. else
  227. tearData.PoopType = 0
  228. end
  229. -- do stuff for tearData.PoopType 0
  230. end
  231. if tearData.PoopType == 0 then
  232. if tearData.HasCostume == nil then
  233. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  234. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  235. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  236. tearData.HasCostume = true
  237. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_petrified_piercing.png")
  238. sprite:LoadGraphics()
  239. else
  240. tearData.HasCostume = true
  241. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_normal_piercing.png")
  242. sprite:LoadGraphics()
  243. end
  244. elseif player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  245. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  246. tearData.HasCostume = true
  247. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_petrified.png")
  248. sprite:LoadGraphics()
  249. end
  250. end
  251. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  252. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  253. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  254. end
  255. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  256.  
  257.  
  258. -- check if the tear collids with an enemy
  259. for _, entities in pairs(Isaac.GetRoomEntities()) do
  260. if entities:IsActiveEnemy()
  261. and not (entities:IsBoss()) then
  262. local enemy = entities
  263. if (enemy.Position:Distance(tear.Position) < 30) then
  264. enemy:GetData().NormalPoop = true
  265. end
  266. end
  267. end
  268. elseif tearData.PoopType == 1 then -- Holy
  269. -- check if the tear collids with an enemy
  270. for _, entities in pairs(Isaac.GetRoomEntities()) do
  271. if entities:IsActiveEnemy()
  272. and not (entities:IsBoss()) then
  273. local enemy = entities
  274. if (enemy.Position:Distance(tear.Position) < 30) then
  275. enemy:GetData().HolyPoop = true
  276. end
  277. end
  278. end
  279. elseif tearData.PoopType == 2 then -- Dank
  280. -- check if the tear collids with an enemy
  281. for _, entities in pairs(Isaac.GetRoomEntities()) do
  282. if entities:IsActiveEnemy()
  283. and not (entities:IsBoss()) then
  284. local enemy = entities
  285. if (enemy.Position:Distance(tear.Position) < 30) then
  286. enemy:GetData().DankPoop = true
  287. end
  288. end
  289. end
  290. elseif tearData.PoopType == 3 then -- Golden
  291. -- check if the tear collids with an enemy
  292. for _, entities in pairs(Isaac.GetRoomEntities()) do
  293. if entities:IsActiveEnemy()
  294. and not (entities:IsBoss()) then
  295. local enemy = entities
  296. if (enemy.Position:Distance(tear.Position) < 30) then
  297. enemy:GetData().GoldenPoop = true
  298. end
  299. end
  300. end
  301. elseif tearData.PoopType == 4 then -- Rainbow
  302. -- check if the tear collids with an enemy
  303. for _, entities in pairs(Isaac.GetRoomEntities()) do
  304. if entities:IsActiveEnemy()
  305. and not (entities:IsBoss()) then
  306. local enemy = entities
  307. if (enemy.Position:Distance(tear.Position) < 30) then
  308. enemy:GetData().RainbowPoop = true
  309. end
  310. end
  311. end
  312. elseif tearData.PoopType == 5 then -- Red
  313. -- check if the tear collids with an enemy
  314. for _, entities in pairs(Isaac.GetRoomEntities()) do
  315. if entities:IsActiveEnemy()
  316. and not (entities:IsBoss()) then
  317. local enemy = entities
  318. if (enemy.Position:Distance(tear.Position) < 30) then
  319. enemy:GetData().RedPoop = true
  320. end
  321. end
  322. end
  323. end
  324. end
  325. end
  326. end
  327.  
  328. end
  329. end
  330. Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onUpdate)
  331.  
  332.  
  333. function Mod:onDamage(entity, amt, flag, source, countdown)
  334.  
  335. -- local tearData = source:GetData()
  336. if source.Type == EntityType.ENTITY_TEAR
  337. and source.Variant == TearVariant.POOPTEAR then
  338. if entity:IsActiveEnemy()
  339. and not (entity:IsBoss()) then
  340. if entity:GetData().NormalPoop == true then
  341. entity:Remove()
  342. Isaac.ConsoleOutput(" Poop!")
  343. Isaac.GridSpawn(GridEntityType.GRID_POOP, 0, entity.Position, true)
  344.  
  345. elseif entity:GetData().HolyPoop == true then
  346. entity:Remove()
  347. Isaac.ConsoleOutput("Holy Poop!")
  348. Isaac.GridSpawn(GridEntityType.GRID_POOP, 6, entity.Position, true)
  349.  
  350. elseif entity:GetData().DankPoop == true then
  351. entity:Remove()
  352. Isaac.ConsoleOutput("Dank Poop!")
  353. Isaac.GridSpawn(GridEntityType.GRID_POOP, 5, entity.Position, true)
  354.  
  355. elseif entity:GetData().GoldenPoop == true then
  356. entity:Remove()
  357. Isaac.ConsoleOutput("Golden Poop!")
  358. Isaac.GridSpawn(GridEntityType.GRID_POOP, 3, entity.Position, true)
  359.  
  360. elseif entity:GetData().RainbowPoop == true then
  361. entity:Remove()
  362. Isaac.ConsoleOutput("Rainbow Poop!")
  363. Isaac.GridSpawn(GridEntityType.GRID_POOP, 4, entity.Position, true)
  364.  
  365. elseif entity:GetData().RedPoop == true then
  366. entity:Remove()
  367. Isaac.ConsoleOutput("Red Poop!")
  368. Isaac.GridSpawn(GridEntityType.GRID_POOP, 1, entity.Position, true)
  369. end
  370. end
  371. end
  372. end
  373. Mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, Mod.onDamage)
Advertisement
Add Comment
Please, Sign In to add comment