1 /* SCCS Id: @(#)rm.h 3.4 1999/12/12 */
2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
3 /* NetHack may be freely redistributed. See license for details. */
9 * The dungeon presentation graphics code and data structures were rewritten
10 * and generalized for NetHack's release 2 by Eric S. Raymond (eric@snark)
11 * building on Don G. Kneller's MS-DOS implementation. See drawing.c for
12 * the code that permits the user to set the contents of the symbol structure.
14 * The door representation was changed by Ari Huttunen(ahuttune@niksula.hut.fi)
18 * TLCORNER TDWALL TRCORNER
22 * TRWALL CROSSWALL TLWALL HWALL
27 * BLCORNER TUWALL BRCORNER VWALL
32 /* Level location types */
40 #define CROSSWALL 7 /* For pretty mazes and special levels */
46 #define TREE 13 /* KMH */
50 #define MOAT 17 /* pool that doesn't boil, adjust messages */
52 #define DRAWBRIDGE_UP 19
54 #define IRONBARS 21 /* KMH */
66 #define DRAWBRIDGE_DOWN 33
71 #define INVALID_TYPE 127
74 * Avoid using the level types in inequalities:
75 * these types are subject to change.
76 * Instead, use one of the macros below.
78 #define IS_WALL(typ) ((typ) && (typ) <= DBWALL)
79 #define IS_STWALL(typ) ((typ) <= DBWALL) /* STONE <= (typ) <= DBWALL */
80 #define IS_ROCK(typ) ((typ) < POOL) /* absolutely nonaccessible */
81 #define IS_DOOR(typ) ((typ) == DOOR)
82 #define IS_TREE(typ) ((typ) == TREE || \
83 (level.flags.arboreal && (typ) == STONE))
84 #define ACCESSIBLE(typ) ((typ) >= DOOR) /* good position */
85 #define IS_ROOM(typ) ((typ) >= ROOM) /* ROOM, STAIRS, furniture.. */
86 #define ZAP_POS(typ) ((typ) >= POOL)
87 #define SPACE_POS(typ) ((typ) > DOOR)
88 #define IS_POOL(typ) ((typ) >= POOL && (typ) <= DRAWBRIDGE_UP)
89 #define IS_THRONE(typ) ((typ) == THRONE)
90 #define IS_FOUNTAIN(typ) ((typ) == FOUNTAIN)
91 #define IS_SINK(typ) ((typ) == SINK)
92 #define IS_GRAVE(typ) ((typ) == GRAVE)
93 #define IS_ALTAR(typ) ((typ) == ALTAR)
94 #define IS_DRAWBRIDGE(typ) ((typ) == DRAWBRIDGE_UP || (typ) == DRAWBRIDGE_DOWN)
95 #define IS_FURNITURE(typ) ((typ) >= STAIRS && (typ) <= ALTAR)
96 #define IS_AIR(typ) ((typ) == AIR || (typ) == CLOUD)
97 #define IS_SOFT(typ) ((typ) == AIR || (typ) == CLOUD || IS_POOL(typ))
100 * The screen symbols may be the default or defined at game startup time.
101 * See drawing.c for defaults.
102 * Note: {ibm|dec}_graphics[] arrays (also in drawing.c) must be kept in synch.
105 /* begin dungeon characters */
122 #define S_vcdoor 15 /* closed door, vertical wall */
123 #define S_hcdoor 16 /* closed door, horizontal wall */
124 #define S_bars 17 /* KMH -- iron bars */
125 #define S_tree 18 /* KMH */
131 #define S_upladder 24
132 #define S_dnladder 25
137 #define S_fountain 30
141 #define S_vodbridge 34
142 #define S_hodbridge 35
143 #define S_vcdbridge 36 /* closed drawbridge, vertical wall */
144 #define S_hcdbridge 37 /* closed drawbridge, horizontal wall */
149 /* end dungeon characters, begin traps */
151 #define S_arrow_trap 41
152 #define S_dart_trap 42
153 #define S_falling_rock_trap 43
154 #define S_squeaky_board 44
155 #define S_bear_trap 45
156 #define S_land_mine 46
157 #define S_rolling_boulder_trap 47
158 #define S_sleeping_gas_trap 48
159 #define S_rust_trap 49
160 #define S_fire_trap 50
162 #define S_spiked_pit 52
164 #define S_trap_door 54
165 #define S_teleportation_trap 55
166 #define S_level_teleporter 56
167 #define S_magic_portal 57
169 #define S_statue_trap 59
170 #define S_magic_trap 60
171 #define S_anti_magic_trap 61
172 #define S_polymorph_trap 62
174 /* end traps, begin special effects */
176 #define S_vbeam 63 /* The 4 zap beam symbols. Do NOT separate. */
177 #define S_hbeam 64 /* To change order or add, see function */
178 #define S_lslant 65 /* zapdir_to_glyph() in display.c. */
180 #define S_digbeam 67 /* dig beam symbol */
181 #define S_flashbeam 68 /* camera flash symbol */
182 #define S_boomleft 69 /* thrown boomerang, open left, e.g ')' */
183 #define S_boomright 70 /* thrown boomerand, open right, e.g. '(' */
184 #define S_ss1 71 /* 4 magic shield glyphs */
189 /* The 8 swallow symbols. Do NOT separate. To change order or add, see */
190 /* the function swallow_to_glyph() in display.c. */
191 #define S_sw_tl 75 /* swallow top left [1] */
192 #define S_sw_tc 76 /* swallow top center [2] Order: */
193 #define S_sw_tr 77 /* swallow top right [3] */
194 #define S_sw_ml 78 /* swallow middle left [4] 1 2 3 */
195 #define S_sw_mr 79 /* swallow middle right [6] 4 5 6 */
196 #define S_sw_bl 80 /* swallow bottom left [7] 7 8 9 */
197 #define S_sw_bc 81 /* swallow bottom center [8] */
198 #define S_sw_br 82 /* swallow bottom right [9] */
200 #define S_explode1 83 /* explosion top left */
201 #define S_explode2 84 /* explosion top center */
202 #define S_explode3 85 /* explosion top right Ex. */
203 #define S_explode4 86 /* explosion middle left */
204 #define S_explode5 87 /* explosion middle center /-\ */
205 #define S_explode6 88 /* explosion middle right |@| */
206 #define S_explode7 89 /* explosion bottom left \-/ */
207 #define S_explode8 90 /* explosion bottom center */
208 #define S_explode9 91 /* explosion bottom right */
212 #define MAXPCHARS 92 /* maximum number of mapped characters */
213 #define MAXDCHARS 41 /* maximum of mapped dungeon characters */
214 #define MAXTCHARS 22 /* maximum of mapped trap characters */
215 #define MAXECHARS 29 /* maximum of mapped effects characters */
216 #define MAXEXPCHARS 9 /* number of explosion characters */
220 const char *explanation;
226 extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
227 extern uchar showsyms[MAXPCHARS];
228 extern const struct symdef def_warnsyms[WARNCOUNT];
231 * Graphics sets for display symbols
233 #define ASCII_GRAPHICS 0 /* regular characters: '-', '+', &c */
234 #define IBM_GRAPHICS 1 /* PC graphic characters */
235 #define DEC_GRAPHICS 2 /* VT100 line drawing characters */
236 #define MAC_GRAPHICS 3 /* Macintosh drawing characters */
239 * The 5 possible states of doors
250 * Some altars are considered as shrines, so we need a flag.
255 * Thrones should only be looted once.
260 * Trees have more than one kick result.
262 #define TREE_LOOTED 1
266 * Fountains have limits, and special warnings.
270 #define FOUNTAIN_IS_WARNED(x,y) (levl[x][y].looted & F_WARNED)
271 #define FOUNTAIN_IS_LOOTED(x,y) (levl[x][y].looted & F_LOOTED)
272 #define SET_FOUNTAIN_WARNED(x,y) levl[x][y].looted |= F_WARNED;
273 #define SET_FOUNTAIN_LOOTED(x,y) levl[x][y].looted |= F_LOOTED;
274 #define CLEAR_FOUNTAIN_WARNED(x,y) levl[x][y].looted &= ~F_WARNED;
275 #define CLEAR_FOUNTAIN_LOOTED(x,y) levl[x][y].looted &= ~F_LOOTED;
278 * Doors are even worse :-) The special warning has a side effect
279 * of instantly trapping the door, and if it was defined as trapped,
280 * the guards consider that you have already been warned!
285 * Sinks have 3 different types of loot that shouldn't be abused
292 * The four directions for a DrawBridge.
298 #define DB_DIR 3 /* mask for direction */
301 * What's under a drawbridge.
307 #define DB_UNDER 28 /* mask for underneath */
312 #define WM_MASK 0x07 /* wall mode (bottom three bits) */
313 #define W_NONDIGGABLE 0x08
314 #define W_NONPASSWALL 0x10
317 * Ladders (in Vlad's tower) may be up or down.
323 * Room areas may be iced pools
329 * The structure describing a coordinate position.
330 * Before adding fields, remember that this will significantly affect
331 * the size of temporary files and save files.
334 int glyph; /* what the hero thinks is there */
335 schar typ; /* what is really there */
336 uchar seenv; /* seen vector */
337 Bitfield(flags,5); /* extra information for typ */
338 Bitfield(horizontal,1); /* wall/door/etc is horiz. (more typ info) */
339 Bitfield(lit,1); /* speed hack for lit rooms */
340 Bitfield(waslit,1); /* remember if a location was lit */
341 Bitfield(roomno,6); /* room # for special rooms */
342 Bitfield(edge,1); /* marks boundaries for special rooms*/
346 * Add wall angle viewing by defining "modes" for each wall type. Each
347 * mode describes which parts of a wall are finished (seen as as wall)
348 * and which are unfinished (seen as rock).
350 * We use the bottom 3 bits of the flags field for the mode. This comes
351 * in conflict with secret doors, but we avoid problems because until
352 * a secret door becomes discovered, we know what sdoor's bottom three
355 * The following should cover all of the cases.
357 * type mode Examples: R=rock, F=finished
358 * ----- ---- ----------------------------
359 * WALL: 0 none hwall, mode 1
360 * 1 left/top (1/2 rock) RRR
361 * 2 right/bottom (1/2 rock) ---
364 * CORNER: 0 none trcorn, mode 2
365 * 1 outer (3/4 rock) FFF
366 * 2 inner (1/4 rock) F+-
369 * TWALL: 0 none tlwall, mode 3
370 * 1 long edge (1/2 rock) F|F
371 * 2 bottom left (on a tdwall) -+F
372 * 3 bottom right (on a tdwall) R|F
374 * CRWALL: 0 none crwall, mode 5
375 * 1 top left (1/4 rock) R|F
376 * 2 top right (1/4 rock) -+-
377 * 3 bottom left (1/4 rock) F|R
378 * 4 bottom right (1/4 rock)
379 * 5 top left & bottom right (1/2 rock)
380 * 6 bottom left & top right (1/2 rock)
383 #define WM_W_LEFT 1 /* vertical or horizontal wall */
385 #define WM_W_TOP WM_W_LEFT
386 #define WM_W_BOTTOM WM_W_RIGHT
388 #define WM_C_OUTER 1 /* corner wall */
391 #define WM_T_LONG 1 /* T wall */
395 #define WM_X_TL 1 /* cross wall */
403 * Seen vector values. The seen vector is an array of 8 bits, one for each
404 * octant around a given center x:
410 * In the case of walls, a single wall square can be viewed from 8 possible
411 * directions. If we know the type of wall and the directions from which
412 * it has been seen, then we can determine what it looks like to the hero.
426 #define doormask flags
427 #define altarmask flags
428 #define wall_info flags
430 #define drawbridgemask flags
432 #define icedpool flags
434 #define blessedftn horizontal /* a fountain that grants attribs */
435 #define disturbed horizontal /* a grave that has been disturbed */
445 uchar nfountains; /* number of fountains on level */
446 uchar nsinks; /* number of sinks on the level */
447 /* Several flags that give hints about what's on the level */
448 Bitfield(has_shop, 1);
449 Bitfield(has_vault, 1);
450 Bitfield(has_zoo, 1);
451 Bitfield(has_court, 1);
452 Bitfield(has_morgue, 1);
453 Bitfield(has_beehive, 1);
454 Bitfield(has_barracks, 1);
455 Bitfield(has_temple, 1);
457 Bitfield(has_swamp, 1);
458 Bitfield(noteleport,1);
459 Bitfield(hardfloor,1);
461 Bitfield(hero_memory,1); /* hero has memory */
462 Bitfield(shortsighted,1); /* monsters are shortsighted */
463 Bitfield(graveyard,1); /* has_morgue, but remains set */
464 Bitfield(is_maze_lev,1);
466 Bitfield(is_cavernous_lev,1);
467 Bitfield(arboreal, 1); /* Trees replace rock */
472 struct rm locations[COLNO][ROWNO];
473 #ifndef MICROPORT_BUG
474 struct obj *objects[COLNO][ROWNO];
475 struct monst *monsters[COLNO][ROWNO];
477 struct obj *objects[1][ROWNO];
478 char *yuk1[COLNO-1][ROWNO];
479 struct monst *monsters[1][ROWNO];
480 char *yuk2[COLNO-1][ROWNO];
483 struct obj *buriedobjlist;
484 struct monst *monlist;
485 struct damage *damagelist;
486 struct levelflags flags;
490 extern dlevel_t level; /* structure describing the current level */
493 * Macros for compatibility with old code. Someday these will go away.
495 #define levl level.locations
496 #define fobj level.objlist
497 #define fmon level.monlist
500 * Covert a trap number into the defsym graphics array.
501 * Convert a defsym number into a trap number.
502 * Assumes that arrow trap will always be the first trap.
504 #define trap_to_defsym(t) (S_arrow_trap+(t)-1)
505 #define defsym_to_trap(d) ((d)-S_arrow_trap+1)
507 #define OBJ_AT(x,y) (level.objects[x][y] != (struct obj *)0)
509 * Macros for encapsulation of level.monsters references.
511 #define MON_AT(x,y) (level.monsters[x][y] != (struct monst *)0 && \
512 !(level.monsters[x][y])->mburied)
513 #define MON_BURIED_AT(x,y) (level.monsters[x][y] != (struct monst *)0 && \
514 (level.monsters[x][y])->mburied)
516 #define place_monster(m,x,y) ((m)->mx=(x),(m)->my=(y),\
517 level.monsters[(m)->mx][(m)->my]=(m))
519 #define place_worm_seg(m,x,y) level.monsters[x][y] = m
520 #define remove_monster(x,y) level.monsters[x][y] = (struct monst *)0
521 #define m_at(x,y) (MON_AT(x,y) ? level.monsters[x][y] : \
523 #define m_buried_at(x,y) (MON_BURIED_AT(x,y) ? level.monsters[x][y] : \