[BACK]Return to extern.c CVS log [TXT][DIR] Up to [contributed] / early-roguelike / rogue4

Annotation of early-roguelike/rogue4/extern.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:  * global variable initializaton
                      3:  *
                      4:  * @(#)extern.c        4.32 (Berkeley) 4/1/82
                      5:  *
                      6:  * Rogue: Exploring the Dungeons of Doom
                      7:  * Copyright (C) 1980, 1981, 1982 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: #include <curses.h>
                     14: #include "rogue.h"
                     15:
                     16: bool after;                            /* True if we want after daemons */
                     17: bool noscore;                          /* Was a wizard sometime */
                     18: bool s_know[MAXSCROLLS];               /* Does he know what a scroll does */
                     19: bool p_know[MAXPOTIONS];               /* Does he know what a potion does */
                     20: bool r_know[MAXRINGS];                 /* Does he know what a ring does */
                     21: bool ws_know[MAXSTICKS];               /* Does he know what a stick does */
                     22: bool amulet = FALSE;                   /* He found the amulet */
                     23: bool askme = TRUE;                     /* Ask about unidentified things */
                     24: bool door_stop = FALSE;                        /* Stop running when we pass a door */
                     25: bool fight_flush = FALSE;              /* True if toilet input */
                     26: bool firstmove = FALSE;                        /* First move after setting door_stop */
                     27: bool in_shell = FALSE;                 /* True if executing a shell */
                     28: bool jump = FALSE;                     /* Show running as series of jumps */
                     29: bool passgo = FALSE;                   /* Follow passages */
                     30: bool playing = TRUE;                   /* True until he quits */
                     31: bool running = FALSE;                  /* True if player is running */
                     32: bool save_msg = TRUE;                  /* Remember last msg */
                     33: bool slow_invent = FALSE;              /* Inventory one line at a time */
                     34: bool terse = FALSE;                    /* True if we should be short */
                     35: bool use_savedir = FALSE;              /* True if using system savefile area */
                     36: #ifdef WIZARD
                     37: bool wizard = FALSE;                   /* True if allows wizard commands */
                     38: #endif
                     39:
                     40: char take;                             /* Thing the rogue is taking */
                     41: char prbuf[MAXSTR];                    /* Buffer for sprintfs */
                     42: char outbuf[BUFSIZ];                   /* Output buffer for stdout */
                     43: char runch;                            /* Direction player is running */
                     44: char *s_names[MAXSCROLLS];             /* Names of the scrolls */
                     45: const char *p_colors[MAXPOTIONS];              /* Colors of the potions */
                     46: const char *r_stones[MAXRINGS];                /* Stone settings of the rings */
                     47: const char *w_names[MAXWEAPONS + 1] = {        /* Names of the various weapons */
                     48:     "mace",
                     49:     "long sword",
                     50:     "short bow",
                     51:     "arrow",
                     52:     "dagger",
                     53:     "two handed sword",
                     54:     "dart",
                     55:     "crossbow",
                     56:     "crossbow bolt",
                     57:     "spear",
                     58:     NULL                               /* fake entry for dragon's breath */
                     59: };
                     60: const char *a_names[MAXARMORS] = {             /* Names of armor types */
                     61:     "leather armor",
                     62:     "ring mail",
                     63:     "studded leather armor",
                     64:     "scale mail",
                     65:     "chain mail",
                     66:     "splint mail",
                     67:     "banded mail",
                     68:     "plate mail",
                     69: };
                     70: const char *ws_made[MAXSTICKS];                /* What sticks are made of */
                     71: char whoami[MAXSTR];                   /* Name of player */
                     72: char fruit[MAXSTR];                    /* Favorite fruit */
                     73: char huh[MAXSTR];                      /* The last message printed */
                     74: char *s_guess[MAXSCROLLS];             /* Players guess at what scroll is */
                     75: char *p_guess[MAXPOTIONS];             /* Players guess at what potion is */
                     76: char *r_guess[MAXRINGS];               /* Players guess at what ring is */
                     77: char *ws_guess[MAXSTICKS];             /* Players guess at what wand is */
                     78: char *ws_type[MAXSTICKS];              /* Is it a wand or a staff */
                     79: char file_name[256];                   /* Save file name */
                     80: char home[MAXSTR];                     /* User's home directory */
                     81: char _level[MAXLINES*MAXCOLS];         /* Level map */
                     82: char _flags[MAXLINES*MAXCOLS];         /* Flags for each space on the map */
                     83:
                     84: int max_level;                         /* Deepest player has gone */
                     85: int ntraps;                            /* Number of traps on this level */
                     86: int dnum;                              /* Dungeon number */
                     87: int level = 1;                         /* What level rogue is on */
                     88: int purse = 0;                         /* How much gold the rogue has */
                     89: int mpos = 0;                          /* Where cursor is on top line */
                     90: int no_move = 0;                       /* Number of turns held in place */
                     91: int no_command = 0;                    /* Number of turns asleep */
                     92: int inpack = 0;                                /* Number of things in pack */
                     93: int total = 0;                         /* Total dynamic memory bytes */
                     94: int lastscore = -1;                    /* Score before this turn */
                     95: int no_food = 0;                       /* Number of levels without food */
                     96: int count = 0;                         /* Number of times to repeat command */
                     97: int fung_hit = 0;                      /* Number of time fungi has hit */
                     98: int quiet = 0;                         /* Number of quiet turns */
                     99: int food_left;                         /* Amount of food in hero's stomach */
                    100: int group = 2;                         /* Current group number */
                    101: int hungry_state = 0;                  /* How hungry is he */
                    102: int a_chances[MAXARMORS] = {           /* Chance for each armor type */
                    103:     20,
                    104:     35,
                    105:     50,
                    106:     63,
                    107:     75,
                    108:     85,
                    109:     95,
                    110:     100
                    111: };
                    112: int a_class[MAXARMORS] = {             /* Armor class for each armor type */
                    113:     8,
                    114:     7,
                    115:     7,
                    116:     6,
                    117:     5,
                    118:     4,
                    119:     4,
                    120:     3,
                    121: };
                    122:
                    123: long seed;                             /* Random number seed */
                    124:
                    125: coord oldpos;                          /* Position before last look() call */
                    126: coord delta;                           /* Change indicated to get_dir() */
                    127:
                    128: THING player;                          /* The rogue */
                    129: THING *cur_armor;                      /* What a well dresssed rogue wears */
                    130: THING *cur_weapon;                     /* Which weapon he is weilding */
                    131: THING *cur_ring[2];                    /* Which rings are being worn */
                    132: THING *lvl_obj = NULL;                 /* List of objects on this level */
                    133: THING *mlist = NULL;                   /* List of monsters on the level */
                    134: THING *_monst[MAXLINES*MAXCOLS];       /* Pointers for monsters at each spot */
                    135:
                    136: FILE *score_file = NULL;               /* Scoreboard */
                    137: FILE *log_file = NULL;                 /* Log file */
                    138:
                    139: WINDOW *hw;                            /* Used as a scratch window */
                    140:
                    141: #define INIT_STATS { 16, 0, 1, 10, 12, "1d4", 12 }
                    142:
                    143: struct stats max_stats = INIT_STATS;   /* The maximum for the player */
                    144:
                    145: struct room *oldrp;                    /* Roomin(&oldpos) */
                    146: struct room rooms[MAXROOMS];           /* One for each room -- A level */
                    147: #define NON {0, 0}
                    148: #define NON12 { NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, NON, NON }
                    149: struct room passages[MAXPASS] =                /* One for each passage */
                    150: {
                    151:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    152:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    153:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    154:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    155:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    156:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    157:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    158:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    159:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    160:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    161:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 },
                    162:     { {0, 0}, {0, 0}, {0, 0}, 0, ISGONE|ISDARK, 0, NON12 }
                    163: };
                    164: #undef NON12
                    165: #undef NON
                    166:
                    167: #define ___ 1
                    168: #define XX 10
                    169: struct monster monsters[26] =
                    170: {
                    171:        /* Name          CARRY  FLAG    str, exp, lvl, amr, hpt, dmg */
                    172:        { "giant ant",   0,     ISMEAN, { XX,  9,   2,   3, ___, "1d6" } },
                    173:        { "bat",         0,     0,      { XX,  1,   1,   3, ___, "1d2" } },
                    174:        { "centaur",     15,    0,      { XX, 15,   4,   4, ___, "1d6/1d6" } },
                    175:        { "dragon",      100,   ISMEAN, { XX,6800, 10,  -1, ___, "1d8/1d8/3d10" } },
                    176:        { "floating eye",0,     0,      { XX,  5,   1,   9, ___, "0d0" } },
                    177:        { "violet fungi",0,     ISMEAN, { XX, 80,   8,   3, ___, "0d0" } },
                    178:        { "gnome",       10,    0,      { XX,  7,   1,   5, ___, "1d6" } },
                    179:        { "hobgoblin",   0,     ISMEAN, { XX,  3,   1,   5, ___, "1d8" } },
                    180:        { "invisible stalker",0,ISINVIS,{ XX,120,   8,   3, ___, "4d4" } },
                    181:        { "jackal",      0,     ISMEAN, { XX,  2,   1,   7, ___, "1d2" } },
                    182:        { "kobold",      0,     ISMEAN, { XX,  1,   1,   7, ___, "1d4" } },
                    183:        { "leprechaun",  0,     0,      { XX, 10,   3,   8, ___, "1d1" } },
                    184:        { "mimic",       30,    0,      { XX,100,   7,   7, ___, "3d4" } },
                    185:        { "nymph",       100,   0,      { XX, 37,   3,   9, ___, "0d0" } },
                    186:        { "orc",         15,    ISGREED,{ XX,  5,   1,   6, ___, "1d8" } },
                    187:        { "purple worm", 70,    0,      { XX,4000, 15,   6, ___, "2d12/2d4" } },
                    188:        { "quasit",      30,    ISMEAN, { XX, 32,   3,   2, ___, "1d2/1d2/1d4" } },
                    189:        { "rust monster",0,     ISMEAN, { XX, 20,   5,   2, ___, "0d0/0d0" } },
                    190:        { "snake",       0,     ISMEAN, { XX,  2,   1,   5, ___, "1d3" } },
                    191:        { "troll",       50,    ISREGEN|ISMEAN,{ XX, 120, 6, 4, ___, "1d8/1d8/2d6" } },
                    192:        { "umber hulk",  40,    ISMEAN, { XX,200,   8,   2, ___, "3d4/3d4/2d5" } },
                    193:        { "vampire",     20,    ISREGEN|ISMEAN,{ XX,350,   8,   1, ___, "1d10" } },
                    194:        { "wraith",      0,     0,      { XX, 55,   5,   4, ___, "1d6" } },
                    195:        { "xorn",        0,     ISMEAN, { XX,190,   7,  -2, ___, "1d3/1d3/1d3/4d6" } },
                    196:        { "yeti",        30,    0,      { XX, 50,   4,   6, ___, "1d6/1d6" } },
                    197:        { "zombie",      0,     ISMEAN, { XX,  6,   2,   8, ___, "1d8" } }
                    198: };
                    199: #undef ___
                    200: #undef XX
                    201:
                    202: struct magic_item things[NUMTHINGS] = {
                    203:     { 0,                       27 },   /* potion */
                    204:     { 0,                       30 },   /* scroll */
                    205:     { 0,                       17 },   /* food */
                    206:     { 0,                        8 },   /* weapon */
                    207:     { 0,                        8 },   /* armor */
                    208:     { 0,                        5 },   /* ring */
                    209:     { 0,                        5 },   /* stick */
                    210: };
                    211:
                    212: struct magic_item s_magic[MAXSCROLLS] = {
                    213:     { "monster confusion",      8, 140 },
                    214:     { "magic mapping",          5, 150 },
                    215:     { "hold monster",           3, 180 },
                    216:     { "sleep",                  5,   5 },
                    217:     { "enchant armor",          8, 160 },
                    218:     { "identify",              27, 100 },
                    219:     { "scare monster",          4, 200 },
                    220:     { "gold detection",                 4,  50 },
                    221:     { "teleportation",          7, 165 },
                    222:     { "enchant weapon",                10, 150 },
                    223:     { "create monster",                 5,  75 },
                    224:     { "remove curse",           8, 105 },
                    225:     { "aggravate monsters",     4,  20 },
                    226:     { "blank paper",            1,   5 },
                    227:     { "genocide",               1, 300 },
                    228: };
                    229:
                    230: struct magic_item p_magic[MAXPOTIONS] = {
                    231:     { "confusion",              8,   5 },
                    232:     { "paralysis",             10,   5 },
                    233:     { "poison",                         8,   5 },
                    234:     { "gain strength",         15, 150 },
                    235:     { "see invisible",          2, 100 },
                    236:     { "healing",               15, 130 },
                    237:     { "monster detection",      6, 130 },
                    238:     { "magic detection",        6, 105 },
                    239:     { "raise level",            2, 250 },
                    240:     { "extra healing",          5, 200 },
                    241:     { "haste self",             4, 190 },
                    242:     { "restore strength",      14, 130 },
                    243:     { "blindness",              4,   5 },
                    244:     { "thirst quenching",       1,   5 },
                    245: };
                    246:
                    247: struct magic_item r_magic[MAXRINGS] = {
                    248:     { "protection",             9, 400 },
                    249:     { "add strength",           9, 400 },
                    250:     { "sustain strength",       5, 280 },
                    251:     { "searching",             10, 420 },
                    252:     { "see invisible",         10, 310 },
                    253:     { "adornment",              1,  10 },
                    254:     { "aggravate monster",     10,  10 },
                    255:     { "dexterity",              8, 440 },
                    256:     { "increase damage",        8, 400 },
                    257:     { "regeneration",           4, 460 },
                    258:     { "slow digestion",                 9, 240 },
                    259:     { "teleportation",          5,  30 },
                    260:     { "stealth",                7, 470 },
                    261:     { "maintain armor",                 5, 380 },
                    262: };
                    263:
                    264: struct magic_item ws_magic[MAXSTICKS] = {
                    265:     { "light",                 12, 250 },
                    266:     { "striking",               9,  75 },
                    267:     { "lightning",              3, 330 },
                    268:     { "fire",                   3, 330 },
                    269:     { "cold",                   3, 330 },
                    270:     { "polymorph",             15, 310 },
                    271:     { "magic missile",         10, 170 },
                    272:     { "haste monster",          9,   5 },
                    273:     { "slow monster",          11, 350 },
                    274:     { "drain life",             9, 300 },
                    275:     { "nothing",                1,   5 },
                    276:     { "teleport away",          5, 340 },
                    277:     { "teleport to",            5,  50 },
                    278:     { "cancellation",           5, 280 },
                    279: };
                    280:
                    281: struct h_list helpstr[] = {
                    282:     { '?',     "       prints help" },
                    283:     { '/',     "       identify object" },
                    284:     { 'h',     "       left" },
                    285:     { 'j',     "       down" },
                    286:     { 'k',     "       up" },
                    287:     { 'l',     "       right" },
                    288:     { 'y',     "       up & left" },
                    289:     { 'u',     "       up & right" },
                    290:     { 'b',     "       down & left" },
                    291:     { 'n',     "       down & right" },
                    292:     { 'H',     "       run left" },
                    293:     { 'J',     "       run down" },
                    294:     { 'K',     "       run up" },
                    295:     { 'L',     "       run right" },
                    296:     { 'Y',     "       run up & left" },
                    297:     { 'U',     "       run up & right" },
                    298:     { 'B',     "       run down & left" },
                    299:     { 'N',     "       run down & right" },
                    300:     { 't',     "<dir>  throw something" },
                    301:     { 'f',     "<dir>  forward until find something" },
                    302:     { 'z',     "<dir>  zap a wand in a direction" },
                    303:     { '^',     "<dir>  identify trap type" },
                    304:     { 's',     "       search for trap/secret door" },
                    305:     { '>',     "       go down a staircase" },
                    306:     { '<',     "       go up a staircase" },
                    307:     { '.',     "       rest for a while" },
                    308:     { 'i',     "       inventory" },
                    309:     { 'I',     "       inventory single item" },
                    310:     { 'q',     "       quaff potion" },
                    311:     { 'r',     "       read paper" },
                    312:     { 'e',     "       eat food" },
                    313:     { 'w',     "       wield a weapon" },
                    314:     { 'W',     "       wear armor" },
                    315:     { 'T',     "       take armor off" },
                    316:     { 'P',     "       put on ring" },
                    317:     { 'R',     "       remove ring" },
                    318:     { 'd',     "       drop object" },
                    319:     { 'c',     "       call object" },
                    320:     { 'D',     "       recall what's been discovered" },
                    321:     { 'o',     "       examine/set options" },
                    322:     { CTRL('L'),       "       redraw screen" },
                    323:     { CTRL('R'),       "       repeat last message" },
                    324:     { ESCAPE,  "       cancel command" },
                    325:     { '!',     "       shell escape" },
                    326:     { 'S',     "       save game" },
                    327:     { 'Q',     "       quit" },
                    328:     { 0, 0 }
                    329: };

CVSweb