summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/dat/layout.des
blob: 59e5d5d561d96476910019f298a60dae22a7d084 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
###############################################################################
# layout.des: All large layout vaults go here.  These are defined by having
#             both ORIENT: encompass and TAGS: layout.  These are not true
#             vaults, in that the dungeon builder can add other vaults on
#             top of them.
#
###############################################################################

##############################################################
# layout_forbidden_doughnut
#
# This replaces dungeon.cc:_plan_1().  It usually creates a
# room with a large hole in the middle.
#
NAME:   layout_forbidden_donut
ORIENT: encompass
TAGS:   layout allow_dup

{{
    local gxm, gym = dgn.max_bounds()
    local wall = dgn.feature_number("rock_wall")
    local floor = dgn.feature_number("floor")
    dgn.fill_area(0, 0, gxm - 1, gym - 1, wall)

    local width = (10 - crawl.random2(7))

    -- construct donut
    dgn.fill_area(10, 10, gxm - 10, 10 + width, floor)
    dgn.fill_area(10, 60 - width, gxm - 10, gym - 10, floor)
    dgn.fill_area(10, 10, 10 + width, gym - 10, floor)
    dgn.fill_area(60 - width, 10, gxm - 10, gym - 10, floor)

    local spotty = crawl.coinflip()
    local smears = crawl.random2(300)

    -- sometimes add a hallway cross through center
    if crawl.coinflip() then
        local width2 = 1 + crawl.random2(5)

        dgn.fill_area(10, gym/2 - width2, gxm - 10, gym/2 + width2, floor)
        dgn.fill_area(gxm/2 - width2, 10, gxm/2 + width2, gym - 10, floor)

        -- sometimes add a small octagon room
        if crawl.coinflip() and crawl.random2(15) > 7 then
            local oblique = 0
            if crawl.coinflip() then
                oblique = 5 + crawl.random2(20)
            end

            local feature_name = crawl.random_element({
                ["floor"]      = 5,
                ["deep_water"] = 1,
                ["lava"]       = 1,
            })
            dgn.octa_room(25, 25, gxm - 25, gym - 25, oblique, feature_name)

            -- decrease spotty chance
            spotty = crawl.one_chance_in(5)
        end
    end

    local spotty_boxy = crawl.coinflip()
    local smear_boxy = crawl.coinflip()

    if spotty then
        dgn.spotty_level(true, 0, spotty_boxy)
    end
    if not spotty and crawl.one_chance_in(4) or spotty then
        dgn.smear_feature(smears, smear_boxy, wall, 0, 0, gxm - 1, gym - 1)
    end
}}
MAP
ENDMAP

##############################################################
# layout_cross
#
# This replaces dungeon.cc:_plan_2().  It creates a large cross
# of varying width.
#
NAME:    layout_cross
ORIENT:  encompass
TAGS:    layout allow_dup

{{
    local width = 5 - crawl.random2(5)
    local height = 5 - crawl.random2(5)

    local gxm, gym = dgn.max_bounds()

    local wall = dgn.feature_number("rock_wall")
    local floor = dgn.feature_number("floor")

    -- Include a small possibility of adding windows around the cross.
    -- This layout can get used with spotty_level, so don't make this
    -- chance too large as lava/water prevents that from happening.
    local window = crawl.one_chance_in(20)

    if window or crawl.one_chance_in(20) then
        if crawl.coinflip() then
            wall = dgn.feature_number("lava")
        else
            wall = dgn.feature_number("deep_water")
        end
    end

    -- fill with rock
    dgn.fill_area(0, 0, gxm-1, gym-1, wall)

    -- create window
    if window then
        local clear = dgn.feature_number("clear_rock_wall")
        dgn.fill_area(10, gym/2 - height - 1, gxm - 10, gym/2 - height - 1, clear)
        dgn.fill_area(10, gym/2 + height + 1, gxm - 10, gym/2 + height + 1, clear)
        dgn.fill_area(gxm/2 - width - 1, 10, gxm/2 - width - 1, gym - 10, clear)
        dgn.fill_area(gxm/2 + width + 1, 10, gxm/2 + width + 1, gym - 10, clear)
    end

    -- create a cross
    dgn.fill_area(10, gym/2 - height, gxm - 10, gym/2 + height, floor)
    dgn.fill_area(gxm/2 - width, 10, gxm/2 + width, gym - 10, floor)

    if not crawl.one_chance_in(4) then
        dgn.spotty_level(true, 0, crawl.coinflip())
    end
}}
MAP
ENDMAP

#############################################################
# layout_big_octagon
#
# This replaces dungeon.cc:_plan_6().  It has an octagonal
# room with some number of pillars in the middle.  The stairs
# are generally all grouped together.
#

NAME: layout_big_octagon
ORIENT:  encompass
TAGS:    layout allow_dup

{{
    local gxm, gym = dgn.max_bounds()
    local wall = dgn.feature_number("rock_wall")
    local floor = dgn.feature_number("floor")

    local oblique = 10 + crawl.random2(20)

    dgn.fill_area(0, 0, gxm - 1, gym - 1, "rock_wall")
    dgn.octa_room(10, 10, gxm - 10, gym - 10, oblique, "floor")

    if crawl.coinflip() or true then
        local iterations = 100 + crawl.random2(200)
        dgn.smear_feature(iterations, false, wall, 0, 0, gxm - 1, gym - 1)
    end

    -- Step 2: Add pillars

    -- pillar types and relative weights
    local pillar_fill = {
        ["rock_wall"]          = 15,
        ["green_crystal_wall"] = 5,
        ["metal_wall"]         = 4,
        ["clear_rock_wall"]    = 3,
        ["deep_water"]         = 2,
        ["lava"]               = 1,
    }
    local fill = dgn.feature_number(crawl.random_element(pillar_fill))

    -- Potential pillar drawing routines
    local pillar_func = {
        dgn.make_circle,
        dgn.make_square,
        dgn.make_rounded_square
    }

    -- Pillar size params
    -- NOTE: Be careful about tweaking the ranges here.  Pillars that are
    -- too large, close, or large in number can entirely surround the center.
    local type = crawl.random2(#pillar_func) + 1
    local num = 3 + crawl.random2(9)
    local pillar_radius = 1 + crawl.random2(3)
    local circle_radius = 2 + crawl.random2(6) + pillar_radius * 2 + num / 2


    -- beautification hack: no "circle" pillars of radius 1
    if type == 1 and pillar_radius == 1 then
        fill = dgn.feature_number("stone_arch")
    end

    -- Finally, make the pillars
    dgn.make_pillars(gxm/2, gym/2, num, 1, circle_radius, pillar_radius,
                     pillar_func[type], fill)

    -- Step 3: Create stairs

    -- Potential stair locations
    -- 0) random
    -- 1) inside
    -- 2) up
    -- 3) right
    -- 4) down
    -- 5) left

    local up_loc = crawl.random2(6)
    local down_loc = crawl.random2(6)
    while up_loc == down_loc do
        down_loc = crawl.random2(6)
    end

    local up_stairs = {
        dgn.feature_number("stone_stairs_up_i"),
        dgn.feature_number("stone_stairs_up_ii"),
        dgn.feature_number("stone_stairs_up_iii"),
    }
    local down_stairs = {
        dgn.feature_number("stone_stairs_down_i"),
        dgn.feature_number("stone_stairs_down_ii"),
        dgn.feature_number("stone_stairs_down_iii"),
    }
    local full_stair_set = {[up_loc] = up_stairs, [down_loc] = down_stairs}

    for loc, stair_list in pairs (full_stair_set) do
        for i = 1, #stair_list do
            local st = stair_list[i]
            local ret = true

            if loc == 0 then
                dgn.replace_random(floor, stair_list[i])
            elseif loc == 1 then
                dgn.grid(gxm/2 + i - 2, gym/2 + 1 - math.abs(i - 2), st)
            elseif loc == 2 then
                ret = dgn.replace_first(gxm/2 + i-2, 0, 0, 1, floor, st)
            elseif loc == 3 then
                ret = dgn.replace_first(gxm - 1, gym/2 + i-2, -1, 0, floor, st)
            elseif loc == 4 then
                ret = dgn.replace_first(gxm/2 + i-2, gym - 1, 0, -1, floor, st)
            elseif loc == 5 then
                ret = dgn.replace_first(0, gym/2 + i-2, 1, 0, floor, st)
            end

            assert(ret)
        end
    end
}}
MAP
ENDMAP