1 /* NetHack 3.7 dungeon.h $NHDT-Date: 1596498535 2020/08/03 23:48:55 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.39 $ */ 2 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ 3 /*-Copyright (c) Michael Allison, 2006. */ 4 /* NetHack may be freely redistributed. See license for details. */ 5 6 #ifndef DUNGEON_H 7 #define DUNGEON_H 8 9 typedef struct d_level { /* basic dungeon level element */ 10 xchar dnum; /* dungeon number */ 11 xchar dlevel; /* level number */ 12 } d_level; 13 14 #if !defined(MAKEDEFS_C) && !defined(MDLIB_C) 15 16 typedef struct d_flags { /* dungeon/level type flags */ 17 Bitfield(town, 1); /* is this a town? (levels only) */ 18 Bitfield(hellish, 1); /* is this part of hell? */ 19 Bitfield(maze_like, 1); /* is this a maze? */ 20 Bitfield(align, 3); /* dungeon alignment. */ 21 Bitfield(unused, 1); /* etc... */ 22 } d_flags; 23 24 typedef struct s_level { /* special dungeon level element */ 25 struct s_level *next; 26 d_level dlevel; /* dungeon & level numbers */ 27 char proto[15]; /* name of prototype file (eg. "tower") */ 28 char boneid; /* character to id level in bones files */ 29 uchar rndlevs; /* no. of randomly available similar levels */ 30 d_flags flags; /* type flags */ 31 } s_level; 32 33 typedef struct stairway { /* basic stairway identifier */ 34 xchar sx, sy; /* x / y location of the stair */ 35 d_level tolev; /* where does it go */ 36 boolean up; /* up or down? */ 37 boolean isladder; /* ladder or stairway? */ 38 struct stairway *next; 39 } stairway; 40 41 /* level region types */ 42 enum level_region_types { 43 LR_DOWNSTAIR = 0, 44 LR_UPSTAIR, 45 LR_PORTAL, 46 LR_BRANCH, 47 LR_TELE, 48 LR_UPTELE, 49 LR_DOWNTELE 50 }; 51 52 typedef struct dest_area { /* non-stairway level change identifier */ 53 xchar lx, ly; /* "lower" left corner (near [0,0]) */ 54 xchar hx, hy; /* "upper" right corner (near [COLNO,ROWNO]) */ 55 xchar nlx, nly; /* outline of invalid area */ 56 xchar nhx, nhy; /* opposite corner of invalid area */ 57 } dest_area; 58 59 typedef struct dungeon { /* basic dungeon identifier */ 60 char dname[24]; /* name of the dungeon (eg. "Hell") */ 61 char proto[15]; /* name of prototype file (eg. "tower") */ 62 char fill_lvl[15]; /* name of "fill" level protype file */ 63 char themerms[15]; /* lua file name containing themed rooms */ 64 char boneid; /* character to id dungeon in bones files */ 65 d_flags flags; /* dungeon flags */ 66 xchar entry_lev; /* entry level */ 67 xchar num_dunlevs; /* number of levels in this dungeon */ 68 xchar dunlev_ureached; /* how deep you have been in this dungeon */ 69 int ledger_start, /* the starting depth in "real" terms */ 70 depth_start; /* the starting depth in "logical" terms */ 71 } dungeon; 72 73 /* 74 * A branch structure defines the connection between two dungeons. They 75 * will be ordered by the dungeon number/level number of 'end1'. Ties 76 * are resolved by 'end2'. 'Type' uses 'end1' arbitrarily as the primary 77 * point. 78 */ 79 typedef struct branch { 80 struct branch *next; /* next in the branch chain */ 81 int id; /* branch identifier */ 82 int type; /* type of branch */ 83 d_level end1; /* "primary" end point */ 84 d_level end2; /* other end point */ 85 boolean end1_up; /* does end1 go up? */ 86 } branch; 87 88 /* branch types */ 89 #define BR_STAIR 0 /* "Regular" connection, 2 staircases. */ 90 #define BR_NO_END1 1 /* "Regular" connection. However, no stair from 91 end1 to end2. There is a stair from end2 to end1. */ 92 #define BR_NO_END2 2 /* "Regular" connection. However, no stair from 93 end2 to end1. There is a stair from end1 to end2. */ 94 #define BR_PORTAL 3 /* Connection by magic portals (traps) */ 95 96 /* A particular dungeon contains num_dunlevs d_levels with dlevel 1.. 97 * num_dunlevs. Ledger_start and depth_start are bases that are added 98 * to the dlevel of a particular d_level to get the effective ledger_no 99 * and depth for that d_level. 100 * 101 * Ledger_no is a bookkeeping number that gives a unique identifier for a 102 * particular d_level (for level.?? files, e.g.). 103 * 104 * Depth corresponds to the number of floors below the surface. 105 */ 106 107 /* These both can't be zero, or dungeon_topology isn't init'd / restored */ 108 #define Lassigned(y) ((y)->dlevel || (y)->dnum) 109 #define Lcheck(x,z) (Lassigned(z) && on_level(x, z)) 110 111 #define Is_astralevel(x) (Lcheck(x, &astral_level)) 112 #define Is_earthlevel(x) (Lcheck(x, &earth_level)) 113 #define Is_waterlevel(x) (Lcheck(x, &water_level)) 114 #define Is_firelevel(x) (Lcheck(x, &fire_level)) 115 #define Is_airlevel(x) (Lcheck(x, &air_level)) 116 #define Is_medusa_level(x) (Lcheck(x, &medusa_level)) 117 #define Is_oracle_level(x) (Lcheck(x, &oracle_level)) 118 #define Is_valley(x) (Lcheck(x, &valley_level)) 119 #define Is_juiblex_level(x) (Lcheck(x, &juiblex_level)) 120 #define Is_asmo_level(x) (Lcheck(x, &asmodeus_level)) 121 #define Is_baal_level(x) (Lcheck(x, &baalzebub_level)) 122 #define Is_wiz1_level(x) (Lcheck(x, &wiz1_level)) 123 #define Is_wiz2_level(x) (Lcheck(x, &wiz2_level)) 124 #define Is_wiz3_level(x) (Lcheck(x, &wiz3_level)) 125 #define Is_sanctum(x) (Lcheck(x, &sanctum_level)) 126 #define Is_portal_level(x) (Lcheck(x, &portal_level)) 127 #define Is_stronghold(x) (Lcheck(x, &stronghold_level)) 128 #define Is_bigroom(x) (Lcheck(x, &bigroom_level)) 129 #define Is_qstart(x) (Lcheck(x, &qstart_level)) 130 #define Is_qlocate(x) (Lcheck(x, &qlocate_level)) 131 #define Is_nemesis(x) (Lcheck(x, &nemesis_level)) 132 #define Is_knox(x) (Lcheck(x, &knox_level)) 133 #define Is_mineend_level(x) (Lcheck(x, &mineend_level)) 134 #define Is_sokoend_level(x) (Lcheck(x, &sokoend_level)) 135 136 #define In_sokoban(x) ((x)->dnum == sokoban_dnum) 137 #define In_tower(x) ((x)->dnum == tower_dnum) 138 #define Inhell In_hell(&u.uz) /* now gehennom */ 139 #define In_endgame(x) ((x)->dnum == astral_level.dnum) 140 141 #define within_bounded_area(X, Y, LX, LY, HX, HY) \ 142 ((X) >= (LX) && (X) <= (HX) && (Y) >= (LY) && (Y) <= (HY)) 143 144 /* monster and object migration codes */ 145 146 #define MIGR_NOWHERE (-1) /* failure flag for down_gate() */ 147 #define MIGR_RANDOM 0 148 #define MIGR_APPROX_XY 1 /* approximate coordinates */ 149 #define MIGR_EXACT_XY 2 /* specific coordinates */ 150 #define MIGR_STAIRS_UP 3 151 #define MIGR_STAIRS_DOWN 4 152 #define MIGR_LADDER_UP 5 153 #define MIGR_LADDER_DOWN 6 154 #define MIGR_SSTAIRS 7 /* dungeon branch */ 155 #define MIGR_PORTAL 8 /* magic portal */ 156 #define MIGR_WITH_HERO 9 /* mon: followers; obj: trap door */ 157 #define MIGR_THIEFSTONE 10 /* thiefstone inter-level teleport */ 158 #define MIGR_NOBREAK 1024 /* bitmask: don't break on delivery */ 159 #define MIGR_NOSCATTER 2048 /* don't scatter on delivery */ 160 #define MIGR_TO_SPECIES 4096 /* migrating to species as they are made */ 161 #define MIGR_LEFTOVERS 8192 /* grab remaining MIGR_TO_SPECIES objects */ 162 /* level information (saved via ledger number) */ 163 164 struct linfo { 165 unsigned char flags; 166 #define VISITED 0x01 /* hero has visited this level */ 167 /* 0x02 was FORGOTTEN, when amnesia made you forget maps */ 168 #define LFILE_EXISTS 0x04 /* a level file exists for this level */ 169 /* Note: VISITED and LFILE_EXISTS are currently almost always 170 * set at the same time. However they _mean_ different things. 171 */ 172 }; 173 174 /* types and structures for dungeon map recording 175 * 176 * It is designed to eliminate the need for an external notes file for some 177 * mundane dungeon elements. "Where was the last altar I passed?" etc... 178 * Presumably the character can remember this sort of thing even if, months 179 * later in real time picking up an old save game, I can't. 180 * 181 * To be consistent, one can assume that this map is in the player's mind and 182 * has no physical correspondence (eliminating illiteracy/blind/hands/hands 183 * free concerns). Therefore, this map is not exhaustive nor detailed ("some 184 * fountains"). This makes it also subject to player conditions (amnesia). 185 */ 186 187 /* what the player knows about a single dungeon level */ 188 /* initialized in mklev() */ 189 typedef struct mapseen { 190 struct mapseen *next; /* next map in the chain */ 191 branch *br; /* knows about branch via taking it in goto_level */ 192 d_level lev; /* corresponding dungeon level */ 193 struct mapseen_feat { 194 /* feature knowledge that must be calculated from levl array */ 195 Bitfield(nfount, 2); 196 Bitfield(nsink, 2); 197 Bitfield(naltar, 2); 198 Bitfield(nthrone, 2); 199 200 Bitfield(ngrave, 2); 201 Bitfield(ntree, 2); 202 Bitfield(water, 2); 203 Bitfield(lava, 2); 204 205 Bitfield(ice, 2); 206 /* calculated from rooms array */ 207 Bitfield(nshop, 2); 208 Bitfield(ntemple, 2); 209 /* altar alignment; MSA_NONE if there is more than one and 210 they aren't all the same */ 211 Bitfield(msalign, 2); 212 213 Bitfield(shoptype, 5); 214 } feat; 215 struct mapseen_flags { 216 Bitfield(unreachable, 1); /* can't get back to this level */ 217 Bitfield(knownbones, 1); /* player aware of bones */ 218 Bitfield(oracle, 1); 219 Bitfield(sokosolved, 1); 220 Bitfield(bigroom, 1); 221 Bitfield(castle, 1); 222 Bitfield(castletune, 1); /* add tune hint to castle annotation */ 223 224 Bitfield(valley, 1); 225 Bitfield(msanctum, 1); 226 Bitfield(ludios, 1); 227 /* quest annotations: quest_summons is for main dungeon level 228 with entry portal and is reset once quest has been finished; 229 questing is for quest home (level 1) */ 230 Bitfield(quest_summons, 1); /* heard summons from leader */ 231 Bitfield(questing, 1); /* quest leader has unlocked quest stairs */ 232 /* "gateway to sanctum" */ 233 Bitfield(vibrating_square, 1); /* found vibrating square 'trap'; 234 * flag cleared once the msanctum 235 * annotation has been added (on 236 * the next dungeon level; temple 237 * entered or high altar mapped) */ 238 Bitfield(spare1, 1); /* not used */ 239 } flags; 240 /* custom naming */ 241 char *custom; 242 unsigned custom_lth; 243 struct mapseen_rooms { 244 Bitfield(seen, 1); 245 Bitfield(untended, 1); /* flag for shop without shk */ 246 } msrooms[(MAXNROFROOMS + 1) * 2]; /* same size as g.rooms[] */ 247 /* dead heroes; might not have graves or ghosts */ 248 struct cemetery *final_resting_place; /* same as level.bonesinfo */ 249 } mapseen; 250 251 #endif /* !MAKEDEFS_C && !MDLIB_C */ 252 253 #endif /* DUNGEON_H */ 254