File: dungeon.h

package info (click to toggle)
gnomehack 1.0.5-1.1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 10,256 kB
  • ctags: 12,966
  • sloc: ansic: 119,783; yacc: 2,002; sh: 610; lex: 417; makefile: 397
file content (170 lines) | stat: -rw-r--r-- 6,378 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
/*	SCCS Id: @(#)dungeon.h	3.2	95/12/08	*/
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed.  See license for details. */

#ifndef DUNGEON_H
#define DUNGEON_H

typedef struct d_flags {	/* dungeon/level type flags */
	Bitfield(town, 1);	/* is this a town? (levels only) */
	Bitfield(hellish, 1);	/* is this part of hell? */
	Bitfield(maze_like, 1);	/* is this a maze? */
	Bitfield(rogue_like, 1); /* is this an old-fashioned presentation? */
	Bitfield(align, 3);	/* dungeon alignment. */
	Bitfield(unused, 1);	/* etc... */
} d_flags;

#ifndef ALIGN_H
#include "align.h"
#endif

typedef struct d_level {	/* basic dungeon level element */
	xchar	dnum;		/* dungeon number */
	xchar	dlevel;		/* level number */
} d_level;

typedef struct s_level {	/* special dungeon level element */
	struct	s_level	*next;
	d_level	dlevel;		/* dungeon & level numbers */
	char	proto[15];	/* name of prototype file (eg. "tower") */
	char    boneid;		/* character to id level in bones files */
	uchar	rndlevs;	/* no. of randomly available similar levels */
	d_flags	flags;		/* type flags */
} s_level;

typedef struct stairway {	/* basic stairway identifier */
	xchar	sx, sy;		/* x / y location of the stair */
	d_level	tolev;		/* where does it go */
	char	up;		/* what type of stairway (up/down) */
} stairway;

/* level region types */
#define LR_DOWNSTAIR 0
#define LR_UPSTAIR 1
#define LR_PORTAL 2
#define LR_BRANCH 3
#define LR_TELE 4
#define LR_UPTELE 5
#define LR_DOWNTELE 6

typedef struct dest_area {	/* non-stairway level change indentifier */
	xchar	lx, ly;		/* "lower" left corner (near [0,0]) */
	xchar	hx, hy;		/* "upper" right corner (near [COLNO,ROWNO]) */
	xchar	nlx, nly;	/* outline of invalid area */
	xchar	nhx, nhy;	/* opposite corner of invalid area */
} dest_area;

typedef struct dungeon {	/* basic dungeon identifier */
	char	dname[24];	/* name of the dungeon (eg. "Hell") */
	char	proto[15];	/* name of prototype file (eg. "tower") */
	char	boneid;		/* character to id dungeon in bones files */
	d_flags	flags;		/* dungeon flags */
	xchar	entry_lev;	/* entry level */
	xchar	num_dunlevs;	/* number of levels in this dungeon */
	xchar	dunlev_ureached; /* how deep you have been in this dungeon */
	int	ledger_start,	/* the starting depth in "real" terms */
		depth_start;	/* the starting depth in "logical" terms */
} dungeon;

/*
 * A branch structure defines the connection between two dungeons.  They
 * will be ordered by the dungeon number/level number of 'end1'.  Ties
 * are resolved by 'end2'.  'Type' uses 'end1' arbitrarily as the primary
 * point.
 */
typedef struct branch {
    struct branch *next;	/* next in the branch chain */
    int		  id;		/* branch identifier */
    int		  type;		/* type of branch */
    d_level	  end1;		/* "primary" end point */
    d_level	  end2;		/* other end point */
    boolean	  end1_up;	/* does end1 go up? */
} branch;

/* branch types */
#define BR_STAIR   0	/* "Regular" connection, 2 staircases. */
#define BR_NO_END1 1	/* "Regular" connection.  However, no stair from  */
			/*	end1 to end2.  There is a stair from end2 */
			/*	to end1.				  */
#define BR_NO_END2 2	/* "Regular" connection.  However, no stair from  */
			/*	end2 to end1.  There is a stair from end1 */
			/*	to end2.				  */
#define BR_PORTAL  3	/* Connection by magic portals (traps) */


/* A particular dungeon contains num_dunlevs d_levels with dlevel 1..
 * num_dunlevs.  Ledger_start and depth_start are bases that are added
 * to the dlevel of a particular d_level to get the effective ledger_no
 * and depth for that d_level.
 *
 * Ledger_no is a bookkeeping number that gives a unique identifier for a
 * particular d_level (for level.?? files, e.g.).
 *
 * Depth corresponds to the number of floors below the surface.
 */
#define Is_astralevel(x)	(on_level(x, &astral_level))
#define Is_earthlevel(x)	(on_level(x, &earth_level))
#define Is_waterlevel(x)	(on_level(x, &water_level))
#define Is_firelevel(x)		(on_level(x, &fire_level))
#define Is_airlevel(x)		(on_level(x, &air_level))
#define Is_medusa_level(x)	(on_level(x, &medusa_level))
#define Is_oracle_level(x)	(on_level(x, &oracle_level))
#define Is_valley(x)		(on_level(x, &valley_level))
#define Is_asmo_level(x)	(on_level(x, &asmodeus_level))
#define Is_baal_level(x)	(on_level(x, &baalzebub_level))
#define Is_wiz1_level(x)	(on_level(x, &wiz1_level))
#define Is_wiz2_level(x)	(on_level(x, &wiz2_level))
#define Is_wiz3_level(x)	(on_level(x, &wiz3_level))
#define Is_sanctum(x)		(on_level(x, &sanctum_level))
#define Is_portal_level(x)	(on_level(x, &portal_level))
#define Is_rogue_level(x)	(on_level(x, &rogue_level))
#define Is_stronghold(x)	(on_level(x, &stronghold_level))
#define Is_bigroom(x)		(on_level(x, &bigroom_level))
#define Is_qstart(x)		(on_level(x, &qstart_level))
#define Is_qlocate(x)		(on_level(x, &qlocate_level))
#define Is_nemesis(x)		(on_level(x, &nemesis_level))
#define Is_knox(x)		(on_level(x, &knox_level))

#define Inhell			In_hell(&u.uz)	/* now gehennom */
#define In_endgame(x)		((x)->dnum == astral_level.dnum)
#define within_bounded_area(X,Y,LX,LY,HX,HY) \
		((X) >= (LX) && (X) <= (HX) && (Y) >= (LY) && (Y) <= (HY))

/* monster and object migration codes */

#define MIGR_NOWHERE	      (-1)	/* failure flag for down_gate() */
#define MIGR_RANDOM		0
#define MIGR_APPROX_XY		1	/* approximate coordinates */
#define MIGR_EXACT_XY		2	/* specific coordinates */
#define MIGR_STAIRS_UP		3
#define MIGR_STAIRS_DOWN	4
#define MIGR_LADDER_UP		5
#define MIGR_LADDER_DOWN	6
#define MIGR_SSTAIRS		7	/* dungeon branch */
#define MIGR_PORTAL		8	/* magic portal */
#define MIGR_NEAR_PLAYER	9	/* mon: followers; obj: trap door */

/* level information (saved via ledger number) */

struct linfo {
	unsigned char	flags;
#define VISITED		0x01	/* hero has visited this level */
#define FORGOTTEN	0x02	/* hero will forget this level when reached */
#define LFILE_EXISTS	0x04	/* a level file exists for this level */
/*
 * Note:  VISITED and LFILE_EXISTS are currently almost always set at the
 * same time.  However they _mean_ different things.
 */

#ifdef MFLOPPY
# define FROMPERM        1      /* for ramdisk use */
# define TOPERM          2      /* for ramdisk use */
# define ACTIVE          1
# define SWAPPED         2
	int	where;
	long	time;
	long	size;
#endif /* MFLOPPY */
};

#endif /* DUNGEON_H */