Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
isaac special rooms pseudo lua
--Pseudo lua code for getting the number of rooms for a floor.
NumberOfRooms = Min(20, Rand(0, 1) + 5 + Floor(StageId * 10 / 3))
if CurseOfTheLabyrinth then
NumberOfRooms = Min(45, Floor(NumberOfRooms * 1.8))
elseif CurseOfTheLost then
NumberOfRooms += 4
end
if StageId == 12 then --The Void
NumberOfRooms = 50 + (Rand() % 10)
end
if IsHardDifficulty then
NumberOfRooms += 2 + Rand(0, 1)
end
--Pseudo lua code for getting the number of deadends a floor must have.
MinDeadEnds = 5
if StageId ~= 1 then
MinDeadEnds += 1
end
if CurseOfTheLabyrinth then
MinDeadEnds += 1
end
if StageId == 12 then
MinDeadEnds += 2
end
--Deadends are sorted by distance from the starting room descending.
--e.g. Boss room is placed in the farthest deadend, super secret is placed in the next farthest deadend
--DequeueDeadend also resizes the deadend. This is important to note because that means most deadends get changed to a 1x1 by the end of this.
PlaceRoom(ROOM_BOSS, DequeueDeadend())
--Super Secret
PlaceRoom(ROOM_SUPERSECRET, DequeueDeadend())
--Shop
if StageId < 7 or (StageId < 9 and HasTrinket(SilverDollar)) and VictoryLap < 3 then
PlaceRoom(ROOM_SHOP, DequeueDeadend())
end
--Treasure
if StageId < 7 or (StageId < 9 and HasTrinket(BloodyCrown)) then
PlaceRoom(ROOM_TREASURE, DequeueDeadend())
end
--Dice and Sacrifice
if StageId < 12 then
local deadend = DequeueDeadend() --resizes the room :(
if deadend ~= nil then
local roomType = nil
if Rng() % 50 == 0 or (Rng() % 5 == 0 and GetNumKeys() > 1) then
roomType = ROOM_DICE
else
roomType = ROOM_SACRIFICE
end
if Rng() % 7 == 0 or (Rng() & 3 == 0 and GetHearts() + GetSoulHearts() >= GetMaxHearts()) then
PlaceRoom(roomType)
else
QueueDeadend(deadend)
end
end
end
--Library
local deadend = DequeueDeadend()
if deadend ~= nil then
if Rng() % 20 == 0 or (Rng() & 3 == 0 and GetStateFlag(STATE_BOOK_PICKED_UP)) then
PlaceRoom(ROOM_LIBRARY, deadend)
else
QueueDeadend(deadend)
end
end
--Curse
local deadend = DequeueDeadend()
if deadend ~= nil then
if Rng() & 1 == 0 or (Rng() & 3 == 0 and GetStateFlag(STATE_DEVILROOM_VISITED)) then
PlaceRoom(ROOM_CURSE, deadend)
else
QueueDeadend(deadend)
end
end
--MiniBoss
local boss = GetMiniBossRoom() --mini boss is picked based on floor, STATE_ULTRAPRIDE_SPAWNED and rng
local deadend = DequeueDeadend()
if deadend ~= nil then
if Rng() & 3 == 0 or (Rng() & 3 == 0 and StageId ~= 1) then
PlaceRoom(boss, deadend)
else
QueueDeadend(deadend)
end
end
--Challenge
local deadend = DequeueDeadend()
if deadend ~= nil then
if (Rng() & 1 == 0 or StageId >= 2) and GetHearts() + GetSoulHearts() >= GetMaxHearts() and StageId > 1 then
PlaceRoom(boss, deadend)
else
QueueDeadend(deadend)
end
end
--Chest and Arcade
local deadend = DequeueDeadend()
if deadend ~= nil then
local roomType = nil
if Rng() % 10 == 0 or (Rng() % 3 == 0 and GetNumKeys() > 1) then
roomType = ROOM_CHEST
else
roomType = ROOM_ARCADE
end
if GetNumCoins() >= 5 and (StageId == 2 or StageId == 4 or StageId == 6 or StageId == 8) then
PlaceRoom(roomType)
else
QueueDeadend(deadend)
end
end
--Bedroom
if StageId < 7 then
local deadend = DequeueDeadend()
if deadend ~= nil then
local roomType = nil
if Rng() & 1 == 0 then
roomType = ROOM_ISAACS
else
roomType = ROOM_BARREN
end
local maxHearts = nil
if GetPlayerType() == PLAYER_THELOST or GetPlayerType() == PLAYER_XXX or GetPlayerType() == PLAYER_THESOUL then
maxHearts = GetMaxHearts()
else
maxHearts = GetMaxHearts() + GetBoneHearts() * 2
end
local second = false
if (GetHearts() < 2 and GetSoulHearts() <= 0) or (maxHearts <= 0 and GetSoulHearts() <= 2) then
second = true
end
if Rng() % 50 == 0 or (Rng() % 5 == 0 and second) then
PlaceRoom(roomType)
else
QueueDeadend(deadend)
end
end
end
--Secret
TryPlacingSecret()
if HasTrinket(TRINKET_FRAGMENTED_CARD) then
TryPlacingSecret()
end
-- Grave Room
if StageId == 11 and StageType == 0 then --Dark Room
PlaceGrave(DequeueDeadend())
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.