OSDN Git Service

shrink mine
[nethackexpress/trunk.git] / doc / lev_comp.6
1 .TH LEV_COMP 6 "16 May 1996"
2 .UC 4
3 .SH NAME
4 lev_comp \- NetHack special levels compiler
5 .SH SYNOPSIS
6 .B lev_comp
7 [
8 .B \-w
9 ]
10 [
11 .I files
12 ]
13 .PP
14 If no arguments are given, it reads standard input.
15 .SH DESCRIPTION
16 .PP
17 .I Lev_comp
18 is a special level compiler for NetHack version 3.2 and higher.  It
19 takes description files as arguments and produces level files that can
20 be loaded by NetHack at runtime.
21 .PP
22 The purpose of this tool is to provide NetHack administrators and
23 implementors with a convenient way for adding special levels to the
24 game, or modifying existing ones, without having to recompile the
25 entire world.
26 .PP
27 The
28 .B \-w
29 option causes
30 .I lev_comp
31 to perform extra checks on the level and display extra warnings, however
32 these warnings are sometimes superfluous, so they are not normally displayed.
33
34 .SH GRAMMAR
35 .PP
36 .LP
37 .nf
38 .ta +8n +8n +8n +8n
39
40 file            : /* nothing */
41                 | levels
42                 ;
43
44 levels          : level
45                 | level levels
46                 ;
47
48 level           : maze_level
49                 | room_level
50                 ;
51
52 maze_level      : maze_def flags lev_init messages regions
53                 ;
54
55 room_level      : level_def flags lev_init messages rreg_init rooms corridors_def
56                 ;
57
58 level_def       : LEVEL_ID ':' string
59                 ;
60
61 lev_init        : /* nothing */
62                 | LEV_INIT_ID ':' CHAR ',' CHAR ',' BOOLEAN ',' BOOLEAN ',' light_state ',' walled
63                 ;
64
65 walled          : BOOLEAN
66                 | RANDOM_TYPE
67                 ;
68
69 flags           : /* nothing */
70                 | FLAGS_ID ':' flag_list
71                 ;
72
73 flag_list       : FLAG_TYPE ',' flag_list
74                 | FLAG_TYPE
75                 ;
76
77 messages        : /* nothing */
78                 | message messages
79                 ;
80
81 message         : MESSAGE_ID ':' STRING
82                 ;
83
84 rreg_init       : /* nothing */
85                 | rreg_init init_rreg
86                 ;
87
88 init_rreg       : RANDOM_OBJECTS_ID ':' object_list
89                 | RANDOM_MONSTERS_ID ':' monster_list
90                 ;
91
92 rooms           : /* Nothing  -  dummy room for use with INIT_MAP */
93                 | roomlist
94                 ;
95
96 roomlist        : aroom
97                 | aroom roomlist
98                 ;
99
100 corridors_def   : random_corridors
101                 | corridors
102                 ;
103
104 random_corridors: RAND_CORRIDOR_ID
105                 ;
106
107 corridors       : /* nothing */
108                 | corridors corridor
109                 ;
110
111 corridor        : CORRIDOR_ID ':' corr_spec ',' corr_spec
112                 | CORRIDOR_ID ':' corr_spec ',' INTEGER
113                 ;
114
115 corr_spec       : '(' INTEGER ',' DIRECTION ',' door_pos ')'
116                 ;
117
118 aroom           : room_def room_details
119                 | subroom_def room_details
120                 ;
121
122 subroom_def     : SUBROOM_ID ':' room_type ',' light_state ',' subroom_pos ',' room_size ',' string roomfill
123                 ;
124
125 room_def        : ROOM_ID ':' room_type ',' light_state ',' room_pos ',' room_align ',' room_size roomfill
126                 ;
127
128 roomfill        : /* nothing */
129                 | ',' BOOLEAN
130                 ;
131
132 room_pos        : '(' INTEGER ',' INTEGER ')'
133                 | RANDOM_TYPE
134                 ;
135
136 subroom_pos     : '(' INTEGER ',' INTEGER ')'
137                 | RANDOM_TYPE
138                 ;
139
140 room_align      : '(' h_justif ',' v_justif ')'
141                 | RANDOM_TYPE
142                 ;
143
144 room_size       : '(' INTEGER ',' INTEGER ')'
145                 | RANDOM_TYPE
146                 ;
147
148 room_details    : /* nothing */
149                 | room_details room_detail
150                 ;
151
152 room_detail     : room_name
153                 | room_chance
154                 | room_door
155                 | monster_detail
156                 | object_detail
157                 | trap_detail
158                 | altar_detail
159                 | fountain_detail
160                 | sink_detail
161                 | pool_detail
162                 | gold_detail
163                 | engraving_detail
164                 | stair_detail
165                 ;
166
167 room_name       : NAME_ID ':' string
168                 ;
169
170 room_chance     : CHANCE_ID ':' INTEGER
171                 ;
172
173 room_door       : DOOR_ID ':' secret ',' door_state ',' door_wall ',' door_pos
174                 ;
175
176 secret          : BOOLEAN
177                 | RANDOM_TYPE
178                 ;
179
180 door_wall       : DIRECTION
181                 | RANDOM_TYPE
182                 ;
183
184 door_pos        : INTEGER
185                 | RANDOM_TYPE
186                 ;
187
188 maze_def        : MAZE_ID ':' string ',' filling
189                 ;
190
191 filling         : CHAR
192                 | RANDOM_TYPE
193                 ;
194
195 regions         : aregion
196                 | aregion regions
197                 ;
198
199 aregion         : map_definition reg_init map_details
200                 ;
201
202 map_definition  : NOMAP_ID
203                 | map_geometry MAP_ID
204                 ;
205
206 map_geometry    : GEOMETRY_ID ':' h_justif ',' v_justif
207                 ;
208
209 h_justif        : LEFT_OR_RIGHT
210                 | CENTER
211                 ;
212
213 v_justif        : TOP_OR_BOT
214                 | CENTER
215                 ;
216
217 reg_init        : /* nothing */
218                 | reg_init init_reg
219                 ;
220
221 init_reg        : RANDOM_OBJECTS_ID ':' object_list
222                 | RANDOM_PLACES_ID ':' place_list
223                 | RANDOM_MONSTERS_ID ':' monster_list
224                 ;
225
226 object_list     : object
227                 | object ',' object_list
228                 ;
229
230 monster_list    : monster
231                 | monster ',' monster_list
232                 ;
233
234 place_list      : place
235                 | place ',' place_list
236                 ;
237
238 map_details     : /* nothing */
239                 | map_details map_detail
240                 ;
241
242 map_detail      : monster_detail
243                 | object_detail
244                 | door_detail
245                 | trap_detail
246                 | drawbridge_detail
247                 | region_detail
248                 | stair_region
249                 | portal_region
250                 | teleprt_region
251                 | branch_region
252                 | altar_detail
253                 | fountain_detail
254                 | mazewalk_detail
255                 | wallify_detail
256                 | ladder_detail
257                 | stair_detail
258                 | gold_detail
259                 | engraving_detail
260                 | diggable_detail
261                 | passwall_detail
262                 ;
263
264 monster_detail  : MONSTER_ID chance ':' monster_c ',' m_name ',' coordinate
265                  monster_infos
266                 ;
267
268 monster_infos   : /* nothing */
269                 | monster_infos monster_info
270                 ;
271
272 monster_info    : ',' string
273                 | ',' MON_ATTITUDE
274                 | ',' MON_ALERTNESS
275                 | ',' alignment
276                 | ',' MON_APPEARANCE string
277                 ;
278
279 object_detail   : OBJECT_ID object_desc
280                 | COBJECT_ID object_desc
281                 ;
282
283 object_desc     : chance ':' object_c ',' o_name ',' object_where object_infos
284                 ;
285
286 object_where    : coordinate
287                 | CONTAINED
288                 ;
289
290 object_infos    : /* nothing */
291                 | ',' curse_state ',' monster_id ',' enchantment optional_name
292                 | ',' curse_state ',' enchantment optional_name
293                 | ',' monster_id ',' enchantment optional_name
294                 ;
295
296 curse_state     : RANDOM_TYPE
297                 | CURSE_TYPE
298                 ;
299
300 monster_id      : STRING
301                 ;
302
303 enchantment     : RANDOM_TYPE
304                 | INTEGER
305                 ;
306
307 optional_name   : /* nothing */
308                 | ',' NONE
309                 | ',' STRING
310                 ;
311
312 door_detail     : DOOR_ID ':' door_state ',' coordinate
313                 ;
314
315 trap_detail     : TRAP_ID chance ':' trap_name ',' coordinate
316                 ;
317
318 drawbridge_detail: DRAWBRIDGE_ID ':' coordinate ',' DIRECTION ',' door_state
319                 ;
320
321 mazewalk_detail : MAZEWALK_ID ':' coordinate ',' DIRECTION
322                 ;
323
324 wallify_detail  : WALLIFY_ID
325                 ;
326
327 ladder_detail   : LADDER_ID ':' coordinate ',' UP_OR_DOWN
328                 ;
329
330 stair_detail    : STAIR_ID ':' coordinate ',' UP_OR_DOWN
331                 ;
332
333 stair_region    : STAIR_ID ':' lev_region ',' lev_region ',' UP_OR_DOWN
334                 ;
335
336 portal_region   : PORTAL_ID ':' lev_region ',' lev_region ',' string
337                 ;
338
339 teleprt_region  : TELEPRT_ID ':' lev_region ',' lev_region teleprt_detail
340                 ;
341
342 branch_region   : BRANCH_ID ':' lev_region ',' lev_region
343                 ;
344
345 teleprt_detail  : /* empty */
346                 | ',' UP_OR_DOWN
347                 ;
348
349 lev_region      : region
350                 | LEV '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'
351                 ;
352
353 fountain_detail : FOUNTAIN_ID ':' coordinate
354                 ;
355
356 sink_detail : SINK_ID ':' coordinate
357                 ;
358
359 pool_detail : POOL_ID ':' coordinate
360                 ;
361
362 diggable_detail : NON_DIGGABLE_ID ':' region
363                 ;
364
365 passwall_detail : NON_PASSWALL_ID ':' region
366                 ;
367
368 region_detail   : REGION_ID ':' region ',' light_state ',' room_type prefilled
369                 ;
370
371 altar_detail    : ALTAR_ID ':' coordinate ',' alignment ',' altar_type
372                 ;
373
374 gold_detail     : GOLD_ID ':' amount ',' coordinate
375                 ;
376
377 engraving_detail: ENGRAVING_ID ':' coordinate ',' engraving_type ',' string
378                 ;
379
380 monster_c       : monster
381                 | RANDOM_TYPE
382                 | m_register
383                 ;
384
385 object_c        : object
386                 | RANDOM_TYPE
387                 | o_register
388                 ;
389
390 m_name          : string
391                 | RANDOM_TYPE
392                 ;
393
394 o_name          : string
395                 | RANDOM_TYPE
396                 ;
397
398 trap_name       : string
399                 | RANDOM_TYPE
400                 ;
401
402 room_type       : string
403                 | RANDOM_TYPE
404                 ;
405
406 prefilled       : /* empty */
407                 | ',' FILLING
408                 | ',' FILLING ',' BOOLEAN
409                 ;
410
411 coordinate      : coord
412                 | p_register
413                 | RANDOM_TYPE
414                 ;
415
416 door_state      : DOOR_STATE
417                 | RANDOM_TYPE
418                 ;
419
420 light_state     : LIGHT_STATE
421                 | RANDOM_TYPE
422                 ;
423
424 alignment       : ALIGNMENT
425                 | a_register
426                 | RANDOM_TYPE
427                 ;
428
429 altar_type      : ALTAR_TYPE
430                 | RANDOM_TYPE
431                 ;
432
433 p_register      : P_REGISTER '[' INTEGER ']'
434                 ;
435
436 o_register      : O_REGISTER '[' INTEGER ']'
437                 ;
438
439 m_register      : M_REGISTER '[' INTEGER ']'
440                 ;
441
442 a_register      : A_REGISTER '[' INTEGER ']'
443                 ;
444
445 place           : coord
446                 ;
447
448 monster         : CHAR
449                 ;
450
451 object          : CHAR
452                 ;
453
454 string          : STRING
455                 ;
456
457 amount          : INTEGER
458                 | RANDOM_TYPE
459                 ;
460
461 chance          : /* empty */
462                 | PERCENT
463                 ;
464
465 engraving_type  : ENGRAVING_TYPE
466                 | RANDOM_TYPE
467                 ;
468
469 coord           : '(' INTEGER ',' INTEGER ')'
470                 ;
471
472 region          : '(' INTEGER ',' INTEGER ',' INTEGER ',' INTEGER ')'
473                 ;
474 .fi
475 .PP
476 .I NOTE:
477 .br
478 Lines beginning with '#' are considered comments.
479 .PP
480 The contents of a "MAP" description of a maze is a rectangle showing the exact
481 level map that should be used for the given part of a maze.
482 Each character in the map corresponds to a location on the screen.
483 Different location types are denoted using different ASCII characters.
484 The following characters are recognized.
485 To give an idea of how these are used, see the EXAMPLE, below.
486 The maximum size of a map is normally 76 columns by 21 rows.
487 .LP
488 .nf
489 .ta +8n +8n +8n
490 \&'-'   horizontal wall
491 \&'|'   vertical wall
492 \&'+'   a doorway (state is specified in a DOOR declaration)
493 \&'A'   open air
494 \&'B'   boundary room location (for bounding unwalled irregular regions)
495 \&'C'   cloudy air
496 \&'I'   ice
497 \&'S'   a secret door
498 \&'H'   a secret corridor
499 \&'{'   a fountain
500 \&'\\'  a throne
501 \&'K'   a sink (if SINKS is defined, else a room location)
502 \&'}'   a part of a moat or other deep water
503 \&'P'   a pool
504 \&'L'   lava
505 \&'W'   water (yes, different from a pool)
506 \&'T'   a tree
507 \&'F'   iron bars
508 \&'#'   a corridor
509 \&'.'   a normal room location (unlit unless lit in a REGION declaration)
510 \&' '   stone
511 .fi
512 .SH EXAMPLE
513 .PP
514 Here is an example of a description file (a very simple one):
515 .LP
516 .nf
517 .ta +8n +8n +8n
518 MAZE : "fortress", random
519 GEOMETRY : center , center
520 MAP
521 }}}}}}}}}
522 }}}|-|}}}
523 }}|-.-|}}
524 }|-...-|}
525 }|.....|}
526 }|-...-|}
527 }}|-.-|}}
528 }}}|-|}}}
529 }}}}}}}}}
530 ENDMAP
531 MONSTER: '@', "Wizard of Yendor", (4,4)
532 OBJECT: '"', "Amulet of Yendor", (4,4)
533 # a hell hound flanking the Wiz on a random side
534 RANDOM_PLACES: (4,3), (4,5), (3,4), (5,4)
535 MONSTER: 'd', "hell hound", place[0]
536 # a chest on another random side
537 OBJECT: '(', "chest", place[1]
538 # a sack on a random side, with a diamond and maybe a ruby in it
539 CONTAINER: '(', "sack", place[2]
540 OBJECT: '*', "diamond", contained
541 OBJECT[50%]: '*', "ruby", contained
542 # a random dragon somewhere
543 MONSTER: 'D', random, random
544 # 3 out of 4 chance for a random trap in the EAST end
545 TRAP[75%]: random, (6,4)
546 # an electric eel below the SOUTH end
547 MONSTER: ';', "electric eel", (4,8)
548 # make the walls non-diggable
549 NON_DIGGABLE: (0,0,8,8)
550 TELEPORT_REGION: levregion(0,0,79,20), (0,0,8,8)
551 .fi
552 .PP
553 This example will produce a file named "fortress" that can be integrated into
554 one of the numerous mazes of the game.
555 .PP
556 Note especially the final, TELEPORT_REGION specification.  This says
557 that level teleports or other non-stairway arrivals on this level can
558 land anywhere on the level except the area of the map.  This shows the
559 use of the ``levregion'' prefix allowed in certain region specifications.
560 Normally, regions apply only to the most recent MAP specification, but
561 when prefixed with ``levregion'', one can refer to any area of the
562 level, regardless of the placement of the current MAP in the level.
563 .SH AUTHOR
564 .PP
565 Jean-Christophe Collet, David Cohrs.
566 .SH "SEE ALSO"
567 .PP
568 dgn_comp(6), nethack(6)
569 .SH BUGS
570 .PP
571 Probably infinite.
572 Most importantly, still needs additional bounds checking.