xref: /original-bsd/games/rogue/rogue.h (revision 29d43723)
1 /*
2  * Copyright (c) 1988 The Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Timoth C. Stoehr.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  *	@(#)rogue.h	5.3 (Berkeley) 02/07/89
21  */
22 
23 /*
24  * rogue.h
25  *
26  * This source herein may be modified and/or distributed by anybody who
27  * so desires, with the following restrictions:
28  *    1.)  This notice shall not be removed.
29  *    2.)  Credit shall not be taken for the creation of this source.
30  *    3.)  This code is not to be traded, sold, or used for personal
31  *         gain or profit.
32  */
33 
34 #define boolean char
35 
36 #define NOTHING		((unsigned short)     0)
37 #define OBJECT		((unsigned short)    01)
38 #define MONSTER		((unsigned short)    02)
39 #define STAIRS		((unsigned short)    04)
40 #define HORWALL		((unsigned short)   010)
41 #define VERTWALL	((unsigned short)   020)
42 #define DOOR		((unsigned short)   040)
43 #define FLOOR		((unsigned short)  0100)
44 #define TUNNEL		((unsigned short)  0200)
45 #define TRAP		((unsigned short)  0400)
46 #define HIDDEN		((unsigned short) 01000)
47 
48 #define ARMOR		((unsigned short)   01)
49 #define WEAPON		((unsigned short)   02)
50 #define SCROL		((unsigned short)   04)
51 #define POTION		((unsigned short)  010)
52 #define GOLD		((unsigned short)  020)
53 #define FOOD		((unsigned short)  040)
54 #define WAND		((unsigned short) 0100)
55 #define RING		((unsigned short) 0200)
56 #define AMULET		((unsigned short) 0400)
57 #define ALL_OBJECTS	((unsigned short) 0777)
58 
59 #define LEATHER 0
60 #define RINGMAIL 1
61 #define SCALE 2
62 #define CHAIN 3
63 #define BANDED 4
64 #define SPLINT 5
65 #define PLATE 6
66 #define ARMORS 7
67 
68 #define BOW 0
69 #define DART 1
70 #define ARROW 2
71 #define DAGGER 3
72 #define SHURIKEN 4
73 #define MACE 5
74 #define LONG_SWORD 6
75 #define TWO_HANDED_SWORD 7
76 #define WEAPONS 8
77 
78 #define MAX_PACK_COUNT 24
79 
80 #define PROTECT_ARMOR 0
81 #define HOLD_MONSTER 1
82 #define ENCH_WEAPON 2
83 #define ENCH_ARMOR 3
84 #define IDENTIFY 4
85 #define TELEPORT 5
86 #define SLEEP 6
87 #define SCARE_MONSTER 7
88 #define REMOVE_CURSE 8
89 #define CREATE_MONSTER 9
90 #define AGGRAVATE_MONSTER 10
91 #define MAGIC_MAPPING 11
92 #define CON_MON 12
93 #define SCROLS 13
94 
95 #define INCREASE_STRENGTH 0
96 #define RESTORE_STRENGTH 1
97 #define HEALING 2
98 #define EXTRA_HEALING 3
99 #define POISON 4
100 #define RAISE_LEVEL 5
101 #define BLINDNESS 6
102 #define HALLUCINATION 7
103 #define DETECT_MONSTER 8
104 #define DETECT_OBJECTS 9
105 #define CONFUSION 10
106 #define LEVITATION 11
107 #define HASTE_SELF 12
108 #define SEE_INVISIBLE 13
109 #define POTIONS 14
110 
111 #define TELE_AWAY 0
112 #define SLOW_MONSTER 1
113 #define INVISIBILITY 2
114 #define POLYMORPH 3
115 #define HASTE_MONSTER 4
116 #define MAGIC_MISSILE 5
117 #define CANCELLATION 6
118 #define DO_NOTHING 7
119 #define DRAIN_LIFE 8
120 #define COLD 9
121 #define FIRE 10
122 #define WANDS 11
123 
124 #define STEALTH 0
125 #define R_TELEPORT 1
126 #define REGENERATION 2
127 #define SLOW_DIGEST 3
128 #define ADD_STRENGTH 4
129 #define SUSTAIN_STRENGTH 5
130 #define DEXTERITY 6
131 #define ADORNMENT 7
132 #define R_SEE_INVISIBLE 8
133 #define MAINTAIN_ARMOR 9
134 #define SEARCHING 10
135 #define RINGS 11
136 
137 #define RATION 0
138 #define FRUIT 1
139 
140 #define NOT_USED		((unsigned short)   0)
141 #define BEING_WIELDED	((unsigned short)  01)
142 #define BEING_WORN		((unsigned short)  02)
143 #define ON_LEFT_HAND	((unsigned short)  04)
144 #define ON_RIGHT_HAND	((unsigned short) 010)
145 #define ON_EITHER_HAND	((unsigned short) 014)
146 #define BEING_USED		((unsigned short) 017)
147 
148 #define NO_TRAP -1
149 #define TRAP_DOOR 0
150 #define BEAR_TRAP 1
151 #define TELE_TRAP 2
152 #define DART_TRAP 3
153 #define SLEEPING_GAS_TRAP 4
154 #define RUST_TRAP 5
155 #define TRAPS 6
156 
157 #define STEALTH_FACTOR 3
158 #define R_TELE_PERCENT 8
159 
160 #define UNIDENTIFIED ((unsigned short) 00)	/* MUST BE ZERO! */
161 #define IDENTIFIED ((unsigned short) 01)
162 #define CALLED ((unsigned short) 02)
163 
164 #define DROWS 24
165 #define DCOLS 80
166 #define NMESSAGES 5
167 #define MAX_TITLE_LENGTH 30
168 #define MAXSYLLABLES 40
169 #define MAX_METAL 14
170 #define WAND_MATERIALS 30
171 #define GEMS 14
172 
173 #define GOLD_PERCENT 46
174 
175 #define SCORE_FILE "/usr/games/lib/rogue.scores"
176 #define LOCK_FILE  "/usr/games/lib/rogue.lock"
177 
178 #define MAX_OPT_LEN 40
179 
180 struct id {
181 	short value;
182 	char *title;
183 	char *real;
184 	unsigned short id_status;
185 };
186 
187 /* The following #defines provide more meaningful names for some of the
188  * struct object fields that are used for monsters.  This, since each monster
189  * and object (scrolls, potions, etc) are represented by a struct object.
190  * Ideally, this should be handled by some kind of union structure.
191  */
192 
193 #define m_damage damage
194 #define hp_to_kill quantity
195 #define m_char ichar
196 #define first_level is_protected
197 #define last_level is_cursed
198 #define m_hit_chance class
199 #define stationary_damage identified
200 #define drop_percent which_kind
201 #define trail_char d_enchant
202 #define slowed_toggle quiver
203 #define moves_confused hit_enchant
204 #define nap_length picked_up
205 #define disguise what_is
206 #define next_monster next_object
207 
208 struct obj {				/* comment is monster meaning */
209 	unsigned long m_flags;	/* monster flags */
210 	char *damage;			/* damage it does */
211 	short quantity;			/* hit points to kill */
212 	short ichar;			/* 'A' is for aquatar */
213 	short kill_exp;			/* exp for killing it */
214 	short is_protected;		/* level starts */
215 	short is_cursed;		/* level ends */
216 	short class;			/* chance of hitting you */
217 	short identified;		/* 'F' damage, 1,2,3... */
218 	unsigned short which_kind; /* item carry/drop % */
219 	short o_row, o_col, o;	/* o is how many times stuck at o_row, o_col */
220 	short row, col;			/* current row, col */
221 	short d_enchant;		/* room char when detect_monster */
222 	short quiver;			/* monster slowed toggle */
223 	short trow, tcol;		/* target row, col */
224 	short hit_enchant;		/* how many moves is confused */
225 	unsigned short what_is;	/* imitator's charactor (?!%: */
226 	short picked_up;		/* sleep from wand of sleep */
227 	unsigned short in_use_flags;
228 	struct obj *next_object;	/* next monster */
229 };
230 
231 typedef struct obj object;
232 
233 #define INIT_AW (object*)0,(object*)0
234 #define INIT_RINGS (object*)0,(object*)0
235 #define INIT_HP 12,12
236 #define INIT_STR 16,16
237 #define INIT_EXP 1,0
238 #define INIT_PACK {0}
239 #define INIT_GOLD 0
240 #define INIT_CHAR '@'
241 #define INIT_MOVES 1250
242 
243 struct fightr {
244 	object *armor;
245 	object *weapon;
246 	object *left_ring, *right_ring;
247 	short hp_current;
248 	short hp_max;
249 	short str_current;
250 	short str_max;
251 	object pack;
252 	long gold;
253 	short exp;
254 	long exp_points;
255 	short row, col;
256 	short fchar;
257 	short moves_left;
258 };
259 
260 typedef struct fightr fighter;
261 
262 struct dr {
263 	short oth_room;
264 	short oth_row,
265 	      oth_col;
266 	short door_row,
267 		  door_col;
268 };
269 
270 typedef struct dr door;
271 
272 struct rm {
273 	short bottom_row, right_col, left_col, top_row;
274 	door doors[4];
275 	unsigned short is_room;
276 };
277 
278 typedef struct rm room;
279 
280 #define MAXROOMS 9
281 #define BIG_ROOM 10
282 
283 #define NO_ROOM -1
284 
285 #define PASSAGE -3		/* cur_room value */
286 
287 #define AMULET_LEVEL 26
288 
289 #define R_NOTHING	((unsigned short) 01)
290 #define R_ROOM		((unsigned short) 02)
291 #define R_MAZE		((unsigned short) 04)
292 #define R_DEADEND	((unsigned short) 010)
293 #define R_CROSS		((unsigned short) 020)
294 
295 #define MAX_EXP_LEVEL 21
296 #define MAX_EXP 10000001L
297 #define MAX_GOLD 999999
298 #define MAX_ARMOR 99
299 #define MAX_HP 999
300 #define MAX_STRENGTH 99
301 #define LAST_DUNGEON 99
302 
303 #define STAT_LEVEL 01
304 #define STAT_GOLD 02
305 #define STAT_HP 04
306 #define STAT_STRENGTH 010
307 #define STAT_ARMOR 020
308 #define STAT_EXP 040
309 #define STAT_HUNGER 0100
310 #define STAT_LABEL 0200
311 #define STAT_ALL 0377
312 
313 #define PARTY_TIME 10	/* one party somewhere in each 10 level span */
314 
315 #define MAX_TRAPS 10	/* maximum traps per level */
316 
317 #define HIDE_PERCENT 12
318 
319 struct tr {
320 	short trap_type;
321 	short trap_row, trap_col;
322 };
323 
324 typedef struct tr trap;
325 
326 extern fighter rogue;
327 extern room rooms[];
328 extern trap traps[];
329 extern unsigned short dungeon[DROWS][DCOLS];
330 extern object level_objects;
331 
332 extern struct id id_scrolls[];
333 extern struct id id_potions[];
334 extern struct id id_wands[];
335 extern struct id id_rings[];
336 extern struct id id_weapons[];
337 extern struct id id_armors[];
338 
339 extern object mon_tab[];
340 extern object level_monsters;
341 
342 #define MONSTERS 26
343 
344 #define HASTED					01L
345 #define SLOWED					02L
346 #define INVISIBLE				04L
347 #define ASLEEP				   010L
348 #define WAKENS				   020L
349 #define WANDERS				   040L
350 #define FLIES				  0100L
351 #define FLITS				  0200L
352 #define CAN_FLIT			  0400L		/* can, but usually doesn't, flit */
353 #define CONFUSED	 		 01000L
354 #define RUSTS				 02000L
355 #define HOLDS				 04000L
356 #define FREEZES				010000L
357 #define STEALS_GOLD			020000L
358 #define STEALS_ITEM			040000L
359 #define STINGS			   0100000L
360 #define DRAINS_LIFE		   0200000L
361 #define DROPS_LEVEL		   0400000L
362 #define SEEKS_GOLD		  01000000L
363 #define FREEZING_ROGUE	  02000000L
364 #define RUST_VANISHED	  04000000L
365 #define CONFUSES		 010000000L
366 #define IMITATES		 020000000L
367 #define FLAMES			 040000000L
368 #define STATIONARY		0100000000L		/* damage will be 1,2,3,... */
369 #define NAPPING			0200000000L		/* can't wake up for a while */
370 #define ALREADY_MOVED	0400000000L
371 
372 #define SPECIAL_HIT		(RUSTS|HOLDS|FREEZES|STEALS_GOLD|STEALS_ITEM|STINGS|DRAINS_LIFE|DROPS_LEVEL)
373 
374 #define WAKE_PERCENT 45
375 #define FLIT_PERCENT 40
376 #define PARTY_WAKE_PERCENT 75
377 
378 #define HYPOTHERMIA 1
379 #define STARVATION 2
380 #define POISON_DART 3
381 #define QUIT 4
382 #define WIN 5
383 #define KFIRE 6
384 
385 #define UPWARD 0
386 #define UPRIGHT 1
387 #define RIGHT 2
388 #define DOWNRIGHT 3
389 #define DOWN 4
390 #define DOWNLEFT 5
391 #define LEFT 6
392 #define UPLEFT 7
393 #define DIRS 8
394 
395 #define ROW1 7
396 #define ROW2 15
397 
398 #define COL1 26
399 #define COL2 52
400 
401 #define MOVED 0
402 #define MOVE_FAILED -1
403 #define STOPPED_ON_SOMETHING -2
404 #define CANCEL '\033'
405 #define LIST '*'
406 
407 #define HUNGRY 300
408 #define WEAK 150
409 #define FAINT 20
410 #define STARVE 0
411 
412 #define MIN_ROW 1
413 
414 /* external routine declarations.
415  */
416 char *strcpy();
417 char *strncpy();
418 char *strcat();
419 
420 char *mon_name();
421 char *get_ench_color();
422 char *name_of();
423 char *md_gln();
424 char *md_getenv();
425 char *md_malloc();
426 boolean is_direction();
427 boolean mon_sees();
428 boolean mask_pack();
429 boolean mask_room();
430 boolean is_digit();
431 boolean check_hunger();
432 boolean reg_move();
433 boolean md_df();
434 boolean has_been_touched();
435 object *add_to_pack();
436 object *alloc_object();
437 object *get_letter_object();
438 object *gr_monster();
439 object *get_thrown_at_monster();
440 object *get_zapped_monster();
441 object *check_duplicate();
442 object *gr_object();
443 object *object_at();
444 object *pick_up();
445 struct id *get_id_table();
446 unsigned short gr_what_is();
447 long rrandom();
448 long lget_number();
449 long xxx();
450 int byebye(), onintr(), error_save();
451 
452 struct rogue_time {
453 	short year;		/* >= 1987 */
454 	short month;	/* 1 - 12 */
455 	short day;		/* 1 - 31 */
456 	short hour;		/* 0 - 23 */
457 	short minute;	/* 0 - 59 */
458 	short second;	/* 0 - 59 */
459 };
460 
461 #ifdef CURSES
462 struct _win_st {
463 	short _cury, _curx;
464 	short _maxy, _maxx;
465 };
466 
467 typedef struct _win_st WINDOW;
468 
469 extern int LINES, COLS;
470 extern WINDOW *curscr;
471 extern char *CL;
472 
473 char *md_gdtcf();
474 
475 #else
476 #include <curses.h>
477 #endif
478