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

Annotation of early-roguelike/urogue/artifact.c, Revision 1.1.1.1

1.1       rubenllo    1: /*
                      2:     artifact.c  -  functions for dealing with artifacts
                      3:
                      4:     UltraRogue: The Ultimate Adventure in the Dungeons of Doom
                      5:     Copyright (C) 1985, 1986, 1992, 1993, 1995 Herb Chong
                      6:     All rights reserved.
                      7:
                      8:     See the file LICENSE.TXT for full copyright and licensing information.
                      9: */
                     10:
                     11: #include <stdlib.h>
                     12: #include <ctype.h>
                     13: #include "rogue.h"
                     14:
                     15: /*
                     16:     apply()
                     17:         apply an artifact
                     18: */
                     19:
                     20: void
                     21: apply(void)
                     22: {
                     23:     struct linked_list  *item;
                     24:     struct object   *obj;
                     25:     int which;
                     26:     int chance;
                     27:
                     28:     if ((item = get_item("activate", ARTIFACT)) == NULL)
                     29:         return;
                     30:
                     31:     obj = OBJPTR(item);
                     32:     which = obj->o_which;
                     33:
                     34:     if (!(obj->ar_flags & ISACTIVE))
                     35:     {
                     36:         chance = rnd(100) - 10 * rnd(luck);
                     37:         debug("Rolled %d.", chance);
                     38:         if (chance < 5)
                     39:             do_major();
                     40:         else if (chance < 50)
                     41:             do_minor(obj);
                     42:         else
                     43:             obj->ar_flags |= ISACTIVE;
                     44:     }
                     45:
                     46:     if (obj->ar_flags & ISACTIVE)
                     47:     {
                     48:         switch (which)
                     49:         {
                     50:             case TR_PURSE:    do_bag(obj);
                     51:                               break;
                     52:             case TR_PHIAL:    do_phial();
                     53:                               break;
                     54:             case TR_AMULET:   do_amulet();
                     55:                               break;
                     56:             case TR_PALANTIR: do_palantir();
                     57:                               break;
                     58:             case TR_CROWN:    do_crown();
                     59:                               break;
                     60:             case TR_SCEPTRE:  do_sceptre();
                     61:                               break;
                     62:             case TR_SILMARIL: do_silmaril();
                     63:                               break;
                     64:             case TR_WAND:     do_wand();
                     65:                               break;
                     66:             default:          nothing_message(ISCURSED);
                     67:                               return;
                     68:         }
                     69:     }
                     70:
                     71:     if (rnd(pstats.s_lvl) < 6)
                     72:         do_minor(obj);
                     73:
                     74:     turn_on(player, POWEREAT);
                     75: }
                     76:
                     77: /*
                     78:     possessed(int artifact)
                     79:         was the hero carrying a particular artifact
                     80: */
                     81:
                     82: int
                     83: possessed(int artifact)
                     84: {
                     85:     return (picked_artifact >> artifact) & 1;
                     86: }
                     87:
                     88: /*
                     89:     is_carrying(int artifact)
                     90:         is the hero carrying a particular artifact
                     91: */
                     92:
                     93: int
                     94: is_carrying(int artifact)
                     95: {
                     96:     return (has_artifact >> artifact) & 1;
                     97: }
                     98:
                     99: /*
                    100:     make_artifact()
                    101:         is it time to make a new artifact?
                    102: */
                    103:
                    104: int
                    105: make_artifact(void)
                    106: {
                    107:     int i;
                    108:
                    109:     mpos = 0;
                    110:
                    111:     debug("Artifact possession and picked flags : %x %x.",
                    112:         has_artifact, picked_artifact);
                    113:
                    114:     for(i = 0; i < maxartifact; i++)
                    115:     {
                    116:        if (!is_carrying(i) && arts[i].ar_level <= level)
                    117:            return TRUE;
                    118:     }
                    119:
                    120:     return FALSE;
                    121: }
                    122:
                    123: /*
                    124:     new_artifact(int which, struct object *cur)
                    125:         make a specified artifact
                    126: */
                    127:
                    128: struct object *
                    129: new_artifact(int which, struct object *cur)
                    130: {
                    131:     if (which >= maxartifact)
                    132:     {
                    133:         debug("Bad artifact %d.  Random one created.", which);
                    134:         which = rnd(maxartifact);
                    135:     }
                    136:
                    137:     if (which < 0)
                    138:     {
                    139:         for (which = 0; which < maxartifact; which++)
                    140:             if (!is_carrying(which) && arts[which].ar_level <= level)
                    141:                 break;
                    142:     }
                    143:
                    144:     debug("Artifact number: %d.", which);
                    145:
                    146:     cur->o_hplus = cur->o_dplus = 0;
                    147:     cur->o_damage = cur->o_hurldmg = "0d0";
                    148:     cur->o_ac = 11;
                    149:     cur->o_mark[0] = '\0';
                    150:     cur->o_type = ARTIFACT;
                    151:     cur->o_which = which;
                    152:     cur->o_weight = arts[which].ar_weight;
                    153:     cur->o_flags = 0;
                    154:     cur->o_group = 0;
                    155:     cur->o_count = 1;
                    156:     cur->o_bag = NULL;
                    157:     cur->ar_flags = 0;
                    158:
                    159:     return(cur);
                    160: }
                    161:
                    162: /*
                    163:     do_minor(struct object *tr)
                    164:         side effects and minor malevolent effects of artifacts
                    165: */
                    166:
                    167: void
                    168: do_minor(struct object *tr)
                    169: {
                    170:     int which;
                    171:     long loss;
                    172:
                    173:     which = rnd(110);
                    174:
                    175:     debug("Rolled %d.", which);
                    176:
                    177:     switch (which)
                    178:     {
                    179:         case 0:
                    180:             seemsg("You develop some acne on your face.");
                    181:             break;
                    182:
                    183:         case 1:
                    184:             if (on(player, CANSCENT))
                    185:             {
                    186:                 msg("A sudden whiff of BO causes you to faint.");
                    187:                 no_command = STONETIME;
                    188:             }
                    189:             else if (off(player, ISUNSMELL))
                    190:                 msg("You begin to smell funny.");
                    191:             break;
                    192:
                    193:         case 2:
                    194:             seemsg("A wart grows on the end of your nose.");
                    195:             break;
                    196:
                    197:         case 3:
                    198:             hearmsg("Your hear strange noises in the distance.");
                    199:             break;
                    200:
                    201:         case 4:
                    202:             hearmsg("You hear shuffling in the distance.");
                    203:             break;
                    204:
                    205:         case 5:
                    206:             hearmsg("You hear clanking in the distance.");
                    207:             break;
                    208:
                    209:         case 6:
                    210:             hearmsg("You hear water dripping onto the floor.");
                    211:             break;
                    212:
                    213:         case 7:
                    214:             hearmsg("The dungeon goes strangely silent.");
                    215:             break;
                    216:
                    217:         case 8:
                    218:             msg("You suddenly feel very warm.");
                    219:             break;
                    220:
                    221:         case 9:
                    222:             msg("You feel very hot.");
                    223:             break;
                    224:
                    225:         case 10:
                    226:             msg("A blast of heat hits you.");
                    227:             break;
                    228:
                    229:         case 11:
                    230:             {
                    231:                  struct room *rp;
                    232:
                    233:                  if (off(player, ISBLIND))
                    234:                     msg("A pillar of flame leaps up beside you.");
                    235:                  else
                    236:                     msg("You feel something very hot nearby.");
                    237:
                    238:                  if (ntraps + 1 < 2 * MAXTRAPS &&
                    239:                      fallpos(hero, &traps[ntraps].tr_pos))
                    240:                  {
                    241:                     mvaddch(traps[ntraps].tr_pos.y, traps[ntraps].tr_pos.x,
                    242:                        FIRETRAP);
                    243:                     traps[ntraps].tr_type = FIRETRAP;
                    244:                     traps[ntraps].tr_flags = ISFOUND;
                    245:                     traps[ntraps].tr_show = FIRETRAP;
                    246:                     ntraps++;
                    247:
                    248:                     if ((rp = roomin(hero)) != NULL)
                    249:                     {
                    250:                         rp->r_flags &= ~ISDARK;
                    251:                         light(&hero);
                    252:                         mvwaddch(cw, hero.y, hero.x, PLAYER);
                    253:                     }
                    254:                 }
                    255:             }
                    256:             break;
                    257:
                    258:         case 12:
                    259:             msg("You feel a blast of hot air.");
                    260:             break;
                    261:
                    262:         case 13:
                    263:             msg("You feel very cold.");
                    264:             break;
                    265:
                    266:         case 14:
                    267:             msg("You break out in a cold sweat.");
                    268:             break;
                    269:
                    270:         case 15:
                    271:             if (off(player, ISBLIND) && cur_armor == NULL)
                    272:                 msg("You are covered with frost.");
                    273:             else if (off(player, ISBLIND))
                    274:                 msg("Your armor is covered with frost.");
                    275:             else if (cur_armor == NULL)
                    276:                 msg("Your body feels very cold and you begin to shiver.");
                    277:             else
                    278:                 msg("Your armor feels very cold.  You hear cracking ice.");
                    279:             break;
                    280:
                    281:         case 16:
                    282:             msg("A cold wind whistles through the dungeon.");
                    283:             break;
                    284:
                    285:         case 17:
                    286:             {
                    287:                 int change;
                    288:
                    289:                 change = 18 - pstats.s_str;
                    290:                 chg_str(change, TRUE, FALSE);
                    291:                 chg_dext(-change, TRUE, FALSE);
                    292:
                    293:                 if (change > 0)
                    294:                     msg("You feel stronger and clumsier now.");
                    295:                 else if (change < 0)
                    296:                     msg("You feel weaker and more dextrous now.");
                    297:                 else
                    298:                     nothing_message(ISCURSED);
                    299:             }
                    300:             break;
                    301:
                    302:         case 18:
                    303:             msg("You begin to itch all over.");
                    304:             break;
                    305:
                    306:         case 19:
                    307:             msg("You begin to feel hot and itchy.");
                    308:             break;
                    309:
                    310:         case 20:
                    311:             msg("You feel a burning itch.");
                    312:             chg_dext(-1, FALSE, TRUE);
                    313:
                    314:             if (off(player, HASITCH))
                    315:             {
                    316:                 turn_on(player, HASITCH);
                    317:                 light_fuse(FUSE_UNITCH, 0, roll(4,6), AFTER);
                    318:             }
                    319:             else
                    320:                 lengthen_fuse(FUSE_UNITCH, roll(4,6));
                    321:             break;
                    322:
                    323:         case 21:
                    324:             if (off(player, ISBLIND))
                    325:                msg("Your skin begins to flake and peel.");
                    326:             else
                    327:                msg("You feel an urge to scratch an itch.");
                    328:             break;
                    329:
                    330:
                    331:         case 22:
                    332:             seemsg("Your hair begins to turn grey.");
                    333:             break;
                    334:
                    335:         case 23:
                    336:             seemsg("Your hair begins to turn white.");
                    337:             break;
                    338:
                    339:         case 24:
                    340:             seemsg("Some of your hair instantly turns white.");
                    341:             break;
                    342:
                    343:         case 25:
                    344:             seemsg("You are covered with long white hair.");
                    345:             break;
                    346:
                    347:         case 26:
                    348:             seemsg("You are covered with long red hair.");
                    349:             break;
                    350:
                    351:         case 27:
                    352:             msg("You grow a beard.");
                    353:             break;
                    354:
                    355:         case 28:
                    356:             msg("Your hair falls out.");
                    357:             break;
                    358:
                    359:         case 29:
                    360:             msg("You feel a burning down below.");
                    361:             break;
                    362:
                    363:         case 30:
                    364:             msg("Your toes fall off.");
                    365:             break;
                    366:
                    367:         case 31:
                    368:             msg("You grow some extra toes.");
                    369:             break;
                    370:
                    371:         case 32:
                    372:             msg("You grow some extra fingers.");
                    373:             break;
                    374:
                    375:         case 33:
                    376:             msg("You grow an extra thumb.");
                    377:             break;
                    378:
                    379:         case 34:
                    380:             msg("Your nose falls off.");
                    381:             break;
                    382:
                    383:         case 35:
                    384:             msg("Your nose gets bigger.");
                    385:             break;
                    386:
                    387:         case 36:
                    388:             msg("Your nose shrinks.");
                    389:             break;
                    390:
                    391:         case 37:
                    392:             msg("An eye grows on your forehead.");
                    393:             break;
                    394:
                    395:         case 38:
                    396:             seemsg("You see beady eyes watching from a distance.");
                    397:             break;
                    398:
                    399:         case 39:
                    400:             msg("The dungeon rumbles for a moment.");
                    401:             break;
                    402:
                    403:         case 40:
                    404:             seemsg("A flower grows on the floor next to you.");
                    405:             break;
                    406:
                    407:         case 41:
                    408:             msg("You are stunned by a psionic blast.");
                    409:
                    410:             if (on(player, ISHUH))
                    411:                 lengthen_fuse(FUSE_UNCONFUSE, rnd(40) + (HUHDURATION * 3));
                    412:             else
                    413:             {
                    414:                 light_fuse(FUSE_UNCONFUSE,0,rnd(40)+(HUHDURATION * 3), AFTER);
                    415:                 turn_on(player, ISHUH);
                    416:             }
                    417:             break;
                    418:
                    419:         case 42:
                    420:             msg("You are confused by thousands of voices in your head.");
                    421:
                    422:             if (on(player, ISHUH))
                    423:                 lengthen_fuse(FUSE_UNCONFUSE, rnd(10) + (HUHDURATION * 2));
                    424:             else
                    425:             {
                    426:                 light_fuse(FUSE_UNCONFUSE,0,rnd(10)+(HUHDURATION * 2), AFTER);
                    427:                 turn_on(player, ISHUH);
                    428:             }
                    429:             break;
                    430:
                    431:         case 43:
                    432:             hearmsg("You hear voices in the distance.");
                    433:             break;
                    434:
                    435:         case 44:
                    436:             msg("You feel a strange pull.");
                    437:             teleport();
                    438:
                    439:             if (off(player, ISCLEAR))
                    440:             {
                    441:                 if (on(player, ISHUH))
                    442:                     lengthen_fuse(FUSE_UNCONFUSE, rnd(8) + HUHDURATION);
                    443:                 else
                    444:                 {
                    445:                     light_fuse(FUSE_UNCONFUSE, 0, rnd(8) + HUHDURATION, AFTER);
                    446:                     turn_on(player, ISHUH);
                    447:                 }
                    448:             }
                    449:             break;
                    450:
                    451:         case 45:
                    452:             msg("You feel less healthy now.");
                    453:             pstats.s_const = max(pstats.s_const - 1, 3);
                    454:             max_stats.s_const = max(max_stats.s_const - 1, 3);
                    455:             break;
                    456:
                    457:         case 46:
                    458:             msg("You feel weaker now.");
                    459:             chg_str(-1, TRUE, FALSE);
                    460:             break;
                    461:
                    462:         case 47:
                    463:             msg("You feel less wise now.");
                    464:             pstats.s_wisdom = max(pstats.s_wisdom - 1, 3);
                    465:             max_stats.s_wisdom = max(max_stats.s_wisdom - 1, 3);
                    466:             break;
                    467:
                    468:         case 48:
                    469:             msg("You feel less dextrous now.");
                    470:             chg_dext(-1, TRUE, FALSE);
                    471:             break;
                    472:
                    473:         case 49:
                    474:             msg("You feel less intelligent now.");
                    475:             pstats.s_intel = max(pstats.s_intel - 1, 3);
                    476:             max_stats.s_intel = max(max_stats.s_intel - 1, 3);
                    477:             break;
                    478:
                    479:         case 50:
                    480:             msg("A trap door opens underneath your feet.");
                    481:             mpos = 0;
                    482:             level++;
                    483:             new_level(NORMLEV,0);
                    484:
                    485:             if (rnd(4) < 2)
                    486:             {
                    487:                 addmsg("You are damaged by the fall");
                    488:
                    489:                 if ((pstats.s_hpt -= roll(1, 6)) <= 0)
                    490:                 {
                    491:                     addmsg("!  The fall killed you.");
                    492:                     endmsg();
                    493:                     death(D_FALL);
                    494:                     return;
                    495:                 }
                    496:             }
                    497:
                    498:             addmsg("!");
                    499:             endmsg();
                    500:
                    501:             if (off(player, ISCLEAR) && rnd(4) < 3)
                    502:             {
                    503:                 if (on(player, ISHUH))
                    504:                     lengthen_fuse(FUSE_UNCONFUSE, rnd(8) + HUHDURATION);
                    505:                 else
                    506:                     light_fuse(FUSE_UNCONFUSE, 0, rnd(8) + HUHDURATION, AFTER);
                    507:
                    508:                 turn_on(player, ISHUH);
                    509:             }
                    510:             else
                    511:                 msg("You feel dizzy for a moment, but it quickly passes.");
                    512:
                    513:             break;
                    514:
                    515:         case 51:
                    516:             msg("A maze entrance opens underneath your feet.");
                    517:             mpos = 0;
                    518:             level++;
                    519:             new_level(MAZELEV,0);
                    520:
                    521:             if (rnd(4) < 2)
                    522:             {
                    523:                 addmsg("You are damaged by the fall");
                    524:
                    525:                 if ((pstats.s_hpt -= roll(1, 6)) <= 0)
                    526:                 {
                    527:                     addmsg("!  The fall killed you.");
                    528:                     endmsg();
                    529:                     death(D_FALL);
                    530:                     return;
                    531:                 }
                    532:             }
                    533:             addmsg("!");
                    534:             endmsg();
                    535:
                    536:             if (off(player, ISCLEAR) && rnd(4) < 3)
                    537:             {
                    538:                 if (on(player, ISHUH))
                    539:                     lengthen_fuse(FUSE_UNCONFUSE, rnd(8) + HUHDURATION);
                    540:                 else
                    541:                     light_fuse(FUSE_UNCONFUSE,0, rnd(8) + HUHDURATION, AFTER);
                    542:
                    543:                 turn_on(player, ISHUH);
                    544:             }
                    545:             else
                    546:                 msg("You feel dizzy for a moment, but it quickly passes.");
                    547:
                    548:             break;
                    549:
                    550:         case 52:
                    551:             hearmsg("You hear a wailing sound in the distance.");
                    552:             aggravate();
                    553:             break;
                    554:
                    555:         case 53:
                    556:             read_scroll(&player, S_HOLD, ISCURSED);
                    557:             break;
                    558:
                    559:         case 54:
                    560:             msg("You can't move.");
                    561:             no_command = 3 * HOLDTIME;
                    562:             break;
                    563:
                    564:         case 55:
                    565:             hearmsg("You hear a buzzing sound.");
                    566:             aggravate();
                    567:             break;
                    568:
                    569:         case 56:
                    570:             msg("Your limbs stiffen.");
                    571:             no_command = 3 * STONETIME;
                    572:             break;
                    573:
                    574:         case 57:
                    575:             msg("You feel a rock in your shoe hurting your foot.");
                    576:             turn_on(player, STUMBLER);
                    577:             break;
                    578:
                    579:         case 58:
                    580:             msg("You get a hollow feeling in your stomach.");
                    581:             food_left -= 500;
                    582:             break;
                    583:
                    584:         case 59:
                    585:             msg("Your purse feels lighter.");
                    586:
                    587:             loss  = 50L + ulrnd(purse / 2L);
                    588:             purse = (purse > loss) ? purse - loss : 0L;
                    589:             break;
                    590:
                    591:         case 60:
                    592:             msg("A pixie appears and grabs gold from your purse.");
                    593:
                    594:             loss = 50L + rnd(50);
                    595:             purse = (purse > loss) ? purse - loss : 0L;
                    596:             break;
                    597:
                    598:         case 61:
                    599:             msg("You feel a tingling sensation all over.");
                    600:             pstats.s_hpt -= ulrnd(pstats.s_hpt / 3L);
                    601:             break;
                    602:
                    603:         case 62:
                    604:             msg("You feel a pull downwards.");
                    605:             break;
                    606:
                    607:         case 63:
                    608:             msg("You feel a strange pull downwards.");
                    609:             break;
                    610:
                    611:         case 64:
                    612:             msg("You feel a peculiar pull downwards.");
                    613:             break;
                    614:
                    615:         case 65:
                    616:             msg("You have a strange urge to go down.");
                    617:             break;
                    618:
                    619:         case 66:
                    620:             msg("You feel a pull upwards.");
                    621:             break;
                    622:
                    623:         case 67:
                    624:             msg("You feel a strange pull upwards.");
                    625:             break;
                    626:
                    627:         case 68:
                    628:             msg("You have a strange feeling for a moment.");
                    629:             break;
                    630:
                    631:         case 69:
                    632:             msg("You float in the air for a moment.");
                    633:             break;
                    634:
                    635:         case 70:
                    636:             msg("You feel very heavy for a moment.");
                    637:             break;
                    638:
                    639:         case 71:
                    640:             msg("You feel a strange sense of loss.");
                    641:             break;
                    642:
                    643:         case 72:
                    644:             msg("You feel the earth spinning underneath your feet.");
                    645:             break;
                    646:
                    647:         case 73:
                    648:             msg("You feel in touch with a Universal Oneness.");
                    649:             break;
                    650:
                    651:         case 74:
                    652:             hearmsg("You hear voices in the distance.");
                    653:             break;
                    654:
                    655:         case 75:
                    656:             msg("A strange feeling of power comes over you.");
                    657:             break;
                    658:
                    659:         case 76:
                    660:             msg("You feel a strange sense of unease.");
                    661:             break;
                    662:
                    663:         case 77:
                    664:             msg("You feel Lady Luck is looking the other way.");
                    665:             luck++;
                    666:             break;
                    667:
                    668:         case 78:
                    669:             msg("You feel your pack vibrate for a moment.");
                    670:             break;
                    671:
                    672:         case 79:
                    673:             msg("You feel someone is watching you.");
                    674:             break;
                    675:
                    676:         case 80:
                    677:             msg("You feel your hair standing on end.");
                    678:             break;
                    679:
                    680:         case 81:
                    681:             msg("Wait!  The walls are moving!");
                    682:             new_level(NORMLEV,0);
                    683:             break;
                    684:
                    685:         case 82:
                    686:             msg("Wait!  Walls are appearing out of nowhere!");
                    687:             new_level(MAZELEV,0);
                    688:             break;
                    689:
                    690:         case 83:
                    691:             blue_light(ISCURSED);
                    692:             break;
                    693:
                    694:         case 84:
                    695:             msg("Your mind goes blank for a moment.");
                    696:             wclear(cw);
                    697:             light(&hero);
                    698:             status(TRUE);
                    699:             break;
                    700:
                    701:         case 85:
                    702:             if (on(player, ISDEAF))
                    703:             {
                    704:                 msg("You feel your ears burn for a moment.");
                    705:                 lengthen_fuse(FUSE_HEAR, 2 * PHASEDURATION);
                    706:             }
                    707:             else
                    708:             {
                    709:                 msg("You are suddenly surrounded by silence.");
                    710:                 turn_on(player, ISDEAF);
                    711:                 light_fuse(FUSE_HEAR, 0, 2 * PHASEDURATION, AFTER);
                    712:             }
                    713:             break;
                    714:
                    715:         case 86:
                    716:             {
                    717:                 apply_to_bag(pack, 0, NULL, baf_curse, NULL);
                    718:
                    719:                 if (off(player, ISUNSMELL))
                    720:                     msg("You smell a faint trace of burning sulfur.");
                    721:             }
                    722:             break;
                    723:
                    724:         case 87:
                    725:             msg("You have contracted a parasitic infestation.");
                    726:             infest_dam++;
                    727:             turn_on(player, HASINFEST);
                    728:             break;
                    729:
                    730:         case 88:
                    731:             msg("You suddenly feel a chill run up and down your spine.");
                    732:             turn_on(player, ISFLEE);
                    733:             player.t_ischasing = FALSE;
                    734:             player.t_chasee = &player;
                    735:             break;
                    736:
                    737:         case 89:
                    738:             if (cur_weapon != NULL)
                    739:                 msg("You feel your %s get very hot.",
                    740:                     inv_name(cur_weapon, LOWERCASE));
                    741:             break;
                    742:
                    743:         case 90:
                    744:             if (cur_weapon != NULL)
                    745:                 msg("Your %s glows white for an instant.",
                    746:                     inv_name(cur_weapon, LOWERCASE));
                    747:             break;
                    748:
                    749:         case 91:
                    750:             if (cur_armor != NULL)
                    751:                 msg("Your %s gets very hot.", inv_name(cur_armor, LOWERCASE));
                    752:             break;
                    753:
                    754:         case 92:
                    755:             if (cur_weapon != NULL)
                    756:                 msg("Your %s suddenly feels very cold.",
                    757:                     inv_name(cur_weapon, LOWERCASE));
                    758:             break;
                    759:
                    760:         case 93:
                    761:             if (cur_armor != NULL)
                    762:                 msg("Your armor is covered by an oily film.");
                    763:             break;
                    764:
                    765:         case 94:
                    766:             read_scroll(&player, S_CREATE, ISNORMAL);
                    767:             break;
                    768:
                    769:         case 95:
                    770:             lower_level(D_POTION);
                    771:             break;
                    772:
                    773:         case 96:
                    774:             {
                    775:                 int x, y;
                    776:
                    777:                 for (x = -1; x <= 1; x++)
                    778:                 {
                    779:                     for (y = -1; y <= 1; y++)
                    780:                     {
                    781:                         if (x == 0 && y == 0)
                    782:                             continue;
                    783:
                    784:                         delta.x = x;
                    785:                         delta.y = y;
                    786:
                    787:                         do_zap(&player, WS_POLYMORPH, rnd(2)
                    788:                             ? ISCURSED : ISNORMAL);
                    789:                     }
                    790:                 }
                    791:             }
                    792:             break;
                    793:
                    794:         case 97:
                    795:             {
                    796:                 int x, y;
                    797:
                    798:                 for (x = -1; x <= 1; x++)
                    799:                 {
                    800:                     for (y = -1; y <= 1; y++)
                    801:                     {
                    802:                         if (x == 0 && y == 0)
                    803:                             continue;
                    804:
                    805:                         delta.x = x;
                    806:                         delta.y = y;
                    807:
                    808:                         do_zap(&player, WS_INVIS, ISNORMAL);
                    809:                     }
                    810:                 }
                    811:             }
                    812:             break;
                    813:
                    814:         default:
                    815:             tr->ar_flags &= ~ISACTIVE;
                    816:             hearmsg("You hear a click coming from %s.",inv_name(tr,LOWERCASE));
                    817:             break;
                    818:
                    819:     }
                    820: }
                    821:
                    822: /*
                    823:     do_major()
                    824:
                    825:         major malevolent effects
                    826:
                    827:         0.  read_scroll(S_SELFTELEPORT, ISCURSED)
                    828:         1.  PERMBLIND for twice normal duration
                    829:         2.  new_level(THRONE);
                    830:         3.  turn_on(player, SUPEREAT);
                    831:         4.  lengthen(noslow, 20 + rnd(20));
                    832:         5.  lower_level(D_POTION) * roll(1,4)
                    833:         6.  change stats
                    834:         7.  FIRETRAP
                    835:         8.  armor crumbles
                    836:         9.  weapon crumbles
                    837:        10. weapon crumbles
                    838:        11. curse weapon
                    839: */
                    840:
                    841: void
                    842: do_major(void)
                    843: {
                    844:     int which;
                    845:
                    846:     which = rnd(12);
                    847:
                    848:     debug("Rolled %d.", which);
                    849:
                    850:     switch (which)
                    851:     {
                    852:         case 0:
                    853:             read_scroll(&player, S_SELFTELEP, ISCURSED);
                    854:             break;
                    855:
                    856:         case 1:
                    857:             quaff(&player, P_TRUESEE, ISCURSED);
                    858:             quaff(&player, P_TRUESEE, ISCURSED);
                    859:             break;
                    860:
                    861:         case 2:
                    862:             new_level(THRONE,0);
                    863:             break;
                    864:
                    865:         case 3: /* Turn off other body-affecting spells */
                    866:
                    867:             if (on(player, ISREGEN))
                    868:             {
                    869:                 extinguish_fuse(FUSE_UNREGEN);
                    870:                 turn_off(player, ISREGEN);
                    871:                 unregen(NULL);
                    872:             }
                    873:
                    874:             if (on(player, NOCOLD))
                    875:             {
                    876:                 extinguish_fuse(FUSE_UNCOLD);
                    877:                 turn_off(player, NOCOLD);
                    878:                 uncold(NULL);
                    879:             }
                    880:
                    881:             if (on(player, NOFIRE))
                    882:             {
                    883:                 extinguish_fuse(FUSE_UNHOT);
                    884:                 turn_off(player, NOFIRE);
                    885:                 unhot(NULL);
                    886:             }
                    887:
                    888:             if (on(player, SUPEREAT))
                    889:             {
                    890:                 lengthen_fuse(FUSE_UNSUPEREAT, 2 * PHASEDURATION);
                    891:                 msg("Your body temperature rises still further.");
                    892:             }
                    893:             else
                    894:             {
                    895:                 msg("You feel very warm all over.");
                    896:                 light_fuse(FUSE_UNSUPEREAT, 0, 2 * PHASEDURATION, AFTER);
                    897:                 turn_on(player, SUPEREAT);
                    898:             }
                    899:             break;
                    900:
                    901:         case 4:
                    902:             msg("You feel yourself moving %sslower.",
                    903:             on(player, ISSLOW) ? "even " : "");
                    904:
                    905:             if (on(player, ISSLOW))
                    906:                 lengthen_fuse(FUSE_NOSLOW, PHASEDURATION);
                    907:             else
                    908:             {
                    909:                 turn_on(player, ISSLOW);
                    910:                 player.t_turn = TRUE;
                    911:                 light_fuse(FUSE_NOSLOW, 0, PHASEDURATION, AFTER);
                    912:             }
                    913:             break;
                    914:
                    915:         case 5:
                    916:             {
                    917:                 int i, n = roll(1, 4);
                    918:
                    919:                 for (i = 1; i < n; i++)
                    920:                     lower_level(D_POTION);
                    921:             }
                    922:             break;
                    923:
                    924:         case 6:
                    925:             if (rnd(2))
                    926:                 add_intelligence(TRUE);
                    927:
                    928:             if (rnd(2))
                    929:                 chg_dext(-1, TRUE, FALSE);
                    930:
                    931:             if (rnd(2))
                    932:                 chg_str(-1, TRUE, FALSE);
                    933:
                    934:             if (rnd(2))
                    935:                 add_wisdom(TRUE);
                    936:
                    937:             if (rnd(2))
                    938:                 add_const(TRUE);
                    939:
                    940:             break;
                    941:
                    942:         case 7:
                    943:             {
                    944:                 struct room *rp;
                    945:
                    946:                 if (ntraps + 1 >= MAXTRAPS)
                    947:                 {
                    948:                     msg("You feel a puff of hot air.");
                    949:                     return;
                    950:                 }
                    951:
                    952:                 for (; ntraps < 2 * MAXTRAPS; ntraps++)
                    953:                 {
                    954:                     if (!fallpos(hero, &traps[ntraps].tr_pos))
                    955:                         break;
                    956:
                    957:                     mvaddch(traps[ntraps].tr_pos.y, traps[ntraps].tr_pos.x,
                    958:                         FIRETRAP);
                    959:                     traps[ntraps].tr_type   = FIRETRAP;
                    960:                     traps[ntraps].tr_flags |= ISFOUND;
                    961:                     traps[ntraps].tr_show   = FIRETRAP;
                    962:
                    963:                     if ((rp = roomin(hero)) != NULL)
                    964:                         rp->r_flags &= ~ISDARK;
                    965:                 }
                    966:             }
                    967:             break;
                    968:
                    969:         case 8:
                    970:             {
                    971:                 object  *obj;
                    972:
                    973:                 if (cur_weapon == NULL)
                    974:                 {
                    975:                     msg("You feel your hands tingle a moment.");
                    976:                     pstats.s_dmg = "1d2";
                    977:                     return;
                    978:                 }
                    979:
                    980:                 obj = apply_to_bag(pack, 0, NULL, bafcweapon, NULL);
                    981:
                    982:                 if (obj->o_flags & ISMETAL)
                    983:                     msg("Your %s melts and disappears.",
                    984:                         inv_name(obj,LOWERCASE));
                    985:                 else
                    986:                     msg("Your %s crumbles in your hands.",
                    987:                         inv_name(obj, LOWERCASE));
                    988:
                    989:                 obj->o_flags &= ~ISCURSED;
                    990:                 dropcheck(obj);
                    991:                 del_bag(pack, obj);
                    992:
                    993:             }
                    994:             break;
                    995:
                    996:         case 9:
                    997:             {
                    998:                 object  *obj;
                    999:
                   1000:                 if (cur_armor == NULL)
                   1001:                 {
                   1002:                     msg("Your body tingles a moment.");
                   1003:                     return;
                   1004:                 }
                   1005:
                   1006:                 obj = apply_to_bag(pack, 0, NULL, bafcarmor, NULL);
                   1007:
                   1008:                 msg("Your %s crumbles into small black powdery dust.",
                   1009:                     inv_name(obj, LOWERCASE));
                   1010:
                   1011:                 obj->o_flags &= ~ISCURSED;
                   1012:                 dropcheck(obj);
                   1013:                 del_bag(pack, obj);
                   1014:             }
                   1015:             break;
                   1016:
                   1017:         default:
                   1018:
                   1019:             if (cur_weapon == NULL)
                   1020:             {
                   1021:                 seemsg("Your hand glows yellow for an instant.");
                   1022:                 pstats.s_dmg = "1d3";
                   1023:                 return;
                   1024:             }
                   1025:
                   1026:             seemsg("Your %s glows bright red for a moment.",
                   1027:                    weaps[cur_weapon->o_which].w_name);
                   1028:
                   1029:             if (cur_weapon->o_hplus > 0)
                   1030:                 cur_weapon->o_hplus = -rnd(3);
                   1031:             else
                   1032:                 cur_weapon->o_hplus -= rnd(3);
                   1033:
                   1034:             if (cur_weapon->o_dplus > 0)
                   1035:                 cur_weapon->o_dplus = -rnd(3);
                   1036:             else
                   1037:                 cur_weapon->o_dplus -= rnd(3);
                   1038:
                   1039:             cur_weapon->o_flags = ISCURSED | ISLOST;
                   1040:             cur_weapon->o_ac = 0;
                   1041:
                   1042:             break;
                   1043:     }
                   1044: }
                   1045:
                   1046: /*
                   1047:     do_phial()
                   1048:         handle powers of the Phial of Galadriel
                   1049: */
                   1050:
                   1051: void
                   1052: do_phial(void)
                   1053: {
                   1054:     int which;
                   1055:
                   1056:     /* Prompt for action */
                   1057:
                   1058:     msg("How do you wish to apply the Phial of Galadriel (* for list)? ");
                   1059:
                   1060:     which = (short) ((readchar() & 0177) - 'a');
                   1061:
                   1062:     if (which == (short) ESCAPE - (short) 'a')
                   1063:     {
                   1064:         after = FALSE;
                   1065:         return;
                   1066:     }
                   1067:
                   1068:     if (which < 0 || which > 1)
                   1069:     {
                   1070:         add_line("[a] total healing");
                   1071:         add_line("[b] total monster confusion");
                   1072:         end_line();
                   1073:         msg("");
                   1074:         msg("Which power do you wish to use? ");
                   1075:
                   1076:         which = (short) ((readchar() & 0177) - 'a');
                   1077:
                   1078:         while (which < 0 || which > 1)
                   1079:         {
                   1080:             if (which == (short) ESCAPE - (short) 'a')
                   1081:             {
                   1082:                 after = FALSE;
                   1083:                 return;
                   1084:             }
                   1085:
                   1086:             msg("");
                   1087:             msg("Please enter one of the listed powers: ");
                   1088:
                   1089:             which = (short) ((readchar() & 0177) - 'a');
                   1090:         }
                   1091:         msg("Your attempt is successful.");
                   1092:     }
                   1093:     else
                   1094:         msg("Your attempt is successsful.");
                   1095:
                   1096:     switch (which)
                   1097:     {
                   1098:         case 0:
                   1099:             pstats.s_hpt = max_stats.s_hpt += rnd(pstats.s_lvl) + 1;
                   1100:             pstats.s_power = max_stats.s_power += rnd(pstats.s_lvl) + 1;
                   1101:             break;
                   1102:
                   1103:         case 1:
                   1104:             {
                   1105:                 struct linked_list  *mi;
                   1106:                 struct thing    *tp;
                   1107:
                   1108:                 for (mi = mlist; mi != NULL; mi = next(mi))
                   1109:                 {
                   1110:                     tp = THINGPTR(mi);
                   1111:
                   1112:                     if (off(*tp, ISUNIQUE) || !save_throw(VS_MAGIC, tp))
                   1113:                         turn_on(*tp, ISHUH);
                   1114:                 }
                   1115:             }
                   1116:             break;
                   1117:
                   1118:         default:
                   1119:             msg("What a strange thing to do!!");
                   1120:             break;
                   1121:
                   1122:     }
                   1123: }
                   1124:
                   1125: /*
                   1126:     do_palantir()
                   1127:         handle powers of the Palantir of Might
                   1128: */
                   1129:
                   1130: void
                   1131: do_palantir(void)
                   1132: {
                   1133:     int which, limit;
                   1134:
                   1135:     /* Prompt for action */
                   1136:
                   1137:     msg("How do you wish to apply the Palantir of Might? (* for list): ");
                   1138:
                   1139:     limit = 3;
                   1140:
                   1141:     if (is_carrying(TR_SCEPTRE))
                   1142:         limit += 1;
                   1143:
                   1144:     if (is_carrying(TR_CROWN))
                   1145:         limit += 1;
                   1146:
                   1147:     which = (short) ((readchar() & 0177) - 'a');
                   1148:
                   1149:     if (which == (short) ESCAPE - (short) 'a')
                   1150:     {
                   1151:         after = FALSE;
                   1152:         return;
                   1153:     }
                   1154:
                   1155:     if (which < 0 || which > limit)
                   1156:     {
                   1157:         msg("");
                   1158:         add_line("[a] monster detection");
                   1159:         add_line("[b] gold detection");
                   1160:         add_line("[c] magic detection");
                   1161:         add_line("[d] food detection");
                   1162:
                   1163:         if (limit >= 4)
                   1164:             add_line("[e] teleportation");
                   1165:
                   1166:         if (limit >= 5)
                   1167:             add_line("[f] clear thought");
                   1168:
                   1169:         end_line();
                   1170:
                   1171:         msg("Which power do you wish to use?");
                   1172:
                   1173:         which = (short) ((readchar() & 0177) - 'a');
                   1174:
                   1175:         while (which < 0 || which > limit)
                   1176:         {
                   1177:             if (which == (short) ESCAPE - (short) 'a')
                   1178:             {
                   1179:                 after = FALSE;
                   1180:                 return;
                   1181:             }
                   1182:
                   1183:             msg("Please enter one of the listed powers: ");
                   1184:             which = (short) ((readchar() & 0177) - 'a');
                   1185:         }
                   1186:
                   1187:         msg("Your attempt is successful.");
                   1188:     }
                   1189:     else
                   1190:         msg("Your attempt is successful.");
                   1191:
                   1192:     switch (which)
                   1193:     {
                   1194:         case 0: quaff(&player, P_MONSTDET, ISNORMAL);
                   1195:                 break;
                   1196:         case 1: read_scroll(&player, S_GFIND, ISNORMAL);
                   1197:                 break;
                   1198:         case 2: quaff(&player, P_TREASDET, ISNORMAL);
                   1199:                 break;
                   1200:         case 3: read_scroll(&player, S_FOODDET, ISNORMAL);
                   1201:                 break;
                   1202:         case 4: read_scroll(&player, S_SELFTELEP, ISNORMAL);
                   1203:                 break;
                   1204:         case 5: quaff(&player, P_CLEAR, ISNORMAL);
                   1205:                 break;
                   1206:         default:
                   1207:                 msg("What a strange thing to do!!");
                   1208:                 break;
                   1209:     }
                   1210: }
                   1211:
                   1212: /*
                   1213:     do_silmaril()
                   1214:         handle powers of the Silamril of Ea
                   1215: */
                   1216:
                   1217: void
                   1218: do_silmaril(void)
                   1219: {
                   1220:     int which;
                   1221:
                   1222:     /* Prompt for action */
                   1223:     msg("How do you wish to apply the Silamril of Ea (* for list)? ");
                   1224:
                   1225:     which = (short) ((readchar() & 0177) - 'a');
                   1226:
                   1227:     if (which == (short) ESCAPE - (short) 'a')
                   1228:     {
                   1229:         after = FALSE;
                   1230:         return;
                   1231:     }
                   1232:
                   1233:     if (which < 0 || which > 2)
                   1234:     {
                   1235:         msg("");
                   1236:         add_line("[a] magic mapping");
                   1237:         add_line("[b] petrification");
                   1238:         add_line("[c] stairwell downwards");
                   1239:         end_line();
                   1240:
                   1241:         msg("Which power do you wish to use?");
                   1242:
                   1243:         which = (short) ((readchar() & 0177) - 'a');
                   1244:
                   1245:         while (which < 0 || which > 2)
                   1246:         {
                   1247:             if (which == (short) ESCAPE - (short) 'a')
                   1248:             {
                   1249:                 after = FALSE;
                   1250:                 return;
                   1251:             }
                   1252:             msg("");
                   1253:             msg("Please enter one of the listed powers: ");
                   1254:             which = (short) ((readchar() & 0177) - 'a');
                   1255:         }
                   1256:         msg("Your attempt is successful.");
                   1257:     }
                   1258:     else
                   1259:         msg("Your attempt is successful.");
                   1260:
                   1261:     switch (which)
                   1262:     {
                   1263:         case 0: read_scroll(&player, S_MAP, ISNORMAL);
                   1264:                 break;
                   1265:         case 1: read_scroll(&player, S_PETRIFY, ISNORMAL);
                   1266:                 break;
                   1267:         case 2: msg("A stairwell opens beneath your feet and you go down.");
                   1268:                 level++;
                   1269:                 new_level(NORMLEV,0);
                   1270:                 break;
                   1271:         default:msg("What a strange thing to do!!");
                   1272:                 break;
                   1273:     }
                   1274: }
                   1275:
                   1276: /*
                   1277:     do_amulet()
                   1278:         handle powers of the Amulet of Yendor
                   1279: */
                   1280:
                   1281: void
                   1282: do_amulet(void)
                   1283: {
                   1284:     int which, limit;
                   1285:
                   1286:     /* Prompt for action */
                   1287:     msg("How do you wish to apply the Amulet of Yendor (* for list)? ");
                   1288:
                   1289:     limit = 0;
                   1290:
                   1291:     if (is_carrying(TR_PURSE))
                   1292:         limit += 1;
                   1293:
                   1294:     which = (short) ((readchar() & 0177) - 'a');
                   1295:
                   1296:     if (which == (short) ESCAPE - (short) 'a')
                   1297:     {
                   1298:         after = FALSE;
                   1299:         return;
                   1300:     }
                   1301:
                   1302:     if (which < 0 || which > limit)
                   1303:     {
                   1304:         msg("");
                   1305:         add_line("[a] level evaluation");
                   1306:
                   1307:         if (limit >= 1)
                   1308:             add_line("[b] invisibility");
                   1309:
                   1310:         end_line();
                   1311:         msg("Which power do you wish to use?");
                   1312:
                   1313:         which = (short) ((readchar() & 0177) - 'a');
                   1314:
                   1315:         while (which < 0 || which > limit)
                   1316:         {
                   1317:             if (which == (short) ESCAPE - (short) 'a')
                   1318:             {
                   1319:                 after = FALSE;
                   1320:                 return;
                   1321:             }
                   1322:
                   1323:             msg("");
                   1324:             msg("Please enter one of the listed powers: ");
                   1325:             which = (short) ((readchar() & 0177) - 'a');
                   1326:         }
                   1327:
                   1328:         msg("Your attempt is successful.");
                   1329:     }
                   1330:     else
                   1331:         msg("Your attempt is successful.");
                   1332:
                   1333:     switch (which)
                   1334:     {
                   1335:         case 0: level_eval();
                   1336:                 break;
                   1337:         case 1: quaff(&player, P_INVIS, ISNORMAL);
                   1338:                 break;
                   1339:         default:msg("What a strange thing to do!!");
                   1340:                 break;
                   1341:     }
                   1342: }
                   1343:
                   1344: /*
                   1345:     do_bag()
                   1346:         handle powers of the Magic Purse of Yendor as a bag of holding
                   1347: */
                   1348:
                   1349: void
                   1350: do_bag(struct object *obj)
                   1351: {
                   1352:     int which, limit;
                   1353:
                   1354:     /* Prompt for action */
                   1355:     msg("How do you wish to apply the Magic Purse of Yendor (* for list)? ");
                   1356:
                   1357:     which = (short) ((readchar() & 0177) - 'a');
                   1358:
                   1359:     if (which == (short) ESCAPE - (short) 'a')
                   1360:     {
                   1361:         after = FALSE;
                   1362:         return;
                   1363:     }
                   1364:
                   1365:     limit = 2;
                   1366:
                   1367:     if (is_carrying(TR_AMULET))
                   1368:         limit += 1;
                   1369:
                   1370:     if (which < 0 || which > limit)
                   1371:     {
                   1372:         msg("");
                   1373:         add_line("[a] inventory");
                   1374:         add_line("[b] add to bag");
                   1375:         add_line("[c] remove from bag");
                   1376:
                   1377:         if (limit >= 3)
                   1378:             add_line("[d] see invisible");
                   1379:
                   1380:         end_line();
                   1381:
                   1382:         msg("Which power do you wish to use?");
                   1383:
                   1384:         which = (short) ((readchar() & 0177) - 'a');
                   1385:
                   1386:         while (which < 0 || which > limit)
                   1387:         {
                   1388:             if (which == (short) ESCAPE - (short) 'a')
                   1389:             {
                   1390:                 after = FALSE;
                   1391:                 return;
                   1392:             }
                   1393:
                   1394:             msg("");
                   1395:             msg("Please enter one of the listed powers: ");
                   1396:             which = (short) ((readchar() & 0177) - 'a');
                   1397:         }
                   1398:
                   1399:         msg("Your attempt is successful.");
                   1400:     }
                   1401:     else
                   1402:         msg("Your attempt is successful.");
                   1403:
                   1404:     switch (which)
                   1405:     {
                   1406:         case 0:
                   1407:             inventory(obj->o_bag, 0);
                   1408:             break;
                   1409:
                   1410:         case 1:
                   1411:             {
                   1412:                 object  *new_obj_p; /* what the user selected */
                   1413:
                   1414:                 if ((new_obj_p = get_object(pack, "add", 0, NULL)) != NULL)
                   1415:                 {
                   1416:                     rem_pack(new_obj_p);    /* free up pack slot */
                   1417:                     push_bag(&obj->o_bag, new_obj_p);
                   1418:                     pack_report(new_obj_p, MESSAGE, "You just added ");
                   1419:                 }
                   1420:             }
                   1421:             break;
                   1422:
                   1423:         case 2:
                   1424:             {
                   1425:                 object  *obj_p;
                   1426:                 linked_list *item_p;
                   1427:
                   1428:                 if ((obj_p=get_object(obj->o_bag,"remove",0,NULL)) != NULL)
                   1429:                 {
                   1430:                     item_p = make_item(obj_p);  /* attach upper structure */
                   1431:
                   1432:                     if (add_pack(item_p, MESSAGE) != FALSE)
                   1433:                         pop_bag(&obj->o_bag, obj_p);
                   1434:                 }
                   1435:             }
                   1436:             break;
                   1437:
                   1438:         case 3:
                   1439:             quaff(&player, P_TRUESEE, ISBLESSED);
                   1440:             break;
                   1441:
                   1442:         default:
                   1443:             msg("What a strange thing to do!!");
                   1444:     }
                   1445: }
                   1446:
                   1447: /*
                   1448:     do_sceptre()
                   1449:         handle powers of the Sceptre of Might
                   1450: */
                   1451:
                   1452: void
                   1453: do_sceptre(void)
                   1454: {
                   1455:     int which, limit;
                   1456:
                   1457:     /* Prompt for action */
                   1458:     msg("How do you wish to apply the Sceptre of Might (* for list)? ");
                   1459:
                   1460:     which = (short) ((readchar() & 0177) - 'a');
                   1461:
                   1462:     if (which == (short) ESCAPE - (short) 'a')
                   1463:     {
                   1464:         after = FALSE;
                   1465:         return;
                   1466:     }
                   1467:
                   1468:     limit = 5;
                   1469:
                   1470:     if (is_carrying(TR_CROWN))
                   1471:         limit += 1;
                   1472:
                   1473:     if (is_carrying(TR_PALANTIR))
                   1474:         limit += 1;
                   1475:
                   1476:     if (which < 0 || which > limit)
                   1477:     {
                   1478:         msg("");
                   1479:         add_line("[a] cancellation");
                   1480:         add_line("[b] polymorph monster");
                   1481:         add_line("[c] slow monster");
                   1482:         add_line("[d] teleport monster");
                   1483:         add_line("[e] monster confusion");
                   1484:         add_line("[f] paralyze monster");
                   1485:
                   1486:         if (limit >= 6)
                   1487:             add_line("[g] drain life");
                   1488:
                   1489:         if (limit >= 7)
                   1490:             add_line("[h] smell monster");
                   1491:
                   1492:         end_line();
                   1493:
                   1494:         msg("Which power do you wish to use?");
                   1495:
                   1496:         which = (short) ((readchar() & 0177) - 'a');
                   1497:
                   1498:         while (which < 0 || which > limit)
                   1499:         {
                   1500:             if (which == (short) ESCAPE - (short) 'a')
                   1501:             {
                   1502:                 after = FALSE;
                   1503:                 return;
                   1504:             }
                   1505:
                   1506:             msg("");
                   1507:             msg("Please enter one of the listed powers: ");
                   1508:             which = (short) ((readchar() & 0177) - 'a');
                   1509:         }
                   1510:
                   1511:         msg("Your attempt is successful.");
                   1512:     }
                   1513:     else
                   1514:         msg("Your attempt is successful.");
                   1515:
                   1516:     if (rnd(pstats.s_lvl) < 7)
                   1517:     {
                   1518:         msg("Your finger slips.");
                   1519:         which = rnd(6);
                   1520:         if (wizard)
                   1521:         {
                   1522:             msg("What wand? (%d)", which);
                   1523:
                   1524:             if (get_string(prbuf, cw) == NORM)
                   1525:             {
                   1526:                 which = atoi(prbuf);
                   1527:                 if (which < 0 || which > 5)
                   1528:                 {
                   1529:                     msg("Invalid selection.");
                   1530:                     which = rnd(6);
                   1531:                     msg("Rolled %d.", which);
                   1532:                 }
                   1533:             }
                   1534:         }
                   1535:     }
                   1536:
                   1537:     switch (which)
                   1538:     {
                   1539:         case 0:
                   1540:             if (get_dir())
                   1541:                 do_zap(&player, WS_CANCEL, ISBLESSED);
                   1542:             break;
                   1543:
                   1544:         case 1:
                   1545:             if (get_dir())
                   1546:                 do_zap(&player, WS_POLYMORPH, ISBLESSED);
                   1547:             break;
                   1548:
                   1549:         case 2:
                   1550:             if (get_dir())
                   1551:                 do_zap(&player, WS_SLOW_M, ISBLESSED);
                   1552:             break;
                   1553:
                   1554:         case 3:
                   1555:             if (get_dir())
                   1556:                 do_zap(&player, WS_MONSTELEP, ISBLESSED);
                   1557:             break;
                   1558:
                   1559:         case 4:
                   1560:             if (get_dir())
                   1561:                 do_zap(&player, WS_CONFMON, ISBLESSED);
                   1562:             break;
                   1563:
                   1564:         case 5:
                   1565:             if (get_dir())
                   1566:                 do_zap(&player, WS_PARALYZE, ISBLESSED);
                   1567:             break;
                   1568:
                   1569:         case 6:
                   1570:             if (get_dir())
                   1571:                 do_zap(&player, WS_DRAIN, ISBLESSED);
                   1572:             break;
                   1573:
                   1574:         case 7:
                   1575:             quaff(&player, P_SMELL, ISBLESSED);
                   1576:             break;
                   1577:
                   1578:         default:
                   1579:             msg("What a strange thing to do!!");
                   1580:             break;
                   1581:     }
                   1582: }
                   1583:
                   1584: /*
                   1585:     do_wand()
                   1586:         handle powers of the Wand of Yendor
                   1587: */
                   1588:
                   1589: void
                   1590: do_wand(void)
                   1591: {
                   1592:     int which, i;
                   1593:
                   1594:     /* Prompt for action */
                   1595:     msg("How do you wish to apply the Wand of Yendor (* for list)? ");
                   1596:
                   1597:     which = (short) ((readchar() & 0177) - 'a');
                   1598:
                   1599:     if (which == (short) ESCAPE - (short) 'a')
                   1600:     {
                   1601:         after = FALSE;
                   1602:         return;
                   1603:     }
                   1604:
                   1605:     if (which < 0 || which >= maxsticks)
                   1606:     {
                   1607:         msg("");
                   1608:
                   1609:         for (i = 0; i < maxsticks; i++)
                   1610:         {
                   1611:             sprintf(prbuf, "[%c] %s", i + 'a', ws_magic[i].mi_name);
                   1612:             add_line(prbuf);
                   1613:         }
                   1614:
                   1615:         end_line();
                   1616:
                   1617:         msg("Which power do you wish to use?");
                   1618:
                   1619:         which = (short) ((readchar() & 0177) - 'a');
                   1620:
                   1621:         while (which < 0 || which >= maxsticks)
                   1622:         {
                   1623:             if (which == (short) ESCAPE - (short) 'a')
                   1624:             {
                   1625:                 after = FALSE;
                   1626:                 return;
                   1627:             }
                   1628:
                   1629:             msg("");
                   1630:             msg("Please enter one of the listed powers: ");
                   1631:             which = (short) ((readchar() & 0177) - 'a');
                   1632:         }
                   1633:         msg("Your attempt is successful.");
                   1634:     }
                   1635:     else
                   1636:         msg("Your attempt is successful.");
                   1637:
                   1638:     if (rnd(pstats.s_lvl) < 12)
                   1639:     {
                   1640:         msg("Your finger slips.");
                   1641:         which = rnd(maxsticks);
                   1642:
                   1643:         if (wizard)
                   1644:         {
                   1645:             msg("What wand? (%d)", which);
                   1646:
                   1647:             if (get_string(prbuf, cw) == NORM)
                   1648:             {
                   1649:                 which = atoi(prbuf);
                   1650:
                   1651:                 if (which < 0 || which >= maxsticks)
                   1652:                 {
                   1653:                     msg("Invalid selection.");
                   1654:                     which = rnd(maxsticks);
                   1655:                     msg("Rolled %d.", which);
                   1656:                 }
                   1657:             }
                   1658:         }
                   1659:     }
                   1660:
                   1661:     if (get_dir())
                   1662:         do_zap(&player, which, ISBLESSED);
                   1663: }
                   1664:
                   1665: /*
                   1666:     do_crown()
                   1667:         handle powers of the Crown of Might
                   1668: */
                   1669:
                   1670: void
                   1671: do_crown(void)
                   1672: {
                   1673:     int which, limit;
                   1674:
                   1675:     /* Prompt for action */
                   1676:     msg("How do you wish to apply the Crown of Might (* for list)? ");
                   1677:
                   1678:     which = (short) ((readchar() & 0177) - 'a');
                   1679:
                   1680:     if (which == (short) ESCAPE - (short) 'a')
                   1681:     {
                   1682:         after = FALSE;
                   1683:         return;
                   1684:     }
                   1685:
                   1686:     limit = 9;
                   1687:
                   1688:     if (is_carrying(TR_PALANTIR))
                   1689:         limit += 1;
                   1690:
                   1691:     if (is_carrying(TR_SCEPTRE))
                   1692:         limit += 1;
                   1693:
                   1694:     if (which < 0 || which > limit)
                   1695:     {
                   1696:         msg("");
                   1697:         add_line("[a] add strength");
                   1698:         add_line("[b] add intelligence");
                   1699:         add_line("[c] add wisdom");
                   1700:         add_line("[d] add dexterity");
                   1701:         add_line("[e] add constitution");
                   1702:         add_line("[f] normal strength");
                   1703:         add_line("[g] normal intelligence");
                   1704:         add_line("[h] normal wisdom");
                   1705:         add_line("[i] normal dexterity");
                   1706:         add_line("[j] normal constitution");
                   1707:
                   1708:         if (limit >= 10)
                   1709:             add_line("[k] disguise");
                   1710:
                   1711:         if (limit >= 11)
                   1712:             add_line("[l] super heroism");
                   1713:
                   1714:         end_line();
                   1715:
                   1716:         msg("Which power do you wish to use?");
                   1717:
                   1718:         which = (short) ((readchar() & 0177) - 'a');
                   1719:
                   1720:         while (which < 0 || which > limit)
                   1721:         {
                   1722:             if (which == (short) ESCAPE - (short) 'a')
                   1723:             {
                   1724:                 after = FALSE;
                   1725:                 return;
                   1726:             }
                   1727:             msg("");
                   1728:             msg("Please enter one of the listed powers: ");
                   1729:             which = (short) ((readchar() & 0177) - 'a');
                   1730:         }
                   1731:
                   1732:         msg("Your attempt is successful.");
                   1733:     }
                   1734:     else
                   1735:         msg("Your attempt is successful.");
                   1736:
                   1737:     switch (which)
                   1738:     {
                   1739:         case 0:
                   1740:             if (off(player, POWERSTR))
                   1741:             {
                   1742:                 turn_on(player, POWERSTR);
                   1743:                 chg_str(10, FALSE, FALSE);
                   1744:                 msg("You feel much stronger now.");
                   1745:             }
                   1746:             else
                   1747:                 nothing_message(ISCURSED);
                   1748:             break;
                   1749:
                   1750:         case 1:
                   1751:             if (off(player, POWERINTEL))
                   1752:             {
                   1753:                 pstats.s_intel += 10;
                   1754:                 turn_on(player, POWERINTEL);
                   1755:                 msg("You feel much more intelligent now.");
                   1756:             }
                   1757:             else
                   1758:                 nothing_message(ISCURSED);
                   1759:             break;
                   1760:
                   1761:         case 2:
                   1762:             if (off(player, POWERWISDOM))
                   1763:             {
                   1764:                 pstats.s_wisdom += 10;
                   1765:                 turn_on(player, POWERWISDOM);
                   1766:                 msg("Your feel much wiser know.");
                   1767:             }
                   1768:             else
                   1769:                 nothing_message(ISCURSED);
                   1770:             break;
                   1771:
                   1772:         case 3:
                   1773:             if (off(player, POWERDEXT))
                   1774:             {
                   1775:                 turn_on(player, POWERDEXT);
                   1776:                 chg_dext(10, FALSE, FALSE);
                   1777:                 msg("You feel much more dextrous now.");
                   1778:             }
                   1779:             else
                   1780:                 nothing_message(ISCURSED);
                   1781:             break;
                   1782:
                   1783:         case 4:
                   1784:             if (off(player, POWERCONST))
                   1785:             {
                   1786:                 pstats.s_const += 10;
                   1787:                 turn_on(player, POWERCONST);
                   1788:                 msg("You feel much healthier now.");
                   1789:             }
                   1790:             else
                   1791:                 nothing_message(ISCURSED);
                   1792:             break;
                   1793:
                   1794:         case 5:
                   1795:             if (on(player, POWERSTR))
                   1796:             {
                   1797:                 turn_off(player, POWERSTR);
                   1798:                 chg_str(-10, FALSE, FALSE);
                   1799:                 msg("Your muscles bulge less now.");
                   1800:             }
                   1801:             else
                   1802:                 nothing_message(ISCURSED);
                   1803:             break;
                   1804:
                   1805:         case 6:
                   1806:             if (on(player, POWERINTEL))
                   1807:             {
                   1808:                 pstats.s_intel = max(pstats.s_intel - 10,
                   1809:                              3 + ring_value(R_ADDINTEL));
                   1810:                 turn_off(player, POWERINTEL);
                   1811:                 msg("You feel less intelligent now.");
                   1812:             }
                   1813:             else
                   1814:                 nothing_message(ISCURSED);
                   1815:             break;
                   1816:
                   1817:         case 7:
                   1818:             if (on(player, POWERWISDOM))
                   1819:             {
                   1820:                 pstats.s_wisdom = max(pstats.s_wisdom - 10,
                   1821:                               3 + ring_value(R_ADDWISDOM));
                   1822:                 turn_off(player, POWERWISDOM);
                   1823:                 msg("You feel less wise now.");
                   1824:             }
                   1825:             else
                   1826:                 nothing_message(ISCURSED);
                   1827:             break;
                   1828:
                   1829:         case 8:
                   1830:             if (on(player, POWERDEXT))
                   1831:             {
                   1832:                 turn_off(player, POWERDEXT);
                   1833:                 chg_dext(-10, FALSE, FALSE);
                   1834:                 msg("You feel less dextrous now.");
                   1835:             }
                   1836:             else
                   1837:                 nothing_message(ISCURSED);
                   1838:             break;
                   1839:
                   1840:         case 9:
                   1841:             if (on(player, POWERCONST))
                   1842:             {
                   1843:                 pstats.s_const -= 10;
                   1844:                 turn_off(player, POWERCONST);
                   1845:                 msg("You feel less healthy now.");
                   1846:             }
                   1847:             else
                   1848:                 nothing_message(ISCURSED);
                   1849:             break;
                   1850:
                   1851:         case 10: quaff(&player, P_DISGUISE, ISNORMAL);
                   1852:             break;
                   1853:
                   1854:         case 11: quaff(&player, P_SHERO, ISNORMAL);
                   1855:             break;
                   1856:
                   1857:         default:
                   1858:             msg("What a strange thing to do!!");
                   1859:             break;
                   1860:
                   1861:     }
                   1862: }
                   1863:
                   1864: /*
                   1865:     level_eval()
                   1866:         have amulet evaluate danger on this level
                   1867: */
                   1868:
                   1869: void
                   1870: level_eval(void)
                   1871: {
                   1872:     int cnt = 0;
                   1873:     long max_nasty = 0;
                   1874:     struct linked_list  *item;
                   1875:     struct thing    *tp;
                   1876:     char    *colour, *temp;
                   1877:
                   1878:     for (item = mlist; item != NULL; item = next(item))
                   1879:     {
                   1880:         tp = THINGPTR(item);
                   1881:         cnt++;
                   1882:         max_nasty = max(max_nasty,(10L-tp->t_stats.s_arm) * tp->t_stats.s_hpt);
                   1883:     }
                   1884:
                   1885:     if (cnt < 3)
                   1886:         colour = "black";
                   1887:     else if (cnt < 6)
                   1888:         colour = "red";
                   1889:     else if (cnt < 9)
                   1890:         colour = "orange";
                   1891:     else if (cnt < 12)
                   1892:         colour = "yellow";
                   1893:     else if (cnt < 15)
                   1894:         colour = "green";
                   1895:     else if (cnt < 18)
                   1896:         colour = "blue";
                   1897:     else if (cnt < 25)
                   1898:         colour = "violet";
                   1899:     else
                   1900:         colour = "pink with purple polka dots";
                   1901:
                   1902:     if (max_nasty < 10)
                   1903:         temp = "feels cold and lifeless";
                   1904:     else if (max_nasty < 30)
                   1905:         temp = "feels cool";
                   1906:     else if (max_nasty < 200)
                   1907:         temp = "feels warm and soft";
                   1908:     else if (max_nasty < 1000)
                   1909:         temp = "feels warm and slippery";
                   1910:     else if (max_nasty < 5000)
                   1911:         temp = "feels hot and dry";
                   1912:     else if (max_nasty < 10000)
                   1913:         temp = "feels too hot to hold";
                   1914:     else if (max_nasty < 20000)
                   1915:         temp = "burns your hand";
                   1916:     else
                   1917:         temp = "jumps up and down shrieking 'DANGER! DANGER'";
                   1918:
                   1919:     msg("The amulet glows %s and %s.", colour, temp);
                   1920:
                   1921:     return;
                   1922: }

CVSweb