|
|
1.1 ! root 1: /* ! 2: * Rogue definitions and variable declarations ! 3: * ! 4: * @(#)rogue.h 3.38 (Berkeley) 6/15/81 ! 5: */ ! 6: ! 7: ! 8: /* ! 9: * Maximum number of different things ! 10: */ ! 11: #define MAXROOMS 9 ! 12: #define MAXTHINGS 9 ! 13: #define MAXOBJ 9 ! 14: #define MAXPACK 23 ! 15: #define MAXTRAPS 10 ! 16: #define NUMTHINGS 7 /* number of types of things (scrolls, rings, etc.) */ ! 17: ! 18: /* ! 19: * return values for get functions ! 20: */ ! 21: #define NORM 0 /* normal exit */ ! 22: #define QUIT 1 /* quit option setting */ ! 23: #define MINUS 2 /* back up one option */ ! 24: ! 25: /* ! 26: * All the fun defines ! 27: */ ! 28: #define next(ptr) (*ptr).l_next ! 29: #define prev(ptr) (*ptr).l_prev ! 30: #define ldata(ptr) (*ptr).l_data ! 31: #define inroom(rp, cp) (\ ! 32: (cp)->x <= (rp)->r_pos.x + ((rp)->r_max.x - 1) && (rp)->r_pos.x <= (cp)->x \ ! 33: && (cp)->y <= (rp)->r_pos.y + ((rp)->r_max.y - 1) && (rp)->r_pos.y <= (cp)->y) ! 34: #define winat(y, x) (mvwinch(mw,y,x)==' '?mvwinch(stdscr,y,x):winch(mw)) ! 35: #define debug if (wizard) msg ! 36: #define RN (((seed = seed*11109+13849) & 0x7fff) >> 1) ! 37: #define unc(cp) (cp).y, (cp).x ! 38: #define cmov(xy) move((xy).y, (xy).x) ! 39: #define DISTANCE(y1, x1, y2, x2) ((x2 - x1)*(x2 - x1) + (y2 - y1)*(y2 - y1)) ! 40: #define when break;case ! 41: #define otherwise break;default ! 42: #define until(expr) while(!(expr)) ! 43: #define ce(a, b) ((a).x == (b).x && (a).y == (b).y) ! 44: #define draw(window) wrefresh(window) ! 45: #define hero player.t_pos ! 46: #define pstats player.t_stats ! 47: #define pack player.t_pack ! 48: #define attach(a,b) _attach(&a,b) ! 49: #define detach(a,b) _detach(&a,b) ! 50: #define free_list(a) _free_list(&a) ! 51: #define max(a, b) ((a) > (b) ? (a) : (b)) ! 52: #define on(thing, flag) (((thing).t_flags & flag) != 0) ! 53: #define off(thing, flag) (((thing).t_flags & flag) == 0) ! 54: #define CTRL(ch) ('ch' & 037) ! 55: #define ALLOC(x) malloc((unsigned int) x) ! 56: #define FREE(x) cfree((char *) x) ! 57: #define EQSTR(a, b, c) (strncmp(a, b, c) == 0) ! 58: #define GOLDCALC (rnd(50 + 10 * level) + 2) ! 59: #define ISRING(h,r) (cur_ring[h] != NULL && cur_ring[h]->o_which == r) ! 60: #define ISWEARING(r) (ISRING(LEFT, r) || ISRING(RIGHT, r)) ! 61: #define newgrp() ++group ! 62: #define o_charges o_ac ! 63: #define ISMULT(type) (type == POTION || type == SCROLL || type == FOOD) ! 64: ! 65: /* ! 66: * Things that appear on the screens ! 67: */ ! 68: #define PASSAGE '#' ! 69: #define DOOR '+' ! 70: #define FLOOR '.' ! 71: #define PLAYER '@' ! 72: #define TRAP '^' ! 73: #define TRAPDOOR '>' ! 74: #define ARROWTRAP '{' ! 75: #define SLEEPTRAP '$' ! 76: #define BEARTRAP '}' ! 77: #define TELTRAP '~' ! 78: #define DARTTRAP '`' ! 79: #define SECRETDOOR '&' ! 80: #define STAIRS '%' ! 81: #define GOLD '*' ! 82: #define POTION '!' ! 83: #define SCROLL '?' ! 84: #define MAGIC '$' ! 85: #define FOOD ':' ! 86: #define WEAPON ')' ! 87: #define ARMOR ']' ! 88: #define AMULET ',' ! 89: #define RING '=' ! 90: #define STICK '/' ! 91: #define CALLABLE -1 ! 92: ! 93: /* ! 94: * Various constants ! 95: */ ! 96: #define PASSWD "C4u3dJWbg7RCk" ! 97: #define BEARTIME 3 ! 98: #define SLEEPTIME 5 ! 99: #define HEALTIME 30 ! 100: #define HOLDTIME 2 ! 101: #define STPOS 0 ! 102: #define WANDERTIME 70 ! 103: #define BEFORE 1 ! 104: #define AFTER 2 ! 105: #define HUHDURATION 20 ! 106: #define SEEDURATION 850 ! 107: #define HUNGERTIME 1300 ! 108: #define MORETIME 150 ! 109: #define STOMACHSIZE 2000 ! 110: #define ESCAPE 27 ! 111: #define LEFT 0 ! 112: #define RIGHT 1 ! 113: #define BOLT_LENGTH 6 ! 114: ! 115: /* ! 116: * Save against things ! 117: */ ! 118: #define VS_POISON 00 ! 119: #define VS_PARALYZATION 00 ! 120: #define VS_DEATH 00 ! 121: #define VS_PETRIFICATION 01 ! 122: #define VS_BREATH 02 ! 123: #define VS_MAGIC 03 ! 124: ! 125: /* ! 126: * Various flag bits ! 127: */ ! 128: #define ISDARK 0000001 ! 129: #define ISCURSED 000001 ! 130: #define ISBLIND 0000001 ! 131: #define ISGONE 0000002 ! 132: #define ISKNOW 0000002 ! 133: #define ISRUN 0000004 ! 134: #define ISFOUND 0000010 ! 135: #define ISINVIS 0000020 ! 136: #define ISMEAN 0000040 ! 137: #define ISGREED 0000100 ! 138: #define ISBLOCK 0000200 ! 139: #define ISHELD 0000400 ! 140: #define ISHUH 0001000 ! 141: #define ISREGEN 0002000 ! 142: #define CANHUH 0004000 ! 143: #define CANSEE 0010000 ! 144: #define ISMISL 0020000 ! 145: #define ISCANC 0020000 ! 146: #define ISMANY 0040000 ! 147: #define ISSLOW 0040000 ! 148: #define ISHASTE 0100000 ! 149: ! 150: /* ! 151: * Potion types ! 152: */ ! 153: #define P_CONFUSE 0 ! 154: #define P_PARALYZE 1 ! 155: #define P_POISON 2 ! 156: #define P_STRENGTH 3 ! 157: #define P_SEEINVIS 4 ! 158: #define P_HEALING 5 ! 159: #define P_MFIND 6 ! 160: #define P_TFIND 7 ! 161: #define P_RAISE 8 ! 162: #define P_XHEAL 9 ! 163: #define P_HASTE 10 ! 164: #define P_RESTORE 11 ! 165: #define P_BLIND 12 ! 166: #define P_NOP 13 ! 167: #define MAXPOTIONS 14 ! 168: ! 169: /* ! 170: * Scroll types ! 171: */ ! 172: #define S_CONFUSE 0 ! 173: #define S_MAP 1 ! 174: #define S_LIGHT 2 ! 175: #define S_HOLD 3 ! 176: #define S_SLEEP 4 ! 177: #define S_ARMOR 5 ! 178: #define S_IDENT 6 ! 179: #define S_SCARE 7 ! 180: #define S_GFIND 8 ! 181: #define S_TELEP 9 ! 182: #define S_ENCH 10 ! 183: #define S_CREATE 11 ! 184: #define S_REMOVE 12 ! 185: #define S_AGGR 13 ! 186: #define S_NOP 14 ! 187: #define S_GENOCIDE 15 ! 188: #define MAXSCROLLS 16 ! 189: ! 190: /* ! 191: * Weapon types ! 192: */ ! 193: #define MACE 0 ! 194: #define SWORD 1 ! 195: #define BOW 2 ! 196: #define ARROW 3 ! 197: #define DAGGER 4 ! 198: #define ROCK 5 ! 199: #define TWOSWORD 6 ! 200: #define SLING 7 ! 201: #define DART 8 ! 202: #define CROSSBOW 9 ! 203: #define BOLT 10 ! 204: #define SPEAR 11 ! 205: #define MAXWEAPONS 12 ! 206: ! 207: /* ! 208: * Armor types ! 209: */ ! 210: #define LEATHER 0 ! 211: #define RING_MAIL 1 ! 212: #define STUDDED_LEATHER 2 ! 213: #define SCALE_MAIL 3 ! 214: #define CHAIN_MAIL 4 ! 215: #define SPLINT_MAIL 5 ! 216: #define BANDED_MAIL 6 ! 217: #define PLATE_MAIL 7 ! 218: #define MAXARMORS 8 ! 219: ! 220: /* ! 221: * Ring types ! 222: */ ! 223: #define R_PROTECT 0 ! 224: #define R_ADDSTR 1 ! 225: #define R_SUSTSTR 2 ! 226: #define R_SEARCH 3 ! 227: #define R_SEEINVIS 4 ! 228: #define R_NOP 5 ! 229: #define R_AGGR 6 ! 230: #define R_ADDHIT 7 ! 231: #define R_ADDDAM 8 ! 232: #define R_REGEN 9 ! 233: #define R_DIGEST 10 ! 234: #define R_TELEPORT 11 ! 235: #define R_STEALTH 12 ! 236: #define MAXRINGS 13 ! 237: ! 238: /* ! 239: * Rod/Wand/Staff types ! 240: */ ! 241: ! 242: #define WS_LIGHT 0 ! 243: #define WS_HIT 1 ! 244: #define WS_ELECT 2 ! 245: #define WS_FIRE 3 ! 246: #define WS_COLD 4 ! 247: #define WS_POLYMORPH 5 ! 248: #define WS_MISSILE 6 ! 249: #define WS_HASTE_M 7 ! 250: #define WS_SLOW_M 8 ! 251: #define WS_DRAIN 9 ! 252: #define WS_NOP 10 ! 253: #define WS_TELAWAY 11 ! 254: #define WS_TELTO 12 ! 255: #define WS_CANCEL 13 ! 256: #define MAXSTICKS 14 ! 257: ! 258: /* ! 259: * Now we define the structures and types ! 260: */ ! 261: ! 262: /* ! 263: * Help list ! 264: */ ! 265: ! 266: struct h_list { ! 267: char h_ch; ! 268: char *h_desc; ! 269: } helpstr[]; ! 270: ! 271: /* ! 272: * Coordinate data type ! 273: */ ! 274: typedef struct { ! 275: int x; ! 276: int y; ! 277: } coord; ! 278: ! 279: typedef struct { ! 280: short st_str; ! 281: short st_add; ! 282: } str_t; ! 283: ! 284: /* ! 285: * Linked list data type ! 286: */ ! 287: struct linked_list { ! 288: struct linked_list *l_next; ! 289: struct linked_list *l_prev; ! 290: char *l_data; /* Various structure pointers */ ! 291: }; ! 292: ! 293: /* ! 294: * Stuff about magic items ! 295: */ ! 296: ! 297: struct magic_item { ! 298: char *mi_name; ! 299: int mi_prob; ! 300: int mi_worth; ! 301: }; ! 302: ! 303: /* ! 304: * Room structure ! 305: */ ! 306: struct room { ! 307: coord r_pos; /* Upper left corner */ ! 308: coord r_max; /* Size of room */ ! 309: coord r_gold; /* Where the gold is */ ! 310: int r_goldval; /* How much the gold is worth */ ! 311: int r_flags; /* Info about the room */ ! 312: int r_nexits; /* Number of exits */ ! 313: coord r_exit[4]; /* Where the exits are */ ! 314: }; ! 315: ! 316: /* ! 317: * Array of all traps on this level ! 318: */ ! 319: struct trap { ! 320: coord tr_pos; /* Where trap is */ ! 321: char tr_type; /* What kind of trap */ ! 322: int tr_flags; /* Info about trap (i.e. ISFOUND) */ ! 323: } traps[MAXTRAPS]; ! 324: ! 325: /* ! 326: * Structure describing a fighting being ! 327: */ ! 328: struct stats { ! 329: str_t s_str; /* Strength */ ! 330: long s_exp; /* Experience */ ! 331: int s_lvl; /* Level of mastery */ ! 332: int s_arm; /* Armor class */ ! 333: int s_hpt; /* Hit points */ ! 334: char *s_dmg; /* String describing damage done */ ! 335: }; ! 336: ! 337: /* ! 338: * Structure for monsters and player ! 339: */ ! 340: struct thing { ! 341: coord t_pos; /* Position */ ! 342: bool t_turn; /* If slowed, is it a turn to move */ ! 343: char t_type; /* What it is */ ! 344: char t_disguise; /* What mimic looks like */ ! 345: char t_oldch; /* Character that was where it was */ ! 346: coord *t_dest; /* Where it is running to */ ! 347: short t_flags; /* State word */ ! 348: struct stats t_stats; /* Physical description */ ! 349: struct linked_list *t_pack; /* What the thing is carrying */ ! 350: }; ! 351: ! 352: /* ! 353: * Array containing information on all the various types of mosnters ! 354: */ ! 355: struct monster { ! 356: char *m_name; /* What to call the monster */ ! 357: short m_carry; /* Probability of carrying something */ ! 358: short m_flags; /* Things about the monster */ ! 359: struct stats m_stats; /* Initial stats */ ! 360: }; ! 361: ! 362: /* ! 363: * Structure for a thing that the rogue can carry ! 364: */ ! 365: ! 366: struct object { ! 367: int o_type; /* What kind of object it is */ ! 368: coord o_pos; /* Where it lives on the screen */ ! 369: char *o_text; /* What it says if you read it */ ! 370: char o_launch; /* What you need to launch it */ ! 371: char *o_damage; /* Damage if used like sword */ ! 372: char *o_hurldmg; /* Damage if thrown */ ! 373: int o_count; /* Count for plural objects */ ! 374: int o_which; /* Which object of a type it is */ ! 375: int o_hplus; /* Plusses to hit */ ! 376: int o_dplus; /* Plusses to damage */ ! 377: int o_ac; /* Armor class */ ! 378: int o_flags; /* Information about objects */ ! 379: int o_group; /* Group number for this object */ ! 380: }; ! 381: ! 382: /* ! 383: * Now all the global variables ! 384: */ ! 385: ! 386: struct room rooms[MAXROOMS]; /* One for each room -- A level */ ! 387: struct room *oldrp; /* Roomin(&oldpos) */ ! 388: struct linked_list *mlist; /* List of monsters on the level */ ! 389: struct thing player; /* The rogue */ ! 390: struct stats max_stats; /* The maximum for the player */ ! 391: struct monster monsters[26]; /* The initial monster states */ ! 392: struct linked_list *lvl_obj; /* List of objects on this level */ ! 393: struct object *cur_weapon; /* Which weapon he is weilding */ ! 394: struct object *cur_armor; /* What a well dresssed rogue wears */ ! 395: struct object *cur_ring[2]; /* Which rings are being worn */ ! 396: struct magic_item things[NUMTHINGS]; /* Chances for each type of item */ ! 397: struct magic_item s_magic[MAXSCROLLS]; /* Names and chances for scrolls */ ! 398: struct magic_item p_magic[MAXPOTIONS]; /* Names and chances for potions */ ! 399: struct magic_item r_magic[MAXRINGS]; /* Names and chances for rings */ ! 400: struct magic_item ws_magic[MAXSTICKS]; /* Names and chances for sticks */ ! 401: ! 402: int level; /* What level rogue is on */ ! 403: int purse; /* How much gold the rogue has */ ! 404: int mpos; /* Where cursor is on top line */ ! 405: int ntraps; /* Number of traps on this level */ ! 406: int no_move; /* Number of turns held in place */ ! 407: int no_command; /* Number of turns asleep */ ! 408: int inpack; /* Number of things in pack */ ! 409: int max_hp; /* Player's max hit points */ ! 410: int total; /* Total dynamic memory bytes */ ! 411: int a_chances[MAXARMORS]; /* Probabilities for armor */ ! 412: int a_class[MAXARMORS]; /* Armor class for various armors */ ! 413: int lastscore; /* Score before this turn */ ! 414: int no_food; /* Number of levels without food */ ! 415: int seed; /* Random number seed */ ! 416: int count; /* Number of times to repeat command */ ! 417: int dnum; /* Dungeon number */ ! 418: int fung_hit; /* Number of time fungi has hit */ ! 419: int quiet; /* Number of quiet turns */ ! 420: int max_level; /* Deepest player has gone */ ! 421: int food_left; /* Amount of food in hero's stomach */ ! 422: int group; /* Current group number */ ! 423: int hungry_state; /* How hungry is he */ ! 424: ! 425: char take; /* Thing the rogue is taking */ ! 426: char prbuf[80]; /* Buffer for sprintfs */ ! 427: char outbuf[BUFSIZ]; /* Output buffer for stdout */ ! 428: char runch; /* Direction player is running */ ! 429: char *s_names[MAXSCROLLS]; /* Names of the scrolls */ ! 430: char *p_colors[MAXPOTIONS]; /* Colors of the potions */ ! 431: char *r_stones[MAXRINGS]; /* Stone settings of the rings */ ! 432: char *w_names[MAXWEAPONS]; /* Names of the various weapons */ ! 433: char *a_names[MAXARMORS]; /* Names of armor types */ ! 434: char *ws_made[MAXSTICKS]; /* What sticks are made of */ ! 435: char *release; /* Release number of rogue */ ! 436: char whoami[80]; /* Name of player */ ! 437: char fruit[80]; /* Favorite fruit */ ! 438: char huh[80]; /* The last message printed */ ! 439: char *s_guess[MAXSCROLLS]; /* Players guess at what scroll is */ ! 440: char *p_guess[MAXPOTIONS]; /* Players guess at what potion is */ ! 441: char *r_guess[MAXRINGS]; /* Players guess at what ring is */ ! 442: char *ws_guess[MAXSTICKS]; /* Players guess at what wand is */ ! 443: char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */ ! 444: char file_name[80]; /* Save file name */ ! 445: char home[80]; /* User's home directory */ ! 446: ! 447: WINDOW *cw; /* Window that the player sees */ ! 448: WINDOW *hw; /* Used for the help command */ ! 449: WINDOW *mw; /* Used to store mosnters */ ! 450: ! 451: bool running; /* True if player is running */ ! 452: bool playing; /* True until he quits */ ! 453: bool wizard; /* True if allows wizard commands */ ! 454: bool after; /* True if we want after daemons */ ! 455: bool notify; /* True if player wants to know */ ! 456: bool fight_flush; /* True if toilet input */ ! 457: bool terse; /* True if we should be short */ ! 458: bool door_stop; /* Stop running when we pass a door */ ! 459: bool jump; /* Show running as series of jumps */ ! 460: bool slow_invent; /* Inventory one line at a time */ ! 461: bool firstmove; /* First move after setting door_stop */ ! 462: bool waswizard; /* Was a wizard sometime */ ! 463: bool askme; /* Ask about unidentified things */ ! 464: bool s_know[MAXSCROLLS]; /* Does he know what a scroll does */ ! 465: bool p_know[MAXPOTIONS]; /* Does he know what a potion does */ ! 466: bool r_know[MAXRINGS]; /* Does he know what a ring does */ ! 467: bool ws_know[MAXSTICKS]; /* Does he know what a stick does */ ! 468: bool amulet; /* He found the amulet */ ! 469: bool in_shell; /* True if executing a shell */ ! 470: ! 471: coord oldpos; /* Position before last look() call */ ! 472: coord delta; /* Change indicated to get_dir() */ ! 473: ! 474: struct linked_list *find_mons(), *find_obj(), *get_item(), *new_item(); ! 475: struct linked_list *new_thing(), *wake_monster(); ! 476: ! 477: char *malloc(), *getenv(), *unctrl(), *tr_name(), *new(), *sprintf(); ! 478: char *vowelstr(), *inv_name(), *strcpy(), *strcat(), *sbrk(), *brk(); ! 479: char *ctime(), *num(), *ring_num(); ! 480: ! 481: struct room *roomin(); ! 482: ! 483: coord *rndmove(); ! 484: ! 485: int auto_save(), endit(), nohaste(), doctor(), runners(), swander(); ! 486: int tstp(), unconfuse(), unsee(), rollwand(), stomach(), sight(); ! 487: ! 488: #ifdef CHECKTIME ! 489: int checkout(); ! 490: #endif ! 491: ! 492: long lseek(); ! 493: ! 494: struct trap *trap_at(); ! 495: ! 496: /* added stuff */ ! 497: int cheating; ! 498: FILE *restfile;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.