home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / mor4873s.lzh / SCROLLS.C < prev    next >
C/C++ Source or Header  |  1988-12-14  |  12KB  |  502 lines

  1. #include <stdio.h>
  2.  
  3. #include "constant.h"
  4. #include "config.h"
  5. #include "types.h"
  6. #include "externs.h"
  7.  
  8. #ifdef sun   /* correct SUN stupidity in the stdio.h file */
  9. char *sprintf();
  10. #endif
  11.  
  12. extern int moria_flag;
  13.  
  14.  
  15. /* Scrolls for the reading                -RAK-    */
  16. read_scroll()
  17. {
  18.   bitset_t i;
  19.   int j, k, l, item_val;
  20.   int y, x;
  21.   int tmp[6];
  22.   bigvtype out_val, tmp_str;
  23.   int redraw, ident, first, flag;
  24.   register treasure_type *i_ptr;
  25.   register struct misc *m_ptr;
  26.  
  27.   first = TRUE;
  28.   reset_flag = TRUE;
  29.   if (inven_ctr > 0)
  30.     {
  31.       if (find_range(70, 71, &j, &k))
  32.     if (py.flags.blind > 0)
  33.       msg_print("You can't see to read the scroll.");
  34.     else if (no_light())
  35.       msg_print("You have no light to read by.");
  36.     else if (py.flags.confused > 0)
  37.       {
  38.         msg_print("The text seems to swim about the page!");
  39.         msg_print("You are too confused to read...");
  40.       }
  41.     else
  42.       {
  43.         redraw = FALSE;
  44.         if (get_item(&item_val, "Read which scroll?", &redraw, j, k))
  45.           {
  46.         i_ptr = &inventory[item_val];
  47.         if (redraw)  draw_cave();
  48.         reset_flag = FALSE;
  49.         i = i_ptr->flags;
  50.         ident = FALSE;
  51.  
  52.         while (i != 0)
  53.           {
  54.             j = bit_pos(&i) + 1;
  55.             if (i_ptr->tval == 71)
  56.               j += 31;
  57.             if (first)
  58.               if ((j != 4) && (j != 25))
  59.             {
  60.               msg_print("As you read the scroll it vanishes.");
  61.               first = FALSE;
  62.             }
  63.  
  64.             /* Scrolls...            */
  65.             switch(j)
  66.               {
  67.               case 1:
  68.             i_ptr = &inventory[INVEN_WIELD];
  69.             if (i_ptr->tval != 0)
  70.               {
  71.                 objdes(tmp_str, INVEN_WIELD, FALSE);
  72.                 (void) sprintf(out_val, "Your %s glows faintly!",
  73.                        tmp_str);
  74.                 msg_print(out_val);
  75.                 if (enchant(&i_ptr->tohit))
  76.                   {
  77.                 i_ptr->flags &= 0x7FFFFFFF;
  78.                 py_bonuses(blank_treasure, 0);
  79.                   }
  80.                 else
  81.                   msg_print("The enchantment fails...");
  82.               }
  83.             ident = TRUE;
  84.             break;
  85.               case 2:
  86.             i_ptr = &inventory[INVEN_WIELD];
  87.             if (i_ptr->tval != 0)
  88.               {
  89.                 objdes(tmp_str, INVEN_WIELD, FALSE);
  90.                 (void) sprintf(out_val, "Your %s glows faintly!",
  91.                        tmp_str);
  92.                 msg_print(out_val);
  93.                 if (enchant(&i_ptr->todam))
  94.                   {
  95.                 i_ptr->flags &= 0x7FFFFFFF;
  96.                 py_bonuses(blank_treasure, 0);
  97.                   }
  98.                 else
  99.                   msg_print("The enchantment fails...");
  100.               }
  101.             ident = TRUE;
  102.             break;
  103.               case 3:
  104.             k = 0;
  105.             l = 0;
  106.             if (inventory[INVEN_BODY].tval != 0)
  107.               tmp[k++] = INVEN_BODY;
  108.             if (inventory[INVEN_ARM].tval != 0)
  109.               tmp[k++] = INVEN_ARM;
  110.             if (inventory[INVEN_OUTER].tval != 0)
  111.               tmp[k++] = INVEN_OUTER;
  112.             if (inventory[INVEN_HANDS].tval != 0)
  113.               tmp[k++] = INVEN_HANDS;
  114.             if (inventory[INVEN_HEAD].tval != 0)
  115.               tmp[k++] = INVEN_HEAD;
  116.             /* also enchant boots */
  117.             if (inventory[INVEN_FEET].tval != 0)
  118.               tmp[k++] = INVEN_FEET;
  119.  
  120.             if (k > 0)  l = tmp[randint(k)-1];
  121.  
  122.             if (0x80000000 & inventory[INVEN_BODY].flags)
  123.               l = INVEN_BODY;
  124.             else if (0x80000000 & inventory[INVEN_ARM].flags)
  125.               l = INVEN_ARM;
  126.             else if (0x80000000 & inventory[INVEN_OUTER].flags)
  127.               l = INVEN_OUTER;
  128.             else if (0x80000000 & inventory[INVEN_HEAD].flags)
  129.               l = INVEN_HEAD;
  130.             else if (0x80000000 & inventory[INVEN_HANDS].flags)
  131.               l = INVEN_HANDS;
  132.             else if (0x80000000 & inventory[INVEN_FEET].flags)
  133.               l = INVEN_FEET;
  134.  
  135.             if (l > 0)
  136.               {
  137.                 i_ptr = &inventory[l];
  138.                 objdes(tmp_str, l, FALSE);
  139.                 (void) sprintf(out_val, "Your %s glows faintly!",
  140.                        tmp_str);
  141.                 msg_print(out_val);
  142.                 if (enchant(&i_ptr->toac))
  143.                   {
  144.                 i_ptr->flags &= 0x7FFFFFFF;
  145.                 py_bonuses(blank_treasure, 0);
  146.                   }
  147.                 else
  148.                   msg_print("The enchantment fails...");
  149.                 ident = TRUE;
  150.               }
  151.             break;
  152.               case 4:
  153.             identify(inventory[item_val]);
  154.             msg_print("This is an identify scroll");
  155.             /* make sure player sees message before ident_spell */
  156.             msg_print(" ");
  157.             if (ident_spell())  first = FALSE;
  158.             break;
  159.               case 5:
  160.             if (remove_curse())
  161.               {
  162.              msg_print("You feel as if someone is watching over you.");
  163.                 ident = TRUE;
  164.               }
  165.             break;
  166.               case 6:
  167.             ident = light_area(char_row, char_col);
  168.             break;
  169.               case 7:
  170.             ident = FALSE;
  171.             for (k = 0; k < randint(3); k++)
  172.               {
  173.                 y = char_row;
  174.                 x = char_col;
  175.                 ident |= summon_monster(&y, &x, FALSE);
  176.               }
  177.             break;
  178.               case 8:
  179.             teleport(10);
  180.             ident = TRUE;
  181.             break;
  182.               case 9:
  183.             teleport(100);
  184.             ident = TRUE;
  185.             break;
  186.               case 10:
  187.             dun_level += (-3) + 2*randint(2);
  188.             if (dun_level < 1)
  189.               dun_level = 1;
  190.             moria_flag = TRUE;
  191.             ident = TRUE;
  192.             break;
  193.               case 11:
  194.             msg_print("Your hands begin to glow.");
  195.             py.flags.confuse_monster = TRUE;
  196.             ident = TRUE;
  197.             break;
  198.               case 12:
  199.             ident = map_area();
  200.             break;
  201.               case 13:
  202.             ident = sleep_monsters1(char_row, char_col);
  203.             break;
  204.               case 14:
  205.             ident = warding_glyph();
  206.             break;
  207.               case 15:
  208.             ident = detect_treasure();
  209.             break;
  210.               case 16:
  211.             ident = detect_object();
  212.             break;
  213.               case 17:
  214.             ident = detect_trap();
  215.             break;
  216.               case 18:
  217.             ident = detect_sdoor();
  218.             break;
  219.               case 19:
  220.             msg_print("This is a mass genocide scroll.");
  221.             ident = mass_genocide();
  222.             break;
  223.               case 20:
  224.             ident = detect_invisible();
  225.             break;
  226.               case 21:
  227.             ident = aggravate_monster(20);
  228.             msg_print("There is a high pitched humming noise");
  229.             break;
  230.               case 22:
  231.             ident = trap_creation();
  232.             break;
  233.               case 23:
  234.             ident = td_destroy();
  235.             break;
  236.               case 24:
  237.             ident = door_creation();
  238.             break;
  239.               case 25:
  240.             identify(inventory[item_val]);
  241.             msg_print("This is a Recharge-Item scroll.");
  242.             /* make sure player see message before recharge */
  243.             msg_print(" ");
  244.             if (recharge(60))  first = FALSE;
  245.             break;
  246.               case 26:
  247.             msg_print("This is a genocide scroll.");
  248.             /* make sure player sees message before genocide() */
  249.             msg_print(" ");
  250.             ident = genocide();
  251.             break;
  252.               case 27:
  253.             ident = unlight_area(char_row, char_col);
  254.             break;
  255.               case 28:
  256.             ident = protect_evil();
  257.             break;
  258.               case 29:
  259.             ident = create_food();
  260.             break;
  261.               case 30:
  262.             ident = dispell_creature(0x0008, 60);
  263.             break;
  264.               case 31:
  265.             msg_print("That scroll appeared to be blank.");
  266.             ident = TRUE;
  267.             break;
  268.               case 32:
  269.             i_ptr = &inventory[INVEN_WIELD];
  270.             if (i_ptr->tval != 0)
  271.               {
  272.                 objdes(tmp_str, INVEN_WIELD, FALSE);
  273.                 (void) sprintf(out_val, "Your %s glows brightly!",
  274.                     tmp_str);
  275.                 msg_print(out_val);
  276.                 flag = FALSE;
  277.                 for (k = 0; k < randint(2); k++)
  278.                   if (enchant(&i_ptr->tohit))
  279.                 flag = TRUE;
  280.                 for (k = 0; k < randint(2); k++)
  281.                   if (enchant(&i_ptr->todam))
  282.                 flag = TRUE;
  283.                 if (flag)
  284.                   {
  285.                 i_ptr->flags &= 0x7FFFFFFF;
  286.                 py_bonuses(blank_treasure, 0);
  287.                   }
  288.                 else
  289.                   msg_print("The enchantment fails...");
  290.                 ident = TRUE;
  291.               }
  292.             break;
  293.               case 33:
  294.             i_ptr = &inventory[INVEN_WIELD];
  295.             if (i_ptr->tval != 0)
  296.               {
  297.                 inventory[INVEN_MAX] = inventory[INVEN_WIELD];
  298.                 objdes(tmp_str, INVEN_WIELD, FALSE);
  299.                 (void)sprintf(out_val,"Your %s glows black, fades",
  300.                     tmp_str);
  301.                 msg_print(out_val);
  302.                 i_ptr->tohit = -randint(5) - randint(5);
  303.                 i_ptr->todam = -randint(5) - randint(5);
  304.                 i_ptr->flags = 0x80000000;
  305.                 py_bonuses(inventory[INVEN_MAX], -1);
  306.                 ident = TRUE;
  307.               }
  308.             break;
  309.               case 34:
  310.             k = 0;
  311.             l = 0;
  312.             if (inventory[INVEN_BODY].tval != 0)
  313.               tmp[k++] = INVEN_BODY;
  314.             if (inventory[INVEN_ARM].tval != 0)
  315.               tmp[k++] = INVEN_ARM;
  316.             if (inventory[INVEN_OUTER].tval != 0)
  317.               tmp[k++] = INVEN_OUTER;
  318.             if (inventory[INVEN_HANDS].tval != 0)
  319.               tmp[k++] = INVEN_HANDS;
  320.             if (inventory[INVEN_HEAD].tval != 0)
  321.               tmp[k++] = INVEN_HEAD;
  322.             /* also enchant boots */
  323.             if (inventory[INVEN_FEET].tval != 0)
  324.               tmp[k++] = INVEN_FEET;
  325.  
  326.             if (k > 0)  l = tmp[randint(k)-1];
  327.  
  328.             if (0x80000000 & inventory[INVEN_BODY].flags)
  329.               l = INVEN_BODY;
  330.             else if (0x80000000 & inventory[INVEN_ARM].flags)
  331.               l = INVEN_ARM;
  332.             else if (0x80000000 & inventory[INVEN_OUTER].flags)
  333.               l = INVEN_OUTER;
  334.             else if (0x80000000 & inventory[INVEN_HEAD].flags)
  335.               l = INVEN_HEAD;
  336.             else if (0x80000000 & inventory[INVEN_HANDS].flags)
  337.               l = INVEN_HANDS;
  338.             else if (0x80000000 & inventory[INVEN_FEET].flags)
  339.               l = INVEN_FEET;
  340.  
  341.             if (l > 0)
  342.               {
  343.                 i_ptr = &inventory[l];
  344.                 objdes(tmp_str, l, FALSE);
  345.                 (void) sprintf(out_val,"Your %s glows brightly!",
  346.                        tmp_str);
  347.                 msg_print(out_val);
  348.                 flag = FALSE;
  349.                 for (k = 0; k < randint(2) + 1; k++)
  350.                   if (enchant(&i_ptr->toac))
  351.                 flag = TRUE;
  352.                 if (flag)
  353.                   {
  354.                 i_ptr->flags &= 0x7FFFFFFF;
  355.                 py_bonuses(blank_treasure, 0);
  356.                   }
  357.                 else
  358.                   msg_print("The enchantment fails...");
  359.                 ident = TRUE;
  360.               }
  361.             break;
  362.               case 35:
  363.             if ((inventory[INVEN_BODY].tval != 0) && (randint(4) == 1))
  364.               k = INVEN_BODY;
  365.             else if ((inventory[INVEN_ARM].tval != 0) && (randint(3) ==1))
  366.               k = INVEN_ARM;
  367.             else if ((inventory[INVEN_OUTER].tval != 0) && (randint(3) ==1))
  368.               k = INVEN_OUTER;
  369.             else if ((inventory[INVEN_HEAD].tval != 0) && (randint(3) ==1))
  370.               k = INVEN_HEAD;
  371.             else if ((inventory[INVEN_HANDS].tval != 0) && (randint(3) ==1))
  372.               k = INVEN_HANDS;
  373.             else if ((inventory[INVEN_FEET].tval != 0) && (randint(3) ==1))
  374.               k = INVEN_FEET;
  375.             else if (inventory[INVEN_BODY].tval != 0)
  376.               k = INVEN_BODY;
  377.             else if (inventory[INVEN_ARM].tval != 0)
  378.               k = INVEN_ARM;
  379.             else if (inventory[INVEN_OUTER].tval != 0)
  380.               k = INVEN_OUTER;
  381.             else if (inventory[INVEN_HEAD].tval != 0)
  382.               k = INVEN_HEAD;
  383.             else if (inventory[INVEN_HANDS].tval != 0)
  384.               k = INVEN_HANDS;
  385.             else if (inventory[INVEN_FEET].tval != 0)
  386.               k = INVEN_FEET;
  387.             else
  388.               k = 0;
  389.             if (k > 0)
  390.               {
  391.                 i_ptr = &inventory[k];
  392.                 inventory[INVEN_MAX] = inventory[k];
  393.                 objdes(tmp_str, k, FALSE);
  394.                (void)sprintf(out_val,"Your %s glows black, fades.",
  395.                     tmp_str);
  396.                 msg_print(out_val);
  397.                 i_ptr->flags = 0x80000000;
  398.                 i_ptr->toac = -randint(5) - randint(5);
  399.                 py_bonuses(inventory[INVEN_MAX], -1);
  400.                 ident = TRUE;
  401.               }
  402.             break;
  403.               case 36:
  404.             ident = FALSE;
  405.             for (k = 0; k < randint(3); k++)
  406.               {
  407.                 y = char_row;
  408.                 x = char_col;
  409.                 ident |= summon_undead(&y, &x);
  410.               }
  411.             break;
  412.               case 37:
  413.             ident = bless(randint(12)+6);
  414.             break;
  415.               case 38:
  416.             ident = bless(randint(24)+12);
  417.             break;
  418.               case 39:
  419.             ident = bless(randint(48)+24);
  420.             break;
  421.               case 40:
  422.             ident = TRUE;
  423.             py.flags.word_recall = 25 + randint(30);
  424.             msg_print("The air about you becomes charged...");
  425.             break;
  426.               case 41:
  427.             ident = destroy_area(char_row, char_col);
  428.             break;
  429.               case 42:
  430.             break;
  431.               case 43:
  432.             break;
  433.               case 44:
  434.             break;
  435.               case 45:
  436.             break;
  437.               case 46:
  438.             break;
  439.               case 47:
  440.             break;
  441.               case 48:
  442.             break;
  443.               case 49:
  444.             break;
  445.               case 50:
  446.             break;
  447.               case 51:
  448.             break;
  449.               case 52:
  450.             break;
  451.               case 53:
  452.             break;
  453.               case 54:
  454.             break;
  455.               case 55:
  456.             break;
  457.               case 56:
  458.             break;
  459.               case 57:
  460.             break;
  461.               case 58:
  462.             break;
  463.               case 59:
  464.             break;
  465.               case 60:
  466.             break;
  467.               case 61:
  468.             break;
  469.               case 62:
  470.             break;
  471.               default:
  472.             break;
  473.               }
  474.             /* End of Scrolls...                         */
  475.           }
  476.         if (!reset_flag)
  477.           {
  478.             if (ident)
  479.               identify(inventory[item_val]);
  480.             if (!first)
  481.               {
  482.             desc_remain(item_val);
  483.             inven_destroy(item_val);
  484.             if (i_ptr->flags != 0)
  485.               {
  486.                 m_ptr = &py.misc;
  487.                 m_ptr->exp += (i_ptr->level/m_ptr->lev);
  488.                 prt_experience();
  489.               }
  490.               }
  491.           }
  492.           }
  493.         else
  494.           if (redraw)  draw_cave();
  495.       }
  496.       else
  497.     msg_print("You are not carrying any scrolls.");
  498.     }
  499.   else
  500.     msg_print("But you are not carrying anything.");
  501. }
  502.