File: geoelf_glyphs.lua

package info (click to toggle)
crawl 2%3A0.34.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 100,204 kB
  • sloc: cpp: 363,900; ansic: 27,765; javascript: 9,516; python: 8,463; perl: 3,293; java: 3,132; xml: 2,380; makefile: 1,835; sh: 611; objc: 250; cs: 15; sed: 9; lisp: 3
file content (258 lines) | stat: -rw-r--r-- 11,134 bytes parent folder | download | duplicates (6)
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
248
249
250
251
252
253
254
255
256
257
258
------------------------------------------------------------------------------
-- geoelf_glyphs.lua:
--
-- Contains the glyphs used by the geoelf layout generator.
--  Using other glyphs than these can lead to crashes if they
--  are used as table lookup indexes (which happens).
------------------------------------------------------------------------------

geoelf.glyphs    = {}    -- Namespace for glyph constants, etc.



----------------
--
-- The recognized glyphs
--
-- Most of these are just attaching names to the standard
--  vault-making characters, but I feel nervous hard-coding
--  constants like 'x' into a complex block of code.
--
-- TODO: Special tiles for door in glass and glass depicting
--       plant or feature (together or separately).
--

geoelf.glyphs.WALL           = 'x'
geoelf.glyphs.DOOR           = '+'
geoelf.glyphs.FLOOR          = '.'
geoelf.glyphs.CORRIDOR       = '_'
geoelf.glyphs.TREE           = 't'
geoelf.glyphs.BUSH           = 'D'
geoelf.glyphs.PLANT          = 'E'
geoelf.glyphs.FUNGUS         = 'F'
geoelf.glyphs.STATUE         = 'G'
geoelf.glyphs.FOUNTAIN       = 'T'
geoelf.glyphs.GLASS          = 'm'
geoelf.glyphs.GLASS_DOOR     = '~'
geoelf.glyphs.GLASS_TREE     = 'J'
geoelf.glyphs.GLASS_BUSH     = 'K'
geoelf.glyphs.GLASS_PLANT    = 'L'
geoelf.glyphs.GLASS_FUNGUS   = 'M'
geoelf.glyphs.GLASS_STATUE   = 'N'
geoelf.glyphs.GLASS_FOUNTAIN = 'O'



----------------
--
-- Groups of glyphs
--
-- Names for a group of similar glyphs concatinating into a
--  single string.
--

geoelf.glyphs.ALL_DOORS       = geoelf.glyphs.DOOR ..
                                geoelf.glyphs.GLASS_DOOR
geoelf.glyphs.ALL_GLASS_WALLS = geoelf.glyphs.GLASS ..
                                geoelf.glyphs.GLASS_TREE ..
                                geoelf.glyphs.GLASS_BUSH ..
                                geoelf.glyphs.GLASS_PLANT ..
                                geoelf.glyphs.GLASS_FUNGUS ..
                                geoelf.glyphs.GLASS_STATUE ..
                                geoelf.glyphs.GLASS_FOUNTAIN
geoelf.glyphs.ALL_PLANTLIKE   = geoelf.glyphs.TREE ..
                                geoelf.glyphs.BUSH ..
                                geoelf.glyphs.PLANT ..
                                geoelf.glyphs.FUNGUS
geoelf.glyphs.ALL_FEATURES    = geoelf.glyphs.STATUE ..
                                geoelf.glyphs.FOUNTAIN
geoelf.glyphs.ALL_WALLLIKE    = geoelf.glyphs.WALL ..
                                geoelf.glyphs.ALL_GLASS_WALLS
geoelf.glyphs.ALL_FLOORLIKE   = geoelf.glyphs.FLOOR ..
                                geoelf.glyphs.CORRIDOR ..
                                geoelf.glyphs.ALL_PLANTLIKE ..
                                geoelf.glyphs.ALL_FEATURES



----------------
--
-- These are glyph substitution arrays used by the room-drawing
--  functions. Any glyph drawn that is not in the array will
--  turn into a "nil" when a substitution is made. This will
--  generate an error when the LUA code runs that says something
--  like:
--    /crawl-ref/source/dat/des/builder/layout_geoelf.des:132:
--    /crawl-ref/source/dat/dlua/layout/geoelf_rooms.lua:395:
--    bad argument #3 to '?' (string expected, got nil)
--

-- for room floors
geoelf.glyphs.OPEN_SUBSTITUTIONS =
  { [geoelf.glyphs.WALL]           = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.DOOR]           = geoelf.glyphs.CORRIDOR,
    [geoelf.glyphs.FLOOR]          = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.CORRIDOR]       = geoelf.glyphs.CORRIDOR,
    [geoelf.glyphs.TREE]           = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.BUSH]           = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.PLANT]          = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.FUNGUS]         = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.STATUE]         = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.FOUNTAIN]       = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.GLASS]          = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.GLASS_DOOR]     = geoelf.glyphs.CORRIDOR,
    [geoelf.glyphs.GLASS_TREE]     = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.GLASS_BUSH]     = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.GLASS_PLANT]    = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.GLASS_FUNGUS]   = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.GLASS_STATUE]   = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.GLASS_FOUNTAIN] = geoelf.glyphs.FLOOR
  }

-- for the wall around a room
geoelf.glyphs.BORDER_SUBSTITUTIONS =
  { [geoelf.glyphs.WALL]           = geoelf.glyphs.WALL,
    [geoelf.glyphs.DOOR]           = geoelf.glyphs.DOOR,
    [geoelf.glyphs.FLOOR]          = geoelf.glyphs.GLASS,
    [geoelf.glyphs.CORRIDOR]       = geoelf.glyphs.DOOR,
    [geoelf.glyphs.TREE]           = geoelf.glyphs.GLASS_TREE,
    [geoelf.glyphs.BUSH]           = geoelf.glyphs.GLASS_BUSH,
    [geoelf.glyphs.PLANT]          = geoelf.glyphs.GLASS_PLANT,
    [geoelf.glyphs.FUNGUS]         = geoelf.glyphs.GLASS_FUNGUS,
    [geoelf.glyphs.STATUE]         = geoelf.glyphs.GLASS_STATUE,
    [geoelf.glyphs.FOUNTAIN]       = geoelf.glyphs.GLASS_FOUNTAIN,
    [geoelf.glyphs.GLASS]          = geoelf.glyphs.GLASS,
    [geoelf.glyphs.GLASS_DOOR]     = geoelf.glyphs.GLASS_DOOR,
    [geoelf.glyphs.GLASS_TREE]     = geoelf.glyphs.GLASS_TREE,
    [geoelf.glyphs.GLASS_BUSH]     = geoelf.glyphs.GLASS_BUSH,
    [geoelf.glyphs.GLASS_PLANT]    = geoelf.glyphs.GLASS_PLANT,
    [geoelf.glyphs.GLASS_FUNGUS]   = geoelf.glyphs.GLASS_FUNGUS,
    [geoelf.glyphs.GLASS_STATUE]   = geoelf.glyphs.GLASS_STATUE,
    [geoelf.glyphs.GLASS_FOUNTAIN] = geoelf.glyphs.GLASS_FOUNTAIN,
  }

-- for the line one around the room wall
geoelf.glyphs.OUTLINE_SUBSTITUTIONS =
  { [geoelf.glyphs.WALL]           = geoelf.glyphs.WALL,
    [geoelf.glyphs.DOOR]           = geoelf.glyphs.DOOR,
    [geoelf.glyphs.FLOOR]          = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.CORRIDOR]       = geoelf.glyphs.CORRIDOR,
    [geoelf.glyphs.TREE]           = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.BUSH]           = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.PLANT]          = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.FUNGUS]         = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.STATUE]         = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.FOUNTAIN]       = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.GLASS]          = geoelf.glyphs.GLASS,
    [geoelf.glyphs.GLASS_DOOR]     = geoelf.glyphs.GLASS_DOOR,
    [geoelf.glyphs.GLASS_TREE]     = geoelf.glyphs.GLASS_TREE,
    [geoelf.glyphs.GLASS_BUSH]     = geoelf.glyphs.GLASS_BUSH,
    [geoelf.glyphs.GLASS_PLANT]    = geoelf.glyphs.GLASS_PLANT,
    [geoelf.glyphs.GLASS_FUNGUS]   = geoelf.glyphs.GLASS_FUNGUS,
    [geoelf.glyphs.GLASS_STATUE]   = geoelf.glyphs.GLASS_STATUE,
    [geoelf.glyphs.GLASS_FOUNTAIN] = geoelf.glyphs.GLASS_FOUNTAIN,
  }

-- choosing a random feature
geoelf.glyphs.FEATURE_OPTIONS =
  { {geoelf.glyphs.STATUE,   2},
    {geoelf.glyphs.FOUNTAIN, 1} }

-- choosing a random plantlike thing
geoelf.glyphs.PLANTLIKE_OPTIONS =
  { {geoelf.glyphs.TREE,   3},
    {geoelf.glyphs.BUSH,   1},
    {geoelf.glyphs.PLANT,  2},
    {geoelf.glyphs.FUNGUS, 4} }

-- making things into glass if possible
geoelf.glyphs.TO_GLASS =
  { [geoelf.glyphs.WALL]           = geoelf.glyphs.GLASS,
    [geoelf.glyphs.DOOR]           = geoelf.glyphs.GLASS_DOOR,
    [geoelf.glyphs.FLOOR]          = geoelf.glyphs.FLOOR,
    [geoelf.glyphs.CORRIDOR]       = geoelf.glyphs.CORRIDOR,
    [geoelf.glyphs.TREE]           = geoelf.glyphs.GLASS_TREE,
    [geoelf.glyphs.BUSH]           = geoelf.glyphs.GLASS_BUSH,
    [geoelf.glyphs.PLANT]          = geoelf.glyphs.GLASS_PLANT,
    [geoelf.glyphs.FUNGUS]         = geoelf.glyphs.GLASS_FUNGUS,
    [geoelf.glyphs.STATUE]         = geoelf.glyphs.GLASS_STATUE,
    [geoelf.glyphs.FOUNTAIN]       = geoelf.glyphs.GLASS_FOUNTAIN,
    [geoelf.glyphs.GLASS]          = geoelf.glyphs.GLASS,
    [geoelf.glyphs.GLASS_DOOR]     = geoelf.glyphs.GLASS_DOOR,
    [geoelf.glyphs.GLASS_TREE]     = geoelf.glyphs.GLASS_TREE,
    [geoelf.glyphs.GLASS_BUSH]     = geoelf.glyphs.GLASS_BUSH,
    [geoelf.glyphs.GLASS_PLANT]    = geoelf.glyphs.GLASS_PLANT,
    [geoelf.glyphs.GLASS_FUNGUS]   = geoelf.glyphs.GLASS_FUNGUS,
    [geoelf.glyphs.GLASS_STATUE]   = geoelf.glyphs.GLASS_STATUE,
    [geoelf.glyphs.GLASS_FOUNTAIN] = geoelf.glyphs.GLASS_FOUNTAIN,
  }



----------------
--
-- assign_glyphs
--
-- A function that assigns the feature types, tiles, and colours
--  to the glyphs with special meanings.
--

function geoelf.glyphs.assign_glyphs (e, only_trees)
  if (geoelf.debug) then print("  geoelf.glyphs.assign_glyphs") end

  -- Bushes, plant, and fungus
  --  -> If only_trees is true, these all become trees
  if (only_trees) then
    e.subst(geoelf.glyphs.BUSH   ..
            geoelf.glyphs.PLANT  ..
            geoelf.glyphs.FUNGUS .. " = " .. geoelf.glyphs.TREE)
    e.subst(geoelf.glyphs.GLASS_BUSH   ..
            geoelf.glyphs.GLASS_PLANT  ..
            geoelf.glyphs.GLASS_FUNGUS .. " = " .. geoelf.glyphs.GLASS_TREE)
  else
    e.kfeat(geoelf.glyphs.BUSH   ..
            geoelf.glyphs.PLANT  ..
            geoelf.glyphs.FUNGUS .. " = floor")
    e.kmons(geoelf.glyphs.BUSH   .. " = bush")
    e.kmons(geoelf.glyphs.PLANT  .. " = plant")
    e.kmons(geoelf.glyphs.FUNGUS .. " = fungus")

    -- prevent bushes, plants, fungus from being overwritten by vaults
    e.kmask(geoelf.glyphs.BUSH   ..
            geoelf.glyphs.PLANT  ..
            geoelf.glyphs.FUNGUS .. " = vault")
  end

  -- Glass doors
  e.kfeat( geoelf.glyphs.GLASS_DOOR .. " = closed_clear_door")

  -- Glass walls with deliberate images
  --  -> Very rare in practice
  --  -> These are only relevant in tiles
  --  -> We need special tiles for these
  --  -> For now, these are just coloured glass
  e.kfeat(geoelf.glyphs.GLASS_TREE     ..
          geoelf.glyphs.GLASS_BUSH     ..
          geoelf.glyphs.GLASS_PLANT    ..
          geoelf.glyphs.GLASS_FUNGUS   ..
          geoelf.glyphs.GLASS_STATUE   ..
          geoelf.glyphs.GLASS_FOUNTAIN .. " = clear_rock_wall")
  e.colour(geoelf.glyphs.GLASS_TREE     .. " = green")
  e.colour(geoelf.glyphs.GLASS_BUSH     .. " = green")
  e.colour(geoelf.glyphs.GLASS_PLANT    .. " = green")
  e.colour(geoelf.glyphs.GLASS_FUNGUS   .. " = brown")
  e.colour(geoelf.glyphs.GLASS_STATUE   .. " = white")
  e.colour(geoelf.glyphs.GLASS_FOUNTAIN .. " = blue")
  e.tile( geoelf.glyphs.GLASS_TREE     .. " = dngn_transparent_wall_green")
  e.tile( geoelf.glyphs.GLASS_BUSH     .. " = dngn_transparent_wall_green")
  e.tile( geoelf.glyphs.GLASS_PLANT    .. " = dngn_transparent_wall_green")
  e.tile( geoelf.glyphs.GLASS_FUNGUS   .. " = dngn_transparent_wall_brown")
  e.tile( geoelf.glyphs.GLASS_STATUE   .. " = dngn_transparent_wall_white")
  e.tile( geoelf.glyphs.GLASS_FOUNTAIN .. " = dngn_transparent_wall_blue")
  --e.tile( geoelf.glyphs.GLASS_TREE     .. " = stained_glass_tree")
  --e.tile( geoelf.glyphs.GLASS_BUSH     .. " = stained_glass_bush")
  --e.tile( geoelf.glyphs.GLASS_PLANT    .. " = stained_glass_plant")
  --e.tile( geoelf.glyphs.GLASS_FUNGUS   .. " = stained_glass_fungus")
  --e.tile( geoelf.glyphs.GLASS_STATUE   .. " = stained_glass_statue")
  --e.tile( geoelf.glyphs.GLASS_FOUNTAIN .. " = stained_glass_fountain")
end