1 /* 2 * rogue.h 3 * 4 * This source herein may be modified and/or distributed by anybody who 5 * so desires, with the following restrictions: 6 * 1.) This notice shall not be removed. 7 * 2.) Credit shall not be taken for the creation of this source. 8 * 3.) This code is not to be traded, sold, or used for personal 9 * gain or profit. 10 * 11 */ 12 13 #ifndef CURSES 14 #ifdef NeXT /* by Yasha (for NeXT jcurses) */ 15 #include "jcurses.h" /* by Yasha (for NeXT jcurses) */ 16 #else 17 #include <curses.h> 18 #endif 19 #endif /*CURSES*/ 20 21 #ifdef MSDOS 22 #undef getchar 23 #undef putchar 24 #define fflush(p) 25 #endif 26 27 #if 0 28 #ifndef ORIGINAL 29 typedef unsigned char uchar; 30 #define char uchar 31 #endif 32 #endif 33 34 #define boolean char 35 36 #define NOTHING ((unsigned short) 0) 37 #define OBJECT ((unsigned short) 01) 38 #define MONSTER ((unsigned short) 02) 39 #define STAIRS ((unsigned short) 04) 40 #define HORWALL ((unsigned short) 010) 41 #define VERTWALL ((unsigned short) 020) 42 #define DOOR ((unsigned short) 040) 43 #define FLOOR ((unsigned short) 0100) 44 #define TUNNEL ((unsigned short) 0200) 45 #define TRAP ((unsigned short) 0400) 46 #define HIDDEN ((unsigned short) 01000) 47 48 #define GOLD ((unsigned short) 01) 49 #define FOOD ((unsigned short) 02) 50 #define ARMOR ((unsigned short) 04) 51 #define WEAPON ((unsigned short) 010) 52 #define SCROL ((unsigned short) 020) 53 #define POTION ((unsigned short) 040) 54 #define WAND ((unsigned short) 0100) 55 #define RING ((unsigned short) 0200) 56 #define AMULET ((unsigned short) 0400) 57 #define ALL_OBJECTS ((unsigned short) 0777) 58 59 #define LEATHER 0 60 #define RINGMAIL 1 61 #define SCALE 2 62 #define CHAIN 3 63 #define BANDED 4 64 #define SPLINT 5 65 #define PLATE 6 66 #define ARMORS 7 67 68 #define BOW 0 69 #define DART 1 70 #define ARROW 2 71 #define DAGGER 3 72 #define SHURIKEN 4 73 #define MACE 5 74 #define LONG_SWORD 6 75 #define TWO_HANDED_SWORD 7 76 #define WEAPONS 8 77 78 #define MAX_PACK_COUNT 24 79 80 #define PROTECT_ARMOR 0 81 #define HOLD_MONSTER 1 82 #define ENCH_WEAPON 2 83 #define ENCH_ARMOR 3 84 #define IDENTIFY 4 85 #define TELEPORT 5 86 #define SLEEP 6 87 #define SCARE_MONSTER 7 88 #define REMOVE_CURSE 8 89 #define CREATE_MONSTER 9 90 #define AGGRAVATE_MONSTER 10 91 #define MAGIC_MAPPING 11 92 #define SCROLS 12 93 94 #define INCREASE_STRENGTH 0 95 #define RESTORE_STRENGTH 1 96 #define HEALING 2 97 #define EXTRA_HEALING 3 98 #define POISON 4 99 #define RAISE_LEVEL 5 100 #define BLINDNESS 6 101 #define HALLUCINATION 7 102 #define DETECT_MONSTER 8 103 #define DETECT_OBJECTS 9 104 #define CONFUSION 10 105 #define LEVITATION 11 106 #define HASTE_SELF 12 107 #define SEE_INVISIBLE 13 108 #define POTIONS 14 109 110 #define TELE_AWAY 0 111 #define SLOW_MONSTER 1 112 #define CONFUSE_MONSTER 2 113 #define INVISIBILITY 3 114 #define POLYMORPH 4 115 #define HASTE_MONSTER 5 116 #define PUT_TO_SLEEP 6 117 #define MAGIC_MISSILE 7 118 #define CANCELLATION 8 119 #define DO_NOTHING 9 120 #define WANDS 10 121 122 #define STEALTH 0 123 #define R_TELEPORT 1 124 #define REGENERATION 2 125 #define SLOW_DIGEST 3 126 #define ADD_STRENGTH 4 127 #define SUSTAIN_STRENGTH 5 128 #define DEXTERITY 6 129 #define ADORNMENT 7 130 #define R_SEE_INVISIBLE 8 131 #define MAINTAIN_ARMOR 9 132 #define SEARCHING 10 133 #define RINGS 11 134 135 #define RATION 0 136 #define FRUIT 1 137 138 #define NOT_USED ((unsigned short) 0) 139 #define BEING_WIELDED ((unsigned short) 01) 140 #define BEING_WORN ((unsigned short) 02) 141 #define ON_LEFT_HAND ((unsigned short) 04) 142 #define ON_RIGHT_HAND ((unsigned short) 010) 143 #define ON_EITHER_HAND ((unsigned short) 014) 144 #define BEING_USED ((unsigned short) 017) 145 146 #define NO_TRAP -1 147 #define TRAP_DOOR 0 148 #define BEAR_TRAP 1 149 #define TELE_TRAP 2 150 #define DART_TRAP 3 151 #define SLEEPING_GAS_TRAP 4 152 #define RUST_TRAP 5 153 #define TRAPS 6 154 155 #define STEALTH_FACTOR 3 156 #define R_TELE_PERCENT 8 157 158 #define UNIDENTIFIED ((unsigned short) 00) /* MUST BE ZERO! */ 159 #define IDENTIFIED ((unsigned short) 01) 160 #define CALLED ((unsigned short) 02) 161 162 #define DROWS 24 163 #define DCOLS 80 164 #define MAX_TITLE_LENGTH 30 165 #define MAXSYLLABLES 40 166 #define MAX_METAL 14 167 #define WAND_MATERIALS 30 168 #define GEMS 14 169 170 #define GOLD_PERCENT 46 171 172 struct id { 173 short value; 174 char *title; 175 char *real; 176 unsigned short id_status; 177 }; 178 179 /* The following #defines provide more meaningful names for some of the 180 * struct object fields that are used for monsters. This, since each monster 181 * and object (scrolls, potions, etc) are represented by a struct object. 182 * Ideally, this should be handled by some kind of union structure. 183 */ 184 185 #define m_damage damage 186 #define hp_to_kill quantity 187 #define m_char ichar 188 #define first_level is_protected 189 #define last_level is_cursed 190 #define m_hit_chance class 191 #define stationary_damage identified 192 #define drop_percent which_kind 193 #define trail_char d_enchant 194 #define slowed_toggle quiver 195 #define moves_confused hit_enchant 196 #define nap_length picked_up 197 #define disguise what_is 198 #define next_monster next_object 199 200 struct obj { /* comment is monster meaning */ 201 unsigned long m_flags; /* monster flags */ 202 char *damage; /* damage it does */ 203 short quantity; /* hit points to kill */ 204 short ichar; /* 'A' is for aquatar */ 205 short kill_exp; /* exp for killing it */ 206 short is_protected; /* level starts */ 207 short is_cursed; /* level ends */ 208 short class; /* chance of hitting you */ 209 short identified; /* 'F' damage, 1,2,3... */ 210 unsigned short which_kind; /* item carry/drop % */ 211 short o_row, o_col, o; /* o is how many times stuck at o_row, o_col */ 212 short row, col; /* current row, col */ 213 short d_enchant; /* room char when detect_monster */ 214 short quiver; /* monster slowed toggle */ 215 short trow, tcol; /* target row, col */ 216 short hit_enchant; /* how many moves is confused */ 217 unsigned short what_is; /* imitator's charactor (?!%: */ 218 short picked_up; /* sleep from wand of sleep */ 219 unsigned short in_use_flags; 220 struct obj *next_object; /* next monster */ 221 }; 222 223 typedef struct obj object; 224 225 #define INIT_HP 12 226 227 struct fight { 228 object *armor; 229 object *weapon; 230 object *left_ring, *right_ring; 231 short hp_current; 232 short hp_max; 233 short str_current; 234 short str_max; 235 object pack; 236 long gold; 237 short exp; 238 long exp_points; 239 short row, col; 240 short fchar; 241 short moves_left; 242 }; 243 244 typedef struct fight fighter; 245 246 struct dr { 247 short oth_room; 248 short oth_row, 249 oth_col; 250 short door_row, 251 door_col; 252 }; 253 254 typedef struct dr door; 255 256 struct rm { 257 char bottom_row, right_col, left_col, top_row; 258 door doors[4]; 259 unsigned short is_room; 260 }; 261 262 typedef struct rm room; 263 264 #define MAXROOMS 9 265 #define BIG_ROOM 10 266 267 #define NO_ROOM -1 268 269 #define PASSAGE -3 /* cur_room value */ 270 271 #define AMULET_LEVEL 26 272 273 #define R_NOTHING ((unsigned short) 01) 274 #define R_ROOM ((unsigned short) 02) 275 #define R_MAZE ((unsigned short) 04) 276 #define R_DEADEND ((unsigned short) 010) 277 #define R_CROSS ((unsigned short) 020) 278 279 #define MAX_EXP_LEVEL 21 280 #define MAX_EXP 10000000L 281 #define MAX_GOLD 900000 282 #define MAX_ARMOR 99 283 #define MAX_HP 800 284 #define MAX_STRENGTH 99 285 #define LAST_DUNGEON 99 286 287 #define STAT_LEVEL 01 288 #define STAT_GOLD 02 289 #define STAT_HP 04 290 #define STAT_STRENGTH 010 291 #define STAT_ARMOR 020 292 #define STAT_EXP 040 293 #define STAT_HUNGER 0100 294 #define STAT_LABEL 0200 295 #define STAT_ALL 0377 296 297 #define PARTY_TIME 10 /* one party somewhere in each 10 level span */ 298 299 #define MAX_TRAPS 10 /* maximum traps per level */ 300 301 #define HIDE_PERCENT 12 302 303 struct tr { 304 short trap_type; 305 short trap_row, trap_col; 306 }; 307 308 typedef struct tr trap; 309 310 extern fighter rogue; 311 extern room rooms[]; 312 extern trap traps[]; 313 extern unsigned short dungeon[DROWS][DCOLS]; 314 extern object level_objects; 315 extern char descs[DROWS][DCOLS]; 316 317 extern struct id id_scrolls[]; 318 extern struct id id_potions[]; 319 extern struct id id_wands[]; 320 extern struct id id_rings[]; 321 extern struct id id_weapons[]; 322 extern struct id id_armors[]; 323 324 extern object mon_tab[]; 325 extern object level_monsters; 326 327 extern char mesg[][80]; 328 329 #define MONSTERS 26 330 331 #define HASTED 01L 332 #define SLOWED 02L 333 #define INVISIBLE 04L 334 #define ASLEEP 010L 335 #define WAKENS 020L 336 #define WANDERS 040L 337 #define FLIES 0100L 338 #define FLITS 0200L 339 #define CAN_FLIT 0400L /* can, but usually doesn't, flit */ 340 #define CONFUSED 01000L 341 #define RUSTS 02000L 342 #define HOLDS 04000L 343 #define FREEZES 010000L 344 #define STEALS_GOLD 020000L 345 #define STEALS_ITEM 040000L 346 #define STINGS 0100000L 347 #define DRAINS_LIFE 0200000L 348 #define DROPS_LEVEL 0400000L 349 #define SEEKS_GOLD 01000000L 350 #define FREEZING_ROGUE 02000000L 351 #define RUST_VANISHED 04000000L 352 #define CONFUSES 010000000L 353 #define IMITATES 020000000L 354 #define FLAMES 040000000L 355 #define STATIONARY 0100000000L /* damage will be 1,2,3,... */ 356 #define NAPPING 0200000000L /* can't wake up for a while */ 357 #define ALREADY_MOVED 0400000000L 358 359 #define SPECIAL_HIT (RUSTS|HOLDS|FREEZES|STEALS_GOLD|STEALS_ITEM|STINGS|DRAINS_LIFE|DROPS_LEVEL) 360 361 #define WAKE_PERCENT 45 362 #define FLIT_PERCENT 33 363 #define PARTY_WAKE_PERCENT 75 364 365 #define HYPOTHERMIA 1 366 #define STARVATION 2 367 #define POISON_DART 3 368 #define QUIT 4 369 #define WIN 5 370 371 #define UPWARD 0 372 #define UPRIGHT 1 373 #define RIGHT 2 374 #define RIGHTDOWN 3 375 #define DOWN 4 376 #define DOWNLEFT 5 377 #define LEFT 6 378 #define LEFTUP 7 379 #define DIRS 8 380 381 #define ROW1 7 382 #define ROW2 15 383 384 #define COL1 26 385 #define COL2 52 386 387 #define MOVED 0 388 #define MOVE_FAILED -1 389 #define STOPPED_ON_SOMETHING -2 390 #define CANCEL '\033' 391 #define LIST '*' 392 393 #define HUNGRY 300 394 #define WEAK 150 395 #define FAINT 20 396 #define STARVE 0 397 398 #define MIN_ROW 1 399 400 /* external routine declarations. 401 */ 402 char *strcpy(); 403 char *strncpy(); 404 char *strcat(); 405 406 char *mon_name(); 407 char *get_ench_color(); 408 char *name_of(); 409 char *md_gln(); 410 char *md_getenv(); 411 char *md_malloc(); 412 #ifndef ORIGINAL 413 char *md_getcwd(); 414 #endif 415 boolean is_direction(); 416 boolean mon_sees(); 417 boolean mask_pack(); 418 boolean mask_room(); 419 boolean is_digit(); 420 boolean check_hunger(); 421 boolean reg_move(); 422 boolean md_df(); 423 boolean has_been_touched(); 424 object *add_to_pack(); 425 object *alloc_object(); 426 object *get_letter_object(); 427 object *gr_monster(); 428 object *get_thrown_at_monster(); 429 object *get_zapped_monster(); 430 object *check_duplicate(); 431 object *gr_object(); 432 object *object_at(); 433 object *pick_up(); 434 struct id *get_id_table(); 435 unsigned short gr_what_is(); 436 long rrandom(); 437 long lget_number(); 438 long xxx(); 439 int byebye(), error_save(); 440 #ifdef MSDOS 441 #if defined(__TURBOC__) && __TURBOC__ < 0x0200 442 int onintr(), ignintr(); 443 #else 444 void onintr(); 445 #endif 446 #else 447 int onintr(); 448 #endif 449 450 void addch(int ch); 451 void put_cursor(int row, int col); 452 void mon_hit(object *monster, char *other, boolean flame); 453 void rogue_hit(object *monster, boolean force_hit); 454 void fight(boolean to_the_death); 455 void set_opts(char *env); 456 void inventory(object *pack, unsigned short mask); 457 void get_desc(object *obj, char *desc, boolean capitalized); 458 void single_inv(short ichar); 459 void discovered(); 460 void message(char *msg, boolean intrpt); 461 void check_message(); 462 void mv_mons(); 463 void mv_monster(object *monster, short row, short col); 464 void show_monsters(); 465 void heal(); 466 void put_objects(); 467 void gr_scroll(object *obj); 468 void gr_potion(object *obj); 469 void new_object_for_wizard(); 470 void list_object(object *obj, short max); 471 void drop(); 472 void wear(); 473 void wield(); 474 void call_it(); 475 void play_level(); 476 void identify(); 477 void put_on_ring(); 478 void light_passage(int row, int col); 479 void dr_course(object *monster, boolean entering, short row, short col); 480 void save_game(); 481 void quit(boolean from_intrpt); 482 void nickize(char *buf, char *score, char *n_name); 483 void special_hit(object *monster); 484 void rust(object *monster); 485 void freeze(object *monster); 486 void steal_gold(object *monster); 487 void steal_item(object *monster); 488 void cough_up(object *monster); 489 void sting(object *monster); 490 void drop_level(); 491 void drain_life(); 492 void throw(); 493 void trap_player(short row, short col); 494 void id_trap(); 495 void search(short n, boolean is_auto); 496 void quaff(); 497 void read_scroll(); 498 void idntfy(); 499 void eat(); 500 void hallucinate(); 501 void zapp(); 502 503 struct rogue_time { 504 short year; /* >= 1987 */ 505 short month; /* 1 - 12 */ 506 short day; /* 1 - 31 */ 507 short hour; /* 0 - 23 */ 508 short minute; /* 0 - 59 */ 509 short second; /* 0 - 59 */ 510 }; 511 512 #ifndef ORIGINAL 513 typedef struct sopt { 514 char *name; /* option name */ 515 boolean *bp; /* boolean ptr */ 516 char **cp; /* string ptr */ 517 boolean ab; /* add blank */ 518 boolean nc; /* no colon */ 519 } opt; 520 extern opt envopt[]; 521 extern char *optdesc[]; 522 #endif 523 524 #ifdef CURSES 525 struct _win_st { 526 short _cury, _curx; 527 short _maxy, _maxx; 528 }; 529 530 typedef struct _win_st WINDOW; 531 532 extern int LINES, COLS; 533 extern WINDOW *curscr; 534 #ifndef MSDOS 535 extern char *CL; 536 char *md_gdtcf(); 537 #endif 538 #endif /*CURSES*/ 539 540 #ifdef COLOR 541 #define WHITE 0 542 #define RED 1 543 #define GREEN 2 544 #define YELLOW 3 545 #define BLUE 4 546 #define MAGENTA 5 547 #define CYAN 6 548 #define RWHITE 8 549 #define RRED 9 550 #define RGREEN 10 551 #define RYELLOW 11 552 #define RBLUE 12 553 #define RMAGENTA 13 554 #define RCYAN 14 555 extern short c_attr[]; 556 #else 557 /*#define colored(ch) ch*/ 558 #define colored(ch) (unsigned char) ch 559 #endif 560 561 #ifndef ORIGINAL 562 extern char org_dir[], *game_dir; 563 #endif 564 #ifdef MSDOS 565 extern char cursor_on[], cursor_off[]; 566 extern char *mac_type; 567 #endif 568 569 #ifdef UNIX 570 #undef getchar 571 #undef putchar 572 #undef putc 573 #define getchar() fgetc(stdin) 574 #define putchar(c) fputc(c, stdout) 575 #define putc(c, fp) fputc(c, fp) 576 #endif 577