comparison rogue4/rogue.h @ 12:9535a08ddc39

Import Rogue 5.2 from the Roguelike Restoration Project (r1490)
author edwarj4
date Sat, 24 Oct 2009 16:52:52 +0000
parents
children a1dc75e38e73
comparison
equal deleted inserted replaced
11:949d558c2162 12:9535a08ddc39
1 /*
2 * Rogue definitions and variable declarations
3 *
4 * @(#)rogue.h 5.2 (Berkeley) 5/10/82
5 *
6 * Rogue: Exploring the Dungeons of Doom
7 * Copyright (C) 1980, 1981, 1982 Michael Toy, Ken Arnold and Glenn Wichman
8 * All rights reserved.
9 *
10 * See the file LICENSE.TXT for full copyright and licensing information.
11 */
12
13 typedef struct {
14 const char *st_name;
15 const int st_value;
16 } STONE;
17
18 extern const char *rainbow[];
19 extern const STONE stones[];
20 extern const char *sylls[];
21 extern const char *wood[];
22 extern const char *metal[];
23
24 #define NCOLORS 27
25 #define NSYLLS 159
26 #define NSTONES 26
27 #define NWOOD 33
28 #define NMETAL 22
29
30 /*
31 * Maximum number of different things
32 */
33 #define MAXDAEMONS 20
34 #define MAXROOMS 9
35 #define MAXTHINGS 9
36 #define MAXOBJ 9
37 #define MAXPACK 23
38 #define MAXTRAPS 10
39 #define AMULETLEVEL 26
40 #define NUMTHINGS 7 /* number of types of things */
41 #define MAXPASS 13 /* upper limit on number of passages */
42
43 /*
44 * return values for get functions
45 */
46 #define NORM 0 /* normal exit */
47 #define QUIT 1 /* quit option setting */
48 #define MINUS 2 /* back up one option */
49
50 /*
51 * All the fun defines
52 */
53 #define shint char /* short integer (for very small #s) */
54 #define when break;case
55 #define otherwise break;default
56 #define until(expr) while(!(expr))
57 #define next(ptr) (*ptr).l_next
58 #define prev(ptr) (*ptr).l_prev
59 #define winat(y,x) (moat(y,x) != NULL ? moat(y,x)->t_disguise : chat(y,x))
60 #define DISTANCE(y1, x1, y2, x2) ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))
61 #define ce(a,b) ((a).x == (b).x && (a).y == (b).y)
62 #define hero player.t_pos
63 #define pstats player.t_stats
64 #define pack player.t_pack
65 #define proom player.t_room
66 #define max_hp player.t_stats.s_maxhp
67 #define attach(a,b) _attach(&a,b)
68 #define detach(a,b) _detach(&a,b)
69 #define free_list(a) _free_list(&a)
70 #ifndef max
71 #define max(a,b) ((a) > (b) ? (a) : (b))
72 #endif
73 #define on(thing,flag) (((thing).t_flags & (flag)) != 0)
74 #undef CTRL
75 #define CTRL(ch) (ch & 037)
76 #define GOLDCALC (rnd(50 + 10 * level) + 2)
77 #define ISRING(h,r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r)
78 #define ISWEARING(r) (ISRING(LEFT, r) || ISRING(RIGHT, r))
79 #define ISMULT(type) (type==POTION || type==SCROLL || type==FOOD || type==GOLD)
80 #define INDEX(y,x) (((x) << 5) + (y))
81 #define chat(y,x) (_level[((x) << 5) + (y)])
82 #define flat(y,x) (_flags[((x) << 5) + (y)])
83 #define moat(y,x) (_monst[((x) << 5) + (y)])
84 #define unc(cp) (cp).y, (cp).x
85 #ifdef WIZARD
86 #define debug if (wizard) msg
87 #endif
88
89 /*
90 * Things that appear on the screens
91 */
92 #define PASSAGE '#'
93 #define DOOR '+'
94 #define FLOOR '.'
95 #define PLAYER '@'
96 #define TRAP '^'
97 #define STAIRS '%'
98 #define GOLD '*'
99 #define POTION '!'
100 #define SCROLL '?'
101 #define MAGIC '$'
102 #define FOOD ':'
103 #define WEAPON ')'
104 #define ARMOR ']'
105 #define AMULET ','
106 #define RING '='
107 #define STICK '/'
108 #define CALLABLE -1
109
110 /*
111 * Various constants
112 */
113 #define PASSWD "mTuZ7WUV9RWkQ"
114 #define BEARTIME spread(3)
115 #define SLEEPTIME spread(5)
116 #define HEALTIME spread(30)
117 #define HOLDTIME spread(2)
118 #define WANDERTIME spread(70)
119 #define BEFORE spread(1)
120 #define AFTER spread(2)
121 #define HUHDURATION spread(20)
122 #define SEEDURATION spread(850)
123 #define HUNGERTIME spread(1300)
124 #define MORETIME 150
125 #define STOMACHSIZE 2000
126 #define STARVETIME 850
127 #define ESCAPE 27
128 #define LEFT 0
129 #define RIGHT 1
130 #define BOLT_LENGTH 6
131 #define LAMPDIST 3
132
133 /*
134 * Save against things
135 */
136 #define VS_POISON 00
137 #define VS_PARALYZATION 00
138 #define VS_DEATH 00
139 #define VS_BREATH 02
140 #define VS_MAGIC 03
141
142 /*
143 * Various flag bits
144 */
145 /* flags for rooms */
146 #define ISDARK 0000001 /* room is dark */
147 #define ISGONE 0000002 /* room is gone (a corridor) */
148
149 /* flags for objects */
150 #define ISCURSED 000001 /* object is cursed */
151 #define ISKNOW 0000002 /* player knows details about the object */
152 #define ISMISL 0000004 /* object is a missile type */
153 #define ISMANY 0000010 /* object comes in groups */
154
155 /* flags for creatures */
156 #define CANHUH 0000001 /* creature can confuse */
157 #define CANSEE 0000002 /* creature can see invisible creatures */
158 #define ISBLIND 0000004 /* creature is blind */
159 #define ISCANC 0000010 /* creature has special qualities cancelled */
160 #define ISFOUND 0000020 /* creature has been seen (used for objects) */
161 #define ISGREED 0000040 /* creature runs to protect gold */
162 #define ISHASTE 0000100 /* creature has been hastened */
163 #define ISHELD 0000400 /* creature has been held */
164 #define ISHUH 0001000 /* creature is confused */
165 #define ISINVIS 0002000 /* creature is invisible */
166 #define ISMEAN 0004000 /* creature can wake when player enters room */
167 #define ISREGEN 0010000 /* creature can regenerate */
168 #define ISRUN 0020000 /* creature is running at the player */
169 #define SEEMONST 040000 /* hero can detect unseen monsters */
170 #define ISSLOW 0100000 /* creature has been slowed */
171
172 /*
173 * Flags for level map
174 */
175 #define F_PASS 0x80 /* is a passageway */
176 #define F_SEEN 0x40 /* have seen this corridor before */
177 #define F_DROPPED 0x20 /* object was dropped here */
178 #define F_LOCKED 0x20 /* door is locked */
179 #define F_REAL 0x10 /* what you see is what you get */
180 #define F_PNUM 0x0f /* passage number mask */
181 #define F_TMASK 0x07 /* trap number mask */
182
183 /*
184 * Trap types
185 */
186 #define T_DOOR 00
187 #define T_ARROW 01
188 #define T_SLEEP 02
189 #define T_BEAR 03
190 #define T_TELEP 04
191 #define T_DART 05
192 #define NTRAPS 6
193
194 /*
195 * Potion types
196 */
197 #define P_CONFUSE 0
198 #define P_PARALYZE 1
199 #define P_POISON 2
200 #define P_STRENGTH 3
201 #define P_SEEINVIS 4
202 #define P_HEALING 5
203 #define P_MFIND 6
204 #define P_TFIND 7
205 #define P_RAISE 8
206 #define P_XHEAL 9
207 #define P_HASTE 10
208 #define P_RESTORE 11
209 #define P_BLIND 12
210 #define P_NOP 13
211 #define MAXPOTIONS 14
212
213 /*
214 * Scroll types
215 */
216 #define S_CONFUSE 0
217 #define S_MAP 1
218 #define S_HOLD 2
219 #define S_SLEEP 3
220 #define S_ARMOR 4
221 #define S_IDENT 5
222 #define S_SCARE 6
223 #define S_GFIND 7
224 #define S_TELEP 8
225 #define S_ENCH 9
226 #define S_CREATE 10
227 #define S_REMOVE 11
228 #define S_AGGR 12
229 #define S_NOP 13
230 #define S_GENOCIDE 14
231 #define MAXSCROLLS 15
232
233 /*
234 * Weapon types
235 */
236 #define MACE 0
237 #define SWORD 1
238 #define BOW 2
239 #define ARROW 3
240 #define DAGGER 4
241 #define TWOSWORD 5
242 #define DART 6
243 #define CROSSBOW 7
244 #define BOLT 8
245 #define SPEAR 9
246 #define FLAME 10 /* fake entry for dragon breath (ick) */
247 #define MAXWEAPONS 10 /* this should equal FLAME */
248
249 /*
250 * Armor types
251 */
252 #define LEATHER 0
253 #define RING_MAIL 1
254 #define STUDDED_LEATHER 2
255 #define SCALE_MAIL 3
256 #define CHAIN_MAIL 4
257 #define SPLINT_MAIL 5
258 #define BANDED_MAIL 6
259 #define PLATE_MAIL 7
260 #define MAXARMORS 8
261
262 /*
263 * Ring types
264 */
265 #define R_PROTECT 0
266 #define R_ADDSTR 1
267 #define R_SUSTSTR 2
268 #define R_SEARCH 3
269 #define R_SEEINVIS 4
270 #define R_NOP 5
271 #define R_AGGR 6
272 #define R_ADDHIT 7
273 #define R_ADDDAM 8
274 #define R_REGEN 9
275 #define R_DIGEST 10
276 #define R_TELEPORT 11
277 #define R_STEALTH 12
278 #define R_SUSTARM 13
279 #define MAXRINGS 14
280
281 /*
282 * Rod/Wand/Staff types
283 */
284
285 #define WS_LIGHT 0
286 #define WS_HIT 1
287 #define WS_ELECT 2
288 #define WS_FIRE 3
289 #define WS_COLD 4
290 #define WS_POLYMORPH 5
291 #define WS_MISSILE 6
292 #define WS_HASTE_M 7
293 #define WS_SLOW_M 8
294 #define WS_DRAIN 9
295 #define WS_NOP 10
296 #define WS_TELAWAY 11
297 #define WS_TELTO 12
298 #define WS_CANCEL 13
299 #define MAXSTICKS 14
300
301 /*
302 * Now we define the structures and types
303 */
304
305 /*
306 * Help list
307 */
308
309 struct h_list {
310 char h_ch;
311 char *h_desc;
312 };
313
314 /*
315 * Coordinate data type
316 */
317 typedef struct {
318 shint x;
319 shint y;
320 } coord;
321
322 /* daemon/fuse data type */
323
324 struct delayed_action {
325 int d_type;
326 int (*d_func)();
327 int d_arg;
328 int d_time;
329 };
330
331 /**/
332
333 typedef unsigned int str_t;
334
335 /*
336 * Stuff about magic items
337 */
338
339 struct magic_item {
340 const char *mi_name;
341 shint mi_prob;
342 short mi_worth;
343 };
344
345 /*
346 * Room structure
347 */
348 struct room {
349 coord r_pos; /* Upper left corner */
350 coord r_max; /* Size of room */
351 coord r_gold; /* Where the gold is */
352 int r_goldval; /* How much the gold is worth */
353 short r_flags; /* Info about the room */
354 shint r_nexits; /* Number of exits */
355 coord r_exit[12]; /* Where the exits are */
356 };
357
358 /*
359 * Structure describing a fighting being
360 */
361 struct stats {
362 str_t s_str; /* Strength */
363 long s_exp; /* Experience */
364 shint s_lvl; /* Level of mastery */
365 shint s_arm; /* Armor class */
366 short s_hpt; /* Hit points */
367 char s_dmg[16]; /* String describing damage done */
368 shint s_maxhp; /* Max hit points */
369 };
370
371 /*
372 * Structure for monsters and player
373 */
374 union thing {
375 struct {
376 union thing *_l_next, *_l_prev; /* Next pointer in link */
377 coord _t_pos; /* Position */
378 bool _t_turn; /* If slowed, is it a turn to move */
379 unsigned char _t_type; /* What it is */
380 char _t_disguise; /* What mimic looks like */
381 char _t_oldch; /* Character that was where it was */
382 coord *_t_dest; /* Where it is running to */
383 short _t_flags; /* State word */
384 struct stats _t_stats; /* Physical description */
385 struct room *_t_room; /* Current room for thing */
386 union thing *_t_pack; /* What the thing is carrying */
387 int _t_reserved;
388 } _t;
389 struct {
390 union thing *_l_next, *_l_prev; /* Next pointer in link */
391 shint _o_type; /* What kind of object it is */
392 coord _o_pos; /* Where it lives on the screen */
393 char *_o_text; /* What it says if you read it */
394 char _o_launch; /* What you need to launch it */
395 char _o_damage[8]; /* Damage if used like sword */
396 char _o_hurldmg[8]; /* Damage if thrown */
397 shint _o_count; /* Count for plural objects */
398 shint _o_which; /* Which object of a type it is */
399 shint _o_hplus; /* Plusses to hit */
400 shint _o_dplus; /* Plusses to damage */
401 short _o_ac; /* Armor class */
402 short _o_flags; /* Information about objects */
403 shint _o_group; /* Group number for this object */
404 } _o;
405 };
406
407 typedef union thing THING;
408
409 #define l_next _t._l_next
410 #define l_prev _t._l_prev
411 #define t_pos _t._t_pos
412 #define t_turn _t._t_turn
413 #define t_type _t._t_type
414 #define t_disguise _t._t_disguise
415 #define t_oldch _t._t_oldch
416 #define t_dest _t._t_dest
417 #define t_flags _t._t_flags
418 #define t_stats _t._t_stats
419 #define t_pack _t._t_pack
420 #define t_room _t._t_room
421 #define t_reserved _t._t_reserved
422 #define o_type _o._o_type
423 #define o_pos _o._o_pos
424 #define o_text _o._o_text
425 #define o_launch _o._o_launch
426 #define o_damage _o._o_damage
427 #define o_hurldmg _o._o_hurldmg
428 #define o_count _o._o_count
429 #define o_which _o._o_which
430 #define o_hplus _o._o_hplus
431 #define o_dplus _o._o_dplus
432 #define o_ac _o._o_ac
433 #define o_charges o_ac
434 #define o_goldval o_ac
435 #define o_flags _o._o_flags
436 #define o_group _o._o_group
437 #define o_reserved _o._o_reserved
438
439 /*
440 * Array containing information on all the various types of mosnters
441 */
442 struct monster {
443 const char *m_name; /* What to call the monster */
444 const shint m_carry; /* Probability of carrying something */
445 const short m_flags; /* Things about the monster */
446 struct stats m_stats; /* Initial stats */
447 };
448
449 /*
450 * External variables
451 */
452
453 extern struct delayed_action d_list[20];
454
455 extern THING *_monst[], *cur_armor, *cur_ring[], *cur_weapon,
456 *lvl_obj, *mlist, player;
457
458 extern coord delta, oldpos;
459
460 extern struct h_list helpstr[];
461
462 extern struct room *oldrp, passages[], rooms[];
463
464 extern struct stats max_stats;
465
466 extern struct monster monsters[];
467
468 extern struct magic_item p_magic[], r_magic[], s_magic[],
469 things[], ws_magic[];
470
471 /*
472 * Function types
473 */
474
475 coord *find_dest(), *rndmove();
476
477 THING *find_mons(), *find_obj(), *get_item(), *new_item(),
478 *new_thing(), *wake_monster();
479
480 struct room *roomin();
481
482 #include "extern.h"
483
484 #ifndef PATH_MAX
485 #define PATH_MAX _MAX_PATH
486 #endif