Josh64

PoopTear 2

Apr 17th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.07 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.  
  127. elseif tearData.PoopType == 2 then -- Dank
  128. if tearData.HasCostume == nil then
  129. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  130. tearData.HasCostume = true
  131. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_dank_piercing.png")
  132. sprite:LoadGraphics()
  133. else
  134. tearData.HasCostume = true
  135. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_dank.png")
  136. sprite:LoadGraphics()
  137. end
  138. end
  139. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  140. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  141. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  142. end
  143. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  144.  
  145. elseif tearData.PoopType == 3 then -- Golden
  146. if tearData.HasCostume == nil then
  147. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  148. tearData.HasCostume = true
  149. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_golden_piercing.png")
  150. sprite:LoadGraphics()
  151. else
  152. tearData.HasCostume = true
  153. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_golden.png")
  154. sprite:LoadGraphics()
  155. end
  156. end
  157. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  158. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  159. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  160. end
  161. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  162.  
  163. elseif tearData.PoopType == 4 then -- Rainbow
  164. if tearData.HasCostume == nil then
  165. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  166. tearData.HasCostume = true
  167. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_rainbow_piercing.png")
  168. sprite:LoadGraphics()
  169. else
  170. tearData.HasCostume = true
  171. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_rainbow.png")
  172. sprite:LoadGraphics()
  173. end
  174. end
  175. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  176. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  177. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  178. end
  179. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  180.  
  181. elseif tearData.PoopType == 5 then -- Red
  182. if tearData.HasCostume == nil then
  183. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  184. tearData.HasCostume = true
  185. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_red_piercing.png")
  186. sprite:LoadGraphics()
  187. else
  188. tearData.HasCostume = true
  189. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_red.png")
  190. sprite:LoadGraphics()
  191. end
  192. end
  193. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  194. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  195. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  196. end
  197. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  198. end
  199. else
  200. earData.PoopType = 0
  201. end
  202. else
  203. tearData.PoopType = 0
  204. end
  205. -- do stuff for tearData.PoopType 0
  206. end
  207. if tearData.PoopType == 0 then
  208. if tearData.HasCostume == nil then
  209. if tear.TearFlags == TearFlags.TEAR_PIERCING then
  210. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  211. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  212. tearData.HasCostume = true
  213. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_petrified_piercing.png")
  214. sprite:LoadGraphics()
  215. else
  216. tearData.HasCostume = true
  217. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_normal_piercing.png")
  218. sprite:LoadGraphics()
  219. end
  220. elseif player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  221. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  222. tearData.HasCostume = true
  223. sprite:ReplaceSpritesheet(0, "gfx/effects/poop_tear_petrified.png")
  224. sprite:LoadGraphics()
  225. end
  226. end
  227. if player:HasTrinket(TrinketType.TRINKET_PETRIFIED_POOP)
  228. or player:GetEffects():HasTrinketEffect(TrinketType.TRINKET_PETRIFIED_POOP) then
  229. tear.CollisionDamage = tear.CollisionDamage * pooptear.STONE_BONUS
  230. end
  231. tear:SetSize(tear.Size * pooptear.SCALE, Vector(pooptear.SCALE, pooptear.SCALE), 8)
  232.  
  233. -- check if the tear collids with an enemy
  234. for _, entities in pairs(Isaac.GetRoomEntities()) do
  235. if entities:IsActiveEnemy()
  236. and not (entities:IsBoss()) then
  237. if ((entities.Position - tear.Position):Length() < entities.Size + tear.Size) then
  238. Isaac.ConsoleOutput("GetData")
  239. if entities:TakeDamage(_,_,tear,_)then
  240. entities:GetData().NormalPoop = true
  241. entity:Remove()
  242. Isaac.ConsoleOutput(" Poop!")
  243. Isaac.GridSpawn(GridEntityType.GRID_POOP, 0, entity.Position, true)
  244. end
  245. end
  246. end
  247. end
  248. end
  249. end
  250. end
  251. end
  252.  
  253. end
  254. end
  255. Mod:AddCallback(ModCallbacks.MC_POST_PEFFECT_UPDATE, Mod.onUpdate)
  256.  
  257.  
  258. function Mod:onDamage(entity, amt, flag, source, countdown)
  259.  
  260. -- local tearData = source:GetData()
  261. if source.Type == EntityType.ENTITY_TEAR
  262. and source.Variant == TearVariant.POOPTEAR then
  263. if entity:IsActiveEnemy()
  264. and not (entity:IsBoss()) then
  265. if entity:GetData().NormalPoop == true then
  266. entity:Remove()
  267. Isaac.ConsoleOutput(" Poop!")
  268. Isaac.GridSpawn(GridEntityType.GRID_POOP, 0, entity.Position, true)
  269. -- elseif source:GetData().PoopType == 2 then
  270. entity:Remove()
  271. Isaac.ConsoleOutput("Dank Poop!")
  272. Isaac.GridSpawn(GridEntityType.GRID_POOP, 4, entity.Position, true)
  273. -- elseif source:GetData().PoopType == 3 then
  274. entity:Remove()
  275. Isaac.ConsoleOutput("Golden Poop!")
  276. Isaac.GridSpawn(GridEntityType.GRID_POOP, 1, entity.Position, true)
  277. -- elseif source:GetData().PoopType == 4 then
  278. entity:Remove()
  279. Isaac.ConsoleOutput("Rainbow Poop!")
  280. Isaac.GridSpawn(GridEntityType.GRID_POOP, 3, entity.Position, true)
  281. -- elseif source:GetData().PoopType == 5 then
  282. entity:Remove()
  283. Isaac.ConsoleOutput("Red Poop!")
  284. Isaac.GridSpawn(GridEntityType.GRID_POOP, 2, entity.Position, true)
  285. -- else
  286. entity:Remove()
  287. Isaac.ConsoleOutput("Failed!")
  288. -- Isaac.GridSpawn(GridEntityType.GRID_POOP, 0, entity.Position, true)
  289. end
  290. end
  291. end
  292. end
  293. Mod:AddCallback(ModCallbacks.MC_ENTITY_TAKE_DMG, Mod.onDamage)
Advertisement
Add Comment
Please, Sign In to add comment