Annotation of early-roguelike/rogue5/extern.c, Revision 1.1
1.1 ! rubenllo 1: /*
! 2: * global variable initializaton
! 3: *
! 4: * @(#)extern.c 4.82 (Berkeley) 02/05/99
! 5: *
! 6: * Rogue: Exploring the Dungeons of Doom
! 7: * Copyright (C) 1980-1983, 1985, 1999 Michael Toy, Ken Arnold and Glenn Wichman
! 8: * All rights reserved.
! 9: *
! 10: * See the file LICENSE.TXT for full copyright and licensing information.
! 11: */
! 12:
! 13: /* All global variables are defined here, or in vers.c or init.c */
! 14:
! 15: #include <curses.h>
! 16: #include "rogue.h"
! 17:
! 18: int after; /* True if we want after daemons */
! 19: int again; /* Repeating the last command */
! 20: int noscore; /* Was a wizard sometime */
! 21: int seenstairs; /* Have seen the stairs (for lsd) */
! 22: int amulet = FALSE; /* He found the amulet */
! 23: int door_stop = FALSE; /* Stop running when we pass a door */
! 24: int fight_flush = FALSE; /* True if toilet input */
! 25: int firstmove = FALSE; /* First move after setting door_stop */
! 26: int got_ltc = FALSE; /* We have gotten the local tty chars */
! 27: int has_hit = FALSE; /* Has a "hit" message pending in msg */
! 28: int in_shell = FALSE; /* True if executing a shell */
! 29: int inv_describe = TRUE; /* Say which way items are being used */
! 30: int jump = FALSE; /* Show running as series of jumps */
! 31: int kamikaze = FALSE; /* to_death really to DEATH */
! 32: int lower_msg = FALSE; /* Messages should start w/lower case */
! 33: int move_on = FALSE; /* Next move shouldn't pick up items */
! 34: int msg_esc = FALSE; /* Check for ESC from msg's --More-- */
! 35: int passgo = FALSE; /* Follow passages */
! 36: int playing = TRUE; /* True until he quits */
! 37: int q_comm = FALSE; /* Are we executing a 'Q' command? */
! 38: int running = FALSE; /* True if player is running */
! 39: int save_msg = TRUE; /* Remember last msg */
! 40: int see_floor = TRUE; /* Show the lamp illuminated floor */
! 41: int stat_msg = FALSE; /* Should status() print as a msg() */
! 42: int terse = FALSE; /* True if we should be short */
! 43: int to_death = FALSE; /* Fighting is to the death! */
! 44: int tombstone = TRUE; /* Print out tombstone at end */
! 45: int use_savedir = FALSE; /* True if using system savefile dir */
! 46: #ifdef MASTER
! 47: int wizard = FALSE; /* True if allows wizard commands */
! 48: #endif
! 49: int pack_used[26] = { /* Is the character used in the pack? */
! 50: FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
! 51: FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE,
! 52: FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE
! 53: };
! 54:
! 55: int dir_ch; /* Direction from last get_dir() call */
! 56: char file_name[MAXSTR]; /* Save file name */
! 57: char huh[MAXSTR]; /* The last message printed */
! 58: const char *p_colors[MAXPOTIONS]; /* Colors of the potions */
! 59: char prbuf[2*MAXSTR]; /* buffer for sprintfs */
! 60: const char *r_stones[MAXRINGS]; /* Stone settings of the rings */
! 61: int runch; /* Direction player is running */
! 62: char *s_names[MAXSCROLLS]; /* Names of the scrolls */
! 63: int take; /* Thing she is taking */
! 64: char whoami[MAXSTR]; /* Name of player */
! 65: const char *ws_made[MAXSTICKS]; /* What sticks are made of */
! 66: char *ws_type[MAXSTICKS]; /* Is it a wand or a staff */
! 67: int orig_dsusp; /* Original dsusp char */
! 68: char fruit[MAXSTR] = /* Favorite fruit */
! 69: { 's', 'l', 'i', 'm', 'e', '-', 'm', 'o', 'l', 'd', '\0' };
! 70: char home[MAXSTR] = { '\0' }; /* User's home directory */
! 71: const char *inv_t_name[] = {
! 72: "Overwrite",
! 73: "Slow",
! 74: "Clear"
! 75: };
! 76: int l_last_comm = '\0'; /* Last last_comm */
! 77: int l_last_dir = '\0'; /* Last last_dir */
! 78: int last_comm = '\0'; /* Last command typed */
! 79: int last_dir = '\0'; /* Last direction given */
! 80: const char *tr_name[] = { /* Names of the traps */
! 81: "a trapdoor",
! 82: "an arrow trap",
! 83: "a sleeping gas trap",
! 84: "a beartrap",
! 85: "a teleport trap",
! 86: "a poison dart trap",
! 87: "a rust trap",
! 88: "a mysterious trap"
! 89: };
! 90:
! 91:
! 92: int n_objs; /* # items listed in inventory() call */
! 93: int ntraps; /* Number of traps on this level */
! 94: int hungry_state = 0; /* How hungry is he */
! 95: int inpack = 0; /* Number of things in pack */
! 96: int inv_type = 0; /* Type of inventory to use */
! 97: int level = 1; /* What level she is on */
! 98: int max_hit; /* Max damage done to her in to_death */
! 99: int max_level; /* Deepest player has gone */
! 100: int mpos = 0; /* Where cursor is on top line */
! 101: int no_food = 0; /* Number of levels without food */
! 102: const int a_class[MAXARMORS] = { /* Armor class for each armor type */
! 103: 8, /* LEATHER */
! 104: 7, /* RING_MAIL */
! 105: 7, /* STUDDED_LEATHER */
! 106: 6, /* SCALE_MAIL */
! 107: 5, /* CHAIN_MAIL */
! 108: 4, /* SPLINT_MAIL */
! 109: 4, /* BANDED_MAIL */
! 110: 3, /* PLATE_MAIL */
! 111: };
! 112:
! 113: int count = 0; /* Number of times to repeat command */
! 114: FILE *scoreboard = NULL; /* File descriptor for score file */
! 115: FILE *logfi = NULL; /* The log file */
! 116: int food_left; /* Amount of food in hero's stomach */
! 117: int lastscore = -1; /* Score before this turn */
! 118: int no_command = 0; /* Number of turns asleep */
! 119: int no_move = 0; /* Number of turns held in place */
! 120: int purse = 0; /* How much gold he has */
! 121: int quiet = 0; /* Number of quiet turns */
! 122: int vf_hit = 0; /* Number of time flytrap has hit */
! 123:
! 124: unsigned int dnum; /* Dungeon number */
! 125: unsigned int seed; /* Random number seed */
! 126: const int e_levels[] = {
! 127: 10L,
! 128: 20L,
! 129: 40L,
! 130: 80L,
! 131: 160L,
! 132: 320L,
! 133: 640L,
! 134: 1300L,
! 135: 2600L,
! 136: 5200L,
! 137: 13000L,
! 138: 26000L,
! 139: 50000L,
! 140: 100000L,
! 141: 200000L,
! 142: 400000L,
! 143: 800000L,
! 144: 2000000L,
! 145: 4000000L,
! 146: 8000000L,
! 147: 0L
! 148: };
! 149:
! 150: coord delta; /* Change indicated to get_dir() */
! 151: coord oldpos; /* Position before last look() call */
! 152: coord stairs; /* Location of staircase */
! 153:
! 154: PLACE places[MAXLINES*MAXCOLS]; /* level map */
! 155:
! 156: THING *cur_armor; /* What he is wearing */
! 157: THING *cur_ring[2]; /* Which rings are being worn */
! 158: THING *cur_weapon; /* Which weapon he is weilding */
! 159: THING *l_last_pick = NULL; /* Last last_pick */
! 160: THING *last_pick = NULL; /* Last object picked in get_item() */
! 161: THING *lvl_obj = NULL; /* List of objects on this level */
! 162: THING *mlist = NULL; /* List of monsters on the level */
! 163: THING player; /* His stats */
! 164: /* restart of game */
! 165:
! 166: WINDOW *hw = NULL; /* used as a scratch window */
! 167:
! 168: #define INIT_STATS { 16, 0, 1, 10, 12, "1x4", 12 }
! 169:
! 170: struct stats max_stats = INIT_STATS; /* The maximum for the player */
! 171:
! 172: struct room *oldrp; /* Roomin(&oldpos) */
! 173: struct room rooms[MAXROOMS]; /* One for each room -- A level */
! 174: struct room passages[MAXPASS] = /* One for each passage */
! 175: {
! 176: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 177: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 178: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 179: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 180: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 181: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 182: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 183: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 184: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 185: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 186: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} },
! 187: { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, {{0,0}} }
! 188: };
! 189:
! 190: #define ___ 1
! 191: #define XX 10
! 192: struct monster monsters[26] =
! 193: {
! 194: /* Name CARRY FLAG str, exp, lvl, amr, hpt, dmg */
! 195: { "aquator", 0, ISMEAN, { XX, 20, 5, 2, ___, "0x0/0x0" } },
! 196: { "bat", 0, ISFLY, { XX, 1, 1, 3, ___, "1x2" } },
! 197: { "centaur", 15, 0, { XX, 17, 4, 4, ___, "1x2/1x5/1x5" } },
! 198: { "dragon", 100, ISMEAN, { XX,5000, 10, -1, ___, "1x8/1x8/3x10" } },
! 199: { "emu", 0, ISMEAN, { XX, 2, 1, 7, ___, "1x2" } },
! 200: { "venus flytrap", 0, ISMEAN, { XX, 80, 8, 3, ___, "0x0" } },
! 201: { "griffin", 20, ISMEAN|ISFLY|ISREGEN, { XX,2000, 13, 2, ___, "4x3/3x5" } },
! 202: { "hobgoblin", 0, ISMEAN, { XX, 3, 1, 5, ___, "1x8" } },
! 203: { "ice monster", 0, 0, { XX, 5, 1, 9, ___, "0x0" } },
! 204: { "jabberwock", 70, 0, { XX,3000, 15, 6, ___, "2x12/2x4" } },
! 205: { "kestrel", 0, ISMEAN|ISFLY, { XX, 1, 1, 7, ___, "1x4" } },
! 206: { "leprechaun", 0, 0, { XX, 10, 3, 8, ___, "1x1" } },
! 207: { "medusa", 40, ISMEAN, { XX,200, 8, 2, ___, "3x4/3x4/2x5" } },
! 208: { "nymph", 100, 0, { XX, 37, 3, 9, ___, "0x0" } },
! 209: { "orc", 15, ISGREED,{ XX, 5, 1, 6, ___, "1x8" } },
! 210: { "phantom", 0, ISINVIS,{ XX,120, 8, 3, ___, "4x4" } },
! 211: { "quagga", 0, ISMEAN, { XX, 15, 3, 3, ___, "1x5/1x5" } },
! 212: { "rattlesnake", 0, ISMEAN, { XX, 9, 2, 3, ___, "1x6" } },
! 213: { "snake", 0, ISMEAN, { XX, 2, 1, 5, ___, "1x3" } },
! 214: { "troll", 50, ISREGEN|ISMEAN,{ XX, 120, 6, 4, ___, "1x8/1x8/2x6" } },
! 215: { "black unicorn", 0, ISMEAN, { XX,190, 7, -2, ___, "1x9/1x9/2x9" } },
! 216: { "vampire", 20, ISREGEN|ISMEAN,{ XX,350, 8, 1, ___, "1x10" } },
! 217: { "wraith", 0, 0, { XX, 55, 5, 4, ___, "1x6" } },
! 218: { "xeroc", 30, 0, { XX,100, 7, 7, ___, "4x4" } },
! 219: { "yeti", 30, 0, { XX, 50, 4, 6, ___, "1x6/1x6" } },
! 220: { "zombie", 0, ISMEAN, { XX, 6, 2, 8, ___, "1x8" } }
! 221: };
! 222: #undef ___
! 223: #undef XX
! 224:
! 225: struct obj_info things[NUMTHINGS] = {
! 226: { 0, 26 }, /* potion */
! 227: { 0, 36 }, /* scroll */
! 228: { 0, 16 }, /* food */
! 229: { 0, 7 }, /* weapon */
! 230: { 0, 7 }, /* armor */
! 231: { 0, 4 }, /* ring */
! 232: { 0, 4 }, /* stick */
! 233: };
! 234:
! 235: struct obj_info arm_info[MAXARMORS] = {
! 236: { "leather armor", 20, 20, NULL, FALSE },
! 237: { "ring mail", 15, 25, NULL, FALSE },
! 238: { "studded leather armor", 15, 20, NULL, FALSE },
! 239: { "scale mail", 13, 30, NULL, FALSE },
! 240: { "chain mail", 12, 75, NULL, FALSE },
! 241: { "splint mail", 10, 80, NULL, FALSE },
! 242: { "banded mail", 10, 90, NULL, FALSE },
! 243: { "plate mail", 5, 150, NULL, FALSE },
! 244: };
! 245: struct obj_info pot_info[MAXPOTIONS] = {
! 246: { "confusion", 7, 5, NULL, FALSE },
! 247: { "hallucination", 8, 5, NULL, FALSE },
! 248: { "poison", 8, 5, NULL, FALSE },
! 249: { "gain strength", 13, 150, NULL, FALSE },
! 250: { "see invisible", 3, 100, NULL, FALSE },
! 251: { "healing", 13, 130, NULL, FALSE },
! 252: { "monster detection", 6, 130, NULL, FALSE },
! 253: { "magic detection", 6, 105, NULL, FALSE },
! 254: { "raise level", 2, 250, NULL, FALSE },
! 255: { "extra healing", 5, 200, NULL, FALSE },
! 256: { "haste self", 5, 190, NULL, FALSE },
! 257: { "restore strength", 13, 130, NULL, FALSE },
! 258: { "blindness", 5, 5, NULL, FALSE },
! 259: { "levitation", 6, 75, NULL, FALSE },
! 260: };
! 261: struct obj_info ring_info[MAXRINGS] = {
! 262: { "protection", 9, 400, NULL, FALSE },
! 263: { "add strength", 9, 400, NULL, FALSE },
! 264: { "sustain strength", 5, 280, NULL, FALSE },
! 265: { "searching", 10, 420, NULL, FALSE },
! 266: { "see invisible", 10, 310, NULL, FALSE },
! 267: { "adornment", 1, 10, NULL, FALSE },
! 268: { "aggravate monster", 10, 10, NULL, FALSE },
! 269: { "dexterity", 8, 440, NULL, FALSE },
! 270: { "increase damage", 8, 400, NULL, FALSE },
! 271: { "regeneration", 4, 460, NULL, FALSE },
! 272: { "slow digestion", 9, 240, NULL, FALSE },
! 273: { "teleportation", 5, 30, NULL, FALSE },
! 274: { "stealth", 7, 470, NULL, FALSE },
! 275: { "maintain armor", 5, 380, NULL, FALSE },
! 276: };
! 277: struct obj_info scr_info[MAXSCROLLS] = {
! 278: { "monster confusion", 7, 140, NULL, FALSE },
! 279: { "magic mapping", 4, 150, NULL, FALSE },
! 280: { "hold monster", 2, 180, NULL, FALSE },
! 281: { "sleep", 3, 5, NULL, FALSE },
! 282: { "enchant armor", 7, 160, NULL, FALSE },
! 283: { "identify potion", 10, 80, NULL, FALSE },
! 284: { "identify scroll", 10, 80, NULL, FALSE },
! 285: { "identify weapon", 6, 80, NULL, FALSE },
! 286: { "identify armor", 7, 100, NULL, FALSE },
! 287: { "identify ring, wand or staff", 10, 115, NULL, FALSE },
! 288: { "scare monster", 3, 200, NULL, FALSE },
! 289: { "food detection", 2, 60, NULL, FALSE },
! 290: { "teleportation", 5, 165, NULL, FALSE },
! 291: { "enchant weapon", 8, 150, NULL, FALSE },
! 292: { "create monster", 4, 75, NULL, FALSE },
! 293: { "remove curse", 7, 105, NULL, FALSE },
! 294: { "aggravate monsters", 3, 20, NULL, FALSE },
! 295: { "protect armor", 2, 250, NULL, FALSE },
! 296: };
! 297: struct obj_info weap_info[MAXWEAPONS + 1] = {
! 298: { "mace", 11, 8, NULL, FALSE },
! 299: { "long sword", 11, 15, NULL, FALSE },
! 300: { "short bow", 12, 15, NULL, FALSE },
! 301: { "arrow", 12, 1, NULL, FALSE },
! 302: { "dagger", 8, 3, NULL, FALSE },
! 303: { "two handed sword", 10, 75, NULL, FALSE },
! 304: { "dart", 12, 2, NULL, FALSE },
! 305: { "shuriken", 12, 5, NULL, FALSE },
! 306: { "spear", 12, 5, NULL, FALSE },
! 307: { NULL, 0 }, /* DO NOT REMOVE: fake entry for dragon's breath */
! 308: };
! 309: struct obj_info ws_info[MAXSTICKS] = {
! 310: { "light", 12, 250, NULL, FALSE },
! 311: { "invisibility", 6, 5, NULL, FALSE },
! 312: { "lightning", 3, 330, NULL, FALSE },
! 313: { "fire", 3, 330, NULL, FALSE },
! 314: { "cold", 3, 330, NULL, FALSE },
! 315: { "polymorph", 15, 310, NULL, FALSE },
! 316: { "magic missile", 10, 170, NULL, FALSE },
! 317: { "haste monster", 10, 5, NULL, FALSE },
! 318: { "slow monster", 11, 350, NULL, FALSE },
! 319: { "drain life", 9, 300, NULL, FALSE },
! 320: { "nothing", 1, 5, NULL, FALSE },
! 321: { "teleport away", 6, 340, NULL, FALSE },
! 322: { "teleport to", 6, 50, NULL, FALSE },
! 323: { "cancellation", 5, 280, NULL, FALSE },
! 324: };
! 325:
! 326: const struct h_list helpstr[] = {
! 327: {'?', " prints help", TRUE},
! 328: {'/', " identify object", TRUE},
! 329: {'h', " left", TRUE},
! 330: {'j', " down", TRUE},
! 331: {'k', " up", TRUE},
! 332: {'l', " right", TRUE},
! 333: {'y', " up & left", TRUE},
! 334: {'u', " up & right", TRUE},
! 335: {'b', " down & left", TRUE},
! 336: {'n', " down & right", TRUE},
! 337: {'H', " run left", FALSE},
! 338: {'J', " run down", FALSE},
! 339: {'K', " run up", FALSE},
! 340: {'L', " run right", FALSE},
! 341: {'Y', " run up & left", FALSE},
! 342: {'U', " run up & right", FALSE},
! 343: {'B', " run down & left", FALSE},
! 344: {'N', " run down & right", FALSE},
! 345: {CTRL('H'), " run left until adjacent", FALSE},
! 346: {CTRL('J'), " run down until adjacent", FALSE},
! 347: {CTRL('K'), " run up until adjacent", FALSE},
! 348: {CTRL('L'), " run right until adjacent", FALSE},
! 349: {CTRL('Y'), " run up & left until adjacent", FALSE},
! 350: {CTRL('U'), " run up & right until adjacent", FALSE},
! 351: {CTRL('B'), " run down & left until adjacent", FALSE},
! 352: {CTRL('N'), " run down & right until adjacent", FALSE},
! 353: {'\0', " <SHIFT><dir>: run that way", TRUE},
! 354: {'\0', " <CTRL><dir>: run till adjacent", TRUE},
! 355: {'f', "<dir> fight till death or near death", TRUE},
! 356: {'t', "<dir> throw something", TRUE},
! 357: {'m', "<dir> move onto without picking up", TRUE},
! 358: {'z', "<dir> zap a wand in a direction", TRUE},
! 359: {'^', "<dir> identify trap type", TRUE},
! 360: {'s', " search for trap/secret door", TRUE},
! 361: {'>', " go down a staircase", TRUE},
! 362: {'<', " go up a staircase", TRUE},
! 363: {'.', " rest for a turn", TRUE},
! 364: {',', " pick something up", TRUE},
! 365: {'i', " inventory", TRUE},
! 366: {'I', " inventory single item", TRUE},
! 367: {'q', " quaff potion", TRUE},
! 368: {'r', " read scroll", TRUE},
! 369: {'e', " eat food", TRUE},
! 370: {'w', " wield a weapon", TRUE},
! 371: {'W', " wear armor", TRUE},
! 372: {'T', " take armor off", TRUE},
! 373: {'P', " put on ring", TRUE},
! 374: {'R', " remove ring", TRUE},
! 375: {'d', " drop object", TRUE},
! 376: {'c', " call object", TRUE},
! 377: {'a', " repeat last command", TRUE},
! 378: {')', " print current weapon", TRUE},
! 379: {']', " print current armor", TRUE},
! 380: {'=', " print current rings", TRUE},
! 381: {'@', " print current stats", TRUE},
! 382: {'D', " recall what's been discovered", TRUE},
! 383: {'o', " examine/set options", TRUE},
! 384: {CTRL('R'), " redraw screen", TRUE},
! 385: {CTRL('P'), " repeat last message", TRUE},
! 386: {ESCAPE, " cancel command", TRUE},
! 387: {'S', " save game", TRUE},
! 388: {'Q', " quit", TRUE},
! 389: {'!', " shell escape", TRUE},
! 390: {'F', "<dir> fight till either of you dies", TRUE},
! 391: {'v', " print version number", TRUE},
! 392: {0, NULL }
! 393: };
! 394: int numscores;
! 395: char *Numname;
! 396: int allscore;
! 397: int between;
! 398:
! 399: #define _X_ { EMPTY }
! 400:
! 401: struct delayed_action d_list[MAXDAEMONS] = {
! 402: _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_,
! 403: _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_, _X_,
! 404: };
! 405:
! 406: int group = 2;
CVSweb