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