comparison xrogue/rogue.h @ 133:e6179860cb76

Import XRogue 8.0 from the Roguelike Restoration Project (r1490)
author John "Elwin" Edwards
date Tue, 21 Apr 2015 08:55:20 -0400
parents
children cfa9d1609b78
comparison
equal deleted inserted replaced
124:d10fc4a065ac 133:e6179860cb76
1 /*
2 rogue.h - Rogue definitions and variable declarations
3
4 XRogue: Expeditions into the Dungeons of Doom
5 Copyright (C) 1991 Robert Pietkivitch
6 All rights reserved.
7
8 Based on "Advanced Rogue"
9 Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
10 All rights reserved.
11
12 Based on "Rogue: Exploring the Dungeons of Doom"
13 Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
14 All rights reserved.
15
16 See the file LICENSE.TXT for full copyright and licensing information.
17 */
18
19 /*
20 * some compiler don't handle void pointers well so
21 */
22 #include <assert.h>
23 #define reg register
24 #define VOID long
25 #undef lines
26 #define ENCREAD encread
27 #define ENCWRITE encwrite
28 #undef SCROLL /* UNIX/370 defines SCROLL for some bizarre reason */
29 #define exfork fork /* Standard fork with no paging available */
30
31 /*
32 * Maximum number of different things
33 */
34
35 #define MINCOLS 70
36 #define MINLINES 22
37 #define MAXROOMS 9
38 #define MAXTHINGS 9
39 #define MAXOBJ 9
40 #define MAXSTATS 74 /* max total of all stats at startup */
41 #define MAXPACK 27 /* max number of items in pack */
42 #define MAXDOUBLE 14 /* max number of times exppts is doubled */
43 #define MAXCONTENTS 20 /* max number of things beaker/book can hold */
44 #define MAXENCHANT 30 /* max number of enchantments on an item */
45 #define MAXTREAS 25 /* number monsters/treasure in treasure room */
46 #define MAXTRAPS 20 /* max number of traps that may be on level */
47 #define MAXTRPTRY 15 /* attempts/level allowed for setting traps */
48 #define MAXDOORS 4 /* maximum doors to a room */
49 #define MAXCHANTS 16 /* maximum number of chants for a druid */
50 #define MAXPRAYERS 16 /* maximum number of prayers for cleric */
51 #define MAXSPELLS 16 /* maximum number of spells for magician */
52 #define MAXQUILL 14 /* scrolls the Quill of Nagrom can write */
53 #define QUILLCHARGES 300 /* max num of charges in the Quill of Nagrom */
54 #define NUM_CNAMES 26 /* number of names per character level */
55 #define NUMMONST 211 /* current number of monsters */
56 #define NUMUNIQUE 60 /* number of UNIQUEs (minus jacaranda) */
57 #define NUMDINOS 30 /* number of dinosaurs (for OUTSIDE level) */
58 #define NLEVMONS 3 /* number of new monsters per level */
59 #define NUMSCORE 20 /* number of entries in score file */
60 #define HARDER 40 /* at this level start making things harder */
61 #define LINELEN 256 /* characters in a buffer */
62 #define JUG_EMPTY -1 /* signifys that the alchemy jug is empty */
63 #define MAXPURCH (pstats.s_charisma/3) /* num of purchases at t.post */
64 #define MAXATT 50 /* charactor's attribute maximum number */
65
66 /* Movement penalties */
67 #define BACKPENALTY 3
68 #define SHOTPENALTY 2 /* In line of sight of missile */
69 #define DOORPENALTY 1 /* Moving out of current room */
70
71 /*
72 * these defines are used in calls to get_item() to signify what
73 * it is we want
74 */
75
76 #define ALL -1
77 #define WEARABLE -2
78 #define CALLABLE -3
79 #define WIELDABLE -4
80 #define USEABLE -5
81 #define IDENTABLE -6
82 #define REMOVABLE -7
83 #define PROTECTABLE -8
84 #define ZAPPABLE -9
85 #define READABLE -10
86 #define QUAFFABLE -11
87
88 /*
89 * stuff to do with encumberance
90 */
91
92 #define NORMENCB 1400 /* normal encumberance */
93 #define F_SATIATED 0 /* player's stomach is very full */
94 #define F_OKAY 1 /* have plenty of food in stomach */
95 #define F_HUNGRY 2 /* player is hungry */
96 #define F_WEAK 3 /* weak from lack of food */
97 #define F_FAINT 4 /* fainting from lack of food */
98
99 /*
100 * actions a player/monster will take
101 */
102
103 #define A_MOVE 0200 /* normal movement */
104 #define A_FREEZE 0201 /* frozen in place */
105 #define A_ATTACK 0202 /* trying to hit */
106 #define A_SELL 0203 /* trying to sell goods */
107 #define A_NIL 0204 /* not doing anything */
108 #define A_BREATHE 0205 /* breathing */
109 #define A_MISSILE 0206 /* Firing magic missiles */
110 #define A_SONIC 0207 /* Sounding a sonic blast */
111 #define A_SUMMON 0210 /* Summoning help */
112 #define A_USERELIC 0211 /* Monster uses a relic */
113 #define A_SLOW 0212 /* monster slows the player */
114 #define A_ZAP 0213 /* monster shoots a wand */
115 #define A_PICKUP 0214 /* player is picking something up */
116 #define A_USEWAND 0215 /* monster is shooting a wand */
117 #define A_THROW 't'
118 #define C_CAST 'C'
119 #define C_COUNT '*'
120 #define C_DIP 'D'
121 #define C_DROP 'd'
122 #define C_EAT 'e'
123 #define C_PRAY 'p'
124 #define C_CHANT 'c'
125 #define C_QUAFF 'q'
126 #define C_READ 'r'
127 #define C_SEARCH 's'
128 #define C_SETTRAP '^'
129 #define C_TAKEOFF 'T'
130 #define C_USE CTRL('U')
131 #define C_WEAR 'W'
132 #define C_WIELD 'w'
133 #define C_ZAP 'z'
134
135 /* Possible ways for the hero to move */
136
137 #define H_TELEPORT 0
138
139 /*
140 * return values for get functions
141 */
142
143 #define NORM 0 /* normal exit */
144 #define QUIT 1 /* quit option setting */
145 #define MINUS 2 /* back up one option */
146
147 /*
148 * The character types
149 */
150
151 #define C_FIGHTER 0
152 #define C_RANGER 1
153 #define C_PALADIN 2
154 #define C_MAGICIAN 3
155 #define C_CLERIC 4
156 #define C_THIEF 5
157 #define C_ASSASSIN 6
158 #define C_DRUID 7
159 #define C_MONK 8
160 #define C_MONSTER 9
161 #define NUM_CHARTYPES 10
162
163 /*
164 * define the ability types
165 */
166
167 #define A_INTELLIGENCE 0
168 #define A_STRENGTH 1
169 #define A_WISDOM 2
170 #define A_DEXTERITY 3
171 #define A_CONSTITUTION 4
172 #define A_CHARISMA 5
173 #define NUMABILITIES 6
174
175 /*
176 * values for games end
177 */
178
179 #define UPDATE -2
180 #define SCOREIT -1
181 #define KILLED 0
182 #define CHICKEN 1
183 #define WINNER 2
184
185 /*
186 * definitions for function step_ok:
187 * MONSTOK indicates it is OK to step on a monster -- it
188 * is only OK when stepping diagonally AROUND a monster;
189 * it is also OK if the stepper is a friendly monster and
190 * is in a fighting mood.
191 */
192
193 #define MONSTOK 1
194 #define NOMONST 2
195 #define FIGHTOK 3
196
197 /*
198 * used for ring stuff
199 */
200
201 #define LEFT_1 0
202 #define LEFT_2 1
203 #define LEFT_3 2
204 #define LEFT_4 3
205 #define RIGHT_1 4
206 #define RIGHT_2 5
207 #define RIGHT_3 6
208 #define RIGHT_4 7
209 #define NUM_FINGERS 8
210
211 /*
212 * used for micellaneous magic (MM) stuff
213 */
214
215 #define WEAR_BOOTS 0
216 #define WEAR_BRACERS 1
217 #define WEAR_CLOAK 2
218 #define WEAR_GAUNTLET 3
219 #define WEAR_JEWEL 4
220 #define WEAR_NECKLACE 5
221 #define NUM_MM 6
222
223 /*
224 How to exit flags:
225 */
226
227 #define EXIT_CLS 1 /* Clear screen first */
228 #define EXIT_ENDWIN 2 /* Shutdown Curses */
229
230
231 /*
232 * All the fun defines
233 */
234
235 #define next(ptr) (*ptr).l_next
236 #define prev(ptr) (*ptr).l_prev
237 #define ldata(ptr) (*ptr).l_data
238 #define inroom(rp, cp) (\
239 (cp)->x <= (rp)->r_pos.x + ((rp)->r_max.x - 1) && (rp)->r_pos.x <= (cp)->x \
240 && (cp)->y <= (rp)->r_pos.y + ((rp)->r_max.y - 1) && (rp)->r_pos.y <= (cp)->y)
241 #define winat(y, x) (mvwinch(mw, y, x)==' '?mvwinch(stdscr, y, x):winch(mw))
242 #define debug if (wizard) msg
243 #define RN (((seed = seed*11109+13849) & 0x7fff) >> 1)
244 #define unc(cp) (cp).y, (cp).x
245 #define cmov(xy) move((xy).y, (xy).x)
246 #define DISTANCE(y1, x1, y2, x2) ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))
247 #define OBJPTR(what) (struct object *)((*what).l_data)
248 #define THINGPTR(what) (struct thing *)((*what).l_data)
249 #define DOORPTR(what) (coord *)((*what).l_data)
250 #define when break;case
251 #define otherwise break;default
252 #define until(expr) while(!(expr))
253 #define ce(a, b) ((a).x == (b).x && (a).y == (b).y)
254 #define draw(window) wrefresh(window)
255 #define newfont(window) if (funfont) wattron(window, A_ALTCHARSET);
256 #define nofont(window) if (funfont) wattroff(window, A_ALTCHARSET);
257 #define hero player.t_pos
258 #define pstats player.t_stats
259 #define max_stats player.maxstats
260 #define pack player.t_pack
261 #define attach(a, b) _attach(&a, b)
262 #define detach(a, b) _detach(&a, b)
263 #define o_free_list(a) _o_free_list(&a)
264 #define r_free_list(a) _r_free_list(&a)
265 #define t_free_list(a) _t_free_list(&a)
266 #undef min
267 #undef max
268 #define max(a, b) ((a) > (b) ? (a) : (b))
269 #define min(a, b) ((a) < (b) ? (a) : (b))
270 #define on(thing, flag) \
271 (((thing).t_flags[(flag >> FLAGSHIFT) & FLAGINDEX] & flag) != 0)
272 #define off(thing, flag) \
273 (((thing).t_flags[(flag >> FLAGSHIFT) & FLAGINDEX] & flag) == 0)
274 #define turn_on(thing, flag) \
275 ((thing).t_flags[(flag >> FLAGSHIFT) & FLAGINDEX] |= (flag & ~FLAGMASK))
276 #define turn_off(thing, flag) \
277 ((thing).t_flags[(flag >> FLAGSHIFT) & FLAGINDEX] &= ~flag)
278
279 /* define the control character */
280
281 #undef CTRL
282 #define CTRL(ch) (ch & 037)
283
284 #define ALLOC(x) malloc((unsigned int) x)
285 #define FREE(x) free((char *) x)
286 #define EQSTR(a, b, c) (strncmp(a, b, c) == 0)
287 #define EQUAL(a, b) (strcmp(a, b) == 0)
288 #define GOLDCALC (rnd(50 + 10 * level) + 2)
289 #define ISRING(h, r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r)
290 #define ISWEARING(r) (ISRING(LEFT_1, r) || ISRING(LEFT_2, r) ||\
291 ISRING(LEFT_3, r) || ISRING(LEFT_4, r) ||\
292 ISRING(RIGHT_1, r) || ISRING(RIGHT_2, r) ||\
293 ISRING(RIGHT_3, r) || ISRING(RIGHT_4, r))
294 #define newgrp() ++group
295 #define o_charges o_ac
296 #define o_kind o_ac
297 #define ISMULT(type) (type == FOOD)
298 #define isrock(ch) ((ch == WALL) || (ch == HORZWALL) || (ch == VERTWALL) || (ch == SECRETDOOR))
299 #define is_stealth(tp) \
300 (rnd(25) < (tp)->t_stats.s_dext || (tp == &player && ISWEARING(R_STEALTH)))
301
302 #define has_light(rp) (((rp)->r_flags & HASFIRE) || ISWEARING(R_LIGHT))
303
304 #define mi_wght mi_worth
305 #define mi_food mi_curse
306
307 /*
308 * Ways to die
309 */
310
311 #define D_PETRIFY -1
312 #define D_ARROW -2
313 #define D_DART -3
314 #define D_POISON -4
315 #define D_BOLT -5
316 #define D_SUFFOCATION -6
317 #define D_POTION -7
318 #define D_INFESTATION -8
319 #define D_DROWN -9
320 #define D_ROT -10
321 #define D_CONSTITUTION -11
322 #define D_STRENGTH -12
323 #define D_SIGNAL -13
324 #define D_CHOKE -14
325 #define D_STRANGLE -15
326 #define D_FALL -16
327 #define D_RELIC -17
328 #define D_STARVATION -18
329 #define D_FOOD_CHOKE -19
330 #define D_SCROLL -20
331 #define D_FRIGHT -21
332 #define D_CRYSTAL -22
333 #define D_CARD -23
334 #define DEATHNUM 23 /* number of ways to die */
335
336 /*
337 * Things that appear on the screens
338 */
339
340 #define WALL ' '
341 #define PASSAGE '#'
342 #define DOOR '+'
343 #define FLOOR '.'
344 #define HORZWALL '-'
345 #define VERTWALL '|'
346 #define VPLAYER '@'
347 #define IPLAYER '_'
348 #define POST '^'
349 #define TRAPDOOR '>'
350 #define ARROWTRAP '{'
351 #define SLEEPTRAP '$'
352 #define BEARTRAP '}'
353 #define TELTRAP '~'
354 #define DARTTRAP '`'
355 #define WORMHOLE '<'
356 #define POOL '"'
357 #define MAZETRAP '\''
358 #define SECRETDOOR '&'
359 #define STAIRS '%'
360 #define GOLD '*'
361 #define POTION '!'
362 #define SCROLL '?'