Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Mod = RegisterMod"naturalOrder", 1)
- local game = Game()
- local minBugNum = 3
- function Mod:onUpdate(player)
- for _, entity in pairs(Isaac.GetRoomEntities()) do
- if entity.Type == EntityType.ENTITY_SPIDER then
- local spider = entity
- for _, entities in pairs(Isaac.GetRoomEntities()) do
- if entities.Type == EntityType.ENTITY_EFFECT then
- if entities.Variant == EffectVariant.TINY_BUG
- or entities.Variant == EffectVariant.TINY_FLY
- or entities.Variant == EffectVariant.WORM
- or entities.Variant == EffectVariant.BEETLE
- or entities.Variant == EffectVariant.WISP
- or entities.Variant == EffectVariant.WALL_BUG
- or entities.Variant == EffectVariant.BUTTERFLY then
- local bug = entities
- if (bug.Position - spider.Position):Length() <= bug.Size + spider.Size then
- -- kill the bug/effect
- bug:Die()
- bug:Remove()
- local tinyBlood = Isaac.Spawn(EntityType.ENTITY_EFFECT, EffectVariant.BLOOD_SPLAT, 0, Vector(0,0), bug.Position, bug):ToEffect()
- -- make it invisible for a couple of frames
- tinyBlood.SpriteScale = Vector(0.1,0.1)
- tinyBlood:Update()
- -- increase the kill count of the spider
- local spiderData = spider:GetData()
- if spiderData.IncreasedCounter == nil then
- if spiderData.EatenBugs == nil then
- spiderData.EatenBugs = 0
- end
- spiderData.EatenBugs = spiderData.EatenBugs + 1
- spiderData.IncreasedCounter = true
- end
- end
- end
- end
- end
- end
- end
- end
- function Mod:onSpiderUpdate(entity)
- local spider = entity
- local spiderData = spider:GetData()
- if spiderData.JustGotInitialized == nil then
- -- get max number of bugs which are needed for the spider to envolve into a big spider
- local spiderRNG = spider:GetDropRNG()
- local hungerRoll = (spiderRNG:RandomInt(2)) + minBugNum
- if spiderData.NeededBugs == nil then
- if hungerRoll == 3 then
- spiderData.NeededBugs = 3
- elseif hungerRoll == 4 then
- spiderData.NeededBugs = 4
- elseif hungerRoll == 5 then
- spiderData.NeededBugs = 5
- end
- end
- if spiderData.EatenBugs == nil then
- spiderData.EatenBugs = 0
- end
- spiderData.JustGotInitialized = true
- end
- if spiderData.EatenBugs == spiderData.MaxBugNum then
- spider:ToNPC():Morph(EntityType.ENTITY_BIG_SPIDER, 1, 0, false)
- end
- end
Add Comment
Please, Sign In to add comment