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