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

Annotation of early-roguelike/arogue7/init.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:  * init.c  -  global variable initializaton
                      3:  *
                      4:  * Advanced Rogue
                      5:  * Copyright (C) 1984, 1985, 1986 Michael Morgan, Ken Dalka and AT&T
                      6:  * All rights reserved.
                      7:  *
                      8:  * Based on "Rogue: Exploring the Dungeons of Doom"
                      9:  * Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
                     10:  * All rights reserved.
                     11:  *
                     12:  * See the file LICENSE.TXT for full copyright and licensing information.
                     13:  */
                     14:
                     15: /*
                     16:  * global variable initializaton
                     17:  *
                     18:  */
                     19:
                     20: #include "curses.h"
                     21: #include <ctype.h>
                     22: #include <string.h>
                     23: #include "rogue.h"
                     24: #include "mach_dep.h"
                     25:
                     26:
                     27: /*
                     28:  * If there is any news, put it in a character string and assign it to
                     29:  * rogue_news.  Otherwise, assign NULL to rogue_news.
                     30:  */
                     31: static char *rogue_news = "You no longer fall into trading posts. They are \
                     32: now entered like going down the stairs.";
                     33:
                     34: char *rainbow[] = {
                     35:
                     36: "amber",               "aquamarine",           "beige",
                     37: "black",               "blue",                 "brown",
                     38: "clear",               "crimson",              "ecru",
                     39: "gold",                        "green",                "grey",
                     40: "indigo",              "khaki",                "lavender",
                     41: "magenta",             "orange",               "pink",
                     42: "plaid",               "purple",               "red",
                     43: "silver",              "saffron",              "scarlet",
                     44: "tan",                 "tangerine",            "topaz",
                     45: "turquoise",           "vermilion",            "violet",
                     46: "white",               "yellow",
                     47: };
                     48: #define NCOLORS (sizeof rainbow / sizeof(char *))
                     49: int cNCOLORS = NCOLORS;
                     50:
                     51: static char *sylls[] = {
                     52:     "a", "ab", "ag", "aks", "ala", "an", "ankh", "app", "arg", "arze",
                     53:     "ash", "ban", "bar", "bat", "bek", "bie", "bin", "bit", "bjor",
                     54:     "blu", "bot", "bu", "byt", "comp", "con", "cos", "cre", "dalf",
                     55:     "dan", "den", "do", "e", "eep", "el", "eng", "er", "ere", "erk",
                     56:     "esh", "evs", "fa", "fid", "for", "fri", "fu", "gan", "gar",
                     57:     "glen", "gop", "gre", "ha", "he", "hyd", "i", "ing", "ion", "ip",
                     58:     "ish", "it", "ite", "iv", "jo", "kho", "kli", "klis", "la", "lech",
                     59:     "man", "mar", "me", "mi", "mic", "mik", "mon", "mung", "mur",
                     60:     "nej", "nelg", "nep", "ner", "nes", "net", "nih", "nin", "o", "od",
                     61:     "ood", "org", "orn", "ox", "oxy", "pay", "pet", "ple", "plu", "po",
                     62:     "pot", "prok", "re", "rea", "rhov", "ri", "ro", "rog", "rok", "rol",
                     63:     "sa", "san", "sat", "see", "sef", "seh", "shu", "ski", "sna",
                     64:     "sne", "snik", "sno", "so", "sol", "sri", "sta", "sun", "ta",
                     65:     "tab", "tem", "ther", "ti", "tox", "trol", "tue", "turs", "u",
                     66:     "ulk", "um", "un", "uni", "ur", "val", "viv", "vly", "vom", "wah",
                     67:     "wed", "werg", "wex", "whon", "wun", "xo", "y", "yot", "yu",
                     68:     "zant", "zap", "zeb", "zim", "zok", "zon", "zum",
                     69: };
                     70:
                     71: char *stones[] = {
                     72:        "agate",                "alexandrite",          "amethyst",
                     73:        "azurite",              "bloodstone",           "cairngorm",
                     74:        "carnelian",            "chalcedony",           "chrysoberyl",
                     75:        "chrysolite",           "chrysoprase",          "citrine",
                     76:        "coral",                "diamond",              "emerald",
                     77:        "garnet",               "heliotrope",           "hematite",
                     78:        "hyacinth",             "jacinth",              "jade",
                     79:        "jargoon",              "jasper",               "kryptonite",
                     80:        "lapus lazuli",         "malachite",            "mocca stone",
                     81:        "moonstone",            "obsidian",             "olivine",
                     82:        "onyx",                 "opal",                 "pearl",
                     83:        "peridot",              "quartz",               "rhodochrosite",
                     84:        "rhodolite",            "ruby",                 "sapphire",
                     85:        "sardonyx",             "serpintine",           "spinel",
                     86:        "tiger eye",            "topaz",                "tourmaline",
                     87:        "turquoise",            "zircon",
                     88: };
                     89: #define NSTONES (sizeof stones / sizeof(char *))
                     90: int cNSTONES = NSTONES;
                     91:
                     92: char *wood[] = {
                     93:        "avocado wood", "balsa",        "banyan",       "birch",
                     94:        "cedar",        "cherry",       "cinnibar",     "dogwood",
                     95:        "driftwood",    "ebony",        "eucalyptus",   "hemlock",
                     96:        "ironwood",     "mahogany",     "manzanita",    "maple",
                     97:        "oak",          "pine",         "redwood",      "rosewood",
                     98:        "teak",         "walnut",       "zebra wood",   "persimmon wood",
                     99: };
                    100: #define NWOOD (sizeof wood / sizeof(char *))
                    101: int cNWOOD = NWOOD;
                    102:
                    103: char *metal[] = {
                    104:        "aluminium",    "bone",         "brass",        "bronze",
                    105:        "copper",       "chromium",     "iron",         "lead",
                    106:        "magnesium",    "pewter",       "platinum",     "silver",
                    107:        "steel",        "tin",          "titanium",     "zinc",
                    108: };
                    109: #define NMETAL (sizeof metal / sizeof(char *))
                    110: int cNMETAL = NMETAL;
                    111: #define MAX3(a,b,c)     (a > b ? (a > c ? a : c) : (b > c ? b : c))
                    112:
                    113: static bool used[MAX3(NCOLORS, NSTONES, NWOOD)];
                    114:
                    115: 
                    116: /*
                    117:  * make sure all the percentages specified in the tables add up to the
                    118:  * right amounts
                    119:  */
                    120: void
                    121: badcheck(char *name, struct magic_item *magic, int bound)
                    122: {
                    123:     register struct magic_item *end;
                    124:
                    125:     if (magic[bound - 1].mi_prob == 1000)
                    126:        return;
                    127:     printf("\nBad percentages for %s:\n", name);
                    128:     for (end = &magic[bound] ; magic < end ; magic++)
                    129:        printf("%4d%% %s\n", magic->mi_prob, magic->mi_name);
                    130:     printf(retstr);
                    131:     fflush(stdout);
                    132:     while (getchar() != '\n')
                    133:        continue;
                    134: }
                    135: 
                    136: /*
                    137:  * init_colors:
                    138:  *     Initialize the potion color scheme for this time
                    139:  */
                    140:
                    141: void
                    142: init_colors(void)
                    143: {
                    144:     register int i, j;
                    145:
                    146:     for (i = 0; i < NCOLORS; i++)
                    147:        used[i] = FALSE;
                    148:
                    149:     for (i = 0 ; i < MAXPOTIONS ; i++)
                    150:     {
                    151:        do
                    152:            j = rnd(NCOLORS);
                    153:        until (!used[j]);
                    154:        used[j] = TRUE;
                    155:        p_colors[i] = rainbow[j];
                    156:        p_know[i] = FALSE;
                    157:        p_guess[i] = NULL;
                    158:        if (i > 0)
                    159:                p_magic[i].mi_prob += p_magic[i-1].mi_prob;
                    160:     }
                    161:     badcheck("potions", p_magic, MAXPOTIONS);
                    162: }
                    163: 
                    164: /*
                    165:  * do any initialization for food
                    166:  */
                    167:
                    168: void
                    169: init_foods(void)
                    170: {
                    171:     register int i;
                    172:
                    173:     for (i=0; i < MAXFOODS; i++) {
                    174:        if (i > 0)
                    175:            foods[i].mi_prob += foods[i-1].mi_prob;
                    176:     }
                    177:     badcheck("foods", foods, MAXFOODS);
                    178: }
                    179: 
                    180: /*
                    181:  * init_materials:
                    182:  *     Initialize the construction materials for wands and staffs
                    183:  */
                    184:
                    185: void
                    186: init_materials(void)
                    187: {
                    188:     register int i, j;
                    189:     register char *str;
                    190:     static bool metused[NMETAL];
                    191:
                    192:     for (i = 0; i < NWOOD; i++)
                    193:        used[i] = FALSE;
                    194:     for (i = 0; i < NMETAL; i++)
                    195:        metused[i] = FALSE;
                    196:
                    197:     for (i = 0 ; i < MAXSTICKS ; i++)
                    198:     {
                    199:        for (;;)
                    200:            if (rnd(100) > 50)
                    201:            {
                    202:                j = rnd(NMETAL);
                    203:                if (!metused[j])
                    204:                {
                    205:                    ws_type[i] = "wand";
                    206:                    str = metal[j];
                    207:                    metused[j] = TRUE;
                    208:                    break;
                    209:                }
                    210:            }
                    211:            else
                    212:            {
                    213:                j = rnd(NWOOD);
                    214:                if (!used[j])
                    215:                {
                    216:                    ws_type[i] = "staff";
                    217:                    str = wood[j];
                    218:                    used[j] = TRUE;
                    219:                    break;
                    220:                }
                    221:            }
                    222:
                    223:        ws_made[i] = str;
                    224:        ws_know[i] = FALSE;
                    225:        ws_guess[i] = NULL;
                    226:        if (i > 0)
                    227:                ws_magic[i].mi_prob += ws_magic[i-1].mi_prob;
                    228:     }
                    229:     badcheck("sticks", ws_magic, MAXSTICKS);
                    230: }
                    231: 
                    232: /*
                    233:  * do any initialization for miscellaneous magic
                    234:  */
                    235:
                    236: void
                    237: init_misc(void)
                    238: {
                    239:     register int i;
                    240:
                    241:     for (i=0; i < MAXMM; i++) {
                    242:        m_know[i] = FALSE;
                    243:        m_guess[i] = NULL;
                    244:        if (i > 0)
                    245:            m_magic[i].mi_prob += m_magic[i-1].mi_prob;
                    246:     }
                    247:     badcheck("miscellaneous magic", m_magic, MAXMM);
                    248: }
                    249: 
                    250: /*
                    251:  * init_names:
                    252:  *     Generate the names of the various scrolls
                    253:  */
                    254:
                    255: void
                    256: init_names(void)
                    257: {
                    258:     register int nsyl;
                    259:     register char *cp, *sp;
                    260:     register int i, nwords;
                    261:
                    262:     for (i = 0 ; i < MAXSCROLLS ; i++)
                    263:     {
                    264:        cp = prbuf;
                    265:        nwords = rnd(cols/20) + 1 + (cols > 40 ? 1 : 0);
                    266:        while(nwords--)
                    267:        {
                    268:            nsyl = rnd(3)+1;
                    269:            while(nsyl--)
                    270:            {
                    271:                sp = sylls[rnd((sizeof sylls) / (sizeof (char *)))];
                    272:                while(*sp)
                    273:                    *cp++ = *sp++;
                    274:            }
                    275:            *cp++ = ' ';
                    276:        }
                    277:        *--cp = '\0';
                    278:        s_names[i] = (char *) new(strlen(prbuf)+1);
                    279:        s_know[i] = FALSE;
                    280:        s_guess[i] = NULL;
                    281:        strcpy(s_names[i], prbuf);
                    282:        if (i > 0)
                    283:                s_magic[i].mi_prob += s_magic[i-1].mi_prob;
                    284:     }
                    285:     badcheck("scrolls", s_magic, MAXSCROLLS);
                    286: }
                    287: 
                    288: /*
                    289:  * init_player:
                    290:  *     roll up the rogue
                    291:  */
                    292:
                    293: void
                    294: init_player(void)
                    295: {
                    296:     int stat_total, round, minimum, maximum, ch, i, j;
                    297:     short do_escape, *our_stats[NUMABILITIES-1];
                    298:     struct linked_list *weap_item, *armor_item;
                    299:     struct object *obj;
                    300:
                    301:     weap_item = armor_item = NULL;
                    302:
                    303:     if (char_type == -1) {
                    304:        /* See what type character will be */
                    305:        wclear(hw);
                    306:        touchwin(hw);
                    307:        wmove(hw,2,0);
                    308:        for(i=1; i<=NUM_CHARTYPES-1; i++) {
                    309:            wprintw(hw,"[%d] %s\n",i,char_class[i-1].name);
                    310:        }
                    311:        mvwaddstr(hw, 0, 0, "What character class do you desire? ");
                    312:        draw(hw);
                    313:        char_type = (wgetch(hw) - '0');
                    314:        while (char_type < 1 || char_type > NUM_CHARTYPES-1) {
                    315:            wmove(hw,0,0);
                    316:            wprintw(hw,"Please enter a character type between 1 and %d: ",
                    317:                    NUM_CHARTYPES-1);
                    318:            draw(hw);
                    319:            char_type = (wgetch(hw) - '0');
                    320:        }
                    321:        char_type--;
                    322:     }
                    323:     player.t_ctype = char_type;
                    324:     player.t_quiet = 0;
                    325:     pack = NULL;
                    326:
                    327:     /* Select the gold */
                    328:     purse = 2700;
                    329:     switch (player.t_ctype) {
                    330:        case C_FIGHTER:
                    331:            purse += 1800;
                    332:        when C_THIEF:
                    333:        case C_ASSASIN:
                    334:            purse += 600;
                    335:     }
                    336: #ifdef WIZARD
                    337:     /*
                    338:      * allow me to describe a super character
                    339:      */
                    340:     if (wizard && strcmp(getenv("SUPER"),"YES") == 0) {
                    341:            pstats.s_str = 25;
                    342:            pstats.s_intel = 25;
                    343:            pstats.s_wisdom = 25;
                    344:            pstats.s_dext = 25;
                    345:            pstats.s_const = 25;
                    346:            pstats.s_charisma = 25;
                    347:            pstats.s_exp = 10000000L;
                    348:            pstats.s_lvladj = 0;
                    349:            pstats.s_lvl = 1;
                    350:            pstats.s_hpt = 500;
                    351:            pstats.s_carry = totalenc(&player);
                    352:            strncpy(pstats.s_dmg, "3d4", sizeof(pstats.s_dmg));
                    353:            check_level();
                    354:            mpos = 0;
                    355:            if (player.t_ctype == C_FIGHTER ||
                    356:                player.t_ctype == C_RANGER  ||
                    357:                player.t_ctype == C_PALADIN)
                    358:                weap_item = spec_item(WEAPON, TWOSWORD, 5, 5);
                    359:            else
                    360:                weap_item = spec_item(WEAPON, SWORD, 5, 5);
                    361:            obj = OBJPTR(weap_item);
                    362:            obj->o_flags |= ISKNOW;
                    363:            add_pack(weap_item, TRUE, NULL);
                    364:            cur_weapon = obj;
                    365:            if (player.t_ctype != C_MONK) {
                    366:                j = PLATE_ARMOR;
                    367:                if (player.t_ctype == C_THIEF || player.t_ctype == C_ASSASIN)
                    368:                    j = STUDDED_LEATHER;
                    369:                armor_item = spec_item(ARMOR, j, 10, 0);
                    370:                obj = OBJPTR(armor_item);
                    371:                obj->o_flags |= (ISKNOW | ISPROT);
                    372:                obj->o_weight = armors[j].a_wght;
                    373:                add_pack(armor_item, TRUE, NULL);
                    374:                cur_armor = obj;
                    375:            }
                    376:            purse += 10000;
                    377:     }
                    378:     else
                    379: #endif
                    380:
                    381:     {
                    382:        switch(player.t_ctype) {
                    383:            case C_MAGICIAN:round = A_INTELLIGENCE;
                    384:            when C_FIGHTER:     round = A_STRENGTH;
                    385:            when C_RANGER:      round = A_STRENGTH;
                    386:            when C_PALADIN:     round = A_STRENGTH;
                    387:            when C_CLERIC:      round = A_WISDOM;
                    388:            when C_DRUID:       round = A_WISDOM;
                    389:            when C_THIEF:       round = A_DEXTERITY;
                    390:            when C_ASSASIN:     round = A_DEXTERITY;
                    391:            when C_MONK:        round = A_DEXTERITY;
                    392:        }
                    393:
                    394:        do {
                    395:            wclear(hw);
                    396:
                    397:            /* If there is any news, display it */
                    398:            if (rogue_news) {
                    399:                register int i;
                    400:
                    401:                /* Print a separator line */
                    402:                wmove(hw, 12, 0);
                    403:                for (i=0; i<cols; i++) waddch(hw, '-');
                    404:
                    405:                /* Print the news */
                    406:                mvwaddstr(hw, 14, 0, rogue_news);
                    407:            }
                    408:
                    409:            stat_total = MAXSTATS;
                    410:            do_escape = FALSE;  /* No escape seen yet */
                    411:
                    412:            /* Initialize abilities */
                    413:            pstats.s_intel = 0;
                    414:            pstats.s_str = 0;
                    415:            pstats.s_wisdom = 0;
                    416:            pstats.s_dext = 0;
                    417:            pstats.s_const = 0;
                    418:            pstats.s_charisma = 0;
                    419:
                    420:            /* Initialize pointer into abilities */
                    421:            our_stats[A_INTELLIGENCE] = &pstats.s_intel;
                    422:            our_stats[A_STRENGTH] = &pstats.s_str;
                    423:            our_stats[A_WISDOM] = &pstats.s_wisdom;
                    424:            our_stats[A_DEXTERITY] = &pstats.s_dext;
                    425:            our_stats[A_CONSTITUTION] = &pstats.s_const;
                    426:
                    427:            /* Let player distribute attributes */
                    428:            for (i=0; i<NUMABILITIES-1; i++) {
                    429:                wmove(hw, 2, 0);
                    430:                wprintw(hw, "You are creating a %s with %2d attribute points.",
                    431:                                char_class[player.t_ctype].name, stat_total);
                    432:
                    433:                /*
                    434:                 * Player must have a minimum of 7 in any attribute and 11 in
                    435:                 * the player's primary attribute.
                    436:                 */
                    437:                minimum = (round == i ? 11 : 7);
                    438:
                    439:                /* Subtract out remaining minimums */
                    440:                maximum = stat_total - (7 * (NUMABILITIES-1 - i));
                    441:
                    442:                /* Subtract out remainder of profession minimum (11 - 7) */
                    443:                if (round > i) maximum -= 4;
                    444:
                    445:                /* Maximum can't be greater than 18 */
                    446:                if (maximum > 18) maximum = 18;
                    447:
                    448:                wmove(hw, 4, 0);
                    449:                wprintw(hw,
                    450:                   "Minimum: %2d; Maximum: %2d (%s corrects previous entry)",
                    451:                   minimum, maximum, unctrl('\b'));
                    452:
                    453:                wmove(hw, 6, 0);
                    454:                wprintw(hw, "    Int: %-2d", pstats.s_intel);
                    455:                wprintw(hw, "    Str: %-2d", pstats.s_str);
                    456:                wprintw(hw, "    Wis: %-2d", pstats.s_wisdom);
                    457:                wprintw(hw, "    Dex: %-2d", pstats.s_dext);
                    458:                wprintw(hw, "    Con: %-2d", pstats.s_const);
                    459:                wprintw(hw, "    Cha: %-2d", pstats.s_charisma);
                    460:                wclrtoeol(hw);
                    461:                wmove(hw, 6, 11*i + 9);
                    462:                if (do_escape == FALSE) draw(hw);
                    463:
                    464:                /* Get player's input */
                    465:                if (do_escape || maximum == minimum) {
                    466:                    *our_stats[i] = maximum;
                    467:                    stat_total -= maximum;
                    468:                }
                    469:                else for (;;) {
                    470:                    ch = wgetch(hw);
                    471:                    if (ch == '\b') {   /* Backspace */
                    472:                        if (i == 0) continue;   /* Can't move back */
                    473:                        else {
                    474:                            stat_total += *our_stats[i-1];
                    475:                            *our_stats[i] = 0;
                    476:                            *our_stats[i-1] = 0;
                    477:                            i -= 2;     /* Back out */
                    478:                            break;
                    479:                        }
                    480:                    }
                    481:                    if (ch == '\033') { /* Escape */
                    482:                        /*
                    483:                         * Escape will result in using all maximums for
                    484:                         * remaining abilities.
                    485:                         */
                    486:                        do_escape = TRUE;
                    487:                        *our_stats[i] = maximum;
                    488:                        stat_total -= maximum;
                    489:                        break;
                    490:                    }
                    491:
                    492:                    /* Do we have a legal digit? */
                    493:                    if (ch >= '0' && ch <= '9') {
                    494:                        ch -= '0';      /* Convert it to a number */
                    495:                        *our_stats[i] = 10 * *our_stats[i] + ch;
                    496:
                    497:                        /* Is the number in range? */
                    498:                        if (*our_stats[i] >= minimum &&
                    499:                            *our_stats[i] <= maximum) {
                    500:                            stat_total -= *our_stats[i];
                    501:                            break;
                    502:                        }
                    503:
                    504:                        /*
                    505:                         * If it's too small, get more - 1x is the only
                    506:                         * allowable case.
                    507:                         */
                    508:                        if (*our_stats[i] < minimum && *our_stats[i] == 1) {
                    509:                            /* Print the player's one */
                    510:                            waddch(hw, '1');
                    511:                            draw(hw);
                    512:                            continue;
                    513:                        }
                    514:                    }
                    515:
                    516:                    /* Error condition */
                    517:                    putchar('\007');
                    518:                    *our_stats[i] = 0;
                    519:                    i--;        /* Rewind */
                    520:                    break;
                    521:                }
                    522:            }
                    523:
                    524:            /* Discard extra points over 18 */
                    525:            if (stat_total > 18) stat_total = 18;
                    526:
                    527:            /* Charisma gets what's left */
                    528:            pstats.s_charisma = stat_total;
                    529:
                    530:            /* Intialize constants */
                    531:            pstats.s_lvl = 1;
                    532:            pstats.s_lvladj = 0;
                    533:            pstats.s_exp = 0L;
                    534:            strncpy(pstats.s_dmg, "1d4", sizeof(pstats.s_dmg));
                    535:            pstats.s_carry = totalenc(&player);
                    536:
                    537:            /* Get the hit points. */
                    538:            pstats.s_hpt = 12 + const_bonus();  /* Base plus bonus */
                    539:
                    540:            /* Add in the component that varies according to class */
                    541:            pstats.s_hpt += char_class[player.t_ctype].hit_pts;
                    542:
                    543:            /* Display the character */
                    544:            wmove(hw, 2, 0);
                    545:            wprintw(hw,"You are creating a %s.",
                    546:                        char_class[player.t_ctype].name);
                    547:            wclrtoeol(hw);
                    548:
                    549:            /* Get rid of max/min line */
                    550:            wmove(hw, 4, 0);
                    551:            wclrtoeol(hw);
                    552:
                    553:            wmove(hw, 6, 0);
                    554:            wprintw(hw, "    Int: %2d", pstats.s_intel);
                    555:            wprintw(hw, "    Str: %2d", pstats.s_str);
                    556:            wprintw(hw, "    Wis: %2d", pstats.s_wisdom);
                    557:            wprintw(hw, "    Dex: %2d", pstats.s_dext);
                    558:            wprintw(hw, "    Con: %2d", pstats.s_const);
                    559:            wprintw(hw, "    Cha: %2d", pstats.s_charisma);
                    560:            wclrtoeol(hw);
                    561:
                    562:            wmove(hw, 8, 0);
                    563:            wprintw(hw, "    Hp: %2d", pstats.s_hpt);
                    564:            wclrtoeol(hw);
                    565:
                    566:            wmove(hw, 10, 0);
                    567:            wprintw(hw, "    Gold: %d", purse);
                    568:
                    569:            mvwaddstr(hw, 0, 0, "Is this character okay? ");
                    570:            draw(hw);
                    571:        } while(wgetch(hw) != 'y');
                    572:     }
                    573:
                    574:     pstats.s_arm = 10;
                    575:     max_stats = pstats;
                    576:
                    577:     /* Set up the initial movement rate */
                    578:     player.t_action = A_NIL;
                    579:     player.t_movement = 6;
                    580:     player.t_no_move = 0;
                    581:     player.t_using = NULL;
                    582: }
                    583:
                    584:
                    585:
                    586:
                    587: 
                    588:
                    589: /*
                    590:  * init_stones:
                    591:  *     Initialize the ring stone setting scheme for this time
                    592:  */
                    593:
                    594: void
                    595: init_stones(void)
                    596: {
                    597:     register int i, j;
                    598:
                    599:     for (i = 0; i < NSTONES; i++)
                    600:        used[i] = FALSE;
                    601:
                    602:     for (i = 0 ; i < MAXRINGS ; i++)
                    603:     {
                    604:         do
                    605:             j = rnd(NSTONES);
                    606:        until (!used[j]);
                    607:        used[j] = TRUE;
                    608:        r_stones[i] = stones[j];
                    609:        r_know[i] = FALSE;
                    610:        r_guess[i] = NULL;
                    611:        if (i > 0)
                    612:                r_magic[i].mi_prob += r_magic[i-1].mi_prob;
                    613:     }
                    614:     badcheck("rings", r_magic, MAXRINGS);
                    615: }
                    616: 
                    617: /*
                    618:  * init_things
                    619:  *     Initialize the probabilities for types of things
                    620:  */
                    621: void
                    622: init_things(void)
                    623: {
                    624:     register struct magic_item *mp;
                    625:
                    626:     for (mp = &things[1] ; mp < &things[NUMTHINGS] ; mp++)
                    627:        mp->mi_prob += (mp-1)->mi_prob;
                    628:     badcheck("things", things, NUMTHINGS);
                    629: }
                    630:
                    631:

CVSweb