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

  1. #include "constant.h"
  2. #include "config.h"
  3. #include "types.h"
  4. #include "externs.h"
  5.  
  6.  
  7. /* Pray like HELL...                    -RAK-    */
  8. pray()
  9. {
  10.   int i, j, item_val, dir;
  11.   int choice, chance, result;
  12.   int dumy, y_dumy, x_dumy;
  13.   int redraw;
  14.   register spell_type *s_ptr;
  15.   register struct misc *m_ptr;
  16.   register struct flags *f_ptr;
  17.   register treasure_type *i_ptr;
  18.  
  19.   reset_flag = TRUE;
  20.   if (py.flags.blind > 0)
  21.     msg_print("You can't see to read your prayer!");
  22.   else if (no_light())
  23.     msg_print("You have no light to read by.");
  24.   else if (py.flags.confused > 0)
  25.     msg_print("You are too confused...");
  26.   else if (class[py.misc.pclass].pspell)
  27.     if (inven_ctr > 0)
  28.       {
  29.     if (find_range(91, -1, &i, &j))
  30.       {
  31.         redraw = FALSE;
  32.         if (get_item(&item_val, "Use which Holy Book?", &redraw, i, j))
  33.           {
  34.         if ((result = cast_spell("Recite which prayer?", item_val,
  35.                    &choice, &chance, &redraw)) == TRUE)
  36.           {
  37.             s_ptr = &magic_spell[py.misc.pclass][choice];
  38.             reset_flag = FALSE;
  39.             if (randint(100) < chance)
  40.               msg_print("You lost your concentration!");
  41.             else
  42.               {
  43.             y_dumy = char_row;
  44.             x_dumy = char_col;
  45.             /* Prayers...                    */
  46.             choice++;
  47.             switch(choice)
  48.               {
  49.               case 1:
  50.                 (void) detect_evil();
  51.                 break;
  52.               case 2:
  53.                 (void) hp_player(damroll("3d3"), "a prayer.");
  54.                 break;
  55.               case 3:
  56.                 (void) bless(randint(12)+12);
  57.                 break;
  58.               case 4:
  59.                 (void) remove_fear();
  60.                 break;
  61.               case 5:
  62.                 (void) light_area(char_row, char_col);
  63.                 break;
  64.               case 6:
  65.                 (void) detect_trap();
  66.                 break;
  67.               case 7:
  68.                 (void) detect_sdoor();
  69.                 break;
  70.               case 8:
  71.                 (void) slow_poison();
  72.                             break;
  73.               case 9:
  74.                 if (get_dir("Which direction?", &dir,
  75.                     &dumy, &y_dumy, &x_dumy))
  76.                   (void) confuse_monster(dir, char_row, char_col);
  77.                 break;
  78.               case 10:
  79.                 teleport((int)(py.misc.lev*3));
  80.                 break;
  81.               case 11:
  82.                 (void) hp_player(damroll("4d4"), "a prayer.");
  83.                 break;
  84.               case 12:
  85.                 (void) bless(randint(24)+24);
  86.                 break;
  87.               case 13:
  88.                 (void) sleep_monsters1(char_row, char_col);
  89.                 break;
  90.               case 14:
  91.                 (void) create_food();
  92.                 break;
  93.               case 15:
  94.                 for (i = 0; i < INVEN_MAX; i++)
  95.                   {
  96.                 i_ptr = &inventory[i];
  97.                 i_ptr->flags &= 0x7FFFFFFF;
  98.                   }
  99.                 break;
  100.               case 16:
  101.                 f_ptr = &py.flags;
  102.                 f_ptr->resist_heat += randint(10) + 10;
  103.                 f_ptr->resist_cold += randint(10) + 10;
  104.                 break;
  105.               case 17:
  106.                 (void) cure_poison();
  107.                 break;
  108.               case 18:
  109.                 if (get_dir("Which direction?", &dir,
  110.                     &dumy, &y_dumy, &x_dumy))
  111.                   fire_ball(6, dir, char_row, char_col,
  112.                     (int)(damroll("3d6")+py.misc.lev),
  113.                     "Black Sphere");
  114.                 break;
  115.               case 19:
  116.                 (void) hp_player(damroll("8d4"), "a prayer.");
  117.                 break;
  118.               case 20:
  119.                 detect_inv2(randint(24)+24);
  120.                 break;
  121.               case 21:
  122.                 (void) protect_evil();
  123.                 break;
  124.               case 22:
  125.                 (void) earthquake();
  126.                 break;
  127.               case 23:
  128.                 (void) map_area();
  129.                 break;
  130.               case 24:
  131.                 (void) hp_player(damroll("16d4"), "a prayer.");
  132.                 break;
  133.               case 25:
  134.                 (void) turn_undead();
  135.                 break;
  136.               case 26:
  137.                 (void) bless(randint(48)+48);
  138.                 break;
  139.               case 27:
  140.                 (void) dispell_creature(0x0008,
  141.                             (int)(3*py.misc.lev));
  142.                 break;
  143.               case 28:
  144.                 (void) hp_player(200, "a prayer.");
  145.                 break;
  146.               case 29:
  147.                 (void) dispell_creature(0x0004,
  148.                             (int)(3*py.misc.lev));
  149.                 break;
  150.               case 30:
  151.                 (void) warding_glyph();
  152.                 break;
  153.               case 31:
  154.                 (void) dispell_creature(0x0004,
  155.                             (int)(4*py.misc.lev));
  156.                 (void) cure_confusion();
  157.                 (void) remove_fear();
  158.                 (void) cure_poison();
  159.                 (void) cure_blindness();
  160.                 (void) hp_player(1000, "a prayer.");
  161.                 break;
  162.               default:
  163.                 break;
  164.               }
  165.             /* End of prayers...                */
  166.             if (!reset_flag)
  167.               {
  168.                 m_ptr = &py.misc;
  169.                 m_ptr->exp += s_ptr->sexp;
  170.                 prt_experience();
  171.                 s_ptr->sexp = 0;
  172.               }
  173.               }
  174.             m_ptr = &py.misc;
  175.             if (!reset_flag)
  176.               {
  177.             if (s_ptr->smana > m_ptr->cmana)
  178.               {
  179.                 msg_print("You faint from fatigue!");
  180.                 py.flags.paralysis =
  181.                   randint(5*(int)(s_ptr->smana-(int)m_ptr->cmana));
  182.                 m_ptr->cmana = 0.0;
  183.                 if (randint(3) == 1)
  184.                   {
  185.                 msg_print("You have damaged your health!");
  186.                 py.stats.ccon = de_statp(py.stats.ccon);
  187.                 prt_constitution();
  188.                   }
  189.               }
  190.             else
  191.               m_ptr->cmana -= (double)s_ptr->smana;
  192.             prt_cmana();
  193.               }
  194.           }
  195.         else if (result == -1)
  196.           msg_print("You don't know any prayers in that book.");
  197.           }
  198.         else
  199.           if (redraw)  draw_cave();
  200.       }
  201.     else
  202.       msg_print("But you are not carrying any Holy Books!");
  203.       }
  204.     else
  205.       msg_print("But you are not carrying any Holy Books!");
  206.   else
  207.     msg_print("Pray hard enough and your prayers may be answered.");
  208. }
  209.