Commit c9de0495e9ffa545ba274ac316771a8fba6d370d

Authored by DarkGod
1 parent 77b7890d

fix bug when importing vaults into mapscripts

... ... @@ -71,7 +71,9 @@ function RoomInstance:build()
71 71 if account_for_border == nil then account_for_border = false end
72 72
73 73 local map = mapscript:makeTemporaryMap(room.w, room.h, function(map)
  74 + mapscript.dont_add_vault_check = true
74 75 mapscript:roomPlace(room, id, 0, 0)
  76 + mapscript.dont_add_vault_check = nil
75 77 end)
76 78 mapscript.maps_registers[id] = map
77 79 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)
115 115 end end
116 116 end end
117 117 if vault.gen_map.startx and vault.gen_map.starty then
118   - 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"}
  118 + if not gen.dont_add_vault_check then
  119 + 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"}
  120 + end
119 121 return vault.gen_map.startx + x, vault.gen_map.starty + y
120 122 end
121 123 end,
... ...
... ... @@ -115,7 +115,9 @@ return function(gen, id, lev, old_lev)
115 115 end end
116 116 end end
117 117 if vault.gen_map.startx and vault.gen_map.starty then
118   - 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"}
  118 + if not gen.dont_add_vault_check then
  119 + 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"}
  120 + end
119 121 return vault.gen_map.startx + x, vault.gen_map.starty + y
120 122 end
121 123 end,
... ...
... ... @@ -25,9 +25,9 @@ local tm = Tilemap.new(self.mapsize, '#')
25 25 local room_factory = Rooms.new(self, "random_room")
26 26 local vault_factory = Rooms.new(self, "greater_vault")
27 27
28   -local nb_vault = 0
  28 +local nb_vault = 1
29 29 local rooms = {}
30   -for i = 1, 20 do
  30 +for i = 1, 5 do
31 31 local proom = (nb_vault > 0 and vault_factory or room_factory):generateRoom()
32 32 local pos = proom and tm:findRandomArea(nil, tm.data_size, proom.data_w, proom.data_h, '#', 1)
33 33 if pos then
... ... @@ -38,23 +38,23 @@ for i = 1, 20 do
38 38 end
39 39
40 40 local up_stairs = true
41   -for i = 1, 20 do
42   - -- Make a little lake
43   - local r = rng.range(7, 15)
44   - 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 '='})
45   - -- Ensure exit from the lake to exterrior
46   - local pond_exit = pond:findRandomExit(pond:centerPoint(), nil, {';'})
47   - pond:tunnelAStar(pond:centerPoint(), pond_exit, ';', {'T'}, {}, {erraticness=9})
48   - -- If lake is big enough and we find a spot, place it
49   - if pond:eliminateByFloodfill{'T', ' '} > 8 then
50   - local pos = tm:findRandomArea(nil, tm.data_size, pond.data_w, pond.data_h, '#', 1)
51   - if pos then
52   - tm:merge(pos, pond)
53   - rooms[#rooms+1] = pond
54   - up_stairs = false
55   - end
56   - end
57   -end
  41 +-- for i = 1, 20 do
  42 +-- -- Make a little lake
  43 +-- local r = rng.range(7, 15)
  44 +-- 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 '='})
  45 +-- -- Ensure exit from the lake to exterrior
  46 +-- local pond_exit = pond:findRandomExit(pond:centerPoint(), nil, {';'})
  47 +-- pond:tunnelAStar(pond:centerPoint(), pond_exit, ';', {'T'}, {}, {erraticness=9})
  48 +-- -- If lake is big enough and we find a spot, place it
  49 +-- if pond:eliminateByFloodfill{'T', ' '} > 8 then
  50 +-- local pos = tm:findRandomArea(nil, tm.data_size, pond.data_w, pond.data_h, '#', 1)
  51 +-- if pos then
  52 +-- tm:merge(pos, pond)
  53 +-- rooms[#rooms+1] = pond
  54 +-- up_stairs = false
  55 +-- end
  56 +-- end
  57 +-- end
58 58
59 59 if not loadMapScript("lib/connect_rooms_multi", {map=tm, rooms=rooms, door_chance=60, edges_surplus=0}) then return self:redo() end
60 60 -- loadMapScript("lib/connect_rooms_multi", {map=tm, rooms=rooms})
... ... @@ -67,8 +67,8 @@ self:setExit(rooms[#rooms]:centerPoint()) tm:put(rooms[#rooms]:centerPoint(), '>
67 67 -- Elimitate the rest
68 68 -- if tm:eliminateByFloodfill{'#', 'T'} < 600 then return self:redo() end
69 69
70   -local spot = tm:point(1, 1)
71   -loadMapScript("lib/subvault", {map=tm, spot=spot, char="V"})
  70 +--local spot = tm:point(1, 1)
  71 +--loadMapScript("lib/subvault", {map=tm, spot=spot, char="V", greater_vaults_list={"living-weapons"}})
72 72
73 73 tm:printResult()
74 74
... ...
... ... @@ -43,6 +43,7 @@ return {
43 43 [';'] = "GRASS", ['T'] = "TREE",
44 44 ['='] = "DEEP_WATER",
45 45 mapscript = "!rooms_test",
  46 + -- greater_vaults_list = {"portal-vault"},
46 47 -- mapscript = "!bsp_islands",
47 48 -- mapscript = "!cavernous_forest",
48 49 -- mapscript = "!testroom2",
... ...