Use ^ rather than & so the player can't be generated 'too boring' for any monster...
[rogue-pphs.git] / rogue.h
1 /*
2 * Rogue definitions and variable declarations
3 *
4 * @(#)rogue.h 3.38 (Berkeley) 6/15/81
5 *
6 * Rogue: Exploring the Dungeons of Doom
7 * Copyright (C) 1980, 1981 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 /*
14 * Maximum number of different things
15 */
16 #define MAXROOMS 9
17 #define MAXTHINGS 9
18 #define MAXOBJ 9
19 #define MAXPACK 23
20 #define MAXTRAPS 10
21 #define NUMTHINGS 7 /* number of types of things (scrolls, rings, etc.) */
22
23 /*
24 * return values for get functions
25 */
26 #define NORM 0 /* normal exit */
27 #define QUIT 1 /* quit option setting */
28 #define MINUS 2 /* back up one option */
29
30 /*
31 * All the fun defines
32 */
33 #define next(ptr) (*ptr).l_next
34 #define prev(ptr) (*ptr).l_prev
35 #define ldata(ptr) (*ptr).l_data
36 #define inroom(rp, cp) (\
37 (cp)->x <= (rp)->r_pos.x + ((rp)->r_max.x - 1) && (rp)->r_pos.x <= (cp)->x \
38 && (cp)->y <= (rp)->r_pos.y + ((rp)->r_max.y - 1) && (rp)->r_pos.y <= (cp)->y)
39 #define winat(y, x) (mvwinch(mw,y,x)==' '?mvwinch(stdscr,y,x):winch(mw))
40 #define debug if (wizard) msg
41 #define RN (((seed = seed*11109+13849) & 0x7fff) >> 1)
42 #define unc(cp) (cp).y, (cp).x
43 #define cmov(xy) move((xy).y, (xy).x)
44 #define DISTANCE(y1, x1, y2, x2) ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1))
45 #define OBJPTR(what) (struct object *)((*what).l_data)
46 #define THINGPTR(what) (struct thing *)((*what).l_data)
47 #define when break;case
48 #define otherwise break;default
49 #define until(expr) while(!(expr))
50 #define ce(a, b) ((a).x == (b).x && (a).y == (b).y)
51 #define draw(window) (wrefresh(window),usleep(20000))
52 #define hero player.t_pos
53 #define pstats player.t_stats
54 #define pack player.t_pack
55 #define attach(a,b) _attach(&a,b)
56 #define detach(a,b) _detach(&a,b)
57 #define free_list(a) _free_list(&a)
58 #ifndef max
59 #define max(a, b) ((a) > (b) ? (a) : (b))
60 #endif
61 #define on(thing, flag) (((thing).t_flags & flag) != 0)
62 #define off(thing, flag) (((thing).t_flags & flag) == 0)
63 #undef CTRL
64 #define CTRL(ch) (ch & 037)
65 #define ALLOC(x) malloc((unsigned int) x)
66 #define FREE(x) free((char *) x)
67 #define EQSTR(a, b, c) (strncmp(a, b, c) == 0)
68 #define GOLDCALC (rnd(50 + 10 * level) + 2)
69 #define ISRING(h,r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r)
70 #define ISWEARING(r) (ISRING(LEFT, r) || ISRING(RIGHT, r))
71 #define newgrp() ++group
72 #define o_charges o_ac
73 #define ISMULT(type) (type == POTION || type == SCROLL || type == FOOD)
74 #define rndchoice(a) (a[rnd(sizeof(a)/sizeof((a)[0]))])
75
76 /*
77 * Things that appear on the screens
78 */
79 #define PASSAGE '#'
80 #define DOOR '+'
81 #define FLOOR '.'
82 #define PLAYER '@'
83 #define TRAP '^'
84 #define TRAPDOOR '>'
85 #define ARROWTRAP '{'
86 #define SLEEPTRAP '$'
87 #define BEARTRAP '}'
88 #define TELTRAP '~'
89 #define DARTTRAP '`'
90 #define SECRETDOOR '&'
91 #define STAIRS '%'
92 #define GOLD '*'
93 #define POTION '!'
94 #define SCROLL '?'
95 #define MAGIC '$'
96 #define FOOD ':'
97 #define WEAPON ')'
98 #define ARMOR ']'
99 #define AMULET ','
100 #define RING '='
101 #define STICK '/'
102 #define CALLABLE -1
103
104 /*
105 * Various constants
106 */
107 #define PASSWD "mTBellIQOsLNA"
108 #define BEARTIME 3
109 #define SLEEPTIME 5
110 #define HEALTIME 30
111 #define HOLDTIME 2
112 #define STPOS 0
113 #define WANDERTIME 70
114 #define BEFORE 1
115 #define AFTER 2
116 #define HUHDURATION 20
117 #define SEEDURATION 850
118 #define HUNGERTIME 1300
119 #define MORETIME 150
120 #define STOMACHSIZE 2000
121 #define ESCAPE 27
122 #define LEFT 0
123 #define RIGHT 1
124 #define BOLT_LENGTH 6
125
126 /*
127 * Save against things
128 */
129 #define VS_POISON 00
130 #define VS_PARALYZATION 00
131 #define VS_DEATH 00
132 #define VS_PETRIFICATION 01
133 #define VS_BREATH 02
134 #define VS_MAGIC 03
135
136 /*
137 * Various flag bits
138 */
139 #define ISDARK 0000001
140 #define ISCURSED 000001
141 #define ISBLIND 0000001
142 #define ISGONE 0000002
143 #define ISKNOW 0000002
144 #define ISRUN 0000004
145 #define ISFOUND 0000010
146 #define ISINVIS 0000020
147 #define ISMEAN 0000040
148 #define ISGREED 0000100
149 #define ISBLOCK 0000200
150 #define ISHELD 0000400
151 #define ISHUH 0001000
152 #define ISREGEN 0002000
153 #define CANHUH 0004000
154 #define CANSEE 0010000
155 #define ISMISL 0020000
156 #define ISCANC 0020000
157 #define ISMANY 0040000
158 #define ISSLOW 0040000
159 #define ISHASTE 0100000
160
161 /*
162 * Potion types
163 */
164 #define P_CONFUSE 0
165 #define P_PARALYZE 1
166 #define P_POISON 2
167 #define P_STRENGTH 3
168 #define P_SEEINVIS 4
169 #define P_HEALING 5
170 #define P_MFIND 6
171 #define P_TFIND 7
172 #define P_RAISE 8
173 #define P_XHEAL 9
174 #define P_HASTE 10
175 #define P_RESTORE 11
176 #define P_BLIND 12
177 #define P_NOP 13
178 #define MAXPOTIONS 14
179
180 /*
181 * Scroll types
182 */
183 #define S_CONFUSE 0
184 #define S_MAP 1
185 #define S_LIGHT 2
186 #define S_HOLD 3
187 #define S_SLEEP 4
188 #define S_ARMOR 5
189 #define S_IDENT 6
190 #define S_SCARE 7
191 #define S_GFIND 8
192 #define S_TELEP 9
193 #define S_ENCH 10
194 #define S_CREATE 11
195 #define S_REMOVE 12
196 #define S_AGGR 13
197 #define S_NOP 14
198 #define S_GENOCIDE 15
199 #define MAXSCROLLS 16
200
201 /*
202 * Weapon types
203 */
204 #define MACE 0
205 #define SWORD 1
206 #define BOW 2
207 #define ARROW 3
208 #define DAGGER 4
209 #define ROCK 5
210 #define TWOSWORD 6
211 #define SLING 7
212 #define DART 8
213 #define CROSSBOW 9
214 #define BOLT 10
215 #define SPEAR 11
216 #define MAXWEAPONS 12
217
218 /*
219 * Armor types
220 */
221 #define LEATHER 0
222 #define RING_MAIL 1
223 #define STUDDED_LEATHER 2
224 #define SCALE_MAIL 3
225 #define CHAIN_MAIL 4
226 #define SPLINT_MAIL 5
227 #define BANDED_MAIL 6
228 #define PLATE_MAIL 7
229 #define MAXARMORS 8
230
231 /*
232 * Ring types
233 */
234 #define R_PROTECT 0
235 #define R_ADDSTR 1
236 #define R_SUSTSTR 2
237 #define R_SEARCH 3
238 #define R_SEEINVIS 4
239 #define R_NOP 5
240 #define R_AGGR 6
241 #define R_ADDHIT 7
242 #define R_ADDDAM 8
243 #define R_REGEN 9
244 #define R_DIGEST 10
245 #define R_TELEPORT 11
246 #define R_STEALTH 12
247 #define MAXRINGS 13
248
249 /*
250 * Rod/Wand/Staff types
251 */
252
253 #define WS_LIGHT 0
254 #define WS_HIT 1
255 #define WS_ELECT 2
256 #define WS_FIRE 3
257 #define WS_COLD 4
258 #define WS_POLYMORPH 5
259 #define WS_MISSILE 6
260 #define WS_HASTE_M 7
261 #define WS_SLOW_M 8
262 #define WS_DRAIN 9
263 #define WS_NOP 10
264 #define WS_TELAWAY 11
265 #define WS_TELTO 12
266 #define WS_CANCEL 13
267 #define MAXSTICKS 14
268
269 /*
270 * Now we define the structures and types
271 */
272
273 /*
274 * Help list
275 */
276
277 struct h_list {
278 char h_ch;
279 char *h_desc;
280 };
281
282 extern struct h_list helpstr[];
283
284 /*
285 * Coordinate data type
286 */
287 typedef struct {
288 int x;
289 int y;
290 } coord;
291
292 typedef struct {
293 short st_str;
294 short st_add;
295 } str_t;
296
297 /*
298 * Linked list data type
299 */
300 struct linked_list {
301 struct linked_list *l_next;
302 struct linked_list *l_prev;
303 char *l_data; /* Various structure pointers */
304 };
305
306 /*
307 * Stuff about magic items
308 */
309
310 struct magic_item {
311 char mi_name[30];
312 int mi_prob;
313 int mi_worth;
314 };
315
316 /*
317 * Room structure
318 */
319 struct room {
320 coord r_pos; /* Upper left corner */
321 coord r_max; /* Size of room */
322 coord r_gold; /* Where the gold is */
323 int r_goldval; /* How much the gold is worth */
324 int r_flags; /* Info about the room */
325 int r_nexits; /* Number of exits */
326 coord r_exit[4]; /* Where the exits are */
327 };
328
329 /*
330 * Array of all traps on this level
331 */
332 struct trap {
333 coord tr_pos; /* Where trap is */
334 char tr_type; /* What kind of trap */
335 int tr_flags; /* Info about trap (i.e. ISFOUND) */
336 };
337
338 extern struct trap traps[MAXTRAPS];
339
340 #define NUM_FEATURES 6
341
342 /*
343 * Structure describing a fighting being
344 */
345 struct stats {
346 str_t s_str; /* Strength */
347 long s_exp; /* Experience */
348 int s_lvl; /* Level of mastery */
349 int s_arm; /* Armor class */
350 int s_hpt; /* Hit points */
351 char s_dmg[30]; /* String describing damage done */
352 int s_ont; /* Orientation flags */
353 int s_int; /* Level of interest in rogue */
354 };
355
356 /*
357 * Structure for monsters and player
358 */
359 struct thing {
360 coord t_pos; /* Position */
361 bool t_turn; /* If slowed, is it a turn to move */
362 char t_type; /* What it is */
363 char t_disguise; /* What mimic looks like */
364 char t_oldch; /* Character that was where it was */
365 coord *t_dest; /* Where it is running to */
366 short t_flags; /* State word */
367 struct stats t_stats; /* Physical description */
368 struct linked_list *t_pack; /* What the thing is carrying */
369 int t_reserved; /* reserved for save/restore code */
370 };
371
372 /*
373 * Array containing information on all the various types of mosnters
374 */
375 struct monster {
376 char m_name[20]; /* What to call the monster */
377 short m_carry; /* Probability of carrying something */
378 short m_flags; /* Things about the monster */
379 struct stats m_stats; /* Initial stats */
380 };
381
382 /*
383 * Structure for a thing that the rogue can carry
384 */
385
386 struct object {
387 int o_type; /* What kind of object it is */
388 coord o_pos; /* Where it lives on the screen */
389 char o_launch; /* What you need to launch it */
390 char o_damage[8]; /* Damage if used like sword */
391 char o_hurldmg[8]; /* Damage if thrown */
392 int o_count; /* Count for plural objects */
393 int o_which; /* Which object of a type it is */
394 int o_hplus; /* Plusses to hit */
395 int o_dplus; /* Plusses to damage */
396 int o_ac; /* Armor class */
397 int o_flags; /* Information about objects */
398 int o_group; /* Group number for this object */
399 };
400
401 struct delayed_action {
402 int d_type;
403 int (*d_func)();
404 int d_arg;
405 int d_time;
406 };
407
408 /*
409 * Now all the global variables
410 */
411
412 extern struct room rooms[MAXROOMS]; /* One for each room -- A level */
413 extern struct room *oldrp; /* Roomin(&oldpos) */
414 extern struct linked_list *mlist; /* List of monsters on the level */
415 extern struct thing player; /* The rogue */
416 extern struct stats max_stats; /* The maximum for the player */
417 extern struct monster monsters[26]; /* The initial monster states */
418 extern struct linked_list *lvl_obj; /* List of objects on this level */
419 extern struct object *cur_weapon; /* Which weapon he is weilding */
420 extern struct object *cur_armor; /* What a well dresssed rogue wears */
421 extern struct object *cur_ring[2]; /* Which rings are being worn */
422 extern struct magic_item things[NUMTHINGS]; /* Chances for each type of item */
423 extern struct magic_item s_magic[MAXSCROLLS]; /* Names and chances for scrolls */
424 extern struct magic_item p_magic[MAXPOTIONS]; /* Names and chances for potions */
425 extern struct magic_item r_magic[MAXRINGS]; /* Names and chances for rings */
426 extern struct magic_item ws_magic[MAXSTICKS]; /* Names and chances for sticks */
427
428 extern int level; /* What level rogue is on */
429 extern int purse; /* How much gold the rogue has */
430 extern int mpos; /* Where cursor is on top line */
431 extern int ntraps; /* Number of traps on this level */
432 extern int no_move; /* Number of turns held in place */
433 extern int no_command; /* Number of turns asleep */
434 extern int inpack; /* Number of things in pack */
435 extern int max_hp; /* Player's max hit points */
436 extern int total; /* Total dynamic memory bytes */
437 extern int a_chances[MAXARMORS]; /* Probabilities for armor */
438 extern int a_class[MAXARMORS]; /* Armor class for various armors */
439 extern int lastscore; /* Score before this turn */
440 extern int no_food; /* Number of levels without food */
441 extern int seed; /* Random number seed */
442 extern int count; /* Number of times to repeat command */
443 extern int dnum; /* Dungeon number */
444 extern int fung_hit; /* Number of time fungi has hit */
445 extern int quiet; /* Number of quiet turns */
446 extern int max_level; /* Deepest player has gone */
447 extern int food_left; /* Amount of food in hero's stomach */
448 extern int group; /* Current group number */
449 extern int hungry_state; /* How hungry is he */
450
451 extern char take; /* Thing the rogue is taking */
452 extern char prbuf[80]; /* Buffer for sprintfs */
453 extern char runch; /* Direction player is running */
454 extern char *s_names[MAXSCROLLS]; /* Names of the scrolls */
455 extern char *p_colors[MAXPOTIONS]; /* Colors of the potions */
456 extern char *r_stones[MAXRINGS]; /* Stone settings of the rings */
457 extern char *w_names[MAXWEAPONS]; /* Names of the various weapons */
458 extern char *a_names[MAXARMORS]; /* Names of armor types */
459 extern char *ws_made[MAXSTICKS]; /* What sticks are made of */
460 extern char *release; /* Release number of rogue */
461 extern char whoami[80]; /* Name of player */
462 extern char fruit[80]; /* Favorite fruit */
463 extern char huh[80]; /* The last message printed */
464 extern char *s_guess[MAXSCROLLS]; /* Players guess at what scroll is */
465 extern char *p_guess[MAXPOTIONS]; /* Players guess at what potion is */
466 extern char *r_guess[MAXRINGS]; /* Players guess at what ring is */
467 extern char *ws_guess[MAXSTICKS]; /* Players guess at what wand is */
468 extern char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */
469 extern char file_name[80]; /* Save file name */
470 extern char home[80]; /* User's home directory */
471
472 extern WINDOW *cw; /* Window that the player sees */
473 extern WINDOW *hw; /* Used for the help command */
474 extern WINDOW *mw; /* Used to store mosnters */
475
476 extern bool running; /* True if player is running */
477 extern bool playing; /* True until he quits */
478 extern bool wizard; /* True if allows wizard commands */
479 extern bool after; /* True if we want after daemons */
480 extern bool notify; /* True if player wants to know */
481 extern bool fight_flush; /* True if toilet input */
482 extern bool terse; /* True if we should be short */
483 extern bool door_stop; /* Stop running when we pass a door */
484 extern bool jump; /* Show running as series of jumps */
485 extern bool slow_invent; /* Inventory one line at a time */
486 extern bool firstmove; /* First move after setting door_stop */
487 extern bool waswizard; /* Was a wizard sometime */
488 extern bool askme; /* Ask about unidentified things */
489 extern bool s_know[MAXSCROLLS]; /* Does he know what a scroll does */
490 extern bool p_know[MAXPOTIONS]; /* Does he know what a potion does */
491 extern bool r_know[MAXRINGS]; /* Does he know what a ring does */
492 extern bool ws_know[MAXSTICKS]; /* Does he know what a stick does */
493 extern bool amulet; /* He found the amulet */
494 extern bool in_shell; /* True if executing a shell */
495
496 extern coord oldpos; /* Position before last look() call */
497 extern coord delta; /* Change indicated to get_dir() */
498
499 extern coord ch_ret;
500 extern char countch,direction,newcount;
501 extern struct delayed_action d_list[20];
502 extern int between;
503 extern int num_checks;
504 extern char lvl_mons[27],wand_mons[27];
505 extern coord nh;
506
507 struct linked_list *find_mons(), *find_obj(), *get_item(), *new_item();
508 struct linked_list *new_thing(), *wake_monster();
509
510 char *tr_name(), *new();
511 char *charge_str(),*vowelstr(), *inv_name();
512 char *ctime(), *num(), *ring_num();
513
514 struct room *roomin();
515
516 coord *rndmove();
517
518 void auto_save(int p), endit(int p), quit(int p), tstp(), checkout();
519 int nohaste(), doctor(), runners(), swander();
520 int unconfuse(), unsee(), rollwand(), stomach(), sight();
521
522 struct trap *trap_at();
523
524 extern char *rainbow[];
525 extern char *stones[];
526 extern char *wood[];
527 extern char *metal[];
528
529 extern const int cNCOLORS;
530 extern const int cNSTONES;
531 extern const int cNWOOD;
532 extern const int cNMETAL;