xref: /dragonfly/games/rogue/rogue.h (revision 267c04fd)
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  * Timothy 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. Neither the name of the University nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30  * SUCH DAMAGE.
31  *
32  *	@(#)rogue.h	8.1 (Berkeley) 5/31/93
33  * $FreeBSD: src/games/rogue/rogue.h,v 1.3.2.1 2001/12/17 12:43:23 phantom Exp $
34  */
35 
36 #include <curses.h>
37 #include <stdbool.h>
38 #include <stdlib.h>
39 #include <string.h>
40 
41 /*
42  * rogue.h
43  *
44  * This source herein may be modified and/or distributed by anybody who
45  * so desires, with the following restrictions:
46  *    1.)  This notice shall not be removed.
47  *    2.)  Credit shall not be taken for the creation of this source.
48  *    3.)  This code is not to be traded, sold, or used for personal
49  *         gain or profit.
50  */
51 
52 #define boolean bool
53 
54 #define NOTHING		((unsigned short)     0)
55 #define OBJECT		((unsigned short)    01)
56 #define MONSTER		((unsigned short)    02)
57 #define STAIRS		((unsigned short)    04)
58 #define HORWALL		((unsigned short)   010)
59 #define VERTWALL	((unsigned short)   020)
60 #define DOOR		((unsigned short)   040)
61 #define FLOOR		((unsigned short)  0100)
62 #define TUNNEL		((unsigned short)  0200)
63 #define TRAP		((unsigned short)  0400)
64 #define HIDDEN		((unsigned short) 01000)
65 
66 #define ARMOR		((unsigned short)   01)
67 #define WEAPON		((unsigned short)   02)
68 #define SCROL		((unsigned short)   04)
69 #define POTION		((unsigned short)  010)
70 #define GOLD		((unsigned short)  020)
71 #define FOOD		((unsigned short)  040)
72 #define WAND		((unsigned short) 0100)
73 #define RING		((unsigned short) 0200)
74 #define AMULET		((unsigned short) 0400)
75 #define ALL_OBJECTS	((unsigned short) 0777)
76 
77 #define LEATHER 0
78 #define RINGMAIL 1
79 #define SCALE 2
80 #define CHAIN 3
81 #define BANDED 4
82 #define SPLINT 5
83 #define PLATE 6
84 #define ARMORS 7
85 
86 #define BOW 0
87 #define DART 1
88 #define ARROW 2
89 #define DAGGER 3
90 #define SHURIKEN 4
91 #define MACE 5
92 #define LONG_SWORD 6
93 #define TWO_HANDED_SWORD 7
94 #define WEAPONS 8
95 
96 #define MAX_PACK_COUNT 24
97 
98 #define PROTECT_ARMOR 0
99 #define HOLD_MONSTER 1
100 #define ENCH_WEAPON 2
101 #define ENCH_ARMOR 3
102 #define IDENTIFY 4
103 #define TELEPORT 5
104 #define SLEEP 6
105 #define SCARE_MONSTER 7
106 #define REMOVE_CURSE 8
107 #define CREATE_MONSTER 9
108 #define AGGRAVATE_MONSTER 10
109 #define MAGIC_MAPPING 11
110 #define CON_MON 12
111 #define SCROLS 13
112 
113 #define INCREASE_STRENGTH 0
114 #define RESTORE_STRENGTH 1
115 #define HEALING 2
116 #define EXTRA_HEALING 3
117 #define POISON 4
118 #define RAISE_LEVEL 5
119 #define BLINDNESS 6
120 #define HALLUCINATION 7
121 #define DETECT_MONSTER 8
122 #define DETECT_OBJECTS 9
123 #define CONFUSION 10
124 #define LEVITATION 11
125 #define HASTE_SELF 12
126 #define SEE_INVISIBLE 13
127 #define POTIONS 14
128 
129 #define TELE_AWAY 0
130 #define SLOW_MONSTER 1
131 #define INVISIBILITY 2
132 #define POLYMORPH 3
133 #define HASTE_MONSTER 4
134 #define MAGIC_MISSILE 5
135 #define CANCELLATION 6
136 #define DO_NOTHING 7
137 #define DRAIN_LIFE 8
138 #define COLD 9
139 #define FIRE 10
140 #define WANDS 11
141 
142 #define STEALTH 0
143 #define R_TELEPORT 1
144 #define REGENERATION 2
145 #define SLOW_DIGEST 3
146 #define ADD_STRENGTH 4
147 #define SUSTAIN_STRENGTH 5
148 #define DEXTERITY 6
149 #define ADORNMENT 7
150 #define R_SEE_INVISIBLE 8
151 #define MAINTAIN_ARMOR 9
152 #define SEARCHING 10
153 #define RINGS 11
154 
155 #define RATION 0
156 #define FRUIT 1
157 
158 #define NOT_USED	((unsigned short)   0)
159 #define BEING_WIELDED	((unsigned short)  01)
160 #define BEING_WORN	((unsigned short)  02)
161 #define ON_LEFT_HAND	((unsigned short)  04)
162 #define ON_RIGHT_HAND	((unsigned short) 010)
163 #define ON_EITHER_HAND	((unsigned short) 014)
164 #define BEING_USED	((unsigned short) 017)
165 
166 #define NO_TRAP -1
167 #define TRAP_DOOR 0
168 #define BEAR_TRAP 1
169 #define TELE_TRAP 2
170 #define DART_TRAP 3
171 #define SLEEPING_GAS_TRAP 4
172 #define RUST_TRAP 5
173 #define TRAPS 6
174 
175 #define STEALTH_FACTOR 3
176 #define R_TELE_PERCENT 8
177 
178 #define UNIDENTIFIED	((unsigned short) 00)	/* MUST BE ZERO! */
179 #define IDENTIFIED	((unsigned short) 01)
180 #define CALLED		((unsigned short) 02)
181 
182 #define DROWS 24
183 #define DCOLS 80
184 #define NMESSAGES 5
185 #define MAX_TITLE_LENGTH 30
186 #define MAXSYLLABLES 40
187 #define MAX_METAL 14
188 #define WAND_MATERIALS 30
189 #define GEMS 14
190 
191 #define GOLD_PERCENT 46
192 
193 #define MAX_OPT_LEN 40
194 
195 #define HUNGER_STR_LEN 8
196 
197 #define MAX_ID_TITLE_LEN 64
198 
199 struct id {
200 	short value;
201 	char title[MAX_ID_TITLE_LEN];
202 	const char *real;
203 	unsigned short id_status;
204 };
205 
206 /* The following #defines provide more meaningful names for some of the
207  * struct object fields that are used for monsters.  This, since each monster
208  * and object (scrolls, potions, etc) are represented by a struct object.
209  * Ideally, this should be handled by some kind of union structure.
210  */
211 
212 #define m_damage damage
213 #define hp_to_kill quantity
214 #define m_char ichar
215 #define first_level is_protected
216 #define last_level is_cursed
217 #define m_hit_chance class
218 #define stationary_damage identified
219 #define drop_percent which_kind
220 #define trail_char d_enchant
221 #define slowed_toggle quiver
222 #define moves_confused hit_enchant
223 #define nap_length picked_up
224 #define disguise what_is
225 #define next_monster next_object
226 
227 struct obj {				/* comment is monster meaning */
228 	unsigned long m_flags;	/* monster flags */
229 	const char *damage;		/* damage it does */
230 	short quantity;			/* hit points to kill */
231 	short ichar;			/* 'A' is for aquatar */
232 	short kill_exp;			/* exp for killing it */
233 	short is_protected;		/* level starts */
234 	short is_cursed;		/* level ends */
235 	short class;			/* chance of hitting you */
236 	short identified;		/* 'F' damage, 1,2,3... */
237 	unsigned short which_kind; /* item carry/drop % */
238 	short o_row, o_col, o;	/* o is how many times stuck at o_row, o_col */
239 	short row, col;			/* current row, col */
240 	short d_enchant;		/* room char when detect_monster */
241 	short quiver;			/* monster slowed toggle */
242 	short trow, tcol;		/* target row, col */
243 	short hit_enchant;		/* how many moves is confused */
244 	unsigned short what_is;	/* imitator's charactor (?!%: */
245 	short picked_up;		/* sleep from wand of sleep */
246 	unsigned short in_use_flags;
247 	struct obj *next_object;	/* next monster */
248 };
249 
250 typedef struct obj object;
251 
252 #define INIT_AW		NULL,NULL
253 #define INIT_RINGS	NULL,NULL
254 #define INIT_HP		12
255 #define INIT_STR	16,16
256 #define INIT_EXP	1,0
257 #define INIT_PACK	{0,"",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,NULL}
258 #define INIT_GOLD	0
259 #define INIT_CHAR	'@'
260 #define INIT_MOVES	1250
261 
262 struct fightr {
263 	object *armor;
264 	object *weapon;
265 	object *left_ring, *right_ring;
266 	short hp_current;
267 	short hp_max;
268 	short str_current;
269 	short str_max;
270 	object pack;
271 	long gold;
272 	short exp;
273 	long exp_points;
274 	short row, col;
275 	short fchar;
276 	short moves_left;
277 };
278 
279 typedef struct fightr fighter;
280 
281 struct dr {
282 	short oth_room;
283 	short oth_row,
284 	      oth_col;
285 	short door_row,
286 		  door_col;
287 };
288 
289 typedef struct dr door;
290 
291 struct rm {
292 	short bottom_row, right_col, left_col, top_row;
293 	door doors[4];
294 	unsigned short is_room;
295 };
296 
297 typedef struct rm room;
298 
299 #define MAXROOMS 9
300 #define BIG_ROOM 10
301 
302 #define NO_ROOM (-1)
303 
304 #define PASSAGE (-3)		/* cur_room value */
305 
306 #define AMULET_LEVEL 26
307 
308 #define R_NOTHING	((unsigned short) 01)
309 #define R_ROOM		((unsigned short) 02)
310 #define R_MAZE		((unsigned short) 04)
311 #define R_DEADEND	((unsigned short) 010)
312 #define R_CROSS		((unsigned short) 020)
313 
314 #define MAX_EXP_LEVEL 21
315 #define MAX_EXP 10000001L
316 #define MAX_GOLD 999999
317 #define MAX_ARMOR 99
318 #define MAX_HP 999
319 #define MAX_STRENGTH 99
320 #define LAST_DUNGEON 99
321 
322 #define STAT_LEVEL 01
323 #define STAT_GOLD 02
324 #define STAT_HP 04
325 #define STAT_STRENGTH 010
326 #define STAT_ARMOR 020
327 #define STAT_EXP 040
328 #define STAT_HUNGER 0100
329 #define STAT_LABEL 0200
330 #define STAT_ALL 0377
331 
332 #define PARTY_TIME 10	/* one party somewhere in each 10 level span */
333 
334 #define MAX_TRAPS 10	/* maximum traps per level */
335 
336 #define HIDE_PERCENT 12
337 
338 struct tr {
339 	short trap_type;
340 	short trap_row, trap_col;
341 };
342 
343 typedef struct tr trap;
344 
345 extern fighter rogue;
346 extern room rooms[];
347 extern trap traps[];
348 extern unsigned short dungeon[DROWS][DCOLS];
349 extern object level_objects;
350 
351 extern struct id id_scrolls[];
352 extern struct id id_potions[];
353 extern struct id id_wands[];
354 extern struct id id_rings[];
355 extern struct id id_weapons[];
356 extern struct id id_armors[];
357 
358 extern object mon_tab[];
359 extern object level_monsters;
360 
361 #define MONSTERS 26
362 
363 #define HASTED					01L
364 #define SLOWED					02L
365 #define INVISIBLE				04L
366 #define ASLEEP				   010L
367 #define WAKENS				   020L
368 #define WANDERS				   040L
369 #define FLIES				  0100L
370 #define FLITS				  0200L
371 #define CAN_FLIT			  0400L		/* can, but usually doesn't, flit */
372 #define CONFUSED	 		 01000L
373 #define RUSTS				 02000L
374 #define HOLDS				 04000L
375 #define FREEZES				010000L
376 #define STEALS_GOLD			020000L
377 #define STEALS_ITEM			040000L
378 #define STINGS			   0100000L
379 #define DRAINS_LIFE		   0200000L
380 #define DROPS_LEVEL		   0400000L
381 #define SEEKS_GOLD		  01000000L
382 #define FREEZING_ROGUE	  02000000L
383 #define RUST_VANISHED	  04000000L
384 #define CONFUSES		 010000000L
385 #define IMITATES		 020000000L
386 #define FLAMES			 040000000L
387 #define STATIONARY		0100000000L		/* damage will be 1,2,3,... */
388 #define NAPPING			0200000000L		/* can't wake up for a while */
389 #define ALREADY_MOVED	0400000000L
390 
391 #define SPECIAL_HIT		(RUSTS|HOLDS|FREEZES|STEALS_GOLD|STEALS_ITEM|STINGS|DRAINS_LIFE|DROPS_LEVEL)
392 
393 #define WAKE_PERCENT 45
394 #define FLIT_PERCENT 40
395 #define PARTY_WAKE_PERCENT 75
396 
397 #define HYPOTHERMIA 1
398 #define STARVATION 2
399 #define POISON_DART 3
400 #define QUIT 4
401 #define WIN 5
402 #define KFIRE 6
403 
404 #define UPWARD 0
405 #define UPRIGHT 1
406 #define RIGHT 2
407 #define DOWNRIGHT 3
408 #define DOWN 4
409 #define DOWNLEFT 5
410 #define LEFT 6
411 #define UPLEFT 7
412 #define DIRS 8
413 
414 #define ROW1 7
415 #define ROW2 15
416 
417 #define COL1 26
418 #define COL2 52
419 
420 #define MOVED 0
421 #define MOVE_FAILED -1
422 #define STOPPED_ON_SOMETHING -2
423 #define CANCEL '\033'
424 #define LIST '*'
425 
426 #define HUNGRY 300
427 #define WEAK 150
428 #define FAINT 20
429 #define STARVE 0
430 
431 #define MIN_ROW 1
432 
433 struct rogue_time {
434 	short year;		/* >= 1987 */
435 	short month;	/* 1 - 12 */
436 	short day;		/* 1 - 31 */
437 	short hour;		/* 0 - 23 */
438 	short minute;	/* 0 - 59 */
439 	short second;	/* 0 - 59 */
440 };
441 
442 /* external routine declarations.
443  */
444 #define rrandom random
445 
446 /* hit.c */
447 void	mon_hit(object *);
448 void	rogue_hit(object *, boolean);
449 void	rogue_damage(short, object *, short);
450 int	get_damage(const char *, boolean);
451 int	get_number(const char *);
452 long	lget_number(const char *);
453 boolean	mon_damage(object *, short);
454 void	fight(boolean);
455 void	get_dir_rc(short, short *, short *, short);
456 short	get_hit_chance(const object *);
457 short	get_weapon_damage(const object *);
458 void	s_con_mon(object *);
459 
460 /* init.c */
461 boolean	init(int, char**);
462 void	clean_up(const char *);
463 void	start_window(void);
464 void	stop_window(void);
465 void	byebye(int);
466 void	onintr(int);
467 void	error_save(int);
468 
469 /* inventory.c */
470 void	inventory(const object *, unsigned short);
471 void	id_com(void);
472 void	mix_colors(void);
473 void	make_scroll_titles(void);
474 void	get_desc(const object *, char *);
475 void	get_wand_and_ring_materials(void);
476 void	single_inv(short);
477 struct id	*get_id_table(const object *);
478 void	inv_armor_weapon(boolean);
479 void	id_type(void);
480 
481 /* level.c */
482 void	make_level(void);
483 void	clear_level(void);
484 void	put_player(short);
485 boolean	drop_check(void);
486 boolean	check_up(void);
487 void	add_exp(int, boolean);
488 int	hp_raise(void);
489 void	show_average_hp(void);
490 
491 /* machdep.c */
492 #ifdef UNIX
493 void	md_slurp(void);
494 void	md_control_keybord(boolean);
495 void	md_heed_signals(void);
496 void	md_ignore_signals(void);
497 int	md_get_file_id(const char *);
498 int	md_link_count(const char *);
499 void	md_gct(struct rogue_time *);
500 void	md_gfmt(const char *, struct rogue_time *);
501 boolean	md_df(const char *);
502 const char	*md_gln(void);
503 void	md_sleep(int);
504 char	*md_getenv(const char *);
505 char	*md_malloc(int);
506 void	md_exit(int);
507 void	md_lock(boolean);
508 void	md_shell(const char *);
509 #endif
510 
511 /* message.c */
512 void	message(const char *, boolean);
513 void	remessage(short);
514 void	check_message(void);
515 short	get_input_line(const char *, const char *, char *,
516 		       const char *, boolean, boolean);
517 int	rgetchar(void);
518 void	print_stats(int);
519 void	sound_bell(void);
520 boolean	is_digit(short);
521 int	r_index(const char *, int, boolean);
522 
523 /* monster.c */
524 void	put_mons(void);
525 object	*gr_monster(object *, int);
526 void	mv_mons(void);
527 void	party_monsters(int, int);
528 short	gmc_row_col(int, int);
529 short	gmc(object *);
530 void	mv_1_monster(object *, short, short);
531 void	move_mon_to(object *, short, short);
532 boolean	mon_can_go(const object *, short, short);
533 void	wake_up(object *);
534 void	wake_room(short, boolean, short, short);
535 const char	*mon_name(const object *);
536 void	wanderer(void);
537 void	show_monsters(void);
538 void	create_monster(void);
539 int	rogue_can_see(int, int);
540 char	gr_obj_char(void);
541 void	aggravate(void);
542 boolean	mon_sees(const object *, int, int);
543 void	mv_aquatars(void);
544 
545 /* move.c */
546 short	one_move_rogue(short, short);
547 void	multiple_move_rogue(short);
548 boolean	is_passable(int, int);
549 boolean	can_move(short, short, short, short);
550 void	move_onto(void);
551 boolean	is_direction(short, short *);
552 boolean	reg_move(void);
553 void	rest(int);
554 
555 /* object.c */
556 void	put_objects(void);
557 void	place_at(object *, int, int);
558 object	*object_at(object *, short, short);
559 object	*get_letter_object(int);
560 void	free_stuff(object *);
561 const char	*name_of(const object *);
562 object	*gr_object(void);
563 void	get_food(object *, boolean);
564 void	put_stairs(void);
565 short	get_armor_class(const object *);
566 object	*alloc_object(void);
567 void	free_object(object *);
568 void	show_objects(void);
569 void	put_amulet(void);
570 void	c_object_for_wizard(void);
571 
572 /* pack.c */
573 object	*add_to_pack(object *, object *, int);
574 void	take_from_pack(object *, object *);
575 object	*pick_up(int, int, short *);
576 void	drop(void);
577 void	wait_for_ack(void);
578 short	pack_letter(const char *, unsigned short);
579 void	take_off(void);
580 void	wear(void);
581 void	unwear(object *);
582 void	do_wear(object *);
583 void	wield(void);
584 void	do_wield(object *);
585 void	unwield(object *);
586 void	call_it(void);
587 short	pack_count(const object *);
588 boolean	has_amulet(void);
589 void	kick_into_pack(void);
590 
591 /* play.c */
592 void	play_level(void);
593 
594 /* random.c */
595 int	get_rand(int, int);
596 boolean	rand_percent(int);
597 boolean	coin_toss(void);
598 
599 /* ring.c */
600 void	put_on_ring(void);
601 void	do_put_on(object *, boolean);
602 void	remove_ring(void);
603 void	un_put_on(object *);
604 void	gr_ring(object *, boolean);
605 void	inv_rings(void);
606 void	ring_stats(boolean);
607 
608 /* room.c */
609 void	light_up_room(int);
610 void	light_passage(int, int);
611 void	darken_room(short);
612 char	get_dungeon_char(int, int);
613 char	get_mask_char(unsigned short);
614 void	gr_row_col(short *, short *, unsigned short);
615 short	gr_room(void);
616 short	party_objects(short);
617 short	get_room_number(int, int);
618 boolean	is_all_connected(void);
619 void	draw_magic_map(void);
620 void	dr_course(object *, boolean, short, short);
621 void	edit_opts(void);
622 void	do_shell(void);
623 
624 /* save.c */
625 void	save_game(void);
626 void	save_into_file(const char *);
627 void	restore(const char *);
628 
629 /* score.c */
630 void	killed_by(const object *, short);
631 void	win(void);
632 void	quit(boolean);
633 void	put_scores(const object *, short);
634 boolean	is_vowel(short);
635 void	xxxx(char *, short);
636 long	xxx(boolean);
637 
638 /* spec_hit.c */
639 void	special_hit(object *);
640 void	rust(object *);
641 void	cough_up(object *);
642 boolean	seek_gold(object *);
643 void	check_gold_seeker(object *);
644 boolean	check_imitator(object *);
645 boolean	imitating(short, short);
646 boolean	m_confuse(object *);
647 boolean	flame_broil(object *);
648 
649 /* throw.c */
650 void	throw(void);
651 void	rand_around(short, short *, short *);
652 
653 /* trap.c */
654 void	trap_player(short, short);
655 void	add_traps(void);
656 void	id_trap(void);
657 void	show_traps(void);
658 void	search(short, boolean);
659 
660 /* use.c */
661 void	quaff(void);
662 void	read_scroll(void);
663 void	vanish(object *, short, object *);
664 void	eat(void);
665 void	tele(void);
666 void	hallucinate(void);
667 void	unhallucinate(void);
668 void	unblind(void);
669 void	relight(void);
670 void	take_a_nap(void);
671 void	cnfs(void);
672 void	unconfuse(void);
673 
674 /* zap.c */
675 void	zapp(void);
676 void	wizardize(void);
677 void	bounce(short, short, short, short, short);
678 
679 /*
680  * external variable declarations.
681  */
682 extern  char    hunger_str[HUNGER_STR_LEN];
683 extern  char    login_name[MAX_OPT_LEN];
684 extern  const char   *error_file;
685