xref: /csrg-svn/games/rogue/rogue.h (revision 60842)
132689Sbostic /*
2*60842Sbostic  * Copyright (c) 1988, 1993
3*60842Sbostic  *	The Regents of the University of California.  All rights reserved.
436704Sbostic  *
536704Sbostic  * This code is derived from software contributed to Berkeley by
636704Sbostic  * Timoth C. Stoehr.
736704Sbostic  *
842602Sbostic  * %sccs.include.redist.c%
936704Sbostic  *
10*60842Sbostic  *	@(#)rogue.h	8.1 (Berkeley) 05/31/93
1136704Sbostic  */
1236704Sbostic 
1336704Sbostic /*
1432689Sbostic  * rogue.h
1532689Sbostic  *
1632689Sbostic  * This source herein may be modified and/or distributed by anybody who
1732689Sbostic  * so desires, with the following restrictions:
1832689Sbostic  *    1.)  This notice shall not be removed.
1932689Sbostic  *    2.)  Credit shall not be taken for the creation of this source.
2032689Sbostic  *    3.)  This code is not to be traded, sold, or used for personal
2132689Sbostic  *         gain or profit.
2232689Sbostic  */
2332689Sbostic 
2432689Sbostic #define boolean char
2532689Sbostic 
2632689Sbostic #define NOTHING		((unsigned short)     0)
2732689Sbostic #define OBJECT		((unsigned short)    01)
2832689Sbostic #define MONSTER		((unsigned short)    02)
2932689Sbostic #define STAIRS		((unsigned short)    04)
3032689Sbostic #define HORWALL		((unsigned short)   010)
3132689Sbostic #define VERTWALL	((unsigned short)   020)
3232689Sbostic #define DOOR		((unsigned short)   040)
3332689Sbostic #define FLOOR		((unsigned short)  0100)
3432689Sbostic #define TUNNEL		((unsigned short)  0200)
3532689Sbostic #define TRAP		((unsigned short)  0400)
3632689Sbostic #define HIDDEN		((unsigned short) 01000)
3732689Sbostic 
3832689Sbostic #define ARMOR		((unsigned short)   01)
3932689Sbostic #define WEAPON		((unsigned short)   02)
4032689Sbostic #define SCROL		((unsigned short)   04)
4132689Sbostic #define POTION		((unsigned short)  010)
4232689Sbostic #define GOLD		((unsigned short)  020)
4332689Sbostic #define FOOD		((unsigned short)  040)
4432689Sbostic #define WAND		((unsigned short) 0100)
4532689Sbostic #define RING		((unsigned short) 0200)
4632689Sbostic #define AMULET		((unsigned short) 0400)
4732689Sbostic #define ALL_OBJECTS	((unsigned short) 0777)
4832689Sbostic 
4932689Sbostic #define LEATHER 0
5032689Sbostic #define RINGMAIL 1
5132689Sbostic #define SCALE 2
5232689Sbostic #define CHAIN 3
5332689Sbostic #define BANDED 4
5432689Sbostic #define SPLINT 5
5532689Sbostic #define PLATE 6
5632689Sbostic #define ARMORS 7
5732689Sbostic 
5832689Sbostic #define BOW 0
5932689Sbostic #define DART 1
6032689Sbostic #define ARROW 2
6132689Sbostic #define DAGGER 3
6232689Sbostic #define SHURIKEN 4
6332689Sbostic #define MACE 5
6432689Sbostic #define LONG_SWORD 6
6532689Sbostic #define TWO_HANDED_SWORD 7
6632689Sbostic #define WEAPONS 8
6732689Sbostic 
6832689Sbostic #define MAX_PACK_COUNT 24
6932689Sbostic 
7032689Sbostic #define PROTECT_ARMOR 0
7132689Sbostic #define HOLD_MONSTER 1
7232689Sbostic #define ENCH_WEAPON 2
7332689Sbostic #define ENCH_ARMOR 3
7432689Sbostic #define IDENTIFY 4
7532689Sbostic #define TELEPORT 5
7632689Sbostic #define SLEEP 6
7732689Sbostic #define SCARE_MONSTER 7
7832689Sbostic #define REMOVE_CURSE 8
7932689Sbostic #define CREATE_MONSTER 9
8032689Sbostic #define AGGRAVATE_MONSTER 10
8132689Sbostic #define MAGIC_MAPPING 11
8232689Sbostic #define CON_MON 12
8332689Sbostic #define SCROLS 13
8432689Sbostic 
8532689Sbostic #define INCREASE_STRENGTH 0
8632689Sbostic #define RESTORE_STRENGTH 1
8732689Sbostic #define HEALING 2
8832689Sbostic #define EXTRA_HEALING 3
8932689Sbostic #define POISON 4
9032689Sbostic #define RAISE_LEVEL 5
9132689Sbostic #define BLINDNESS 6
9232689Sbostic #define HALLUCINATION 7
9332689Sbostic #define DETECT_MONSTER 8
9432689Sbostic #define DETECT_OBJECTS 9
9532689Sbostic #define CONFUSION 10
9632689Sbostic #define LEVITATION 11
9732689Sbostic #define HASTE_SELF 12
9832689Sbostic #define SEE_INVISIBLE 13
9932689Sbostic #define POTIONS 14
10032689Sbostic 
10132689Sbostic #define TELE_AWAY 0
10232689Sbostic #define SLOW_MONSTER 1
10332689Sbostic #define INVISIBILITY 2
10432689Sbostic #define POLYMORPH 3
10532689Sbostic #define HASTE_MONSTER 4
10632689Sbostic #define MAGIC_MISSILE 5
10732689Sbostic #define CANCELLATION 6
10832689Sbostic #define DO_NOTHING 7
10932689Sbostic #define DRAIN_LIFE 8
11032689Sbostic #define COLD 9
11132689Sbostic #define FIRE 10
11232689Sbostic #define WANDS 11
11332689Sbostic 
11432689Sbostic #define STEALTH 0
11532689Sbostic #define R_TELEPORT 1
11632689Sbostic #define REGENERATION 2
11732689Sbostic #define SLOW_DIGEST 3
11832689Sbostic #define ADD_STRENGTH 4
11932689Sbostic #define SUSTAIN_STRENGTH 5
12032689Sbostic #define DEXTERITY 6
12132689Sbostic #define ADORNMENT 7
12232689Sbostic #define R_SEE_INVISIBLE 8
12332689Sbostic #define MAINTAIN_ARMOR 9
12432689Sbostic #define SEARCHING 10
12532689Sbostic #define RINGS 11
12632689Sbostic 
12732689Sbostic #define RATION 0
12832689Sbostic #define FRUIT 1
12932689Sbostic 
13032689Sbostic #define NOT_USED		((unsigned short)   0)
13132689Sbostic #define BEING_WIELDED	((unsigned short)  01)
13232689Sbostic #define BEING_WORN		((unsigned short)  02)
13332689Sbostic #define ON_LEFT_HAND	((unsigned short)  04)
13432689Sbostic #define ON_RIGHT_HAND	((unsigned short) 010)
13532689Sbostic #define ON_EITHER_HAND	((unsigned short) 014)
13632689Sbostic #define BEING_USED		((unsigned short) 017)
13732689Sbostic 
13832689Sbostic #define NO_TRAP -1
13932689Sbostic #define TRAP_DOOR 0
14032689Sbostic #define BEAR_TRAP 1
14132689Sbostic #define TELE_TRAP 2
14232689Sbostic #define DART_TRAP 3
14332689Sbostic #define SLEEPING_GAS_TRAP 4
14432689Sbostic #define RUST_TRAP 5
14532689Sbostic #define TRAPS 6
14632689Sbostic 
14732689Sbostic #define STEALTH_FACTOR 3
14832689Sbostic #define R_TELE_PERCENT 8
14932689Sbostic 
15032689Sbostic #define UNIDENTIFIED ((unsigned short) 00)	/* MUST BE ZERO! */
15132689Sbostic #define IDENTIFIED ((unsigned short) 01)
15232689Sbostic #define CALLED ((unsigned short) 02)
15332689Sbostic 
15432689Sbostic #define DROWS 24
15532689Sbostic #define DCOLS 80
15632689Sbostic #define NMESSAGES 5
15732689Sbostic #define MAX_TITLE_LENGTH 30
15832689Sbostic #define MAXSYLLABLES 40
15932689Sbostic #define MAX_METAL 14
16032689Sbostic #define WAND_MATERIALS 30
16132689Sbostic #define GEMS 14
16232689Sbostic 
16332689Sbostic #define GOLD_PERCENT 46
16432689Sbostic 
16532689Sbostic #define MAX_OPT_LEN 40
16632689Sbostic 
16732689Sbostic struct id {
16832689Sbostic 	short value;
16932689Sbostic 	char *title;
17032689Sbostic 	char *real;
17132689Sbostic 	unsigned short id_status;
17232689Sbostic };
17332689Sbostic 
17432689Sbostic /* The following #defines provide more meaningful names for some of the
17532689Sbostic  * struct object fields that are used for monsters.  This, since each monster
17632689Sbostic  * and object (scrolls, potions, etc) are represented by a struct object.
17732689Sbostic  * Ideally, this should be handled by some kind of union structure.
17832689Sbostic  */
17932689Sbostic 
18032689Sbostic #define m_damage damage
18132689Sbostic #define hp_to_kill quantity
18232689Sbostic #define m_char ichar
18332689Sbostic #define first_level is_protected
18432689Sbostic #define last_level is_cursed
18532689Sbostic #define m_hit_chance class
18632689Sbostic #define stationary_damage identified
18732689Sbostic #define drop_percent which_kind
18832689Sbostic #define trail_char d_enchant
18932689Sbostic #define slowed_toggle quiver
19032689Sbostic #define moves_confused hit_enchant
19132689Sbostic #define nap_length picked_up
19232689Sbostic #define disguise what_is
19332689Sbostic #define next_monster next_object
19432689Sbostic 
19532689Sbostic struct obj {				/* comment is monster meaning */
19632689Sbostic 	unsigned long m_flags;	/* monster flags */
19732689Sbostic 	char *damage;			/* damage it does */
19832689Sbostic 	short quantity;			/* hit points to kill */
19932689Sbostic 	short ichar;			/* 'A' is for aquatar */
20032689Sbostic 	short kill_exp;			/* exp for killing it */
20132689Sbostic 	short is_protected;		/* level starts */
20232689Sbostic 	short is_cursed;		/* level ends */
20332689Sbostic 	short class;			/* chance of hitting you */
20432689Sbostic 	short identified;		/* 'F' damage, 1,2,3... */
20532689Sbostic 	unsigned short which_kind; /* item carry/drop % */
20632689Sbostic 	short o_row, o_col, o;	/* o is how many times stuck at o_row, o_col */
20732689Sbostic 	short row, col;			/* current row, col */
20832689Sbostic 	short d_enchant;		/* room char when detect_monster */
20932689Sbostic 	short quiver;			/* monster slowed toggle */
21032689Sbostic 	short trow, tcol;		/* target row, col */
21132689Sbostic 	short hit_enchant;		/* how many moves is confused */
21232689Sbostic 	unsigned short what_is;	/* imitator's charactor (?!%: */
21332689Sbostic 	short picked_up;		/* sleep from wand of sleep */
21432689Sbostic 	unsigned short in_use_flags;
21532689Sbostic 	struct obj *next_object;	/* next monster */
21632689Sbostic };
21732689Sbostic 
21832689Sbostic typedef struct obj object;
21932689Sbostic 
22032689Sbostic #define INIT_AW (object*)0,(object*)0
22132689Sbostic #define INIT_RINGS (object*)0,(object*)0
22232689Sbostic #define INIT_HP 12,12
22332689Sbostic #define INIT_STR 16,16
22432689Sbostic #define INIT_EXP 1,0
22532689Sbostic #define INIT_PACK {0}
22632689Sbostic #define INIT_GOLD 0
22732689Sbostic #define INIT_CHAR '@'
22832689Sbostic #define INIT_MOVES 1250
22932689Sbostic 
23032689Sbostic struct fightr {
23132689Sbostic 	object *armor;
23232689Sbostic 	object *weapon;
23332689Sbostic 	object *left_ring, *right_ring;
23432689Sbostic 	short hp_current;
23532689Sbostic 	short hp_max;
23632689Sbostic 	short str_current;
23732689Sbostic 	short str_max;
23832689Sbostic 	object pack;
23932689Sbostic 	long gold;
24032689Sbostic 	short exp;
24132689Sbostic 	long exp_points;
24232689Sbostic 	short row, col;
24332689Sbostic 	short fchar;
24432689Sbostic 	short moves_left;
24532689Sbostic };
24632689Sbostic 
24732689Sbostic typedef struct fightr fighter;
24832689Sbostic 
24932689Sbostic struct dr {
25032689Sbostic 	short oth_room;
25132689Sbostic 	short oth_row,
25232689Sbostic 	      oth_col;
25332689Sbostic 	short door_row,
25432689Sbostic 		  door_col;
25532689Sbostic };
25632689Sbostic 
25732689Sbostic typedef struct dr door;
25832689Sbostic 
25932689Sbostic struct rm {
26032689Sbostic 	short bottom_row, right_col, left_col, top_row;
26132689Sbostic 	door doors[4];
26232689Sbostic 	unsigned short is_room;
26332689Sbostic };
26432689Sbostic 
26532689Sbostic typedef struct rm room;
26632689Sbostic 
26732689Sbostic #define MAXROOMS 9
26832689Sbostic #define BIG_ROOM 10
26932689Sbostic 
27032689Sbostic #define NO_ROOM -1
27132689Sbostic 
27232689Sbostic #define PASSAGE -3		/* cur_room value */
27332689Sbostic 
27432689Sbostic #define AMULET_LEVEL 26
27532689Sbostic 
27632689Sbostic #define R_NOTHING	((unsigned short) 01)
27732689Sbostic #define R_ROOM		((unsigned short) 02)
27832689Sbostic #define R_MAZE		((unsigned short) 04)
27932689Sbostic #define R_DEADEND	((unsigned short) 010)
28032689Sbostic #define R_CROSS		((unsigned short) 020)
28132689Sbostic 
28232689Sbostic #define MAX_EXP_LEVEL 21
28332689Sbostic #define MAX_EXP 10000001L
28432689Sbostic #define MAX_GOLD 999999
28532689Sbostic #define MAX_ARMOR 99
28632689Sbostic #define MAX_HP 999
28732689Sbostic #define MAX_STRENGTH 99
28832689Sbostic #define LAST_DUNGEON 99
28932689Sbostic 
29032689Sbostic #define STAT_LEVEL 01
29132689Sbostic #define STAT_GOLD 02
29232689Sbostic #define STAT_HP 04
29332689Sbostic #define STAT_STRENGTH 010
29432689Sbostic #define STAT_ARMOR 020
29532689Sbostic #define STAT_EXP 040
29632689Sbostic #define STAT_HUNGER 0100
29732689Sbostic #define STAT_LABEL 0200
29832689Sbostic #define STAT_ALL 0377
29932689Sbostic 
30032689Sbostic #define PARTY_TIME 10	/* one party somewhere in each 10 level span */
30132689Sbostic 
30232689Sbostic #define MAX_TRAPS 10	/* maximum traps per level */
30332689Sbostic 
30432689Sbostic #define HIDE_PERCENT 12
30532689Sbostic 
30632689Sbostic struct tr {
30732689Sbostic 	short trap_type;
30832689Sbostic 	short trap_row, trap_col;
30932689Sbostic };
31032689Sbostic 
31132689Sbostic typedef struct tr trap;
31232689Sbostic 
31332689Sbostic extern fighter rogue;
31432689Sbostic extern room rooms[];
31532689Sbostic extern trap traps[];
31632689Sbostic extern unsigned short dungeon[DROWS][DCOLS];
31732689Sbostic extern object level_objects;
31832689Sbostic 
31932689Sbostic extern struct id id_scrolls[];
32032689Sbostic extern struct id id_potions[];
32132689Sbostic extern struct id id_wands[];
32232689Sbostic extern struct id id_rings[];
32332689Sbostic extern struct id id_weapons[];
32432689Sbostic extern struct id id_armors[];
32532689Sbostic 
32632689Sbostic extern object mon_tab[];
32732689Sbostic extern object level_monsters;
32832689Sbostic 
32932689Sbostic #define MONSTERS 26
33032689Sbostic 
33132689Sbostic #define HASTED					01L
33232689Sbostic #define SLOWED					02L
33332689Sbostic #define INVISIBLE				04L
33432689Sbostic #define ASLEEP				   010L
33532689Sbostic #define WAKENS				   020L
33632689Sbostic #define WANDERS				   040L
33732689Sbostic #define FLIES				  0100L
33832689Sbostic #define FLITS				  0200L
33932689Sbostic #define CAN_FLIT			  0400L		/* can, but usually doesn't, flit */
34032689Sbostic #define CONFUSED	 		 01000L
34132689Sbostic #define RUSTS				 02000L
34232689Sbostic #define HOLDS				 04000L
34332689Sbostic #define FREEZES				010000L
34432689Sbostic #define STEALS_GOLD			020000L
34532689Sbostic #define STEALS_ITEM			040000L
34632689Sbostic #define STINGS			   0100000L
34732689Sbostic #define DRAINS_LIFE		   0200000L
34832689Sbostic #define DROPS_LEVEL		   0400000L
34932689Sbostic #define SEEKS_GOLD		  01000000L
35032689Sbostic #define FREEZING_ROGUE	  02000000L
35132689Sbostic #define RUST_VANISHED	  04000000L
35232689Sbostic #define CONFUSES		 010000000L
35332689Sbostic #define IMITATES		 020000000L
35432689Sbostic #define FLAMES			 040000000L
35532689Sbostic #define STATIONARY		0100000000L		/* damage will be 1,2,3,... */
35632689Sbostic #define NAPPING			0200000000L		/* can't wake up for a while */
35732689Sbostic #define ALREADY_MOVED	0400000000L
35832689Sbostic 
35932689Sbostic #define SPECIAL_HIT		(RUSTS|HOLDS|FREEZES|STEALS_GOLD|STEALS_ITEM|STINGS|DRAINS_LIFE|DROPS_LEVEL)
36032689Sbostic 
36132689Sbostic #define WAKE_PERCENT 45
36232689Sbostic #define FLIT_PERCENT 40
36332689Sbostic #define PARTY_WAKE_PERCENT 75
36432689Sbostic 
36532689Sbostic #define HYPOTHERMIA 1
36632689Sbostic #define STARVATION 2
36732689Sbostic #define POISON_DART 3
36832689Sbostic #define QUIT 4
36932689Sbostic #define WIN 5
37032689Sbostic #define KFIRE 6
37132689Sbostic 
37232689Sbostic #define UPWARD 0
37332689Sbostic #define UPRIGHT 1
37432689Sbostic #define RIGHT 2
37532689Sbostic #define DOWNRIGHT 3
37632689Sbostic #define DOWN 4
37732689Sbostic #define DOWNLEFT 5
37832689Sbostic #define LEFT 6
37932689Sbostic #define UPLEFT 7
38032689Sbostic #define DIRS 8
38132689Sbostic 
38232689Sbostic #define ROW1 7
38332689Sbostic #define ROW2 15
38432689Sbostic 
38532689Sbostic #define COL1 26
38632689Sbostic #define COL2 52
38732689Sbostic 
38832689Sbostic #define MOVED 0
38932689Sbostic #define MOVE_FAILED -1
39032689Sbostic #define STOPPED_ON_SOMETHING -2
39132689Sbostic #define CANCEL '\033'
39232689Sbostic #define LIST '*'
39332689Sbostic 
39432689Sbostic #define HUNGRY 300
39532689Sbostic #define WEAK 150
39632689Sbostic #define FAINT 20
39732689Sbostic #define STARVE 0
39832689Sbostic 
39932689Sbostic #define MIN_ROW 1
40032689Sbostic 
40132689Sbostic /* external routine declarations.
40232689Sbostic  */
40332689Sbostic char *strcpy();
40432689Sbostic char *strncpy();
40532689Sbostic char *strcat();
40632689Sbostic 
40732689Sbostic char *mon_name();
40832689Sbostic char *get_ench_color();
40932689Sbostic char *name_of();
41032689Sbostic char *md_gln();
41132689Sbostic char *md_getenv();
41232689Sbostic char *md_malloc();
41332689Sbostic boolean is_direction();
41432689Sbostic boolean mon_sees();
41532689Sbostic boolean mask_pack();
41632689Sbostic boolean mask_room();
41732689Sbostic boolean is_digit();
41832689Sbostic boolean check_hunger();
41932689Sbostic boolean reg_move();
42032689Sbostic boolean md_df();
42132689Sbostic boolean has_been_touched();
42232689Sbostic object *add_to_pack();
42332689Sbostic object *alloc_object();
42432689Sbostic object *get_letter_object();
42532689Sbostic object *gr_monster();
42632689Sbostic object *get_thrown_at_monster();
42732689Sbostic object *get_zapped_monster();
42832689Sbostic object *check_duplicate();
42932689Sbostic object *gr_object();
43032689Sbostic object *object_at();
43132689Sbostic object *pick_up();
43232689Sbostic struct id *get_id_table();
43332689Sbostic unsigned short gr_what_is();
43432689Sbostic long rrandom();
43532689Sbostic long lget_number();
43632689Sbostic long xxx();
43746758Sbostic void byebye(), onintr(), error_save();
43832689Sbostic 
43932689Sbostic struct rogue_time {
44032689Sbostic 	short year;		/* >= 1987 */
44132689Sbostic 	short month;	/* 1 - 12 */
44232689Sbostic 	short day;		/* 1 - 31 */
44332689Sbostic 	short hour;		/* 0 - 23 */
44432689Sbostic 	short minute;	/* 0 - 59 */
44532689Sbostic 	short second;	/* 0 - 59 */
44632689Sbostic };
44732689Sbostic 
44832689Sbostic #ifdef CURSES
44932689Sbostic struct _win_st {
45032689Sbostic 	short _cury, _curx;
45132689Sbostic 	short _maxy, _maxx;
45232689Sbostic };
45332689Sbostic 
45432689Sbostic typedef struct _win_st WINDOW;
45532689Sbostic 
45632689Sbostic extern int LINES, COLS;
45732689Sbostic extern WINDOW *curscr;
45832689Sbostic extern char *CL;
45932689Sbostic 
46032689Sbostic char *md_gdtcf();
46132689Sbostic 
46232689Sbostic #else
46332689Sbostic #include <curses.h>
46432689Sbostic #endif
465