1 /* $NetBSD: rogue.h,v 1.19 2008/01/14 03:50:02 dholland Exp $ */
4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)rogue.h 8.1 (Berkeley) 5/31/93
40 * This source herein may be modified and/or distributed by anybody who
41 * so desires, with the following restrictions:
42 * 1.) This notice shall not be removed.
43 * 2.) Credit shall not be taken for the creation of this source.
44 * 3.) This code is not to be traded, sold, or used for personal
50 #define NOTHING ((unsigned short) 0)
51 #define OBJECT ((unsigned short) 01)
52 #define MONSTER ((unsigned short) 02)
53 #define STAIRS ((unsigned short) 04)
54 #define HORWALL ((unsigned short) 010)
55 #define VERTWALL ((unsigned short) 020)
56 #define DOOR ((unsigned short) 040)
57 #define FLOOR ((unsigned short) 0100)
58 #define TUNNEL ((unsigned short) 0200)
59 #define TRAP ((unsigned short) 0400)
60 #define HIDDEN ((unsigned short) 01000)
62 #define ARMOR ((unsigned short) 01)
63 #define WEAPON ((unsigned short) 02)
64 #define SCROL ((unsigned short) 04)
65 #define POTION ((unsigned short) 010)
66 #define GOLD ((unsigned short) 020)
67 #define FOOD ((unsigned short) 040)
68 #define WAND ((unsigned short) 0100)
69 #define RING ((unsigned short) 0200)
70 #define AMULET ((unsigned short) 0400)
71 #define ALL_OBJECTS ((unsigned short) 0777)
89 #define TWO_HANDED_SWORD 7
92 #define MAX_PACK_COUNT 24
94 #define PROTECT_ARMOR 0
95 #define HOLD_MONSTER 1
101 #define SCARE_MONSTER 7
102 #define REMOVE_CURSE 8
103 #define CREATE_MONSTER 9
104 #define AGGRAVATE_MONSTER 10
105 #define MAGIC_MAPPING 11
109 #define INCREASE_STRENGTH 0
110 #define RESTORE_STRENGTH 1
112 #define EXTRA_HEALING 3
114 #define RAISE_LEVEL 5
116 #define HALLUCINATION 7
117 #define DETECT_MONSTER 8
118 #define DETECT_OBJECTS 9
120 #define LEVITATION 11
121 #define HASTE_SELF 12
122 #define SEE_INVISIBLE 13
126 #define SLOW_MONSTER 1
127 #define INVISIBILITY 2
129 #define HASTE_MONSTER 4
130 #define MAGIC_MISSILE 5
131 #define CANCELLATION 6
140 #define REGENERATION 2
141 #define SLOW_DIGEST 3
142 #define ADD_STRENGTH 4
143 #define SUSTAIN_STRENGTH 5
146 #define R_SEE_INVISIBLE 8
147 #define MAINTAIN_ARMOR 9
154 #define NOT_USED ((unsigned short) 0)
155 #define BEING_WIELDED ((unsigned short) 01)
156 #define BEING_WORN ((unsigned short) 02)
157 #define ON_LEFT_HAND ((unsigned short) 04)
158 #define ON_RIGHT_HAND ((unsigned short) 010)
159 #define ON_EITHER_HAND ((unsigned short) 014)
160 #define BEING_USED ((unsigned short) 017)
167 #define SLEEPING_GAS_TRAP 4
171 #define STEALTH_FACTOR 3
172 #define R_TELE_PERCENT 8
174 #define UNIDENTIFIED ((unsigned short) 00) /* MUST BE ZERO! */
175 #define IDENTIFIED ((unsigned short) 01)
176 #define CALLED ((unsigned short) 02)
181 #define MAX_TITLE_LENGTH 30
182 #define MAXSYLLABLES 40
184 #define WAND_MATERIALS 30
187 #define GOLD_PERCENT 46
189 #define MAX_OPT_LEN 40
191 #define MAX_ID_TITLE_LEN 64
194 char title
[MAX_ID_TITLE_LEN
];
196 unsigned short id_status
;
199 /* The following #defines provide more meaningful names for some of the
200 * struct object fields that are used for monsters. This, since each monster
201 * and object (scrolls, potions, etc) are represented by a struct object.
202 * Ideally, this should be handled by some kind of union structure.
205 #define m_damage damage
206 #define hp_to_kill quantity
208 #define first_level is_protected
209 #define last_level is_cursed
210 #define m_hit_chance class
211 #define stationary_damage identified
212 #define drop_percent which_kind
213 #define trail_char d_enchant
214 #define slowed_toggle quiver
215 #define moves_confused hit_enchant
216 #define nap_length picked_up
217 #define disguise what_is
218 #define next_monster next_object
220 struct obj
{ /* comment is monster meaning */
221 unsigned long m_flags
; /* monster flags */
222 const char *damage
; /* damage it does */
223 short quantity
; /* hit points to kill */
224 short ichar
; /* 'A' is for aquatar */
225 short kill_exp
; /* exp for killing it */
226 short is_protected
; /* level starts */
227 short is_cursed
; /* level ends */
228 short class; /* chance of hitting you */
229 short identified
; /* 'F' damage, 1,2,3... */
230 unsigned short which_kind
; /* item carry/drop % */
231 short o_row
, o_col
, o
; /* o is how many times stuck at o_row, o_col */
232 short row
, col
; /* current row, col */
233 short d_enchant
; /* room char when detect_monster */
234 short quiver
; /* monster slowed toggle */
235 short trow
, tcol
; /* target row, col */
236 short hit_enchant
; /* how many moves is confused */
237 unsigned short what_is
; /* imitator's charactor (?!%: */
238 short picked_up
; /* sleep from wand of sleep */
239 unsigned short in_use_flags
;
240 struct obj
*next_object
; /* next monster */
243 typedef struct obj object
;
246 #define INIT_RINGS NULL
249 #define INIT_EXPLEVEL 1
251 #define INIT_PACK {0}
253 #define INIT_CHAR '@'
254 #define INIT_MOVES 1250
259 object
*left_ring
, *right_ring
;
273 typedef struct fightr fighter
;
283 typedef struct dr door
;
286 short bottom_row
, right_col
, left_col
, top_row
;
288 unsigned short is_room
;
291 typedef struct rm room
;
298 #define PASSAGE (-3) /* cur_room value */
300 #define AMULET_LEVEL 26
302 #define R_NOTHING ((unsigned short) 01)
303 #define R_ROOM ((unsigned short) 02)
304 #define R_MAZE ((unsigned short) 04)
305 #define R_DEADEND ((unsigned short) 010)
306 #define R_CROSS ((unsigned short) 020)
308 #define MAX_EXP_LEVEL 21
309 #define MAX_EXP 10000001L
310 #define MAX_GOLD 999999
313 #define MAX_STRENGTH 99
314 #define LAST_DUNGEON 99
316 #define STAT_LEVEL 01
319 #define STAT_STRENGTH 010
320 #define STAT_ARMOR 020
322 #define STAT_HUNGER 0100
323 #define STAT_LABEL 0200
324 #define STAT_ALL 0377
326 #define PARTY_TIME 10 /* one party somewhere in each 10 level span */
328 #define MAX_TRAPS 10 /* maximum traps per level */
330 #define HIDE_PERCENT 12
334 short trap_row
, trap_col
;
337 typedef struct tr trap
;
339 extern fighter rogue
;
342 extern unsigned short dungeon
[DROWS
][DCOLS
];
343 extern object level_objects
;
345 extern struct id id_scrolls
[];
346 extern struct id id_potions
[];
347 extern struct id id_wands
[];
348 extern struct id id_rings
[];
349 extern struct id id_weapons
[];
350 extern struct id id_armors
[];
352 extern object level_monsters
;
358 #define INVISIBLE 04L
364 #define CAN_FLIT 0400L /* can, but usually doesn't, flit */
365 #define CONFUSED 01000L
368 #define FREEZES 010000L
369 #define STEALS_GOLD 020000L
370 #define STEALS_ITEM 040000L
371 #define STINGS 0100000L
372 #define DRAINS_LIFE 0200000L
373 #define DROPS_LEVEL 0400000L
374 #define SEEKS_GOLD 01000000L
375 #define FREEZING_ROGUE 02000000L
376 #define RUST_VANISHED 04000000L
377 #define CONFUSES 010000000L
378 #define IMITATES 020000000L
379 #define FLAMES 040000000L
380 #define STATIONARY 0100000000L /* damage will be 1,2,3,... */
381 #define NAPPING 0200000000L /* can't wake up for a while */
382 #define ALREADY_MOVED 0400000000L
384 #define SPECIAL_HIT (RUSTS|HOLDS|FREEZES|STEALS_GOLD|STEALS_ITEM|STINGS|DRAINS_LIFE|DROPS_LEVEL)
386 #define WAKE_PERCENT 45
387 #define FLIT_PERCENT 40
388 #define PARTY_WAKE_PERCENT 75
390 #define HYPOTHERMIA 1
392 #define POISON_DART 3
414 #define MOVE_FAILED -1
415 #define STOPPED_ON_SOMETHING -2
416 #define CANCEL '\033'
427 short year
; /* >= 1987 */
428 short month
; /* 1 - 12 */
429 short day
; /* 1 - 31 */
430 short hour
; /* 0 - 23 */
431 short minute
; /* 0 - 59 */
432 short second
; /* 0 - 59 */
438 * external routine declarations.
442 #include <sys/types.h>
445 object
*alloc_object(void);
446 object
*get_letter_object(int);
447 object
*gr_monster(object
*, int);
448 object
*gr_object(void);
449 char *md_getenv(const char *);
452 void *md_malloc(size_t);
453 const char *mon_name(const object
*);
454 const char *name_of(const object
*);
455 object
*object_at(object
*, short, short);
456 object
*pick_up(int, int, short *);
457 void add_exp(int, boolean
);
458 void add_traps(void);
459 void aggravate(void);
460 void bounce(short, short, short, short, short);
462 void c_object_for_wizard(void);
464 boolean
can_move(int, int, int, int);
465 void check_gold_seeker(object
*);
466 boolean
check_imitator(object
*);
467 void check_message(void);
469 void clean_up(const char *) __attribute__((__noreturn__
));
470 void clear_level(void);
473 void cough_up(object
*);
474 void create_monster(void);
475 void darken_room(short);
476 void do_put_on(object
*, boolean
);
478 void do_wear(object
*);
479 void do_wield(object
*);
480 void dr_course(object
*, boolean
, short, short);
481 void draw_magic_map(void);
483 int drop_check(void);
485 void edit_opts(void);
486 void error_save(int) __attribute__((__noreturn__
));
488 boolean
flame_broil(object
*);
489 void free_object(object
*);
490 void free_stuff(object
*);
491 int get_armor_class(const object
*);
492 int get_damage(const char *, boolean
);
493 void get_desc(const object
*, char *, size_t);
494 void get_dir_rc(short, short *, short *, short);
495 char get_dungeon_char(short, short);
496 void get_food(object
*, boolean
);
497 int get_hit_chance(const object
*);
498 int get_input_line(const char *, const char *, char *, size_t, const char *, boolean
, boolean
);
499 char get_mask_char(unsigned short);
500 int get_number(const char *);
501 int get_rand(int, int);
502 short get_room_number(int, int);
503 void get_wand_and_ring_materials(void);
504 int get_weapon_damage(const object
*);
506 char gmc_row_col(int, int);
507 char gr_obj_char(void);
508 void gr_ring(object
*, boolean
);
510 void gr_row_col(short *, short *, unsigned short);
511 void hallucinate(void);
512 boolean
has_amulet(void);
517 boolean
imitating(short, short);
518 int init(int, char **);
519 void insert_score(char [][82], char [][30], const char *, short, short, const object
*, int);
520 void inv_armor_weapon(boolean
);
521 void inv_rings(void);
522 void inventory(const object
*, unsigned short);
523 boolean
is_all_connected(void);
524 boolean
is_digit(int);
525 boolean
is_direction(short, short *);
526 boolean
is_passable(int, int);
527 boolean
is_vowel(short);
528 void kick_into_pack(void);
529 void killed_by(const object
*, short) __attribute__((__noreturn__
));
530 long lget_number(const char *);
531 void light_passage(int, int);
532 void light_up_room(int);
533 boolean
m_confuse(object
*);
534 void make_level(void);
535 void make_scroll_titles(void);
536 boolean
md_df(const char *);
537 void md_exit(int) __attribute__((__noreturn__
));
538 void md_gct(struct rogue_time
*);
539 int md_get_file_id(const char *);
540 void md_gfmt(const char *, struct rogue_time
*);
542 void md_heed_signals(void);
543 void md_ignore_signals(void);
544 int md_link_count(const char *);
545 void md_lock(boolean
);
546 void md_shell(const char *);
549 /*void message(const char *, boolean);*/
550 void messagef(boolean
, const char *, ...)
551 __attribute__((__format__(__printf__
, 2, 3)));
552 void mix_colors(void);
553 int mon_can_go(const object
*, short, short);
554 int mon_damage(object
*, short);
555 void mon_hit(object
*);
556 boolean
mon_sees(const object
*, int, int);
557 void move_mon_to(object
*, short, short);
558 void move_onto(void);
559 void multiple_move_rogue(short);
560 void mv_1_monster(object
*, short, short);
561 void mv_aquatars(void);
563 int name_cmp(char *, const char *);
564 void nickize(char *, const char *, const char *);
565 int one_move_rogue(short, short);
567 short pack_count(const object
*);
568 short pack_letter(const char *, unsigned short);
569 void pad(const char *, short);
570 void party_monsters(int, int);
571 short party_objects(int);
572 void place_at(object
*, int, int);
573 void play_level(void);
574 void print_stats(int);
575 void put_amulet(void);
577 void put_objects(void);
578 void put_on_ring(void);
579 void put_player(short);
580 void put_scores(const object
*, short) __attribute__((__noreturn__
));
581 void put_stairs(void);
584 int r_index(const char *, int, boolean
);
585 void rand_around(short, short *, short *);
586 int rand_percent(int);
587 void read_scroll(void);
588 boolean
reg_move(void);
590 void remessage(short);
591 void remove_ring(void);
593 void restore(const char *);
595 void ring_stats(boolean
);
596 int rogue_can_see(int, int);
597 void rogue_damage(short, object
*, short);
598 void rogue_hit(object
*, boolean
);
600 void s_con_mon(object
*);
601 void save_game(void);
602 void save_into_file(const char *);
603 void search(short, boolean
);
604 boolean
seek_gold(object
*);
605 void show_average_hp(void);
606 void show_monsters(void);
607 void show_objects(void);
608 void show_traps(void);
609 void single_inv(short);
610 void sound_bell(void);
611 void special_hit(object
*);
613 void start_window(void);
614 void stop_window(void);
615 void take_a_nap(void);
616 void take_from_pack(object
*, object
*);
620 void trap_player(short, short);
621 void un_put_on(object
*);
623 void unconfuse(void);
624 void unhallucinate(void);
625 void unwear(object
*);
626 void unwield(object
*);
627 void vanish(object
*, short, object
*);
628 void wait_for_ack(void);
629 void wake_room(short, boolean
, short, short);
630 void wake_up(object
*);
634 void win(void) __attribute__((__noreturn__
));
635 void wizardize(void);
637 void xxxx(char *, short);
639 object
*add_to_pack(object
*, object
*, int);
640 struct id
*get_id_table(const object
*);
642 extern boolean ask_quit
;
643 extern boolean being_held
;
644 extern boolean cant_int
;
645 extern boolean con_mon
;
646 extern boolean detect_monster
;
647 extern boolean did_int
;
648 extern boolean interrupted
;
649 extern boolean is_wood
[];
651 extern boolean maintain_armor
;
652 extern boolean mon_disappeared
;
653 extern boolean msg_cleared
;
654 extern boolean no_skull
;
655 extern boolean passgo
;
656 extern boolean r_see_invisible
;
657 extern boolean r_teleport
;
658 extern boolean save_is_interactive
;
659 extern boolean score_only
;
660 extern boolean see_invisible
;
661 extern boolean sustain_strength
;
662 extern boolean trap_door
;
663 extern boolean wizard
;
664 #define HIT_MESSAGE_SIZE 80
665 extern char hit_message
[HIT_MESSAGE_SIZE
];
666 #define HUNGER_STR_LEN 8
667 extern char hunger_str
[HUNGER_STR_LEN
];
668 extern char login_name
[MAX_OPT_LEN
];
669 extern const char *byebye_string
;
670 extern const char *curse_message
;
671 extern const char *error_file
;
673 extern const char *const m_names
[];
674 extern const char *more
;
675 extern const char *new_level_message
;
676 extern char *nick_name
;
677 extern const char *press_space
;
678 extern char *save_file
;
679 extern const char *you_can_move_again
;
680 extern const long level_points
[];
681 extern short add_strength
;
682 extern short auto_search
;
683 extern short bear_trap
;
685 extern short confused
;
686 extern short cur_level
;
687 extern short cur_room
;
688 extern short e_rings
;
689 extern short extra_hp
;
692 extern short haste_self
;
693 extern short less_hp
;
694 extern short levitate
;
695 extern short m_moves
;
696 extern short max_level
;
697 extern short party_room
;
698 extern short r_rings
;
699 extern short regeneration
;
700 extern short ring_exp
;
701 extern short stealthy
;