dungeon.h

Go to the documentation of this file.
00001 /*      SCCS Id: @(#)dungeon.h  3.4     1999/07/02      */
00002 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
00003 /* NetHack may be freely redistributed.  See license for details. */
00004 
00005 #ifndef DUNGEON_H
00006 #define DUNGEON_H
00007 
00008 typedef struct d_flags {        /* dungeon/level type flags */
00009         Bitfield(town, 1);      /* is this a town? (levels only) */
00010         Bitfield(hellish, 1);   /* is this part of hell? */
00011         Bitfield(maze_like, 1); /* is this a maze? */
00012         Bitfield(rogue_like, 1); /* is this an old-fashioned presentation? */
00013         Bitfield(align, 3);     /* dungeon alignment. */
00014         Bitfield(unused, 1);    /* etc... */
00015 } d_flags;
00016 
00017 typedef struct d_level {        /* basic dungeon level element */
00018         xchar   dnum;           /* dungeon number */
00019         xchar   dlevel;         /* level number */
00020 } d_level;
00021 
00022 typedef struct s_level {        /* special dungeon level element */
00023         struct  s_level *next;
00024         d_level dlevel;         /* dungeon & level numbers */
00025         char    proto[15];      /* name of prototype file (eg. "tower") */
00026         char    boneid;         /* character to id level in bones files */
00027         uchar   rndlevs;        /* no. of randomly available similar levels */
00028         d_flags flags;          /* type flags */
00029 } s_level;
00030 
00031 typedef struct stairway {       /* basic stairway identifier */
00032         xchar   sx, sy;         /* x / y location of the stair */
00033         d_level tolev;          /* where does it go */
00034         char    up;             /* what type of stairway (up/down) */
00035 } stairway;
00036 
00037 /* level region types */
00038 #define LR_DOWNSTAIR 0
00039 #define LR_UPSTAIR 1
00040 #define LR_PORTAL 2
00041 #define LR_BRANCH 3
00042 #define LR_TELE 4
00043 #define LR_UPTELE 5
00044 #define LR_DOWNTELE 6
00045 
00046 typedef struct dest_area {      /* non-stairway level change indentifier */
00047         xchar   lx, ly;         /* "lower" left corner (near [0,0]) */
00048         xchar   hx, hy;         /* "upper" right corner (near [COLNO,ROWNO]) */
00049         xchar   nlx, nly;       /* outline of invalid area */
00050         xchar   nhx, nhy;       /* opposite corner of invalid area */
00051 } dest_area;
00052 
00053 typedef struct dungeon {        /* basic dungeon identifier */
00054         char    dname[24];      /* name of the dungeon (eg. "Hell") */
00055         char    proto[15];      /* name of prototype file (eg. "tower") */
00056         char    boneid;         /* character to id dungeon in bones files */
00057         d_flags flags;          /* dungeon flags */
00058         xchar   entry_lev;      /* entry level */
00059         xchar   num_dunlevs;    /* number of levels in this dungeon */
00060         xchar   dunlev_ureached; /* how deep you have been in this dungeon */
00061         int     ledger_start,   /* the starting depth in "real" terms */
00062                 depth_start;    /* the starting depth in "logical" terms */
00063 } dungeon;
00064 
00065 /*
00066  * A branch structure defines the connection between two dungeons.  They
00067  * will be ordered by the dungeon number/level number of 'end1'.  Ties
00068  * are resolved by 'end2'.  'Type' uses 'end1' arbitrarily as the primary
00069  * point.
00070  */
00071 typedef struct branch {
00072     struct branch *next;        /* next in the branch chain */
00073     int           id;           /* branch identifier */
00074     int           type;         /* type of branch */
00075     d_level       end1;         /* "primary" end point */
00076     d_level       end2;         /* other end point */
00077     boolean       end1_up;      /* does end1 go up? */
00078 } branch;
00079 
00080 /* branch types */
00081 #define BR_STAIR   0    /* "Regular" connection, 2 staircases. */
00082 #define BR_NO_END1 1    /* "Regular" connection.  However, no stair from  */
00083                         /*      end1 to end2.  There is a stair from end2 */
00084                         /*      to end1.                                  */
00085 #define BR_NO_END2 2    /* "Regular" connection.  However, no stair from  */
00086                         /*      end2 to end1.  There is a stair from end1 */
00087                         /*      to end2.                                  */
00088 #define BR_PORTAL  3    /* Connection by magic portals (traps) */
00089 
00090 
00091 /* A particular dungeon contains num_dunlevs d_levels with dlevel 1..
00092  * num_dunlevs.  Ledger_start and depth_start are bases that are added
00093  * to the dlevel of a particular d_level to get the effective ledger_no
00094  * and depth for that d_level.
00095  *
00096  * Ledger_no is a bookkeeping number that gives a unique identifier for a
00097  * particular d_level (for level.?? files, e.g.).
00098  *
00099  * Depth corresponds to the number of floors below the surface.
00100  */
00101 #define Is_astralevel(x)        (on_level(x, &astral_level))
00102 #define Is_earthlevel(x)        (on_level(x, &earth_level))
00103 #define Is_waterlevel(x)        (on_level(x, &water_level))
00104 #define Is_firelevel(x)         (on_level(x, &fire_level))
00105 #define Is_airlevel(x)          (on_level(x, &air_level))
00106 #define Is_medusa_level(x)      (on_level(x, &medusa_level))
00107 #define Is_oracle_level(x)      (on_level(x, &oracle_level))
00108 #define Is_valley(x)            (on_level(x, &valley_level))
00109 #define Is_juiblex_level(x)     (on_level(x, &juiblex_level))
00110 #define Is_asmo_level(x)        (on_level(x, &asmodeus_level))
00111 #define Is_baal_level(x)        (on_level(x, &baalzebub_level))
00112 #define Is_wiz1_level(x)        (on_level(x, &wiz1_level))
00113 #define Is_wiz2_level(x)        (on_level(x, &wiz2_level))
00114 #define Is_wiz3_level(x)        (on_level(x, &wiz3_level))
00115 #define Is_sanctum(x)           (on_level(x, &sanctum_level))
00116 #define Is_portal_level(x)      (on_level(x, &portal_level))
00117 #define Is_rogue_level(x)       (on_level(x, &rogue_level))
00118 #define Is_stronghold(x)        (on_level(x, &stronghold_level))
00119 #define Is_bigroom(x)           (on_level(x, &bigroom_level))
00120 #define Is_qstart(x)            (on_level(x, &qstart_level))
00121 #define Is_qlocate(x)           (on_level(x, &qlocate_level))
00122 #define Is_nemesis(x)           (on_level(x, &nemesis_level))
00123 #define Is_knox(x)              (on_level(x, &knox_level))
00124 #ifdef RECORD_ACHIEVE
00125 #define Is_mineend_level(x)     (on_level(x, &mineend_level))
00126 #define Is_sokoend_level(x)     (on_level(x, &sokoend_level))
00127 #endif
00128 #ifdef BLACKMARKET
00129 #define Is_blackmarket(x)       (on_level(x, &blackmarket_level))
00130 #endif /* BLACKMARKET */
00131 #define Is_minetown_level(x)    (on_level(x, &minetown_level))
00132 #define Is_town_level(x)        (on_level(x, &town_level))
00133 
00134 #define In_sokoban(x)           ((x)->dnum == sokoban_dnum)
00135 #define Inhell                  In_hell(&u.uz)  /* now gehennom */
00136 #define In_endgame(x)           ((x)->dnum == astral_level.dnum)
00137 
00138 #define within_bounded_area(X,Y,LX,LY,HX,HY) \
00139                 ((X) >= (LX) && (X) <= (HX) && (Y) >= (LY) && (Y) <= (HY))
00140 
00141 /* monster and object migration codes */
00142 
00143 #define MIGR_NOWHERE          (-1)      /* failure flag for down_gate() */
00144 #define MIGR_RANDOM             0
00145 #define MIGR_APPROX_XY          1       /* approximate coordinates */
00146 #define MIGR_EXACT_XY           2       /* specific coordinates */
00147 #define MIGR_STAIRS_UP          3
00148 #define MIGR_STAIRS_DOWN        4
00149 #define MIGR_LADDER_UP          5
00150 #define MIGR_LADDER_DOWN        6
00151 #define MIGR_SSTAIRS            7       /* dungeon branch */
00152 #define MIGR_PORTAL             8       /* magic portal */
00153 #define MIGR_NEAR_PLAYER        9       /* mon: followers; obj: trap door */
00154 
00155 /* level information (saved via ledger number) */
00156 
00157 struct linfo {
00158         unsigned char   flags;
00159 #define VISITED         0x01    /* hero has visited this level */
00160 #define FORGOTTEN       0x02    /* hero will forget this level when reached */
00161 #define LFILE_EXISTS    0x04    /* a level file exists for this level */
00162 /*
00163  * Note:  VISITED and LFILE_EXISTS are currently almost always set at the
00164  * same time.  However they _mean_ different things.
00165  */
00166 
00167 #ifdef MFLOPPY
00168 # define FROMPERM        1      /* for ramdisk use */
00169 # define TOPERM          2      /* for ramdisk use */
00170 # define ACTIVE          1
00171 # define SWAPPED         2
00172         int     where;
00173         long    time;
00174         long    size;
00175 #endif /* MFLOPPY */
00176 };
00177 
00178 /* types and structures for dungeon map recording
00179  *
00180  * It is designed to eliminate the need for an external notes file for some of
00181  * the more mundane dungeon elements.  "Where was the last altar I passed?" etc...
00182  * Presumably the character can remember this sort of thing even if, months
00183  * later in real time picking up an old save game, I can't.
00184  *
00185  * To be consistent, one can assume that this map is in the player's mind and
00186  * has no physical correspondence (eliminating illiteracy/blind/hands/hands free
00187  * concerns.) Therefore, this map is not exaustive nor detailed ("some fountains").
00188  * This makes it also subject to player conditions (amnesia).
00189  */
00190 
00191 /* Because clearly Nethack needs more ways to specify alignment */
00192 #define Amask2msa(x) ((x) == 4 ? 3 : (x) & AM_MASK)
00193 #define Msa2amask(x) ((x) == 3 ? 4 : (x))
00194 #define MSA_NONE        0  /* unaligned or multiple alignments */
00195 #define MSA_LAWFUL  1
00196 #define MSA_NEUTRAL 2
00197 #define MSA_CHAOTIC 3
00198 
00199 typedef struct mapseen_feat {
00200         /* feature knowledge that must be calculated from levl array */
00201         Bitfield(nfount, 2);
00202         Bitfield(nsink, 2);
00203         Bitfield(naltar, 2);
00204         Bitfield(msalign, 2); /* corresponds to MSA_* above */
00205         Bitfield(nthrone, 2);
00206         Bitfield(ntree, 2);
00207         /* water, lava, ice are too verbose so commented out for now */
00208         /*
00209         Bitfield(water, 1);
00210         Bitfield(lava, 1);
00211         Bitfield(ice, 1);
00212         */
00213 
00214         /* calculated from rooms array */
00215         Bitfield(nshop, 2);
00216         Bitfield(ntemple, 2);
00217         Bitfield(shoptype, 5);
00218 
00219         Bitfield(forgot, 1); /* player has forgotten about this level? */
00220 } mapseen_feat;
00221 
00222 /* for mapseen->rooms */
00223 #define MSR_SEEN                1
00224 
00225 /* what the player knows about a single dungeon level */
00226 /* initialized in mklev() */
00227 typedef struct mapseen  {
00228         struct mapseen *next; /* next map in the chain */
00229         branch *br; /* knows about branch via taking it in goto_level */
00230         d_level lev; /* corresponding dungeon level */
00231 
00232         mapseen_feat feat;
00233 
00234         /* custom naming */
00235         char *custom;
00236         unsigned custom_lth;
00237 
00238         /* maybe this should just be in struct mkroom? */
00239         schar rooms[(MAXNROFROOMS+1)*2];
00240 } mapseen;
00241 
00242 #endif /* DUNGEON_H */