Skip to content
Snippets Groups Projects
Commit 18d11a6c authored by DarkGod's avatar DarkGod
Browse files

roomer generate also handles rooms forcing up/down

parent e78c3d1c
No related branches found
No related tags found
No related merge requests found
......@@ -42,25 +42,33 @@ end
function _M:makeStairsInside(lev, old_lev, spots)
-- Put down stairs
local dx, dy
if lev < self.zone.max_level or self.data.force_last_stair then
while true do
dx, dy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
if not self.map:checkEntity(dx, dy, Map.TERRAIN, "block_move") and not self.map.room_map[dx][dy].special then
self.map(dx, dy, Map.TERRAIN, self:resolve("down"))
self.map.room_map[dx][dy].special = "exit"
break
if self.forced_down then
dx, dy = self.forced_down.x, self.forced_down.y
else
if lev < self.zone.max_level or self.data.force_last_stair then
while true do
dx, dy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
if not self.map:checkEntity(dx, dy, Map.TERRAIN, "block_move") and not self.map.room_map[dx][dy].special then
self.map(dx, dy, Map.TERRAIN, self:resolve("down"))
self.map.room_map[dx][dy].special = "exit"
break
end
end
end
end
-- Put up stairs
local ux, uy
while true do
ux, uy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
if not self.map:checkEntity(ux, uy, Map.TERRAIN, "block_move") and not self.map.room_map[ux][uy].special then
self.map(ux, uy, Map.TERRAIN, self:resolve("up"))
self.map.room_map[ux][uy].special = "exit"
break
if self.forced_up then
ux, uy = self.forced_up.x, self.forced_up.y
else
while true do
ux, uy = rng.range(1, self.map.w - 1), rng.range(1, self.map.h - 1)
if not self.map:checkEntity(ux, uy, Map.TERRAIN, "block_move") and not self.map.room_map[ux][uy].special then
self.map(ux, uy, Map.TERRAIN, self:resolve("up"))
self.map.room_map[ux][uy].special = "exit"
break
end
end
end
......@@ -71,39 +79,47 @@ end
function _M:makeStairsSides(lev, old_lev, sides, rooms, spots)
-- Put down stairs
local dx, dy
if lev < self.zone.max_level or self.data.force_last_stair then
while true do
if sides[2] == 4 then dx, dy = 0, rng.range(1, self.map.h - 1)
elseif sides[2] == 6 then dx, dy = self.map.w - 1, rng.range(1, self.map.h - 1)
elseif sides[2] == 8 then dx, dy = rng.range(1, self.map.w - 1), 0
elseif sides[2] == 2 then dx, dy = rng.range(1, self.map.w - 1), self.map.h - 1
end
if not self.map.room_map[dx][dy].special then
local i = rng.range(1, #rooms)
if not self.data.no_tunnels then self:tunnel(dx, dy, rooms[i].cx, rooms[i].cy, rooms[i].id) end
self.map(dx, dy, Map.TERRAIN, self:resolve("down"))
self.map.room_map[dx][dy].special = "exit"
break
if self.forced_down then
dx, dy = self.forced_down.x, self.forced_down.y
else
if lev < self.zone.max_level or self.data.force_last_stair then
while true do
if sides[2] == 4 then dx, dy = 0, rng.range(1, self.map.h - 1)
elseif sides[2] == 6 then dx, dy = self.map.w - 1, rng.range(1, self.map.h - 1)
elseif sides[2] == 8 then dx, dy = rng.range(1, self.map.w - 1), 0
elseif sides[2] == 2 then dx, dy = rng.range(1, self.map.w - 1), self.map.h - 1
end
if not self.map.room_map[dx][dy].special then
local i = rng.range(1, #rooms)
if not self.data.no_tunnels then self:tunnel(dx, dy, rooms[i].cx, rooms[i].cy, rooms[i].id) end
self.map(dx, dy, Map.TERRAIN, self:resolve("down"))
self.map.room_map[dx][dy].special = "exit"
break
end
end
end
end
-- Put up stairs
local ux, uy
while true do
if sides[1] == 4 then ux, uy = 0, rng.range(1, self.map.h - 1)
elseif sides[1] == 6 then ux, uy = self.map.w - 1, rng.range(1, self.map.h - 1)
elseif sides[1] == 8 then ux, uy = rng.range(1, self.map.w - 1), 0
elseif sides[1] == 2 then ux, uy = rng.range(1, self.map.w - 1), self.map.h - 1
end
if self.forced_up then
ux, uy = self.forced_up.x, self.forced_up.y
else
while true do
if sides[1] == 4 then ux, uy = 0, rng.range(1, self.map.h - 1)
elseif sides[1] == 6 then ux, uy = self.map.w - 1, rng.range(1, self.map.h - 1)
elseif sides[1] == 8 then ux, uy = rng.range(1, self.map.w - 1), 0
elseif sides[1] == 2 then ux, uy = rng.range(1, self.map.w - 1), self.map.h - 1
end
if not self.map.room_map[ux][uy].special then
local i = rng.range(1, #rooms)
if not self.data.no_tunnels then self:tunnel(ux, uy, rooms[i].cx, rooms[i].cy, rooms[i].id) end
self.map(ux, uy, Map.TERRAIN, self:resolve("up"))
self.map.room_map[ux][uy].special = "exit"
break
if not self.map.room_map[ux][uy].special then
local i = rng.range(1, #rooms)
if not self.data.no_tunnels then self:tunnel(ux, uy, rooms[i].cx, rooms[i].cy, rooms[i].id) end
self.map(ux, uy, Map.TERRAIN, self:resolve("up"))
self.map.room_map[ux][uy].special = "exit"
break
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment