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

fix bug when importing vaults into mapscripts

parent 77b7890d
No related branches found
No related tags found
No related merge requests found
......@@ -71,7 +71,9 @@ function RoomInstance:build()
if account_for_border == nil then account_for_border = false end
local map = mapscript:makeTemporaryMap(room.w, room.h, function(map)
mapscript.dont_add_vault_check = true
mapscript:roomPlace(room, id, 0, 0)
mapscript.dont_add_vault_check = nil
end)
mapscript.maps_registers[id] = map
mapscript.maps_positions[id] = account_for_border and self:point(0, 0) or self:point(1, 1)
......
......@@ -115,7 +115,9 @@ return function(gen, id, lev, old_lev)
end end
end end
if vault.gen_map.startx and vault.gen_map.starty then
gen.spots[#gen.spots+1] = {x=vault.gen_map.startx + x, y=vault.gen_map.starty + y, check_connectivity=not vault.no_tunnels and "entrance", type="vault", subtype="greater"}
if not gen.dont_add_vault_check then
gen.spots[#gen.spots+1] = {x=vault.gen_map.startx + x, y=vault.gen_map.starty + y, check_connectivity=not vault.no_tunnels and "entrance", type="vault", subtype="greater"}
end
return vault.gen_map.startx + x, vault.gen_map.starty + y
end
end,
......
......@@ -115,7 +115,9 @@ return function(gen, id, lev, old_lev)
end end
end end
if vault.gen_map.startx and vault.gen_map.starty then
gen.spots[#gen.spots+1] = {x=vault.gen_map.startx + x, y=vault.gen_map.starty + y, check_connectivity=not vault.no_tunnels and "entrance", type="vault", subtype="lesser"}
if not gen.dont_add_vault_check then
gen.spots[#gen.spots+1] = {x=vault.gen_map.startx + x, y=vault.gen_map.starty + y, check_connectivity=not vault.no_tunnels and "entrance", type="vault", subtype="lesser"}
end
return vault.gen_map.startx + x, vault.gen_map.starty + y
end
end,
......
......@@ -25,9 +25,9 @@ local tm = Tilemap.new(self.mapsize, '#')
local room_factory = Rooms.new(self, "random_room")
local vault_factory = Rooms.new(self, "greater_vault")
local nb_vault = 0
local nb_vault = 1
local rooms = {}
for i = 1, 20 do
for i = 1, 5 do
local proom = (nb_vault > 0 and vault_factory or room_factory):generateRoom()
local pos = proom and tm:findRandomArea(nil, tm.data_size, proom.data_w, proom.data_h, '#', 1)
if pos then
......@@ -38,23 +38,23 @@ for i = 1, 20 do
end
local up_stairs = true
for i = 1, 20 do
-- Make a little lake
local r = rng.range(7, 15)
local pond = Heightmap.new(1.6, {up_left=0, down_left=0, up_right=0, down_right=0, middle=1}):make(r, r, {' ', ' ', ';', ';', 'T', '=', '=', up_stairs and '<' or '='})
-- Ensure exit from the lake to exterrior
local pond_exit = pond:findRandomExit(pond:centerPoint(), nil, {';'})
pond:tunnelAStar(pond:centerPoint(), pond_exit, ';', {'T'}, {}, {erraticness=9})
-- If lake is big enough and we find a spot, place it
if pond:eliminateByFloodfill{'T', ' '} > 8 then
local pos = tm:findRandomArea(nil, tm.data_size, pond.data_w, pond.data_h, '#', 1)
if pos then
tm:merge(pos, pond)
rooms[#rooms+1] = pond
up_stairs = false
end
end
end
-- for i = 1, 20 do
-- -- Make a little lake
-- local r = rng.range(7, 15)
-- local pond = Heightmap.new(1.6, {up_left=0, down_left=0, up_right=0, down_right=0, middle=1}):make(r, r, {' ', ' ', ';', ';', 'T', '=', '=', up_stairs and '<' or '='})
-- -- Ensure exit from the lake to exterrior
-- local pond_exit = pond:findRandomExit(pond:centerPoint(), nil, {';'})
-- pond:tunnelAStar(pond:centerPoint(), pond_exit, ';', {'T'}, {}, {erraticness=9})
-- -- If lake is big enough and we find a spot, place it
-- if pond:eliminateByFloodfill{'T', ' '} > 8 then
-- local pos = tm:findRandomArea(nil, tm.data_size, pond.data_w, pond.data_h, '#', 1)
-- if pos then
-- tm:merge(pos, pond)
-- rooms[#rooms+1] = pond
-- up_stairs = false
-- end
-- end
-- end
if not loadMapScript("lib/connect_rooms_multi", {map=tm, rooms=rooms, door_chance=60, edges_surplus=0}) then return self:redo() end
-- loadMapScript("lib/connect_rooms_multi", {map=tm, rooms=rooms})
......@@ -67,8 +67,8 @@ self:setExit(rooms[#rooms]:centerPoint()) tm:put(rooms[#rooms]:centerPoint(), '>
-- Elimitate the rest
-- if tm:eliminateByFloodfill{'#', 'T'} < 600 then return self:redo() end
local spot = tm:point(1, 1)
loadMapScript("lib/subvault", {map=tm, spot=spot, char="V"})
--local spot = tm:point(1, 1)
--loadMapScript("lib/subvault", {map=tm, spot=spot, char="V", greater_vaults_list={"living-weapons"}})
tm:printResult()
......
......@@ -43,6 +43,7 @@ return {
[';'] = "GRASS", ['T'] = "TREE",
['='] = "DEEP_WATER",
mapscript = "!rooms_test",
-- greater_vaults_list = {"portal-vault"},
-- mapscript = "!bsp_islands",
-- mapscript = "!cavernous_forest",
-- mapscript = "!testroom2",
......
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