Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Written by Matrefeytontias
- -- This code is free to use in your own mod.
- -- The only thing I will ask is that you keep at least those three lines and also credit me in your mod.
- local statueDeleted = false
- local statueReplaced = false
- function "your mod here":checkDevilRoom()
- local room = Game():GetRoom()
- if room:GetType() == RoomType.ROOM_DEVIL then
- local devilIndex = room:GetGridIndex(room:GetCenterPos()) - room:GetGridWidth()
- -- only works in "normal" devil deals (no tiny room or double statue rooms); intentional but you can change that easily by using Isaac.GetRoomEntities()
- -- and searching for the entity that matches the conditions on line 38
- if not statueDeleted then
- -- Remove the statue
- -- First, retrieve the devil statue's entity
- local devilStatue = room:GetGridEntity(devilIndex)
- if devilStatue ~= nil then
- -- 0 is the devil statue variant ; angel statues can still spawn in the devil deal
- if devilStatue.Desc.Type == GridEntityType.GRID_STATUE and devilStatue.Desc.Variant == 0 then
- -- Remove the statue
- room:RemoveGridEntity(devilIndex, 0, false) -- any idea what the pathtrail argument (0 here) is for ?
- -- Spawn a rock in its place when the room has processed the statue's deletion, that is, on the next frame
- statueDeleted = true
- end
- end
- else
- if not statueReplaced then
- -- At this point, the statue has been removed and a dummy rock needs to be spawned in its place
- room:SpawnGridEntity(devilIndex, GridEntityType.GRID_ROCK, 0, room:GetSpawnSeed(), 0)
- statueReplaced = true
- else
- -- Check if the rock is still there ; if it's not, it has been destroyed so we also remove the devil statue
- if room:GetGridCollision(devilIndex) == GridCollisionClass.COLLISION_NONE then
- local ents = Isaac.GetRoomEntities()
- for i = 1, #ents do
- if ents[i].Type == EntityType.ENTITY_EFFECT and ents[i].Variant == EffectVariant.DEVIL then
- ents[i]:Remove()
- -- ##################
- -- do your stuff here, the statue just got destroyed
- -- ##################
- break
- end
- end
- statueDeleted = false
- statueReplaced = false
- end
- end
- end
- end
- end
- "your mod here":AddCallback(ModCallbacks.MC_POST_UPDATE, "your mod here".checkDevilRoom)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement