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

some more upgrades to Vor & Gorbat

parent c6294229
No related branches found
No related tags found
No related merge requests found
Showing
with 448 additions and 141 deletions
......@@ -62,7 +62,22 @@ function _M:makeCharsTable(v, default)
return table.reverse(v)
end
local point_meta = {
local point_meta
--- Make a point data, can be added
function _M:point(x, y)
if type(x) == "table" then
local p = {x=math.floor(x.x), y=math.floor(x.y)}
setmetatable(p, point_meta)
return p
else
local p = {x=math.floor(x), y=math.floor(y)}
setmetatable(p, point_meta)
return p
end
end
point_meta = {
__add = function(a, b)
if type(b) == "number" then return _M:point(a.x + b, a.y + b)
else return _M:point(a.x + b.x, a.y + b.y) end
......@@ -92,21 +107,11 @@ local point_meta = {
area = function(p)
return p.y * p.x
end,
clone = function(p)
return _M:point(p)
end,
},
}
--- Make a point data, can be added
function _M:point(x, y)
if type(x) == "table" then
local p = {x=math.floor(x.x), y=math.floor(x.y)}
setmetatable(p, point_meta)
return p
else
local p = {x=math.floor(x), y=math.floor(y)}
setmetatable(p, point_meta)
return p
end
end
--- Returns a point at the center of the map, accounting for merged_pos
function _M:centerPoint()
......@@ -181,6 +186,22 @@ function _M:put(pos, char)
end
end
function _M:get(pos)
if self:isBound(pos) then
return self.data[pos.y][pos.x]
end
end
function _M:isA(pos, ...)
if self:isBound(pos) then
local pc = self.data[pos.y][pos.x]
for _, c in ipairs{...} do
if pc == c then return true end
end
end
return false
end
--- Flip the map
function _M:flip(axis)
local ndata = self:makeData(self.data_w, self.data_h, '')
......@@ -413,6 +434,186 @@ function _M:pointsBoundingRectangle(list)
return from, to
end
local group_meta
--- Make a point data, can be added
function _M:group(list)
local g = {list=list}
setmetatable(g, group_meta)
g:updateReverse()
return g
end
group_meta = {
__add = function(a, b)
local g = _M:group{}
for _, p in ipairs(a.list) do g:add(p:clone()) end
for _, p in ipairs(b.list) do g:add(p:clone()) end
return g
end,
__sub = function(a, b)
local g = _M:group{}
for _, p in ipairs(a.list) do g:add(p:clone()) end
for _, p in ipairs(b.list) do g:remove(p:clone()) end
return g
end,
__eq = function(a, b)
if #a.list ~= #b.list then return false end
for _, p in ipairs(b.list) do
if not a.reverse[p.x] or not not a.reverse[p.x][p.y] then return false end
end
return true
end,
__tostring = function(g)
return ("Group(%d points)"):format(#g.list)
end,
__index = {
updateReverse = function(g)
g.reverse = {}
print("================")
table.print(g.list)
print("================")
for j = 1, #g.list do
local jn = g.list[j]
print("=====", j, jn)
g.reverse[jn.x] = g.reverse[jn.x] or {}
g.reverse[jn.x][jn.y] = jn
end
print("================")
end,
sortPoints = function(g)
table.sort(g.list, function(a, b)
if a.x == b.x then return a.y < b.y
else return a.x < b.x end
end)
end,
area = function(p)
return #p.list
end,
bounds = function(g)
return _M:pointsBoundingRectangle(g.list)
end,
submap = function(g, map)
local from, to = g:bounds()
to = to - from + 1
local sm = Proxy.new(map, from, to.x, to.y)
sm:maskOtherPoints(list, true)
return sm
end,
add = function(g, p)
if g.reverse[p.x] and g.reverse[p.x][p.y] then return false end
g.list[#g.list+1] = p
g.reverse[p.x] = g.reverse[p.x] or {}
g.reverse[p.x][p.y] = p
return true
end,
remove = function(g, p)
if not g.reverse[p.x] or not g.reverse[p.x][p.y] then return false end
for i, pp in ipairs(g.list) do if pp == p then
table.remove(g.list, i)
break
end end
g.reverse[p.x][p.y] = nil
if not next(g.reverse[p.x]) then g.reverse[p.x] = nil end
return true
end,
hasPoint = function(g, x, y)
if type(x) == "table" then x, y = x.x, x.y end
return g.reverse[x] and g.reverse[x][y]
end,
pickSpot = function(group, mode, what, mapcheck)
local function check(x, y)
if mapcheck then
local r = mapcheck(_M:point(x, y))
if r ~= nil then return r end
end
return group.reverse[x] and group.reverse[x][y]
end
local list = table.clone(group.list)
while #list > 0 do
local jn = rng.tableRemove(list)
if mode == "any" or not mode then
return jn
elseif mode == "inside-wall" then
local g8 = check(jn.x+0, jn.y-1)
local g2 = check(jn.x+0, jn.y+1)
local g4 = check(jn.x-1, jn.y+0)
local g6 = check(jn.x+1, jn.y+0)
local g7 = check(jn.x-1, jn.y-1)
local g3 = check(jn.x+1, jn.y+1)
local g1 = check(jn.x-1, jn.y+1)
local g9 = check(jn.x+1, jn.y-1)
if not what or what == "any" or what == "straight" then
if g8 and g2 and not g4 and not g6 then
return jn
elseif g4 and g6 and not g2 and not g8 then
return jn
end
end
if what == "any" or what == "diagonal" then
if not g8 and not g2 and not g4 and not g6 then
return jn
elseif not g4 and not g6 and not g2 and not g8 then
return jn
end
end
elseif mode == "corder" then
local g8 = check(jn.x+0, jn.y-1)
local g2 = check(jn.x+0, jn.y+1)
local g4 = check(jn.x-1, jn.y+0)
local g6 = check(jn.x+1, jn.y+0)
local g7 = check(jn.x-1, jn.y-1)
local g3 = check(jn.x+1, jn.y+1)
local g1 = check(jn.x-1, jn.y+1)
local g9 = check(jn.x+1, jn.y-1)
if not what or what == "any" or what == "straight" then
if not g8 and g2 and not g4 and g6 and not g7 and not g3 and not g1 and not g9 then
return jn
elseif g4 and not g6 and g2 and not g8 and not g7 and not g3 and not g1 and not g9 then
return jn
elseif g4 and not g6 and not g2 and g8 and not g7 and not g3 and not g1 and not g9 then
return jn
elseif not g4 and g6 and not g2 and g8 and not g7 and not g3 and not g1 and not g9 then
return jn
end
end
if what == "any" or what == "diagonal" then
if not g4 and not g6 and not g2 and not g8 and g7 and not g3 and g1 and not g7 then
return jn
elseif not g4 and not g6 and not g2 and not g8 and g7 and not g3 and not g1 and g9 then
return jn
elseif not g4 and not g6 and not g2 and not g8 and not g7 and g3 and not g1 and g9 then
return jn
elseif not g4 and not g6 and not g2 and not g8 and not g7 and g3 and g1 and not g9 then
return jn
end
end
elseif mode == "has-neighbours" then
local nb = 0
for i = -1, 1 do for j = -1, 1 do if (i ~= 0 or j ~= 0) and check(jn.x+i, jn.y+j) then
nb = nb + 1
end end end
if nb == what then
return jn
end
end
end
return nil
end,
randomNearPoint = function(g, p)
local points = {}
for i = -1, 1 do for j = -1, 1 do
if (i ~= 0 or j ~= 0) and g:hasPoint(p.x + i, p.y + j) then
points[#points+1] = g:hasPoint(p.x + i, p.y + j)
end
end end
if #points == 0 then return nil end
return rng.table(points)
end,
},
}
--- Return a list of groups of tiles that matches the given cond function
function _M:findGroups(cond)
if not self.data then return {} end
......@@ -463,12 +664,7 @@ function _M:findGroups(cond)
local i, l = next(list)
local closed = floodFill(l.x, l.y)
local from, to = self:pointsBoundingRectangle(closed)
to = to - from + 1
local map = Proxy.new(self, from, to.x, to.y)
map:maskOtherPoints(closed, true)
groups[#groups+1] = {list=closed, map=map}
groups[#groups+1] = self:group(closed)
print("[Tilemap] Floodfill group", i, #closed)
end
......@@ -535,12 +731,12 @@ function _M:eliminateByFloodfill(walls)
end
function _M:getBorderGroup(group)
local border = {list={}}
local border = self:group{}
for _, d in ipairs(group.list) do
for i = -1, 1 do for j = -1, 1 do if (i ~= 0 or j ~= 0) and self.data[d.y+j] and self.data[d.y+j][d.x+i] then
if not self:isInGroup(group, d.x+i, d.y+j) then
if not self:isInGroup(border, d.x+i, d.y+j, true) then
border.list[#border.list+1] = self:point{x=d.x+i, y=d.y+j}
if not group:hasPoint(d.x+i, d.y+j) then
if not border:hasPoint(d.x+i, d.y+j, true) then
border:add(self:point{x=d.x+i, y=d.y+j})
end
end
end end end
......@@ -556,102 +752,6 @@ function _M:fillGroup(group, char)
end
end
function _M:computeGroupReverse(group)
group.reverse = {}
for j = 1, #group.list do
local jn = group.list[j]
group.reverse[jn.x] = group.reverse[jn.x] or {}
group.reverse[jn.x][jn.y] = true
end
end
function _M:isInGroup(group, x, y, force)
if not group.reverse or force then
self:computeGroupReverse(group)
end
return group.reverse[x] and group.reverse[x][y]
end
function _M:pickGroupSpot(group, mode, what)
self:computeGroupReverse(group)
local function check(x, y)
return group.reverse[x] and group.reverse[x][y]
end
local list = table.clone(group.list)
while #list > 0 do
local jn = rng.tableRemove(list)
if mode == "any" or not mode then
return self:point{x=jn.x, y=jn.y}
elseif mode == "inside-wall" then
local g8 = check(jn.x+0, jn.y-1)
local g2 = check(jn.x+0, jn.y+1)
local g4 = check(jn.x-1, jn.y+0)
local g6 = check(jn.x+1, jn.y+0)
local g7 = check(jn.x-1, jn.y-1)
local g3 = check(jn.x+1, jn.y+1)
local g1 = check(jn.x-1, jn.y+1)
local g9 = check(jn.x+1, jn.y-1)
if not what or what == "any" or what == "straight" then
print("==check on ", jn.x, jn.y, "::", g8,g2,g4,g6)
if g8 and g2 and not g4 and not g6 then
return self:point{x=jn.x, y=jn.y}
elseif g4 and g6 and not g2 and not g8 then
return self:point{x=jn.x, y=jn.y}
end
end
if what == "any" or what == "diagonal" then
if not g8 and not g2 and not g4 and not g6 then
return self:point{x=jn.x, y=jn.y}
elseif not g4 and not g6 and not g2 and not g8 then
return self:point{x=jn.x, y=jn.y}
end
end
elseif mode == "corder" then
local g8 = check(jn.x+0, jn.y-1)
local g2 = check(jn.x+0, jn.y+1)
local g4 = check(jn.x-1, jn.y+0)
local g6 = check(jn.x+1, jn.y+0)
local g7 = check(jn.x-1, jn.y-1)
local g3 = check(jn.x+1, jn.y+1)
local g1 = check(jn.x-1, jn.y+1)
local g9 = check(jn.x+1, jn.y-1)
if not what or what == "any" or what == "straight" then
if not g8 and g2 and not g4 and g6 and not g7 and not g3 and not g1 and not g9 then
return self:point{x=jn.x, y=jn.y}
elseif g4 and not g6 and g2 and not g8 and not g7 and not g3 and not g1 and not g9 then
return self:point{x=jn.x, y=jn.y}
elseif g4 and not g6 and not g2 and g8 and not g7 and not g3 and not g1 and not g9 then
return self:point{x=jn.x, y=jn.y}
elseif not g4 and g6 and not g2 and g8 and not g7 and not g3 and not g1 and not g9 then
return self:point{x=jn.x, y=jn.y}
end
end
if what == "any" or what == "diagonal" then
if not g4 and not g6 and not g2 and not g8 and g7 and not g3 and g1 and not g7 then
return self:point{x=jn.x, y=jn.y}
elseif not g4 and not g6 and not g2 and not g8 and g7 and not g3 and not g1 and g9 then
return self:point{x=jn.x, y=jn.y}
elseif not g4 and not g6 and not g2 and not g8 and not g7 and g3 and not g1 and g9 then
return self:point{x=jn.x, y=jn.y}
elseif not g4 and not g6 and not g2 and not g8 and not g7 and g3 and g1 and not g9 then
return self:point{x=jn.x, y=jn.y}
end
end
elseif mode == "has-neighbours" then
local nb = 0
for i = -1, 1 do for j = -1, 1 do if (i ~= 0 or j ~= 0) and check(jn.x+i, jn.y+j) then
nb = nb + 1
end end end
if nb == what then
return self:point{x=jn.x, y=jn.y}
end
end
end
return nil
end
--[=[
--- Find the biggest rectangle that can fit fully in the given group
function _M:groupInnerRectangle(group)
......@@ -760,7 +860,7 @@ function _M:groupOuterRectangle(group)
-- Debug
-- for i = x1, x2 do for j = y1, y2 do
-- if not self:isInGroup(group, i, j) then
-- if not group:hasPoint(i, j) then
-- if self.data[j][i] == '#' then
-- self.data[j][i] = 'T'
-- end
......
game/modules/tome/data/gfx/shockbolt/terrain/book_generic.png

9.46 KiB

......@@ -28,3 +28,87 @@ newEntity{ base = "GENERIC_LEVER",
subtype = "sand",
image = "terrain/sandfloor.png",
}
newEntity{
define_as = "FENCE_FLOOR",
type = "floor", subtype = "floor",
name = "floor", image = "terrain/bamboo/hut_dirt_floor_01.png",
display = '.', color=colors.UMBER, back_color=colors.DARK_UMBER,
grow = "FENCE_WALL",
}
newEntity{
define_as = "FENCE_WALL",
type = "wall", subtype = "roost",
name = "wall", image = "terrain/bamboo/hut_dirt_floor_01.png",
display = '#', color=colors.LIGHT_UMBER, back_color=colors.DARK_UMBER,
always_remember = true,
does_block_move = true,
can_pass = {pass_wall=1},
block_sight = true,
air_level = -5,
dig = "FENCE_FLOOR",
nice_tiler = { method="singleWall", use_subtype=true, type="bamboo hut",
v_full={"BHW_V_FULL", 100, 1, 1},
h_full={"BHW_H_FULL", 20, 1, 8},
n_cross={"BHW_N_CROSS", 100, 1, 1},
s_cross={"BHW_S_CROSS", 100, 1, 1},
e_cross={"BHW_E_CROSS", 100, 1, 1},
w_cross={"BHW_W_CROSS", 100, 1, 1},
cross={"BHW_CROSS", 100, 1, 1},
ne={"BHW_NE", 100, 1, 1},
nw={"BHW_NW", 100, 1, 1},
se={"BHW_SE", 100, 1, 1},
sw={"BHW_SW", 100, 1, 1},
},
}
newEntity{base="FENCE_WALL", define_as="BHW_V_FULL1", add_displays={class.new{z=16, image="terrain/bamboo/hut_wall_full_hor_01.png"}}}
newEntity{base="FENCE_WALL", define_as="BHW_H_FULL", add_displays={class.new{z=16, image="terrain/bamboo/hut_wall_bottom_hor_01.png"}, class.new{image="terrain/bamboo/hut_wall_top_hor_01.png", display_y=-1, z=17}}}
local decors = {"wall_decor_skin_b_01","wall_decor_skin_a_01","wall_decor_spears_01","wall_decor_sticks_01","wall_decor_mask_c_01","wall_decor_mask_b_01","wall_decor_mask_a_01","wall_decor_3_masks_01"}
for i = 1, 8 do
newEntity{base="FENCE_WALL", define_as="BHW_H_FULL"..i, add_displays={class.new{z=16, image="terrain/bamboo/hut_wall_bottom_hor_01.png", add_mos={{image="terrain/bamboo/"..decors[i]..".png"}}}, class.new{image="terrain/bamboo/hut_wall_top_hor_01.png", display_y=-1, z=17}}}
end
newEntity{base="FENCE_WALL", define_as="BHW_N_CROSS1", add_displays={class.new{z=16, image="terrain/bamboo/hut_wall_bottom_hor_01.png"}, class.new{z=17, image="terrain/bamboo/hut_corner_vert_south_4_1_2_top_01.png", display_y=-1, add_mos={{image="terrain/bamboo/hut_wall_top_hor_01.png", display_y=-1}}}}}
newEntity{base="FENCE_WALL", define_as="BHW_S_CROSS1", add_displays={class.new{z=16, image="terrain/bamboo/hut_wall_bottom_hor_01.png"}, class.new{z=17, image="terrain/bamboo/hut_wall_full_hor_01.png", add_mos={{image="terrain/bamboo/hut_wall_top_hor_01.png", display_y=-1},{image="terrain/bamboo/hut_corner_vert_4_7_8_top_01.png", display_y=-1}}}}}
newEntity{base="FENCE_WALL", define_as="BHW_E_CROSS1", add_displays={class.new{z=17, image="terrain/bamboo/hut_wall_full_hor_01.png"}, class.new{image="terrain/bamboo/wall_hor_divider_left_bottom_01.png", z=16, add_mos={{image="terrain/bamboo/wall_hor_divider_left_top_01.png", display_y=-1}}}}}
newEntity{base="FENCE_WALL", define_as="BHW_W_CROSS1", add_displays={class.new{z=17, image="terrain/bamboo/hut_wall_full_hor_01.png"}, class.new{image="terrain/bamboo/wall_hor_divider_right_bottom_01.png", z=16, add_mos={{image="terrain/bamboo/wall_hor_divider_right_top_01.png", display_y=-1}}}}}
newEntity{base="FENCE_WALL", define_as="BHW_CROSS1", add_displays={class.new{z=17, image="terrain/bamboo/hut_wall_bottom_hor_01.png"}, class.new{image="terrain/bamboo/hut_wall_top_hor_01.png", z=16, display_y=-1, add_mos={{image="terrain/bamboo/hut_wall_full_hor_01.png"},{image="terrain/bamboo/hut_corner_vert_4_7_8_top_01.png", display_y=-1}}}}}
newEntity{base="FENCE_WALL", define_as="BHW_NE1", add_displays={class.new{z=17, image="terrain/bamboo/hut_corner_4_1_2_bottom_01.png"}, class.new{image="terrain/bamboo/hut_corner_4_1_2_top_01.png", display_y=-1, z=16}}}
newEntity{base="FENCE_WALL", define_as="BHW_NW1", add_displays={class.new{z=17, image="terrain/bamboo/hut_corner_6_3_2_bottom_01.png"}, class.new{image="terrain/bamboo/hut_corner_6_3_2_top_01.png", display_y=-1, z=16}}}
newEntity{base="FENCE_WALL", define_as="BHW_SE1", add_displays={class.new{z=17, image="terrain/bamboo/hut_corner_4_7_8_bottom_01.png"}, class.new{image="terrain/bamboo/hut_corner_4_7_8_top_01.png", display_y=-1, z=16}}}
newEntity{base="FENCE_WALL", define_as="BHW_SW1", add_displays={class.new{z=17, image="terrain/bamboo/hut_corner_8_9_6_bottom_01.png"}, class.new{image="terrain/bamboo/hut_corner_8_9_6_top_01.png", display_y=-1, z=16}}}
-----------------------------------------
-- Doors
-----------------------------------------
newEntity{
define_as = "FENCE_DOOR",
type = "wall", subtype = "roost",
name = "door", image = "terrain/bamboo/hut_dirt_floor_01.png",
display = '+', color=colors.LIGHT_UMBER, back_color=colors.DARK_UMBER,
nice_tiler = { method="door3d", north_south="FENCE_DOOR_VERT", west_east="FENCE_DOOR_HORIZ" },
notice = true,
always_remember = true,
block_sight = true,
is_door = true,
door_opened = "FENCE_DOOR_OPEN",
dig = "FLOOR",
}
newEntity{
define_as = "FENCE_DOOR_OPEN",
type = "wall", subtype = "roost",
name = "open door", image = "terrain/bamboo/hut_dirt_floor_01.png",
display = "'", color=colors.LIGHT_UMBER, back_color=colors.DARK_UMBER,
always_remember = true,
is_door = true,
door_closed = "FENCE_DOOR",
}
newEntity{ base = "FENCE_DOOR", define_as = "FENCE_DOOR_HORIZ", add_displays = {class.new{image="terrain/bamboo/hut_wall_door_closed_hor_01.png", z=17}, class.new{image="terrain/bamboo/hut_wall_top_hor_01.png", z=18, display_y=-1}}, door_opened = "FENCE_DOOR_HORIZ_OPEN"}
newEntity{ base = "FENCE_DOOR_OPEN", define_as = "FENCE_DOOR_HORIZ_OPEN", add_displays = {class.new{image="terrain/bamboo/hut_door_hor_open_door_palm_leaves_01.png"}, class.new{image="terrain/bamboo/hut_door_hor_open_door_01.png", z=17}, class.new{image="terrain/bamboo/hut_wall_top_hor_01.png", z=18, display_y=-1}}, door_closed = "FENCE_DOOR_HORIZ"}
newEntity{ base = "FENCE_DOOR", define_as = "FENCE_DOOR_VERT", add_displays = {class.new{image="terrain/bamboo/palm_door_closed_ver_01.png"}, class.new{image="terrain/bamboo/hut_wall_full_hor_01.png", z=18}}, door_opened = "FENCE_DOOR_OPEN_VERT", dig = "FENCE_DOOR_OPEN_VERT"}
newEntity{ base = "FENCE_DOOR_OPEN", define_as = "FENCE_DOOR_OPEN_VERT", add_displays = {class.new{image="terrain/bamboo/palm_door_open_bottom_ver_01.png"}, class.new{image="terrain/bamboo/palm_door_open_top_ver_01.png", z=18, display_y=-1, add_mos={{image="terrain/bamboo/hut_wall_full_hor_01.png"}, {image="terrain/bamboo/palm_door_open_bottom_ver_door_01.png"}}}}, door_closed = "FENCE_DOOR_VERT"}
......@@ -17,17 +17,22 @@
-- Nicolas Casalini "DarkGod"
-- darkgod@te4.org
self:defineTile("|", "FENCE_WALL")
self:defineTile(":", "FENCE_FLOOR")
self:defineTile("!", "FENCE_DOOR")
self:defineTile("-", "FLOOR", nil, nil, nil, {no_teleport=true})
self:defineTile("o", "FLOOR", nil, {entity_mod=function(e) e.make_escort = nil return e end, random_filter={type='humanoid', subtype='orc', special=function(e) return e.pride == mapdata.pride end}})
if level.level == zone.max_level then self:defineTile(">", 'FLOOR') else self:defineTile(">", "FLAT_DOWN4", nil, nil, nil, {no_teleport=true}) end
self:defineTile("O", "FLOOR", nil, {random_filter={type='humanoid', subtype='orc', special=function(e) return e.pride == mapdata.pride end, random_boss={nb_classes=1, loot_quality="store", loot_quantity=3, ai_move="move_complex", rank=4,}}})
self:defineTile("X", "FLOOR", nil, {entity_mod=function(e) e.make_escort = nil return e end, random_filter={type='humanoid', subtype='orc', special=function(e) return e.pride == mapdata.pride end, random_boss={nb_classes=1, loot_quality="store", loot_quantity=1, no_loot_randart=true, ai_move="move_complex", rank=3}}}, nil, {no_teleport=true})
self:defineTile("D", "FENCE_FLOOR", nil, {entity_mod=function(e) e.make_escort = nil return e end, random_filter={type='dragon', random_boss={nb_classes=1, loot_quality="store", loot_quantity=1, no_loot_randart=true, ai_move="move_complex", rank=3.5}}}, nil, {no_teleport=true})
self:defineTile('&', "GENERIC_LEVER", nil, nil, nil, {lever=1, lever_kind="pride-doors", lever_spot={type="lever", subtype="door", check_connectivity="entrance"}}, {type="lever", subtype="lever", check_connectivity="entrance"})
self:defineTile('*', "GENERIC_LEVER_DOOR", nil, nil, nil, {lever_action=2, lever_action_value=0, lever_action_kind="pride-doors"}, {type="lever", subtype="door", check_connectivity="entrance"})
local wfc = WaveFunctionCollapse.new{
mode="overlapping",
sample=self:getFile("!buildings.tmx", "samples"),
sample=self:getFile("!buildings2.tmx", "samples"),
size={34, 34},
n=3, symmetry=8, periodic_out=false, periodic_in=false, has_foundation=false
}
......@@ -36,15 +41,15 @@ tm:merge(1, 1, outer, merge_order)
tm:merge(8, 8, wfc, merge_order)
-- Find rooms
local rooms = tm:findGroupsOf{'r'}
local rooms = tm:findGroupsOf{':'}
tm:applyOnGroups(rooms, function(room, idx)
tm:fillGroup(room, '.')
-- tm:fillGroup(room, '.')
local border = tm:getBorderGroup(room)
local door = tm:pickGroupSpot(border, "inside-wall")
if door then tm:put(door, '+') end
local door = border:pickSpot("inside-wall", "straight", function(p) return tm:isA(p, '#', '|') end)
if door then tm:put(door, '!') end
local event = tm:pickGroupSpot(room, "any")
if event then self:addSpot(event, "event-spot", "subvault-place") end
local drake = room:pickSpot("any")
if drake then tm:put(drake, 'D') end
end)
-- Complete the map by putting wall in all the remaining blank spaces
......
......@@ -19,11 +19,11 @@
load("/data/general/npcs/orc.lua", rarity(3))
load("/data/general/npcs/orc-gorbat.lua", rarity(0))
load("/data/general/npcs/cold-drake.lua", rarity(0))
load("/data/general/npcs/storm-drake.lua", rarity(0))
load("/data/general/npcs/fire-drake.lua", rarity(0))
load("/data/general/npcs/venom-drake.lua", rarity(0))
load("/data/general/npcs/multihued-drake.lua", rarity(3))
load("/data/general/npcs/cold-drake.lua", rarity(5))
load("/data/general/npcs/storm-drake.lua", rarity(5))
load("/data/general/npcs/fire-drake.lua", rarity(5))
load("/data/general/npcs/venom-drake.lua", rarity(5))
load("/data/general/npcs/multihued-drake.lua", rarity(8))
load("/data/general/npcs/all.lua", rarity(4, 35))
......
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" tiledversion="1.0.3" orientation="orthogonal" renderorder="right-down" width="22" height="22" tilewidth="32" tileheight="32" nextobjectid="31">
<properties>
<property name="status_all" value="{no_teleport=true}"/>
</properties>
<tileset firstgid="1" name="dg_dungeon32" tilewidth="32" tileheight="32" tilecount="90" columns="9">
<image source="../../../../../../../tiled-maps/gfx/dg_dungeon32.gif" width="288" height="320"/>
<tile id="0">
<properties>
<property name="id" value="#"/>
</properties>
</tile>
<tile id="3">
<properties>
<property name="id" value="+"/>
</properties>
</tile>
<tile id="51">
<properties>
<property name="id" value="."/>
</properties>
</tile>
<tile id="54">
<properties>
<property name="id" value="_"/>
</properties>
</tile>
<tile id="58">
<properties>
<property name="id" value="r"/>
</properties>
</tile>
</tileset>
<tileset firstgid="91" name="tome-terrains" tilewidth="32" tileheight="32" tilecount="144" columns="8">
<image source="../../../../../../../tiled-maps/gfx/tome-terrains.png" width="256" height="576"/>
<tile id="24">
<objectgroup draworder="index">
<properties>
<property name="id" value=";"/>
</properties>
</objectgroup>
</tile>
<tile id="58">
<objectgroup draworder="index">
<properties>
<property name="id" value=";"/>
</properties>
</objectgroup>
</tile>
<tile id="60">
<objectgroup draworder="index">
<properties>
<property name="id" value=":"/>
</properties>
</objectgroup>
</tile>
<tile id="100">
<objectgroup draworder="index">
<properties>
<property name="id" value="T"/>
</properties>
</objectgroup>
</tile>
<tile id="134">
<objectgroup draworder="index">
<properties>
<property name="id" value="|"/>
</properties>
</objectgroup>
</tile>
</tileset>
<tileset firstgid="235" name="numbers" tilewidth="32" tileheight="32" tilecount="36" columns="6">
<image source="../../../../../../../tiled-maps/gfx/numbers.png" width="192" height="192"/>
</tileset>
<layer name="Terrain" width="22" height="22">
<data encoding="base64" compression="zlib">
eJzVVDkOwDAM8v/3KO/LT7p0qJAP7DpVOrBhQizwEJHxARagU2vesHSRb3l4as1AF9+OuBqvwwPDq3hA/tvdaj46srAjX6eh+i9rDruT0dfmmOxG2l7erK55uWRznOmx55XpZ6Yb7N1hdxvNVHvJ7jerueNO/OH2XF6dO54=
</data>
</layer>
</map>
......@@ -49,6 +49,7 @@ return {
actor = {
class = "mod.class.generator.actor.Random",
nb_npc = {35, 40},
filters = { {type="humanoid", subtype="orc"}, {type="humanoid", subtype="orc"}, {type="humanoid", subtype="orc"}, {type="humanoid", subtype="orc"}, {}, },
guardian = "GORBAT",
},
object = {
......
......@@ -40,10 +40,10 @@ local rooms = tm:findGroupsOf{'r'}
tm:applyOnGroups(rooms, function(room, idx)
tm:fillGroup(room, '.')
local border = tm:getBorderGroup(room)
local door = tm:pickGroupSpot(border, "inside-wall")
local door = border:pickSpot("inside-wall")
if door then tm:put(door, '+') end
local event = tm:pickGroupSpot(room, "any")
local event = room:pickSpot("any")
if event then self:addSpot(event, "event-spot", "subvault-place") end
end)
......
......@@ -25,3 +25,23 @@ end)
load("/data/general/grids/forest.lua")
load("/data/general/grids/water.lua")
load("/data/general/grids/burntland.lua")
newEntity{
define_as = "GENERIC_BOOK", image = "terrain/marble_floor.png", add_mos = {{image="terrain/book_generic.png"}},
type = "floor", subtype = "floor",
name = "book",
display = '_', color_r=255, color_g=0, color_b=0,
notice = true,
always_remember = true,
}
newEntity{
define_as = "CANDLE",
type = "floor", subtype = "floor",
name = "reading candle", image = "terrain/marble_floor.png",
force_clone = true,
display = ';', color=colors.GOLD,
always_remember = true,
nice_tiler = { method="replace", base={"CANDLE", 100, 1, 3}},
}
for i = 1, 3 do newEntity{base = "CANDLE", define_as = "CANDLE"..i, embed_particles = {{name="candle", rad=1, args={candle_id="light1"}}} } end
......@@ -25,6 +25,9 @@ self:defineTile("X", "BURNT_GROUND", nil, {entity_mod=function(e) e.make_escort
self:defineTile('&', "GENERIC_LEVER", nil, nil, nil, {lever=1, lever_kind="pride-doors", lever_spot={type="lever", subtype="door", check_connectivity="entrance"}}, {type="lever", subtype="lever", check_connectivity="entrance"})
self:defineTile('*', "GENERIC_LEVER_DOOR", nil, nil, nil, {lever_action=2, lever_action_value=0, lever_action_kind="pride-doors"}, {type="lever", subtype="door", check_connectivity="entrance"})
self:defineTile('B', "GENERIC_BOOK")
self:defineTile('C', "CANDLE", nil, {random_filter={type='humanoid', subtype='orc', special=function(e) return e.pride == mapdata.pride end, random_boss={nb_classes=0, loot_quality="store", loot_quantity=1, no_loot_randart=true, ai_move="move_complex", rank=3.5, force_classes={Archmage=true}}}})
local wfc = WaveFunctionCollapse.new{
mode="overlapping",
sample=self:getFile("!buildings.tmx", "samples"),
......@@ -40,18 +43,32 @@ local rooms = tm:findGroupsOf{'r'}
tm:applyOnGroups(rooms, function(room, idx)
tm:fillGroup(room, '.')
local border = tm:getBorderGroup(room)
local door = tm:pickGroupSpot(border, "inside-wall")
local door = border:pickSpot("inside-wall", "straight", function(p) return tm:isA(p, '#', 'T') end)
if door then tm:put(door, '+') end
local event = tm:pickGroupSpot(room, "any")
if event then self:addSpot(event, "event-spot", "subvault-place") end
-- A spot for subvaults
local event = room:pickSpot("any")
if event then
self:addSpot(event, "event-spot", "subvault-place")
room:remove(event)
end
-- Sometimes an archmage rare that reads a book
if rng.percent(25) then
local bpos = room:pickSpot("any")
if bpos then
local cpos = room:randomNearPoint(bpos)
if cpos then
tm:put(bpos, 'B')
tm:put(cpos, 'C')
end
end
end
end)
-- Complete the map by putting wall in all the remaining blank spaces
tm:fillAll()
-- if tm:eliminateByFloodfill{'#', 'T'} < 400 then return self:regenerate() end
tm:printResult()
-- tm:printResult()
return tm
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