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