home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / mor4873s.lzh / POTIONS.C < prev    next >
C/C++ Source or Header  |  1988-11-01  |  10KB  |  378 lines

  1. #include "constant.h"
  2. #include "config.h"
  3. #include "types.h"
  4. #include "externs.h"
  5.  
  6.  
  7. /* Potions for the quaffing                -RAK-    */
  8. quaff()
  9. {
  10.   bitset_t i;
  11.   int j, k; bigint_t l; int item_val;
  12.   int redraw, ident;
  13.   register treasure_type *i_ptr;
  14.   register struct misc *m_ptr;
  15.   register struct flags *f_ptr;
  16.   register struct stats *s_ptr;
  17.   register class_type *c_ptr;
  18.  
  19.   reset_flag = TRUE;
  20.   if (inven_ctr > 0)
  21.     {
  22.       if (find_range(75, 76, &j, &k))
  23.     {
  24.       redraw = FALSE;
  25.       if (get_item(&item_val, "Quaff which potion?", &redraw, j, k))
  26.         {
  27.           i_ptr = &inventory[item_val];
  28.           if (redraw)  draw_cave();
  29.           reset_flag = FALSE;
  30.           i = i_ptr->flags;
  31.           ident = FALSE;
  32.           while (i != 0)
  33.         {
  34.           j = bit_pos(&i) + 1;
  35.           if (i_ptr->tval == 76)
  36.             j += 31;
  37.           /* Potions                        */
  38.           switch(j)
  39.             {
  40.             case 1:
  41.               s_ptr = &py.stats;
  42.               s_ptr->cstr = in_statp(s_ptr->cstr);
  43.               if (s_ptr->cstr > s_ptr->str)
  44.             s_ptr->str = s_ptr->cstr;
  45.               msg_print("Wow!  What bulging muscles!");
  46.               prt_strength();
  47.               ident = TRUE;
  48.               /* adjust misc stats */
  49.               py_bonuses(blank_treasure, 0);
  50.               break;
  51.             case 2:
  52.               ident = lose_str();
  53.               break;
  54.             case 3:
  55.               s_ptr = &py.stats;
  56.               s_ptr->cstr = s_ptr->str;
  57.               msg_print("You feel warm all over.");
  58.               prt_strength();
  59.               ident = TRUE;
  60.               /* adjust misc stats */
  61.               py_bonuses(blank_treasure, 0);
  62.               break;
  63.             case 4:
  64.               s_ptr = &py.stats;
  65.               s_ptr->cint = in_statp(s_ptr->cint);
  66.               if (s_ptr->cint > py.stats.intel)
  67.             py.stats.intel = s_ptr->cint;
  68.               msg_print("Aren't you brilliant!");
  69.               prt_intelligence();
  70.               ident = TRUE;
  71.               break;
  72.             case 5:
  73.               msg_print("This potion tastes very dull.");
  74.               ident = lose_int();
  75.               break;
  76.             case 6:
  77.               s_ptr = &py.stats;
  78.               s_ptr->cint = py.stats.intel;
  79.               msg_print("You have have a warm feeling.");
  80.               prt_intelligence();
  81.               ident = TRUE;
  82.               break;
  83.             case 7:
  84.               s_ptr = &py.stats;
  85.               s_ptr->cwis = in_statp(s_ptr->cwis);
  86.               if (s_ptr->cwis > s_ptr->wis)
  87.             s_ptr->wis = s_ptr->cwis;
  88.               msg_print("You suddenly have a profound thought!");
  89.               prt_wisdom();
  90.               ident = TRUE;
  91.               break;
  92.             case 8:
  93.               ident = lose_wis();
  94.               break;
  95.             case 9:
  96.               s_ptr = &py.stats;
  97.               if (s_ptr->cwis < s_ptr->wis)
  98.             {
  99.               s_ptr->cwis = s_ptr->wis;
  100.               msg_print("You feel your wisdom returning.");
  101.               prt_wisdom();
  102.               ident = TRUE;
  103.             }
  104.               break;
  105.             case 10:
  106.               s_ptr = &py.stats;
  107.               s_ptr->cchr = in_statp(s_ptr->cchr);
  108.               if (s_ptr->cchr > s_ptr->chr)
  109.             s_ptr->chr = s_ptr->cchr;
  110.               msg_print("Gee,  ain't you cute!");
  111.               prt_charisma();
  112.               ident = TRUE;
  113.               break;
  114.             case 11:
  115.               ident = lose_chr();
  116.               break;
  117.             case 12:
  118.               s_ptr = &py.stats;
  119.               if (s_ptr->cchr < s_ptr->chr)
  120.             {
  121.               s_ptr->cchr = s_ptr->chr;
  122.               msg_print("You feel your looks returning.");
  123.               prt_charisma();
  124.               ident = TRUE;
  125.             }
  126.               break;
  127.             case 13:
  128.               ident = hp_player(damroll("2d7"), "a potion.");
  129.               break;
  130.             case 14:
  131.               ident = hp_player(damroll("4d7"), "a potion.");
  132.               break;
  133.             case 15:
  134.               ident = hp_player(damroll("6d7"), "a potion.");
  135.               break;
  136.             case 16:
  137.               ident = hp_player(1000, "a potion.");
  138.               break;
  139.             case 17:
  140.               m_ptr = &py.misc;
  141.               py.stats.ccon = in_statp(py.stats.ccon);
  142.               if (py.stats.ccon > py.stats.con)
  143.             py.stats.con = py.stats.ccon;
  144.               m_ptr->mhp++;
  145.               m_ptr->chp += m_ptr->mhp;
  146.               msg_print("You feel tingly for a moment.");
  147.               prt_mhp();
  148.               prt_chp();
  149.               prt_constitution();
  150.               ident = TRUE;
  151.               break;
  152.             case 18:
  153.               m_ptr = &py.misc;
  154.               l = (m_ptr->exp / 2) + 10;
  155.               if (l > 100000)  l = 100000;
  156.               m_ptr->exp += l;
  157.               msg_print("You feel more experienced.");
  158.               prt_experience();
  159.               ident = TRUE;
  160.               break;
  161.             case 19:
  162.               f_ptr = &py.flags;
  163.               if (!f_ptr->free_act)
  164.             {
  165.               msg_print("You fall asleep.");
  166.               f_ptr->paralysis += randint(4) + 4;
  167.               ident = TRUE;
  168.             }
  169.               break;
  170.             case 20:
  171.               f_ptr = &py.flags;
  172.               msg_print("You are covered by a veil of darkness.");
  173.               f_ptr->blind += randint(100) + 100;
  174.               ident = TRUE;
  175.               break;
  176.             case 21:
  177.               f_ptr = &py.flags;
  178.               msg_print("Hey!  This is good stuff!  * Hick! *");
  179.               f_ptr->confused += randint(20) + 12;
  180.               ident = TRUE;
  181.               break;
  182.             case 22:
  183.               f_ptr = &py.flags;
  184.               msg_print("You feel very sick.");
  185.               f_ptr->poisoned += randint(15) + 10;
  186.               ident = TRUE;
  187.               break;
  188.             case 23:
  189.               py.flags.fast += randint(25) + 15;
  190.               ident = TRUE;
  191.               break;
  192.             case 24:
  193.               py.flags.slow += randint(25) + 15;
  194.               ident = TRUE;
  195.               break;
  196.             case 25:
  197.               ident = detect_monsters();
  198.               break;
  199.             case 26:
  200.               s_ptr = &py.stats;
  201.               s_ptr->cdex = in_statp(s_ptr->cdex);
  202.               if (s_ptr->cdex > s_ptr->dex)
  203.             s_ptr->dex = s_ptr->cdex;
  204.               msg_print("You feel more limber!");
  205.               prt_dexterity();
  206.               ident = TRUE;
  207.               /* adjust misc stats */
  208.               py_bonuses(blank_treasure, 0);
  209.               break;
  210.             case 27:
  211.               s_ptr = &py.stats;
  212.               if (s_ptr->cdex < s_ptr->dex)
  213.             {
  214.               s_ptr->cdex = s_ptr->dex;
  215.               msg_print("You feel less clumsy.");
  216.               prt_dexterity();
  217.               ident = TRUE;
  218.               /* adjust misc stats */
  219.               py_bonuses(blank_treasure, 0);
  220.             }
  221.               break;
  222.             case 28:
  223.               s_ptr= &py.stats;
  224.               if (s_ptr->ccon < s_ptr->con)
  225.             {
  226.               s_ptr->ccon = s_ptr->con;
  227.               msg_print("You feel your health returning!");
  228.               prt_constitution();
  229.               ident = TRUE;
  230.             }
  231.               break;
  232.             case 29:
  233.               (void) cure_blindness();
  234.               break;
  235.             case 30:
  236.               (void) cure_confusion();
  237.               break;
  238.             case 31:
  239.               (void) cure_poison();
  240.               break;
  241.             case 32:
  242.               m_ptr = &py.misc;
  243.               c_ptr = &class[m_ptr->pclass];
  244.               if (c_ptr->mspell)
  245.             {
  246.               ident = learn_spell(&redraw);
  247.               if (redraw)  draw_cave();
  248.             }
  249.               else if (c_ptr->pspell)
  250.             ident = learn_prayer();
  251.               break;
  252.             case 33:
  253.               msg_print("You feel your memories fade...");
  254.               /* Lose between 1/5 and 2/5 of your experience */
  255.               lose_exp((bigint_t)
  256.                   (py.misc.exp * (0.2 + (0.2 * randint(MAXINT)) / MAXINT)));
  257.               /* Empty lines
  258.              for diff synchronization
  259.                */
  260.               ident = TRUE;
  261.               break;
  262.             case 34:
  263.               f_ptr = &py.flags;
  264.               (void) cure_poison();
  265.               if (f_ptr->food > 150)  f_ptr->food = 150;
  266.               f_ptr->paralysis = 4;
  267.               msg_print("The potion makes you vomit!");
  268.               ident = TRUE;
  269.               break;
  270.             case 35:
  271.               py.flags.invuln += randint(10) + 10;
  272.               ident = TRUE;
  273.               break;
  274.             case 36:
  275.               py.flags.hero += randint(25) + 25;
  276.               ident = TRUE;
  277.               break;
  278.             case 37:
  279.               py.flags.shero += randint(25) + 25;
  280.               ident = TRUE;
  281.               break;
  282.             case 38:
  283.               ident = remove_fear();
  284.               break;
  285.             case 39:
  286.               ident = restore_level();
  287.               break;
  288.             case 40:
  289.               f_ptr = &py.flags;
  290.               f_ptr->resist_heat += randint(10) + 10;
  291.               break;
  292.             case 41:
  293.               f_ptr = &py.flags;
  294.               f_ptr->resist_cold += randint(10) + 10;
  295.                       break;
  296.             case 42:
  297.               detect_inv2(randint(12)+12);
  298.               break;
  299.             case 43:
  300.               ident = slow_poison();
  301.               break;
  302.             case 44:
  303.               ident = cure_poison();
  304.               break;
  305.             case 45:
  306.               m_ptr = &py.misc;
  307.               if (m_ptr->cmana < m_ptr->mana)
  308.             {
  309.               m_ptr->cmana = (double)m_ptr->mana;
  310.               ident = TRUE;
  311.               msg_print("Your feel your head clear...");
  312.             }
  313.               break;
  314.             case 46:
  315.               f_ptr = &py.flags;
  316.               f_ptr->tim_infra += 100 + randint(100);
  317.               ident = TRUE;
  318.               msg_print("Your eyes begin to tingle.");
  319.               break;
  320.             case 47:
  321.               break;
  322.             case 48:
  323.               break;
  324.             case 49:
  325.               break;
  326.             case 50:
  327.               break;
  328.             case 51:
  329.               break;
  330.             case 52:
  331.               break;
  332.             case 53:
  333.               break;
  334.             case 54:
  335.               break;
  336.             case 55:
  337.               break;
  338.             case 56:
  339.               break;
  340.             case 57:
  341.               break;
  342.             case 58:
  343.               break;
  344.             case 59:
  345.               break;
  346.             case 60:
  347.               break;
  348.             case 61:
  349.               break;
  350.             case 62:
  351.               break;
  352.             default:
  353.               break;
  354.             }
  355.           /* End of Potions...                    */
  356.         }
  357.           if (ident)
  358.         identify(inventory[item_val]);
  359.           if (i_ptr->flags != 0)
  360.         {
  361.           m_ptr = &py.misc;
  362.           m_ptr->exp += (bigint_t)(i_ptr->level/m_ptr->lev + 0.5);
  363.           prt_experience();
  364.         }
  365.           add_food(i_ptr->p1);
  366.           desc_remain(item_val);
  367.           inven_destroy(item_val);
  368.         }
  369.       else
  370.         if (redraw)  draw_cave();
  371.     }
  372.       else
  373.     msg_print("You are not carrying any potions.");
  374.     }
  375.   else
  376.     msg_print("But you are not carrying anything.");
  377. }
  378.