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

Annotation of early-roguelike/xrogue/wizard.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:     wizard.c - Special wizard commands
                      3:
                      4:     XRogue: Expeditions into the Dungeons of Doom
                      5:     Copyright (C) 1991 Robert Pietkivitch
                      6:     All rights reserved.
                      7:
                      8:     Based on "Advanced Rogue"
                      9:     Copyright (C) 1984, 1985 Michael Morgan, Ken Dalka and AT&T
                     10:     All rights reserved.
                     11:
                     12:     Based on "Rogue: Exploring the Dungeons of Doom"
                     13:     Copyright (C) 1980, 1981 Michael Toy, Ken Arnold and Glenn Wichman
                     14:     All rights reserved.
                     15:
                     16:     See the file LICENSE.TXT for full copyright and licensing information.
                     17: */
                     18:
                     19: /*
                     20:  * Special wizard commands (some of which are also non-wizard commands
                     21:  * under strange circumstances)
                     22:  */
                     23:
                     24: int getbless(void);
                     25:
                     26: #include <stdlib.h>
                     27: #include <curses.h>
                     28: #include <ctype.h>
                     29: #include <string.h>
                     30: #include "rogue.h"
                     31: #include "mach_dep.h"
                     32:
                     33: /*
                     34:  * create_obj:
                     35:  *      Create any object for wizard, scroll, magician, or cleric
                     36:  */
                     37:
                     38: void
                     39: create_obj(bool prompt, int which_item, int which_type)
                     40: {
                     41:     reg struct linked_list *item;
                     42:     reg struct object *obj;
                     43:     reg int wh;
                     44:     char *pt;
                     45:     reg int ch, whc, newtype = 0, msz, newitem;
                     46:     WINDOW *thiswin;
                     47:
                     48:     thiswin = cw;
                     49:     if (prompt) {
                     50:         bool nogood = TRUE;
                     51:
                     52:         thiswin = hw;
                     53:         wclear(hw);
                     54:         wprintw(hw,"Item\t\t\tKey\n\n");
                     55:         wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_RING].mi_name,RING,
                     56:                 things[TYP_STICK].mi_name,STICK);
                     57:         wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_POTION].mi_name,POTION,
                     58:                 things[TYP_SCROLL].mi_name,SCROLL);
                     59:         wprintw(hw,"%s\t\t\t%c\n%s\t\t\t%c\n",things[TYP_ARMOR].mi_name,ARMOR,
                     60:                 things[TYP_WEAPON].mi_name,WEAPON);
                     61:         wprintw(hw,"%s\t%c\n",things[TYP_MM].mi_name,MM);
                     62:         wprintw(hw,"%s\t\t\t%c\n",things[TYP_FOOD].mi_name,FOOD);
                     63:         if (wizard) {
                     64:             wprintw(hw,"%s\t\t%c\n",things[TYP_RELIC].mi_name,RELIC);
                     65:             wprintw(hw,"monster\t\t\tm");
                     66:         }
                     67:         wprintw(hw,"\n\nWhat do you want to create? ");
                     68:         draw(hw);
                     69:         do {
                     70:             ch = wgetch(hw);
                     71:             if (ch == ESC) {
                     72:                 restscr(cw);
                     73:                 return;
                     74:             }
                     75:             switch (ch) {
                     76:                 case RING:
                     77:                 case STICK:
                     78:                 case POTION:
                     79:                 case SCROLL:
                     80:                 case ARMOR:
                     81:                 case WEAPON:
                     82:                 case FOOD:
                     83:                 case MM:
                     84:                     nogood = FALSE;
                     85:                     break;
                     86:                 case RELIC:
                     87:                 case 'm':
                     88:                     if (wizard)
                     89:                         nogood = FALSE;
                     90:                     break;
                     91:                 default:
                     92:                     nogood = TRUE;
                     93:             }
                     94:         } while (nogood);
                     95:         newitem = ch;
                     96:     }
                     97:     else
                     98:         newitem = which_item;
                     99:
                    100:     pt = "those";
                    101:     msz = 0;
                    102:     if(newitem == 'm') {
                    103:         /* make monster and be done with it */
                    104:         wh = makemonster(TRUE, "create");
                    105:         if (wh > 0) {
                    106:             creat_mons (&player, wh, TRUE);
                    107:             light(&hero);
                    108:         }
                    109:         return;
                    110:     }
                    111:     if(newitem == GOLD) pt = "gold";
                    112:     else if(isatrap(newitem)) pt = "traps";
                    113:
                    114:     switch(newitem) {
                    115:         case POTION:    whc = TYP_POTION;       msz = MAXPOTIONS;
                    116:         when SCROLL:    whc = TYP_SCROLL;       msz = MAXSCROLLS;
                    117:         when WEAPON:    whc = TYP_WEAPON;       msz = MAXWEAPONS;
                    118:         when ARMOR:     whc = TYP_ARMOR;        msz = MAXARMORS;
                    119:         when RING:      whc = TYP_RING;         msz = MAXRINGS;
                    120:         when STICK:     whc = TYP_STICK;        msz = MAXSTICKS;
                    121:         when MM:        whc = TYP_MM;           msz = MAXMM;
                    122:         when RELIC:     whc = TYP_RELIC;        msz = MAXRELIC;
                    123:         when FOOD:      whc = TYP_FOOD;         msz = MAXFOODS;
                    124:         otherwise:
                    125:             if (thiswin == hw)
                    126:                 restscr(cw);
                    127:             mpos = 0;
                    128:             msg("Even wizards can't create %s !!",pt);
                    129:             return;
                    130:     }
                    131:     if(msz == 1) {              /* if only one type of item */
                    132:         ch = 'a';
                    133:     }
                    134:     else if (prompt) {
                    135:         register struct magic_item *wmi;
                    136:         char wmn;
                    137:         register int ii;
                    138:         int old_prob;
                    139:
                    140:         mpos = 0;
                    141:         wmi = NULL;
                    142:         wmn = 0;
                    143:         switch(newitem) {
                    144:                 case POTION:    wmi = &p_magic[0];
                    145:                 when SCROLL:    wmi = &s_magic[0];
                    146:                 when RING:      wmi = &r_magic[0];
                    147:                 when STICK:     wmi = &ws_magic[0];
                    148:                 when MM:        wmi = &m_magic[0];
                    149:                 when RELIC:     wmi = &rel_magic[0];
                    150:                 when FOOD:      wmi = &foods[0];
                    151:                 when WEAPON:    wmn = 1;
                    152:                 when ARMOR:     wmn = 2;
                    153:         }
                    154:         wclear(hw);
                    155:         thiswin = hw;
                    156:         if (wmi != NULL) {
                    157:             ii = old_prob = 0;
                    158:             while (ii < msz) {
                    159:                 if(wmi->mi_prob == old_prob && wizard == FALSE) {
                    160:                     msz--; /* can't make a unique item */
                    161:                 }
                    162:                 else {
                    163:                     mvwaddch(hw,ii % 13,ii > 12 ? cols/2 : 0, ii + 'a');
                    164:                     waddstr(hw,") ");
                    165:                     waddstr(hw,wmi->mi_name);
                    166:                     ii++;
                    167:                 }
                    168:                 old_prob = wmi->mi_prob;
                    169:                 wmi++;
                    170:             }
                    171:         }
                    172:         else if (wmn != 0) {
                    173:             for(ii = 0 ; ii < msz ; ii++) {
                    174:                 mvwaddch(hw,ii % 13,ii > 12 ? cols/2 : 0, ii + 'a');
                    175:                 waddstr(hw,") ");
                    176:                 if(wmn == 1)
                    177:                     waddstr(hw,weaps[ii].w_name);
                    178:                 else
                    179:                     waddstr(hw,armors[ii].a_name);
                    180:             }
                    181:         }
                    182:         sprintf(prbuf,"Which %s? ",things[whc].mi_name);
                    183:         mvwaddstr(hw,lines - 1, 0, prbuf);
                    184:         draw(hw);
                    185:         do {
                    186:             ch = wgetch(hw);
                    187:             if (ch == ESC) {
                    188:                 restscr(cw);
                    189:                 msg("");
                    190:                 return;
                    191:             }
                    192:         } until (isalpha(ch));
                    193:         if (thiswin == hw)                      /* restore screen if need be */
                    194:             restscr(cw);
                    195:         newtype = ch - 'a';
                    196:         if(newtype < 0 || newtype >= msz) {     /* if an illegal value */
                    197:             mpos = 0;
                    198:             msg("There is no such %s",things[whc].mi_name);
                    199:             return;
                    200:         }
                    201:     }
                    202:     else
                    203:         newtype = which_type;
                    204:     item = new_item(sizeof *obj);       /* get some memory */
                    205:     obj = OBJPTR(item);
                    206:     obj->o_type = newitem;              /* store the new items */
                    207:     obj->o_mark[0] = '\0';
                    208:     obj->o_which = newtype;
                    209:     obj->o_group = 0;
                    210:     obj->contents = NULL;
                    211:     obj->o_count = 1;
                    212:     obj->o_flags = 0;
                    213:     obj->o_dplus = obj->o_hplus = 0;
                    214:     obj->o_weight = 0;
                    215:     wh = obj->o_which;
                    216:     mpos = 0;
                    217:     if (!wizard)                /* users get 0 to +5 */
                    218:         whc = rnd(6);
                    219:     else                        /* wizard gets to choose */
                    220:         whc = getbless();
                    221:     if (whc < 0)
                    222:         obj->o_flags |= ISCURSED;
                    223:     switch (obj->o_type) {
                    224:         case WEAPON:
                    225:         case ARMOR:
                    226:             if (obj->o_type == WEAPON) {
                    227:                 init_weapon(obj, wh);
                    228:                 obj->o_hplus += whc;
                    229:                 if (!wizard) whc = rnd(6);
                    230:                 obj->o_dplus += whc;
                    231:             }
                    232:             else {                              /* armor here */
                    233:                 obj->o_weight = armors[wh].a_wght;
                    234:                 obj->o_ac = armors[wh].a_class - whc;
                    235:             }
                    236:         when RING:
                    237:             r_know[wh] = TRUE;
                    238:             switch(wh) {
                    239:                 case R_ADDSTR:
                    240:                 case R_ADDWISDOM:
                    241:                 case R_ADDINTEL:
                    242:                 case R_PROTECT:
                    243:                 case R_ADDHIT:
                    244:                 case R_ADDDAM:
                    245:                 case R_DIGEST:
                    246:                     obj->o_ac = whc + 2;
                    247:                     break;
                    248:                 default:
                    249:                     obj->o_ac = 0;
                    250:             }
                    251:             obj->o_weight = things[TYP_RING].mi_wght;
                    252:         when MM:
                    253:             if (whc > 1 && m_magic[wh].mi_bless != 0)
                    254:                 obj->o_flags |= ISBLESSED;
                    255:             m_know[wh] = TRUE;
                    256:             switch(wh) {
                    257:                 case MM_JUG:
                    258:                     switch(rnd(11)) {
                    259:                         case 0: obj->o_ac = P_PHASE;
                    260:                         when 1: obj->o_ac = P_CLEAR;
                    261:                         when 2: obj->o_ac = P_SEEINVIS;
                    262:                         when 3: obj->o_ac = P_HEALING;
                    263:                         when 4: obj->o_ac = P_MFIND;
                    264:                         when 5: obj->o_ac = P_TFIND;
                    265:                         when 6: obj->o_ac = P_HASTE;
                    266:                         when 7: obj->o_ac = P_RESTORE;
                    267:                         when 8: obj->o_ac = P_FLY;
                    268:                         when 9: obj->o_ac = P_SKILL;
                    269:                         when 10:obj->o_ac = P_FFIND;
                    270:                     }
                    271:                 when MM_HUNGER:
                    272:                 case MM_CHOKE:
                    273:             if (whc < 0 )
                    274:             whc = -whc;     /* cannot be negative */
                    275:             obj->o_ac = (whc + 1) * 2;
                    276:             break;
                    277:                 when MM_OPEN:
                    278:                 case MM_DRUMS:
                    279:                 case MM_DISAPPEAR:
                    280:                 case MM_KEOGHTOM:
                    281:                     if (whc < 0)
                    282:                         whc = -whc;     /* these cannot be negative */
                    283:                     obj->o_ac = (whc + 3) * 5;
                    284:                     break;
                    285:                 when MM_BRACERS:
                    286:                     obj->o_ac = whc + 4;
                    287:                 when MM_DISP:
                    288:                     obj->o_ac = 3;
                    289:                 when MM_PROTECT:
                    290:                     obj->o_ac = whc + 4;
                    291:                 when MM_SKILLS:
                    292:                     if (whc < 2)
                    293:                         obj->o_ac = rnd(NUM_CHARTYPES-1);
                    294:                     else
                    295:                         obj->o_ac = player.t_ctype;
                    296:         when MM_CRYSTAL:
                    297:             obj->o_ac = 1;
                    298:                 otherwise:
                    299:                     obj->o_ac = 0;
                    300:             }
                    301:             obj->o_weight = things[TYP_MM].mi_wght;
                    302:         when STICK:
                    303:             if (whc > 1 && ws_magic[wh].mi_bless != 0)
                    304:                 obj->o_flags |= ISBLESSED;
                    305:             ws_know[wh] = TRUE;
                    306:             fix_stick(obj);
                    307:         when SCROLL:
                    308:             if (whc > 3 && s_magic[wh].mi_bless != 0)
                    309:                 obj->o_flags |= ISBLESSED;
                    310:             obj->o_weight = things[TYP_SCROLL].mi_wght;
                    311:             s_know[wh] = TRUE;
                    312:         when POTION:
                    313:             if (whc > 3 && p_magic[wh].mi_bless != 0)
                    314:                 obj->o_flags |= ISBLESSED;
                    315:             obj->o_weight = things[TYP_POTION].mi_wght;
                    316:             if (wh == P_ABIL) obj->o_kind = rnd(NUMABILITIES);
                    317:             p_know[wh] = TRUE;
                    318:         when RELIC:
                    319:             obj->o_weight = things[TYP_RELIC].mi_wght;
                    320:             switch (obj->o_which) {
                    321:                 case QUILL_NAGROM: obj->o_charges = QUILLCHARGES;
                    322:                 when EMORI_CLOAK:  obj->o_charges = 1;
                    323:                 otherwise: break;
                    324:             }
                    325:         when FOOD:
                    326:             obj->o_weight = things[TYP_FOOD].mi_wght;
                    327:     }
                    328:     mpos = 0;
                    329:     obj->o_flags |= ISKNOW;
                    330:     if (add_pack(item, FALSE) == FALSE) {
                    331:         obj->o_pos = hero;
                    332:         fall(item, TRUE);
                    333:     }
                    334: }
                    335:
                    336: /*
                    337:  * getbless:
                    338:  *      Get a blessing for a wizards object
                    339:  */
                    340:
                    341: int
                    342: getbless(void)
                    343: {
                    344:         reg char bless;
                    345:
                    346:         msg("Blessing? (+,-,n)");
                    347:         bless = wgetch(msgw);
                    348:         if (bless == '+')
                    349:                 return (15);
                    350:         else if (bless == '-')
                    351:                 return (-1);
                    352:         else
                    353:                 return (0);
                    354: }
                    355:
                    356: /*
                    357:  * get a non-monster death type
                    358:  */
                    359:
                    360: int
                    361: getdeath(void)
                    362: {
                    363:     register int i;
                    364:     int which_death;
                    365:     char label[80];
                    366:
                    367:     clear();
                    368:     for (i=0; i<DEATHNUM; i++) {
                    369:         sprintf(label, "[%d] %s", i+1, deaths[i].name);
                    370:         mvaddstr(i+2, 0, label);
                    371:     }
                    372:     mvaddstr(0, 0, "Which death? ");
                    373:     refresh();
                    374:
                    375:     /* Get the death */
                    376:     for (;;) {
                    377:         get_str(label, stdscr);
                    378:         which_death = atoi(label);
                    379:         if ((which_death < 1 || which_death > DEATHNUM)) {
                    380:             mvaddstr(0, 0, "Please enter a number in the displayed range -- ");
                    381:             refresh();
                    382:         }
                    383:         else break;
                    384:     }
                    385:     return(deaths[which_death-1].reason);
                    386: }
                    387:
                    388: /*
                    389:  * make a monster for the wizard
                    390:  * showall -> show uniques and genocided creatures
                    391:  */
                    392:
                    393: short
                    394: makemonster(bool showall, char *action)
                    395: {
                    396:     register int i;
                    397:     register short which_monst;
                    398:     register int num_monst = NUMMONST, pres_monst=1, num_lines=2*(lines-3);
                    399:     int max_monster;
                    400:     char monst_name[40];
                    401:
                    402:     /* If we're not showing all, subtract UNIQUES, DINOS, and quartermaster */
                    403:     if (!showall) num_monst -= NUMUNIQUE + NUMDINOS + 1;
                    404:     max_monster = num_monst;
                    405:
                    406:     /* Print out the monsters */
                    407:
                    408:     if (levtype == OUTSIDE) {
                    409:         num_monst = NUMDINOS;
                    410:         max_monster = NUMMONST - 1;
                    411:         pres_monst = (pres_monst + NUMMONST - NUMDINOS - 1);
                    412:     }
                    413:
                    414:     while (num_monst > 0) {
                    415:         register int left_limit;
                    416:
                    417:         if (num_monst < num_lines) left_limit = (num_monst+1)/2;
                    418:         else left_limit = num_lines/2;
                    419:
                    420:         wclear(hw);
                    421:         touchwin(hw);
                    422:
                    423:         /* Print left column */
                    424:         wmove(hw, 2, 0);
                    425:         for (i=0; i<left_limit; i++) {
                    426:             sprintf(monst_name, "[%d] %c%s\n",
                    427:                                 pres_monst,
                    428:                                 (showall || monsters[pres_monst].m_normal)
                    429:                                     ? ' '
                    430:                                     : '*',
                    431:                                 monsters[pres_monst].m_name);
                    432:             waddstr(hw, monst_name);
                    433:             pres_monst++;
                    434:         }
                    435:
                    436:         /* Print right column */
                    437:         for (i=0; i<left_limit && pres_monst<=max_monster; i++) {
                    438:             sprintf(monst_name, "[%d] %c%s",
                    439:                                 pres_monst,
                    440:                                 (showall || monsters[pres_monst].m_normal)
                    441:                                     ? ' '
                    442:                                     : '*',
                    443:                                 monsters[pres_monst].m_name);
                    444:             wmove(hw, i+2, cols/2);
                    445:             waddstr(hw, monst_name);
                    446:             pres_monst++;
                    447:         }
                    448:
                    449:         if ((num_monst -= num_lines) > 0) {
                    450:             mvwaddstr(hw, lines-1, 0, morestr);
                    451:             draw(hw);
                    452:             wait_for(' ');
                    453:         }
                    454:
                    455:         else {
                    456:             mvwaddstr(hw, 0, 0, "Which monster");
                    457:             if (!terse) {
                    458:                 waddstr(hw, " do you wish to ");
                    459:                 waddstr(hw, action);
                    460:             }
                    461:             waddstr(hw, "? ");
                    462:             draw(hw);
                    463:         }
                    464:     }
                    465:
                    466: get_monst:
                    467:     get_str(monst_name, hw);
                    468:     which_monst = atoi(monst_name);
                    469:     if (levtype == OUTSIDE)
                    470:     if ((which_monst < NUMMONST-NUMDINOS || which_monst > max_monster)) {
                    471:         mvwaddstr(hw, 0, 0, "Please enter a number in the displayed range -- ");
                    472:         draw(hw);
                    473:         goto get_monst;
                    474:     }
                    475:     if ((which_monst < 1 || which_monst > max_monster)) {
                    476:         mvwaddstr(hw, 0, 0, "Please enter a number in the displayed range -- ");
                    477:         draw(hw);
                    478:         goto get_monst;
                    479:     }
                    480:     restscr(cw);
                    481:     return(which_monst);
                    482: }
                    483:
                    484: /*
                    485:  * passwd:
                    486:  *      see if user knows password
                    487:  */
                    488:
                    489: bool
                    490: passwd(void)
                    491: {
                    492:     register char *sp, c;
                    493:     char buf[LINELEN];
                    494:
                    495:     msg("Wizard's Password:");
                    496:     mpos = 0;
                    497:     sp = buf;
                    498:     while ((c = wgetch(cw)) != '\n' && c != '\r' && c != '\033') {
                    499:         if (c == killchar())
                    500:             sp = buf;
                    501:         else if (c == erasechar() && sp > buf)
                    502:             sp--;
                    503:         else
                    504:             *sp++ = c;
                    505:     }
                    506:     if (sp == buf)
                    507:         return FALSE;
                    508:     *sp = '\0';
                    509:     return (strcmp(PASSWD, xcrypt(buf, "mT")) == 0);
                    510:
                    511:     /* don't mess with the password here or elsewhere.
                    512:      *
                    513:      * If anyone goes wizard they forfeit being placed in the scorefile.
                    514:      * So, no need to be secretive about it.  Let them have it!
                    515:      *
                    516:      * Additionally, you can begin the game as wizard by starting it
                    517:      * with a null argument, as in: xrogue ""
                    518:      */
                    519: }
                    520:
                    521: /*
                    522:  * teleport:
                    523:  *      Bamf the hero someplace else
                    524:  */
                    525:
                    526: void
                    527: teleport(void)
                    528: {
                    529:     register struct room *new_rp = NULL, *old_rp = roomin(&hero);
                    530:     register int rm, which;
                    531:     coord old;
                    532:     bool got_position = FALSE;
                    533:
                    534:     /* Disrupt whatever the hero was doing */
                    535:     dsrpt_player();
                    536:
                    537:     /*
                    538:      * If the hero wasn't doing something disruptable, NULL out his
                    539:      * action anyway and let him know about it.  We don't want him
                    540:      * swinging or moving into his old place.
                    541:      */
                    542:     if (player.t_action != A_NIL) {
                    543:         player.t_action = A_NIL;
                    544:         msg("You feel momentarily disoriented.");
                    545:     }
                    546:
                    547:     old = hero;
                    548:     mvwaddch(cw, hero.y, hero.x, mvwinch(stdscr, hero.y, hero.x));
                    549:     if (ISWEARING(R_TELCONTROL) || wizard) {
                    550:         got_position = move_hero(H_TELEPORT);
                    551:         if (!got_position)
                    552:             msg("Your attempt fails.");
                    553:         else {
                    554:             new_rp = roomin(&hero);
                    555:             msg("You teleport successfully.");
                    556:         }
                    557:     }
                    558:     if (!got_position) {
                    559:         do {
                    560:             rm = rnd_room();
                    561:             rnd_pos(&rooms[rm], &hero);
                    562:         } until(winat(hero.y, hero.x) == FLOOR);
                    563:         new_rp = &rooms[rm];
                    564:     }
                    565:     player.t_oldpos = old;      /* Save last position */
                    566:
                    567:     /* If hero gets moved, darken old room */
                    568:     if (old_rp && old_rp != new_rp) {
                    569:         old_rp->r_flags |= FORCEDARK;   /* Fake darkness */
                    570:         light(&old);
                    571:         old_rp->r_flags &= ~FORCEDARK; /* Restore light state */
                    572:     }
                    573:
                    574:     /* Darken where we just came from */
                    575:     else if (levtype == MAZELEV) light(&old);
                    576:
                    577:     light(&hero);
                    578:     mvwaddch(cw, hero.y, hero.x, PLAYER);
                    579:     /* if entering a treasure room, wake everyone up......Surprise! */
                    580:     if (new_rp->r_flags & ISTREAS)
                    581:         wake_room(new_rp);
                    582:
                    583:     /* Reset current room and position */
                    584:     oldrp = new_rp;     /* Used in look() */
                    585:     player.t_oldpos = hero;
                    586:     /*
                    587:      * make sure we set/unset the ISINWALL on a teleport
                    588:      */
                    589:     which = winat(hero.y, hero.x);
                    590:     if (isrock(which)) turn_on(player, ISINWALL);
                    591:     else turn_off(player, ISINWALL);
                    592:
                    593:     /*
                    594:      * turn off ISHELD in case teleportation was done while fighting
                    595:      * something that holds you
                    596:      */
                    597:     if (on(player, ISHELD)) {
                    598:         register struct linked_list *ip, *nip;
                    599:         register struct thing *mp;
                    600:
                    601:         turn_off(player, ISHELD);
                    602:         hold_count = 0;
                    603:         for (ip = mlist; ip; ip = nip) {
                    604:             mp = THINGPTR(ip);
                    605:             nip = next(ip);
                    606:             if (on(*mp, DIDHOLD)) {
                    607:                 turn_off(*mp, DIDHOLD);
                    608:                 turn_on(*mp, CANHOLD);
                    609:             }
                    610:             turn_off(*mp, DIDSUFFOCATE); /* Suffocation -- see below */
                    611:         }
                    612:     }
                    613:
                    614:     /* Make sure player does not suffocate */
                    615:     extinguish(suffocate);
                    616:
                    617:     count = 0;
                    618:     running = FALSE;
                    619:     flushinp();
                    620: }
                    621:
                    622: /*
                    623:  * whatis:
                    624:  *      What a certin object is
                    625:  */
                    626:
                    627: void
                    628: whatis(struct linked_list *what)
                    629: {
                    630:     register struct object *obj;
                    631:     register struct linked_list *item;
                    632:
                    633:     if (what == NULL) {         /* do we need to ask which one? */
                    634:         if ((item = get_item(pack, "identify", IDENTABLE, FALSE, FALSE))==NULL)
                    635:             return;
                    636:     }
                    637:     else
                    638:         item = what;
                    639:     obj = OBJPTR(item);
                    640:     switch (obj->o_type) {
                    641:         case SCROLL:
                    642:             s_know[obj->o_which] = TRUE;
                    643:             if (s_guess[obj->o_which]) {
                    644:                 free(s_guess[obj->o_which]);
                    645:                 s_guess[obj->o_which] = NULL;
                    646:             }
                    647:         when POTION:
                    648:             p_know[obj->o_which] = TRUE;
                    649:             if (p_guess[obj->o_which]) {
                    650:                 free(p_guess[obj->o_which]);
                    651:                 p_guess[obj->o_which] = NULL;
                    652:             }
                    653:         when STICK:
                    654:             ws_know[obj->o_which] = TRUE;
                    655:             if (ws_guess[obj->o_which]) {
                    656:                 free(ws_guess[obj->o_which]);
                    657:                 ws_guess[obj->o_which] = NULL;
                    658:             }
                    659:         when RING:
                    660:             r_know[obj->o_which] = TRUE;
                    661:             if (r_guess[obj->o_which]) {
                    662:                 free(r_guess[obj->o_which]);
                    663:                 r_guess[obj->o_which] = NULL;
                    664:             }
                    665:         when MM:
                    666:             /* If it's an identified jug, identify its potion */
                    667:             if (obj->o_which == MM_JUG && (obj->o_flags & ISKNOW)) {
                    668:                 if (obj->o_ac != JUG_EMPTY)
                    669:                     p_know[obj->o_ac] = TRUE;
                    670:                 break;
                    671:             }
                    672:
                    673:             m_know[obj->o_which] = TRUE;
                    674:             if (m_guess[obj->o_which]) {
                    675:                 free(m_guess[obj->o_which]);
                    676:                 m_guess[obj->o_which] = NULL;
                    677:             }
                    678:         otherwise:
                    679:             break;
                    680:     }
                    681:     obj->o_flags |= ISKNOW;
                    682:     if (what == NULL)
                    683:         msg(inv_name(obj, FALSE));
                    684: }
                    685:
                    686: /*
                    687:  *  Choose a quest item
                    688:  *      (if on STARTLEV equipage level = 0)
                    689:  */
                    690:
                    691: void
                    692: choose_qst(void)
                    693: {
                    694:     bool doit = TRUE;
                    695:     bool escp = TRUE;
                    696:
                    697:     /* let wizard in on this too */
                    698:     if (waswizard == TRUE || (levtype == POSTLEV && level == 0)) {
                    699:         wclear(hw);
                    700:     touchwin(hw);
                    701:         wmove(hw, 2, 0);
                    702:         wprintw(hw, "a) Cloak of Emori\n");
                    703:         wprintw(hw, "b) Ankh of Heil\n");
                    704:         wprintw(hw, "c) Quill of Nagrom\n");
                    705:         wprintw(hw, "d) Eye of Vecna\n");
                    706:         wprintw(hw, "e) Ring of Surtur\n");
                    707:         wprintw(hw, "f) Staff of Ming\n");
                    708:         wprintw(hw, "g) Wand of Orcus\n");
                    709:         wprintw(hw, "h) Rod of Asmodeus\n");
                    710:         wprintw(hw, "i) Amulet of Yendor\n");
                    711:         wprintw(hw, "j) Amulet of Stonebones\n");
                    712:         wprintw(hw, "k) Mandolin of Brian\n");
                    713:         wprintw(hw, "l) Horn of Geryon\n");
                    714:         wprintw(hw, "m) Daggers of Musty Doit\n");
                    715:         wprintw(hw, "n) Axe of Aklad\n");
                    716:         wprintw(hw, "o) Morning Star of Hruggek\n");
                    717:         wprintw(hw, "p) Flail of Yeenoghu\n");
                    718:         wprintw(hw, "q) Card of Alteran\n");
                    719:         mvwaddstr(hw, 0, 0, "Select a quest item: "); /* prompt */
                    720:
                    721:         if (menu_overlay)  /* Print the selections.  The longest line is
                    722:                 * Hruggek (26 characters).  The prompt is 21.
                    723:                 */
                    724:             over_win(cw, hw, 20, 29, 0, 21, '\0');
                    725:         else
                    726:             draw(hw);
                    727:
                    728:         while (doit) {
                    729:         switch (wgetch(cw)) {
                    730:             case EOF:
                    731:             case ESC:
                    732:                 escp = FALSE;   /* used below */
                    733:             doit = FALSE;
                    734:             when 'a':
                    735:                 quest_item = EMORI_CLOAK;
                    736:             doit = FALSE;
                    737:             when 'b':
                    738:                 quest_item = HEIL_ANKH;
                    739:             doit = FALSE;
                    740:             when 'c':
                    741:                 quest_item = QUILL_NAGROM;
                    742:             doit = FALSE;
                    743:             when 'd':
                    744:                 quest_item = EYE_VECNA;
                    745:             doit = FALSE;
                    746:             when 'e':
                    747:                 quest_item = SURTUR_RING;
                    748:             doit = FALSE;
                    749:             when 'f':
                    750:                 quest_item = MING_STAFF;
                    751:             doit = FALSE;
                    752:             when 'g':
                    753:                 quest_item = ORCUS_WAND;
                    754:             doit = FALSE;
                    755:             when 'h':
                    756:                 quest_item = ASMO_ROD;
                    757:             doit = FALSE;
                    758:             when 'i':
                    759:                 quest_item = YENDOR_AMULET;
                    760:             doit = FALSE;
                    761:             when 'j':
                    762:                 quest_item = STONEBONES_AMULET;
                    763:             doit = FALSE;
                    764:             when 'k':
                    765:                 quest_item = BRIAN_MANDOLIN;
                    766:             doit = FALSE;
                    767:             when 'l':
                    768:                 quest_item = GERYON_HORN;
                    769:             doit = FALSE;
                    770:             when 'm':
                    771:                 quest_item = MUSTY_DAGGER;
                    772:             doit = FALSE;
                    773:             when 'n':
                    774:                 quest_item = AXE_AKLAD;
                    775:             doit = FALSE;
                    776:             when 'o':
                    777:                 quest_item = HRUGGEK_MSTAR;
                    778:             doit = FALSE;
                    779:             when 'p':
                    780:                 quest_item = YEENOGHU_FLAIL;
                    781:             doit = FALSE;
                    782:             when 'q':
                    783:                 quest_item = ALTERAN_CARD;
                    784:             doit = FALSE;
                    785:             otherwise:
                    786:             doit = TRUE;
                    787:         }
                    788:     }
                    789:     if (menu_overlay) {
                    790:             status(FALSE);
                    791:             touchwin(cw);
                    792:         if (escp == TRUE) {
                    793:                 msg("Your quest item is the %s.  --More--",
                    794:              rel_magic[quest_item].mi_name);
                    795:             wait_for(' ');
                    796:         }
                    797:         return;
                    798:     }
                    799:     else {
                    800:         if (escp == TRUE) {
                    801:                 wmove(hw, lines-4, 0);
                    802:                 wprintw(hw, "Your quest item is the %s.",
                    803:                     rel_magic[quest_item].mi_name);
                    804:         }
                    805:             wmove(hw, lines-1, 0);
                    806:             wprintw(hw, spacemsg);
                    807:             draw(hw);
                    808:             wait_for(' ');
                    809:             wclear(hw);
                    810:             draw(hw);
                    811:             wmove(cw, 0, 0);
                    812:             wclrtoeol(cw);
                    813:             status(FALSE);
                    814:             touchwin(cw);
                    815:         return;
                    816:     }
                    817:     }
                    818:     else {
                    819:         msg("You can no longer select a quest item. ");
                    820:         return;
                    821:     }
                    822: }
                    823:

CVSweb