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

  1. #include "constant.h"
  2. #include "config.h"
  3. #include "types.h"
  4. #include "externs.h"
  5.  
  6.  
  7. /* Eat some food...                    -RAK-    */
  8. eat()
  9. {
  10.   bitset_t i;
  11.   int j, k, item_val;
  12.   int redraw, ident;
  13.   register struct flags *f_ptr;
  14.   register struct misc *m_ptr;
  15.   register struct stats *s_ptr;
  16.   register treasure_type *i_ptr;
  17.  
  18.   reset_flag = TRUE;
  19.   if (inven_ctr > 0)
  20.     {
  21.       if (find_range(80, -1, &j, &k))
  22.     {
  23.       redraw = FALSE;
  24.       if (get_item(&item_val, "Eat what?", &redraw, j, k))
  25.         {
  26.           i_ptr = &inventory[item_val];
  27.           if (redraw)  draw_cave();
  28.           reset_flag = FALSE;
  29.           i = i_ptr->flags;
  30.           ident = FALSE;
  31.           while (i != 0)
  32.         {
  33.           j = bit_pos(&i) + 1;
  34.           /* Foods                    */
  35.           switch(j)
  36.             {
  37.             case 1:
  38.               f_ptr = &py.flags;
  39.               f_ptr->poisoned += randint(10) + i_ptr->level;
  40.               ident = TRUE;
  41.               break;
  42.             case 2:
  43.               f_ptr = &py.flags;
  44.               f_ptr->blind += randint(250) + 10*i_ptr->level + 100;
  45.               draw_cave();
  46.               msg_print("A veil of darkness surrounds you.");
  47.               ident = TRUE;
  48.               break;
  49.             case 3:
  50.               f_ptr = &py.flags;
  51.               f_ptr->afraid += randint(10) + i_ptr->level;
  52.               msg_print("You feel terrified!");
  53.               ident = TRUE;
  54.               break;
  55.             case 4:
  56.               f_ptr = &py.flags;
  57.               f_ptr->confused += randint(10) + i_ptr->level;
  58.               msg_print("You feel drugged.");
  59.               ident = TRUE;
  60.               break;
  61.             case 5:
  62.               f_ptr = &py.flags;
  63.               f_ptr->image += randint(200) + 25*i_ptr->level + 200;
  64.               ident = TRUE;
  65.               break;
  66.             case 6:
  67.               ident = cure_poison();
  68.               break;
  69.             case 7:
  70.               ident = cure_blindness();
  71.               break;
  72.             case 8:
  73.               f_ptr = &py.flags;
  74.               if (f_ptr->afraid > 1)
  75.             {
  76.               f_ptr->afraid = 1;
  77.               ident = TRUE;
  78.             }
  79.               break;
  80.             case 9:
  81.               ident = cure_confusion();
  82.               break;
  83.             case 10:
  84.               ident = lose_str();
  85.               break;
  86.             case 11:
  87.               ident = lose_con();
  88.               break;
  89.             case 12:
  90.               ident = lose_int();
  91.               break;
  92.             case 13:
  93.               ident = lose_wis();
  94.               break;
  95.             case 14:
  96.               ident = lose_dex();
  97.               break;
  98.             case 15:
  99.               ident = lose_chr();
  100.               break;
  101.             case 16:
  102.               s_ptr = &py.stats;
  103.               if (s_ptr->str > s_ptr->cstr)
  104.             {
  105.               s_ptr->cstr = s_ptr->str;
  106.               msg_print("You feel your strength returning.");
  107.               prt_strength();
  108.               ident = TRUE;
  109.               /* adjust misc stats */
  110.               py_bonuses(blank_treasure, 0);
  111.             }
  112.               break;
  113.             case 17:
  114.               s_ptr = &py.stats;
  115.               if (s_ptr->con > s_ptr->ccon)
  116.             {
  117.               s_ptr->ccon = s_ptr->con;
  118.               msg_print("You feel your health returning.");
  119.               prt_constitution();
  120.               ident = TRUE;
  121.             }
  122.               break;
  123.             case 18:
  124.               s_ptr = &py.stats;
  125.               if (py.stats.intel > s_ptr->cint)
  126.             {
  127.               s_ptr->cint = py.stats.intel;
  128.               msg_print("Your head spins a moment.");
  129.               prt_intelligence();
  130.               ident = TRUE;
  131.             }
  132.               break;
  133.             case 19:
  134.               s_ptr = &py.stats;
  135.               if (s_ptr->wis > s_ptr->cwis)
  136.             {
  137.               s_ptr->cwis = s_ptr->wis;
  138.               msg_print("You feel your wisdom returning.");
  139.               prt_wisdom();
  140.               ident = TRUE;
  141.             }
  142.               break;
  143.             case 20:
  144.               s_ptr = &py.stats;
  145.               if (s_ptr->dex > s_ptr->cdex)
  146.             {
  147.               s_ptr->cdex = s_ptr->dex;
  148.               msg_print("You feel more dextrous.");
  149.               prt_dexterity();
  150.               ident = TRUE;
  151.               /* adjust misc stats */
  152.               py_bonuses(blank_treasure, 0);
  153.             }
  154.               break;
  155.             case 21:
  156.               s_ptr = &py.stats;
  157.               if (s_ptr->chr > s_ptr->cchr)
  158.             {
  159.               s_ptr->cchr = s_ptr->chr;
  160.               msg_print("Your skin starts itching.");
  161.               prt_charisma();
  162.               ident = TRUE;
  163.             }
  164.               break;
  165.             case 22:
  166.               ident = hp_player(randint(3), "poisonous food.");
  167.               break;
  168.             case 23:
  169.               ident = hp_player(randint(6), "poisonous food.");
  170.               break;
  171.             case 24:
  172.               ident = hp_player(randint(12), "poisonous food.");
  173.               break;
  174.             case 25:
  175.               ident = hp_player(damroll("3d6"), "poisonous food.");
  176.               break;
  177.             case 26:
  178.               ident = hp_player(damroll("3d12"), "poisonous food.");
  179.               break;
  180.             case 27:
  181.               ident = hp_player(-randint(4), "poisonous food.");
  182.               break;
  183.             case 28:
  184.               ident = hp_player(-randint(8), "poisonous food.");
  185.               break;
  186.             case 29:
  187.               ident = hp_player(-damroll("2d8"), "poisonous food.");
  188.               break;
  189.             case 30:
  190.               ident = hp_player(-damroll("3d8"), "poisonous food.");
  191.               break;
  192.             case 31:
  193.               m_ptr = &py.misc;
  194.               m_ptr->mhp--;
  195.               if (m_ptr->mhp < m_ptr->chp)
  196.             m_ptr->chp = (double)m_ptr->mhp;
  197.               take_hit(1, "poisonous food.");
  198.               prt_mhp();
  199.               prt_chp();
  200.               ident = TRUE;
  201.               break;
  202.             default:
  203.               break;
  204.             }
  205.           /* End of food actions...                */
  206.         }
  207.           if (ident)
  208.         identify(inventory[item_val]);
  209.           if (i_ptr->flags != 0)
  210.         {
  211.           m_ptr = &py.misc;
  212.           m_ptr->exp += ((i_ptr->level/m_ptr->lev) + .5);
  213.           prt_experience();
  214.         }
  215.           add_food(i_ptr->p1);
  216.           py.flags.status = (0xFFFFFFFC & py.flags.status);
  217.           prt_hunger();
  218.           desc_remain(item_val);
  219.           inven_destroy(item_val);
  220.         }
  221.       else
  222.         if (redraw)  draw_cave();
  223.     }
  224.       else
  225.     msg_print("You are not carrying any food.");
  226.     }
  227.   else
  228.     msg_print("But you are not carrying anything.");
  229. }
  230.