home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / mor4873s.lzh / DUNGEON.C < prev    next >
C/C++ Source or Header  |  1988-12-05  |  43KB  |  1,622 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 USG
  9. #include <string.h>
  10. #else
  11. #include <strings.h>
  12. #endif
  13.  
  14. #ifdef sun   /* correct SUN stupidity in the stdio.h file */
  15. char *sprintf();
  16. #endif
  17.  
  18. #ifdef USG
  19. unsigned sleep();
  20. #endif
  21.  
  22. #ifdef ultrix
  23. void sleep();
  24. #endif
  25.  
  26. /* global flags */
  27. int moria_flag;        /* Next level when true  */
  28. int search_flag;       /* Player is searching   */
  29. int teleport_flag;     /* Handle teleport traps  */
  30. int player_light;      /* Player carrying light */
  31. int cave_flag;         /* used in get_panel */
  32. int light_flag;        /* used in move_light */
  33.  
  34. /* value of msg_flag at start of turn */
  35. int save_msg_flag;
  36.  
  37. /* Moria game module                    -RAK-    */
  38. /* The code in this section has gone through many revisions, and */
  39. /* some of it could stand some more hard work...  -RAK-          */
  40. dungeon()
  41. {
  42.   int old_chp, old_cmana;      /* Detect change         */
  43.   double regen_amount;         /* Regenerate hp and mana*/
  44.   char command;         /* Last command          */
  45.   register struct misc *p_ptr;
  46.   register treasure_type *i_ptr;
  47.   register struct flags *f_ptr;
  48.   int set_floor();
  49.  
  50.   /* Main procedure for dungeon...             -RAK-    */
  51.   /* Note: There is a lot of preliminary magic going on here at first*/
  52.  
  53.   /* Check light status for setup          */
  54.   i_ptr = &inventory[INVEN_LIGHT];
  55.   if (i_ptr->p1 > 0)
  56.     player_light = TRUE;
  57.   else
  58.     player_light = FALSE;
  59.   /* Check for a maximum level             */
  60.   p_ptr = &py.misc;
  61.   if (dun_level > p_ptr->max_lev)  p_ptr->max_lev = dun_level;
  62.   /* Set up the character co-ords          */
  63.   if ((char_row == -1) || (char_col == -1))
  64.     new_spot(&char_row, &char_col);
  65.   /* Reset flags and initialize variables  */
  66.   moria_flag    = FALSE;
  67.   cave_flag     = FALSE;
  68.   find_flag     = FALSE;
  69.   search_flag   = FALSE;
  70.   teleport_flag = FALSE;
  71.   mon_tot_mult  = 0;
  72.   cave[char_row][char_col].cptr = 1;
  73.   old_chp   = (int)py.misc.chp;
  74.   old_cmana = (int)py.misc.cmana;
  75.   /* Light up the area around character    */
  76.   move_char(5);
  77.   /* Light,  but do not move critters       */
  78.   creatures(FALSE);
  79.   /* Print the depth                       */
  80.   prt_depth();
  81.  
  82.   /* Loop until dead,  or new level         */
  83.   do
  84.     {
  85.       /* Increment turn counter            */
  86.       turn++;
  87.       /* Check for game hours                          */
  88.       if (!wizard1)
  89.     if ((turn % 250) == 1)
  90.       if (!check_time())
  91.         if (closing_flag > 4)
  92.           {
  93.         if (search_flag)
  94.           search_off();
  95.         if (py.flags.rest > 0)
  96.           rest_off();
  97.         find_flag = FALSE;
  98.         msg_print("The gates to Moria are now closed.");
  99.         /* make sure player sees the message */
  100.         msg_print(" ");
  101.         do
  102.           {
  103.             save_char(TRUE, FALSE);
  104.           }
  105.         while (TRUE);
  106.           }
  107.         else
  108.           {
  109.         if (search_flag)
  110.           search_off();
  111.         if (py.flags.rest > 0)
  112.           rest_off();
  113.         find_flag = FALSE;
  114.         move_light (char_row, char_col, char_row, char_col);
  115.         closing_flag++;
  116.         msg_print("The gates to Moria are closing...");
  117.         msg_print("Please finish up or save your game.");
  118.         /* make sure the player sees the message */
  119.         msg_print(" ");
  120.           }
  121.  
  122.       /* turn over the store contents every, say, 1000 turns */
  123.       if ((dun_level != 0) && ((turn % 1000) == 0))
  124.     store_maint();
  125.  
  126.       /* Check for creature generation         */
  127.       if (randint(MAX_MALLOC_CHANCE) == 1)
  128.     alloc_monster(set_floor, 1, MAX_SIGHT, FALSE);
  129.       /* Screen may need updating,  used mostly for stats*/
  130.       if (print_stat != 0)
  131.     {
  132.       if (0x0001 & print_stat)
  133.         prt_strength();
  134.       if (0x0002 & print_stat)
  135.         prt_dexterity();
  136.       if (0x0004 & print_stat)
  137.         prt_constitution();
  138.       if (0x0008 & print_stat)
  139.         prt_intelligence();
  140.       if (0x0010 & print_stat)
  141.         prt_wisdom();
  142.       if (0x0020 & print_stat)
  143.         prt_charisma();
  144.       if (0x0040 & print_stat)
  145.         prt_pac();
  146.       if (0x0100 & print_stat)
  147.         prt_mhp();
  148.       if (0x0200 & print_stat)
  149.         prt_title();
  150.       if (0x0400 & print_stat)
  151.         prt_level();
  152.     }
  153.       /* Check light status                            */
  154.       i_ptr = &inventory[INVEN_LIGHT];
  155.       if (player_light)
  156.     if (i_ptr->p1 > 0)
  157.       {
  158.         i_ptr->p1--;
  159.         if (i_ptr->p1 == 0)
  160.           {
  161.         player_light = FALSE;
  162.         find_flag = FALSE;
  163.         msg_print("Your light has gone out!");
  164.         move_light(char_row, char_col, char_row, char_col);
  165.           }
  166.         else if (i_ptr->p1 < 40)
  167.           if (randint(5) == 1)
  168.         {
  169.           if (find_flag)
  170.             {
  171.               find_flag = FALSE;
  172.               move_light(char_row, char_col, char_row, char_col);
  173.             }
  174.           msg_print("Your light is growing faint.");
  175.         }
  176.       }
  177.     else
  178.       {
  179.         player_light = FALSE;
  180.         find_flag = FALSE;
  181.         move_light(char_row, char_col, char_row, char_col);
  182.       }
  183.       else if (i_ptr->p1 > 0)
  184.     {
  185.       i_ptr->p1--;
  186.       player_light = TRUE;
  187.       move_light(char_row, char_col, char_row, char_col);
  188.     }
  189.  
  190.       /* Update counters and messages            */
  191.       f_ptr = &py.flags;
  192.       /* Check food status             */
  193.       regen_amount = PLAYER_REGEN_NORMAL;
  194.       if (f_ptr->food < PLAYER_FOOD_ALERT)
  195.     {
  196.       if (f_ptr->food < PLAYER_FOOD_WEAK)
  197.         {
  198.           if (f_ptr->food < 0)
  199.         regen_amount = 0;
  200.           else if (f_ptr->food < PLAYER_FOOD_FAINT)
  201.         regen_amount = PLAYER_REGEN_FAINT;
  202.           else if (f_ptr->food < PLAYER_FOOD_WEAK)
  203.         regen_amount = PLAYER_REGEN_WEAK;
  204.           if ((0x00000002 & f_ptr->status) == 0)
  205.         {
  206.           f_ptr->status |= 0x00000003;
  207.           msg_print("You are getting weak from hunger.");
  208.           if (find_flag)
  209.             {
  210.               find_flag = FALSE;
  211.               move_light (char_row, char_col, char_row, char_col);
  212.             }
  213.           prt_hunger();
  214.         }
  215.           if (f_ptr->food < PLAYER_FOOD_FAINT)
  216.         if (randint(8) == 1)
  217.           {
  218.             f_ptr->paralysis += randint(5);
  219.             msg_print("You faint from the lack of food.");
  220.             if (find_flag)
  221.               {
  222.             find_flag = FALSE;
  223.             move_light (char_row, char_col, char_row, char_col);
  224.               }
  225.           }
  226.         }
  227.       else
  228.         {
  229.           if ((0x00000001 & f_ptr->status) == 0)
  230.         {
  231.           f_ptr->status |= 0x00000001;
  232.           msg_print("You are getting hungry.");
  233.           if (find_flag)
  234.             {
  235.               find_flag = FALSE;
  236.               move_light (char_row, char_col, char_row, char_col);
  237.             }
  238.           prt_hunger();
  239.         }
  240.         }
  241.     }
  242.       /* Food consumption       */
  243.       /* Note: Speeded up characters really burn up the food!  */
  244.       if (f_ptr->speed < 0)
  245.     f_ptr->food +=  -(f_ptr->speed*f_ptr->speed) -
  246.       f_ptr->food_digested;
  247.       else
  248.     f_ptr->food -= f_ptr->food_digested;
  249.       /* Regenerate            */
  250.       p_ptr = &py.misc;
  251.       if (f_ptr->regenerate)  regen_amount = regen_amount * 1.5;
  252.       if (f_ptr->rest > 0)    regen_amount = regen_amount * 2;
  253.       if (py.flags.poisoned < 1)
  254.     if (p_ptr->chp < p_ptr->mhp)
  255.       regenhp(regen_amount);
  256.       if (p_ptr->cmana < p_ptr->mana)
  257.     regenmana(regen_amount);
  258.       /* Blindness             */
  259.       if (f_ptr->blind > 0)
  260.     {
  261.       if ((0x00000004 & f_ptr->status) == 0)
  262.         {
  263.           f_ptr->status |= 0x00000004;
  264.           prt_map();
  265.           prt_blind();
  266.           if (search_flag)
  267.         search_off();
  268.         }
  269.       f_ptr->blind--;
  270.       if (f_ptr->blind == 0)
  271.         {
  272.           f_ptr->status &= 0xFFFFFFFB;
  273.           prt_blind();
  274.           prt_map();
  275.           msg_print("The veil of darkness lifts.");
  276.           if (find_flag)
  277.         {
  278.           find_flag = FALSE;
  279.         }
  280.           /* turn light back on */
  281.           move_char(5);
  282.           /* light creatures */
  283.           creatures(FALSE);
  284.         }
  285.     }
  286.       /* Confusion             */
  287.       if (f_ptr->confused > 0)
  288.     {
  289.       if ((0x00000008 & f_ptr->status) == 0)
  290.         {
  291.           f_ptr->status |= 0x00000008;
  292.           prt_confused();
  293.         }
  294.       f_ptr->confused--;
  295.       if (f_ptr->confused == 0)
  296.         {
  297.           f_ptr->status &= 0xFFFFFFF7;
  298.           prt_confused();
  299.           msg_print("You feel less confused now.");
  300.           if (find_flag)
  301.         {
  302.           find_flag = FALSE;
  303.           move_light (char_row, char_col, char_row, char_col);
  304.         }
  305.         }
  306.     }
  307.       /* Afraid                */
  308.       if (f_ptr->afraid > 0)
  309.     {
  310.       if ((0x00000010 & f_ptr->status) == 0)
  311.         {
  312.           if ((f_ptr->shero+f_ptr->hero) > 0)
  313.         f_ptr->afraid = 0;
  314.           else
  315.         {
  316.           f_ptr->status |= 0x00000010;
  317.           prt_afraid();
  318.         }
  319.         }
  320.       else if ((f_ptr->shero+f_ptr->hero) > 0)
  321.         f_ptr->afraid = 1;
  322.       f_ptr->afraid--;
  323.       if (f_ptr->afraid == 0)
  324.         {
  325.           f_ptr->status &= 0xFFFFFFEF;
  326.           prt_afraid();
  327.           msg_print("You feel bolder now.");
  328.           if (find_flag)
  329.         {
  330.           find_flag = FALSE;
  331.           move_light (char_row, char_col, char_row, char_col);
  332.         }
  333.         }
  334.     }
  335.       /* Poisoned              */
  336.       if (f_ptr->poisoned > 0)
  337.     {
  338.       if ((0x00000020 & f_ptr->status) == 0)
  339.         {
  340.           f_ptr->status |= 0x00000020;
  341.           prt_poisoned();
  342.         }
  343.       f_ptr->poisoned--;
  344.       if (f_ptr->poisoned == 0)
  345.         {
  346.           f_ptr->status &= 0xFFFFFFDF;
  347.           prt_poisoned();
  348.           msg_print("You feel better.");
  349.           if (find_flag)
  350.         {
  351.           find_flag = FALSE;
  352.           move_light (char_row, char_col, char_row, char_col);
  353.         }
  354.         }
  355.       else
  356.         {
  357.           switch(con_adj())
  358.         {
  359.         case -4:
  360.           take_hit(4, "poison.");
  361.           break;
  362.         case -3: case  -2:
  363.           take_hit(3, "poison.");
  364.           break;
  365.         case -1:
  366.           take_hit(2, "poison.");
  367.           break;
  368.         case 0:
  369.           take_hit(1, "poison.");
  370.           break;
  371.         case 1: case 2: case 3:
  372.           if ((turn % 2) == 0)
  373.             take_hit(1, "poison.");
  374.           break;
  375.         case 4: case 5:
  376.           if ((turn % 3) == 0)
  377.             take_hit(1, "poison.");
  378.           break;
  379.         case 6:
  380.           if ((turn % 4) == 0)
  381.             take_hit(1, "poison.");
  382.           break;
  383.         }
  384.         }
  385.     }
  386.       /* Fast                  */
  387.       if (f_ptr->fast > 0)
  388.     {
  389.       if ((0x00000040 & f_ptr->status) == 0)
  390.         {
  391.           f_ptr->status |= 0x00000040;
  392.           change_speed(-1);
  393.           msg_print("You feel yourself moving faster.");
  394.           if (find_flag)
  395.         {
  396.           find_flag = FALSE;
  397.           move_light (char_row, char_col, char_row, char_col);
  398.         }
  399.         }
  400.       f_ptr->fast--;
  401.       if (f_ptr->fast == 0)
  402.         {
  403.           f_ptr->status &= 0xFFFFFFBF;
  404.           change_speed(1);
  405.           msg_print("You feel yourself slow down.");
  406.           if (find_flag)
  407.         {
  408.           find_flag = FALSE;
  409.           move_light (char_row, char_col, char_row, char_col);
  410.         }
  411.         }
  412.     }
  413.       /* Slow                  */
  414.       if (f_ptr->slow > 0)
  415.     {
  416.       if ((0x00000080 & f_ptr->status) == 0)
  417.         {
  418.           f_ptr->status |= 0x00000080;
  419.           change_speed(1);
  420.           msg_print("You feel yourself moving slower.");
  421.           if (find_flag)
  422.         {
  423.           find_flag = FALSE;
  424.           move_light (char_row, char_col, char_row, char_col);
  425.         }
  426.         }
  427.       f_ptr->slow--;
  428.       if (f_ptr->slow == 0)
  429.         {
  430.           f_ptr->status &= 0xFFFFFF7F;
  431.           change_speed(-1);
  432.           msg_print("You feel yourself speed up.");
  433.           if (find_flag)
  434.         {
  435.           find_flag = FALSE;
  436.           move_light (char_row, char_col, char_row, char_col);
  437.         }
  438.         }
  439.     }
  440.       /* Resting is over?      */
  441.       if (f_ptr->rest > 0)
  442.     {
  443. #ifdef SLOW
  444.       /* Hibernate every 20 iterations so that process does  */
  445.       /* not eat up system...                                */
  446.       if ((f_ptr->rest % 20) == 1)  (void) sleep(1);
  447. #endif
  448.       f_ptr->rest--;
  449.       /* do not need to refresh screen here, if any movement/hit occurs
  450.          update_mon/take_hit will turn off resting and screen refreshes */
  451.       put_qio();
  452.       if (f_ptr->rest == 0)               /* Resting over          */
  453.         rest_off();
  454. #ifdef MSDOS
  455.       else if (kbhit()) {    /* accept any key to abort resting */
  456.         (void) getch();
  457.         rest_off();
  458.       }
  459. #endif
  460.     }
  461.       /* Hallucinating?  (Random characters appear!)*/
  462.       if (f_ptr->image > 0)
  463.     {
  464.       f_ptr->image--;
  465.       if (f_ptr->image == 0)
  466.         draw_cave();
  467.     }
  468.       /* Paralysis             */
  469.       if (f_ptr->paralysis > 0)
  470.     {
  471.       /* when paralysis true, you can not see any movement that occurs */
  472.       f_ptr->paralysis--;
  473.       if (f_ptr->rest > 0)
  474.         rest_off();
  475.       if (search_flag)
  476.         search_off();
  477.     }
  478.       /* Protection from evil counter*/
  479.       if (f_ptr->protevil > 0)  f_ptr->protevil--;
  480.       /* Invulnerability        */
  481.       if (f_ptr->invuln > 0)
  482.     {
  483.       if ((0x00001000 & f_ptr->status) == 0)
  484.         {
  485.           f_ptr->status |= 0x00001000;
  486.           if (find_flag)
  487.         {
  488.           find_flag = FALSE;
  489.           move_light (char_row, char_col, char_row, char_col);
  490.         }
  491.           py.misc.pac += 100;
  492.           py.misc.dis_ac += 100;
  493.           prt_pac();
  494.           msg_print("Your skin turns into steel!");
  495.         }
  496.       f_ptr->invuln--;
  497.       if (f_ptr->invuln == 0)
  498.         {
  499.           f_ptr->status &= 0xFFFFEFFF;
  500.           if (find_flag)
  501.         {
  502.           find_flag = FALSE;
  503.           move_light (char_row, char_col, char_row, char_col);
  504.         }
  505.           py.misc.pac -= 100;
  506.           py.misc.dis_ac -= 100;
  507.           prt_pac();
  508.           msg_print("Your skin returns to normal...");
  509.         }
  510.     }
  511.       /* Heroism       */
  512.       if (f_ptr->hero > 0)
  513.     {
  514.       if ((0x00002000 & f_ptr->status) == 0)
  515.         {
  516.           f_ptr->status |= 0x00002000;
  517.           if (find_flag)
  518.         {
  519.           find_flag = FALSE;
  520.           move_light (char_row, char_col, char_row, char_col);
  521.         }
  522.           p_ptr = &py.misc;
  523.           p_ptr->mhp += 10;
  524.           p_ptr->chp += 10.0;
  525.           p_ptr->bth += 12;
  526.           p_ptr->bthb+= 12;
  527.           msg_print("You feel like a HERO!");
  528.           prt_mhp();
  529.         }
  530.       f_ptr->hero--;
  531.       if (f_ptr->hero == 0)
  532.         {
  533.           f_ptr->status &= 0xFFFFDFFF;
  534.           if (find_flag)
  535.         {
  536.           find_flag = FALSE;
  537.           move_light (char_row, char_col, char_row, char_col);
  538.         }
  539.           p_ptr = &py.misc;
  540.           p_ptr->mhp -= 10;
  541.           if (p_ptr->chp > p_ptr->mhp)  p_ptr->chp = p_ptr->mhp;
  542.           p_ptr->bth -= 12;
  543.           p_ptr->bthb-= 12;
  544.           msg_print("The heroism wears off.");
  545.           prt_mhp();
  546.         }
  547.     }
  548.       /* Super Heroism */
  549.       if (f_ptr->shero > 0)
  550.     {
  551.       if ((0x00004000 & f_ptr->status) == 0)
  552.         {
  553.           f_ptr->status |= 0x00004000;
  554.           if (find_flag)
  555.         {
  556.           find_flag = FALSE;
  557.           move_light (char_row, char_col, char_row, char_col);
  558.         }
  559.           p_ptr = &py.misc;
  560.           p_ptr->mhp += 20;
  561.           p_ptr->chp += 20.0;
  562.           p_ptr->bth += 24;
  563.           p_ptr->bthb+= 24;
  564.           msg_print("You feel like a SUPER HERO!");
  565.           prt_mhp();
  566.         }
  567.       f_ptr->shero--;
  568.       if (f_ptr->shero == 0)
  569.         {
  570.           f_ptr->status &= 0xFFFFBFFF;
  571.           if (find_flag)
  572.         {
  573.           find_flag = FALSE;
  574.           move_light (char_row, char_col, char_row, char_col);
  575.         }
  576.           p_ptr = &py.misc;
  577.           p_ptr->mhp -= 20;
  578.           if (p_ptr->chp > p_ptr->mhp)  p_ptr->chp = p_ptr->mhp;
  579.           p_ptr->bth -= 24;
  580.           p_ptr->bthb-= 24;
  581.           msg_print("The super heroism wears off.");
  582.           prt_mhp();
  583.         }
  584.     }
  585.       /* Blessed       */
  586.       if (f_ptr->blessed > 0)
  587.     {
  588.       if ((0x00008000 & f_ptr->status) == 0)
  589.         {
  590.           f_ptr->status |= 0x00008000;
  591.           if (find_flag)
  592.         {
  593.           find_flag = FALSE;
  594.           move_light (char_row, char_col, char_row, char_col);
  595.         }
  596.           p_ptr = &py.misc;
  597.           p_ptr->bth += 5;
  598.           p_ptr->bthb+= 5;
  599.           p_ptr->pac += 2;
  600.           p_ptr->dis_ac+= 2;
  601.           msg_print("You feel righteous!");
  602.           prt_pac();
  603.         }
  604.       f_ptr->blessed--;
  605.       if (f_ptr->blessed == 0)
  606.         {
  607.           f_ptr->status &= 0xFFFF7FFF;
  608.           if (find_flag)
  609.         {
  610.           find_flag = FALSE;
  611.           move_light (char_row, char_col, char_row, char_col);
  612.         }
  613.           p_ptr = &py.misc;
  614.           p_ptr->bth -= 5;
  615.           p_ptr->bthb-= 5;
  616.           p_ptr->pac -= 2;
  617.           p_ptr->dis_ac -= 2;
  618.           msg_print("The prayer has expired.");
  619.           prt_pac();
  620.         }
  621.     }
  622.       /* Resist Heat   */
  623.       if (f_ptr->resist_heat > 0)  f_ptr->resist_heat--;
  624.       /* Resist Cold   */
  625.       if (f_ptr->resist_cold > 0)  f_ptr->resist_cold--;
  626.       /* Detect Invisible      */
  627.       if (f_ptr->detect_inv > 0)
  628.     {
  629.       if ((0x00010000 & f_ptr->status) == 0)
  630.         {
  631.           f_ptr->status |= 0x00010000;
  632.           f_ptr->see_inv = TRUE;
  633.         }
  634.       f_ptr->detect_inv--;
  635.       if (f_ptr->detect_inv == 0)
  636.         {
  637.           f_ptr->status &= 0xFFFEFFFF;
  638.           f_ptr->see_inv = FALSE;
  639.           py_bonuses(blank_treasure, 0);
  640.         }
  641.     }
  642.       /* Timed infra-vision    */
  643.       if (f_ptr->tim_infra > 0)
  644.     {
  645.       if ((0x00020000 & f_ptr->status) == 0)
  646.         {
  647.           f_ptr->status |= 0x00020000;
  648.           f_ptr->see_infra++;
  649.         }
  650.       f_ptr->tim_infra--;
  651.       if (f_ptr->tim_infra == 0)
  652.         {
  653.           f_ptr->status &= 0xFFFDFFFF;
  654.           f_ptr->see_infra--;
  655.         }
  656.     }
  657.     /* Word-of-Recall  Note: Word-of-Recall is a delayed action      */
  658.       if (f_ptr->word_recall > 0)
  659.     if (f_ptr->word_recall == 1)
  660.       {
  661.         moria_flag = TRUE;
  662.         f_ptr->paralysis++;
  663.         f_ptr->word_recall = 0;
  664.         if (dun_level > 0)
  665.           {
  666.         dun_level = 0;
  667.         msg_print("You feel yourself yanked upwards!");
  668.           }
  669.         else if (py.misc.max_lev != 0)
  670.           {
  671.         dun_level = py.misc.max_lev;
  672.         msg_print("You feel yourself yanked downwards!");
  673.           }
  674.       }
  675.     else
  676.       f_ptr->word_recall--;
  677.  
  678.       /* Check hit points for adjusting...            */
  679.       p_ptr = &py.misc;
  680.       if (!find_flag)
  681.     if (py.flags.rest < 1)
  682.       {
  683.         if (old_chp != (int)(p_ptr->chp))
  684.           {
  685.         if (p_ptr->chp > p_ptr->mhp)
  686.           p_ptr->chp = (double)p_ptr->mhp;
  687.         prt_chp();
  688.         old_chp = (int)p_ptr->chp;
  689.           }
  690.         if (old_cmana != (int)(p_ptr->cmana))
  691.           {
  692.         if (p_ptr->cmana > p_ptr->mana)
  693.           p_ptr->cmana = (double)p_ptr->mana;
  694.         prt_cmana();
  695.         old_cmana = (int)p_ptr->cmana;
  696.           }
  697.       }
  698.  
  699.       if ((py.flags.paralysis < 1) &&        /* Accept a command?     */
  700.       (py.flags.rest < 1) &&
  701.       (!death))
  702.     /* Accept a command and execute it                               */
  703.     {
  704.       do
  705.         {
  706.           print_stat = 0;
  707.           reset_flag = FALSE;
  708.           /* Random teleportation  */
  709.           if (py.flags.teleport)
  710.         if (randint(100) == 1)
  711.           {
  712.             find_flag = FALSE; /* no need for move_char(5) */
  713.             teleport(40);
  714.           }
  715.           if (!find_flag)
  716.         {
  717.           /* move the cursor to the players character */
  718.           print("", char_row, char_col);
  719.           save_msg_flag = msg_flag;
  720.           do
  721.             {
  722.               inkey(&command);
  723.             }
  724.           while (command == ' ');
  725.           if (save_msg_flag)  erase_line(MSG_LINE, 0);
  726.           global_com_val = (command);
  727.         }
  728.           /* Commands are executed in following subroutines     */
  729.           if (key_bindings == ORIGINAL)
  730.         original_commands(&global_com_val);
  731.           else
  732.         rogue_like_commands(&global_com_val);
  733.           /* End of commands                                     */
  734.         }
  735.       while ((reset_flag) && (!moria_flag));
  736.     }
  737.       /* Teleport?                     */
  738.       if (teleport_flag)  teleport(100);
  739.       /* Move the creatures            */
  740.       if (!moria_flag)  creatures(TRUE);
  741.       /* Exit when moria_flag is set   */
  742.     }
  743.   while (!moria_flag);
  744.   if (search_flag)  search_off();  /* Fixed "SLOW" bug; 06-11-86 RAK     */
  745. }
  746.  
  747.  
  748. original_commands(com_val)
  749. int *com_val;
  750. {
  751.   int y, x, dir_val;
  752.   char command;
  753.   int i;
  754.   vtype out_val, tmp_str;
  755.   register struct stats *s_ptr;
  756.   register struct flags *f_ptr;
  757.   int set_floor();
  758.  
  759.   switch(*com_val)
  760.     {
  761.     case 0: case 11:        /*^K == exit    */
  762.       flush();
  763.       if (get_com("Enter 'Q' to quit", &command))
  764.     switch(command)
  765.       {
  766.       case 'q': case  'Q':
  767.         moria_flag = TRUE;
  768.         death      = TRUE;
  769.             /* need dot on the end to be consistent with creature.c */
  770.             (void) strcpy(died_from, "Quitting.");
  771.         break;
  772.       default:
  773.         break;
  774.       }
  775.       reset_flag = TRUE;
  776.       break;
  777.     case 16:                               /*^P == repeat  */
  778.       repeat_msg ();
  779.       reset_flag = TRUE;
  780.       break;
  781.     case 23:
  782.       if (wizard1)                        /*^W == password*/
  783.     {
  784.       wizard1 = FALSE;
  785.       wizard2 = FALSE;
  786.       msg_print("Wizard mode off.");
  787.     }
  788.       else
  789.     {
  790.       if (check_pswd())
  791.         {
  792.           msg_print("Wizard mode on.");
  793.         }
  794.     }
  795.       reset_flag = TRUE;
  796.       break;
  797.     case 18:                               /*^R == redraw  */
  798.       really_clear_screen();
  799.       draw_cave();
  800.       reset_flag = TRUE;
  801.       break;
  802.     case 24:                               /*^X == save    */
  803.       if (total_winner)
  804.     {
  805.       msg_print("You are a Total Winner,  your character must be retired...");
  806.       msg_print("Use <Control>-K to when you are ready to quit.");
  807.     }
  808.       else
  809.     {
  810.       if (search_flag)  search_off();
  811.       save_char(TRUE, FALSE);
  812.     }
  813.       reset_flag = TRUE;
  814.       break;
  815.     case 32:                                /*SPACE do nothing */
  816.       reset_flag = TRUE;
  817.       break;
  818.     case '!':                                /*!  == Shell   */
  819.       shell_out();
  820.       reset_flag = TRUE;
  821.       break;
  822.     case 46:                                   /*. == find     */
  823.       y = char_row;
  824.       x = char_col;
  825.       if (get_dir("Which direction?", &dir_val, com_val, &y, &x))
  826.     {
  827.       find_flag = TRUE;
  828.       move_char(dir_val);
  829.     }
  830.       break;
  831.     case 47:                          /* / == identify */
  832.       ident_char();
  833.       reset_flag = TRUE;
  834.       break;
  835.     case 49:
  836.       move_char(*com_val - 48);        /* Move dir 1    */
  837.       break;
  838.     case 50:
  839.       move_char(*com_val - 48);        /* Move dir 2    */
  840.       break;
  841.     case 51:
  842.       move_char(*com_val - 48);        /* Move dir 3    */
  843.       break;
  844.     case 52:
  845.       move_char(*com_val - 48);        /* Move dir 4    */
  846.       break;
  847.     case 53:                          /* Rest one turn */
  848.       move_char(*com_val - 48);
  849. #ifdef SLOW
  850.       (void) sleep(0);     /* Sleep 1/10 a second*/
  851. #endif
  852.       flush();
  853.       break;
  854.     case 54:
  855.       move_char(*com_val - 48);        /* Move dir 6    */
  856.       break;
  857.     case 55:
  858.       move_char(*com_val - 48);        /* Move dir 7    */
  859.       break;
  860.     case 56:
  861.       move_char(*com_val - 48);        /* Move dir 8    */
  862.       break;
  863.     case 57:
  864.       move_char(*com_val - 48);        /* Move dir 9    */
  865.       break;
  866.     case 60:
  867.       go_up();                                  /*< == go up    */
  868.       break;
  869.     case 62:
  870.       go_down();                                /*> == go down  */
  871.       break;
  872.     case 63:                                  /*? == help     */
  873.       original_help();
  874.       reset_flag = TRUE;   /* Free move     */
  875.       break;
  876.     case 66:
  877.       bash();                                   /*B == bash     */
  878.       break;
  879.     case 67:                                   /*C == character*/
  880.       if (get_com("Print to file? (Y/N)", &command))
  881.     switch(command)
  882.       {
  883.       case 'y': case 'Y':
  884.         file_character();
  885.         break;
  886.       case 'n': case 'N':
  887.         change_name();
  888.         draw_cave();
  889.         break;
  890.       default:
  891.         break;
  892.       }
  893.       reset_flag = TRUE;   /* Free move     */
  894.       break;
  895.     case 68:
  896.       disarm_trap();                            /*D == disarm   */
  897.       break;
  898.     case 69:
  899.       eat();                                    /*E == eat      */
  900.       break;
  901.     case 70:
  902.       refill_lamp();                            /*F == refill   */
  903.       break;
  904.     case 76:                                   /*L == location */
  905.       if ((py.flags.blind > 0) || (no_light()))
  906.     msg_print("You can't see your map.");
  907.       else
  908.     {
  909.       (void) sprintf(out_val,
  910.              "Section [%d,%d]; Location == [%d,%d]",
  911.              (((char_row-1)/OUTPAGE_HEIGHT)+1),
  912.              (((char_col-1)/OUTPAGE_WIDTH )+1),
  913.              char_row, char_col);
  914.       msg_print(out_val);
  915.     }
  916.       reset_flag = TRUE;   /* Free move     */
  917.       break;
  918.     case 80:                                   /*P == print map*/
  919.       if ((py.flags.blind > 0) || (no_light()))
  920.     msg_print("You can't see to draw a map.");
  921.       else
  922.     print_map();
  923.       reset_flag = TRUE;   /* Free move     */
  924.       break;
  925.     case 82:
  926.       rest();                                   /*R == rest     */
  927.       break;
  928.     case 83:
  929.       if (search_flag)                    /*S == srh mode */
  930.     {
  931.       search_off();
  932.       reset_flag = TRUE; /* Free move     */
  933.     }
  934.       else if (py.flags.blind > 0)
  935.     msg_print("You are incapable of searching while blind.");
  936.       else
  937.     {
  938.       search_on();
  939.       reset_flag = TRUE; /* Free move     */
  940.     }
  941.       break;
  942.     case 84:
  943.       y = char_row;
  944.       x = char_col;
  945.       if (get_dir("Which direction?", &dir_val, com_val, &y, &x))
  946.     {
  947.       tunnel(y, x);                /*T == tunnel   */
  948.     }
  949.       break;
  950.     case 97:
  951.       aim();                                    /*a == aim      */
  952.       break;
  953.     case 98:
  954.       examine_book();                           /*b == browse   */
  955.       reset_flag = TRUE;
  956.       break;
  957.     case 99:
  958.       closeobject();                            /*c == close    */
  959.       break;
  960.     case 100:
  961.       drop();                                   /*d == drop     */
  962.       break;
  963.     case 101:                                   /*e == equipment*/
  964.       reset_flag = TRUE;   /* Free move     */
  965.       if (inven_command('e', 0, 0))  draw_cave();
  966.       break;
  967.     case 102:
  968.       throw_object();                           /*f == throw    */
  969.       break;
  970. #if 0
  971.     case 104:                                 /*h == moria hlp */
  972.       moria_help("");
  973.       draw_cave();
  974.       reset_flag = TRUE;   /* Free move   */
  975.       break;
  976. #endif
  977.     case 105:                                /*i == inventory*/
  978.       reset_flag = TRUE;   /* Free move     */
  979.       if (inven_command('i', 0, 0))  draw_cave();
  980.       break;
  981.     case 106:
  982.       jamdoor();                                /*j == jam      */
  983.       break;
  984.     case 108:                                 /*l == look     */
  985.       look();
  986.       reset_flag = TRUE;   /* Free move     */
  987.       break;
  988.     case 109:
  989.       cast();                                   /*m == magick   */
  990.       break;
  991.     case 111:
  992.       openobject();                             /*o == open     */
  993.       break;
  994.     case 112:
  995.       pray();                                   /*p == pray     */
  996.       break;
  997.     case 113:
  998.       quaff();                                  /*q == quaff    */
  999.       break;
  1000.     case 114:
  1001.       read_scroll();                            /*r == read     */
  1002.       break;
  1003.     case 115:
  1004.       if (py.flags.blind > 0)             /*s == search   */
  1005.     msg_print("You are incapable of searching while blind.");
  1006.       else
  1007.     search(char_row, char_col, py.misc.srh);
  1008.       break;
  1009.     case 116:                              /*t == unwear   */
  1010.       reset_flag = TRUE;
  1011.       if (inven_command('t', 0, 0))  draw_cave();
  1012.       break;
  1013.     case 117:
  1014.       use();                                    /*u == use staff*/
  1015.       break;
  1016.     case 118:
  1017.       game_version();                           /*v == version  */
  1018.       reset_flag = TRUE;
  1019.       break;
  1020.     case 119:                                 /*w == wear     */
  1021.       reset_flag = TRUE;
  1022.       if (inven_command('w', 0, 0))  draw_cave();
  1023.       break;
  1024.     case 120:                                 /*x == exchange */
  1025.       reset_flag = TRUE;
  1026.       if (inven_command('x', 0, 0))  draw_cave();
  1027.       break;
  1028.     default:
  1029.       if (wizard1)
  1030.     {
  1031.       reset_flag = TRUE; /* Wizard commands are free moves*/
  1032.       switch(*com_val)
  1033.         {
  1034.         case 1:                            /*^A == Cure all*/
  1035.           (void) remove_curse();
  1036.           (void) cure_blindness();
  1037.           (void) cure_confusion();
  1038.           (void) cure_poison();
  1039.           (void) remove_fear();
  1040.           s_ptr = &py.stats;
  1041.           s_ptr->cstr = s_ptr->str;
  1042.           s_ptr->cint = s_ptr->intel;
  1043.           s_ptr->cwis = s_ptr->wis;
  1044.           s_ptr->cdex = s_ptr->dex;
  1045.           s_ptr->ccon = s_ptr->con;
  1046.           s_ptr->cchr = s_ptr->chr;
  1047.           f_ptr = &py.flags;
  1048.           if (f_ptr->slow > 1)
  1049.         f_ptr->slow = 1;
  1050.           if (f_ptr->image > 1)
  1051.         f_ptr->image = 1;
  1052.           /* put_qio(); */
  1053.           /* adjust misc stats */
  1054.           py_bonuses(blank_treasure, 0);
  1055.           break;
  1056.         case 2:
  1057.           print_objects();                  /*^B == objects */
  1058.           break;
  1059.         case 4:                           /*^D == up/down */
  1060.           prt("Go to which level (0 -1200) ? ", 0, 0);
  1061.           i = -1;
  1062.           if (get_string(tmp_str, 0, 30, 10))
  1063.         (void) sscanf(tmp_str, "%d", &i);
  1064.           if (i > -1)
  1065.         {
  1066.           dun_level = i;
  1067.           if (dun_level > 1200)
  1068.             dun_level = 1200;
  1069.           moria_flag = TRUE;
  1070.         }
  1071.           else
  1072.         erase_line(MSG_LINE, 0);
  1073.           break;
  1074.         case 8:
  1075.           original_wizard_help();           /*^H == wizhelp */
  1076.           break;
  1077.         case 9:
  1078.           (void) ident_spell();             /*^I == identify*/
  1079.           break;
  1080.         case 14:
  1081.           print_monsters();                 /*^N == mon map */
  1082.           break;
  1083.         case 12:
  1084.           wizard_light();                   /*^L == wizlight*/
  1085.           break;
  1086.         case 20:
  1087.           teleport(100);                    /*^T == teleport*/
  1088.           break;
  1089.         case 22:
  1090.           restore_char();                   /*^V == restore */
  1091.           prt_stat_block();
  1092.           moria_flag = TRUE;
  1093.           break;
  1094.         default:
  1095.           if (wizard2)
  1096.         switch(*com_val)
  1097.           {
  1098.           case 5:
  1099.             change_character();         /*^E == wizchar */
  1100.             break;
  1101.           case 6:
  1102.             (void) mass_genocide();     /*^F == genocide*/
  1103.             /* put_qio(); */
  1104.             break;
  1105.           case 7:                       /*^G == treasure*/
  1106.             alloc_object(set_floor, 5, 10);
  1107.             /* put_qio(); */
  1108.             break;
  1109.           case 10:                      /*^J == gain exp*/
  1110.             if (py.misc.exp == 0)
  1111.               py.misc.exp = 1;
  1112.             else
  1113.               py.misc.exp = py.misc.exp * 2;
  1114.             prt_experience();
  1115.             break;
  1116.           case 21:                    /*^U == summon  */
  1117.             y = char_row;
  1118.             x = char_col;
  1119.             (void) summon_monster(&y, &x, TRUE);
  1120.             creatures(FALSE);
  1121.             break;
  1122.           case '@':
  1123.             wizard_create();          /*^Q == create  */
  1124.             break;
  1125.           default:
  1126.             prt("Type '?' or '^H' for help...", 0, 0);
  1127.             break;
  1128.           }
  1129.           else
  1130.         prt("Type '?' or '^H' for help...", 0, 0);
  1131.         }
  1132.     }
  1133.       else
  1134.     {
  1135.       prt("Type '?' for help...", 0, 0);
  1136.       reset_flag = TRUE;
  1137.     }
  1138.     }
  1139. }
  1140.  
  1141.  
  1142. rogue_like_commands(com_val)
  1143. int *com_val;
  1144. {
  1145.   int y, x;
  1146.   char command;
  1147.   int i;
  1148.   vtype out_val, tmp_str;
  1149.   register struct stats *s_ptr;
  1150.   register struct flags *f_ptr;
  1151.   int set_floor();
  1152.  
  1153.   switch(*com_val)
  1154.     {
  1155.     case 0: case 'Q':        /*Q == exit    */
  1156.       flush();
  1157.       if (get_com("Do you really want to quit?", &command))
  1158.     switch(command)
  1159.       {
  1160.       case 'y': case  'Y':
  1161.         moria_flag = TRUE;
  1162.         death      = TRUE;
  1163.             /* need dot on the end to be consistent with creature.c */
  1164.             (void) strcpy(died_from, "Quitting.");
  1165.         break;
  1166.       default:
  1167.         break;
  1168.       }
  1169.       reset_flag = TRUE;
  1170.       break;
  1171.     case 16:                               /*^P == repeat  */
  1172.       repeat_msg ();
  1173.       reset_flag = TRUE;
  1174.       break;
  1175.     case 23:
  1176.       if (wizard1)                        /*^W == password*/
  1177.     {
  1178.       wizard1 = FALSE;
  1179.       wizard2 = FALSE;
  1180.       msg_print("Wizard mode off.");
  1181.     }
  1182.       else
  1183.     {
  1184.       if (check_pswd())
  1185.         {
  1186.           msg_print("Wizard mode on.");
  1187.         }
  1188.     }
  1189.       reset_flag = TRUE;
  1190.       break;
  1191.     case 18:                               /*^R == redraw  */
  1192.       really_clear_screen();
  1193.       draw_cave();
  1194.       reset_flag = TRUE;
  1195.       break;
  1196.     case 24:                               /*^X == save    */
  1197.       if (total_winner)
  1198.     {
  1199.       msg_print("You are a Total Winner,  your character must be retired...");
  1200.       msg_print("Use 'Q' to when you are ready to quit.");
  1201.     }
  1202.       else
  1203.     {
  1204.       if (search_flag)  search_off();
  1205.       save_char(TRUE, FALSE);
  1206.     }
  1207.       reset_flag = TRUE;
  1208.       break;
  1209.     case ' ':                                /*SPACE do nothing */
  1210.       reset_flag = TRUE;
  1211.       break;
  1212.     case '!':                                /*!  == Shell   */
  1213.       shell_out();
  1214.       reset_flag = TRUE;
  1215.       break;
  1216.     case 'b':
  1217.       move_char(1);
  1218.       break;
  1219.     case 'j':
  1220.       move_char(2);
  1221.       break;
  1222.     case 'n':
  1223.       move_char(3);
  1224.       break;
  1225.     case 'h':
  1226.       move_char(4);
  1227.       break;
  1228.     case 'l':
  1229.       move_char(6);
  1230.       break;
  1231.     case 'y':
  1232.       move_char(7);
  1233.       break;
  1234.     case 'k':
  1235.       move_char(8);
  1236.       break;
  1237.     case 'u':
  1238.       move_char(9);
  1239.       break;
  1240.     case 'B':                                   /*. == find     */
  1241.       find_flag = TRUE;
  1242.       move_char(1);
  1243.       break;
  1244.     case 'J':                                   /*. == find     */
  1245.       find_flag = TRUE;
  1246.       move_char(2);
  1247.       break;
  1248.     case 'N':                                   /*. == find     */
  1249.       find_flag = TRUE;
  1250.       move_char(3);
  1251.       break;
  1252.     case 'H':                                   /*. == find     */
  1253.       find_flag = TRUE;
  1254.       move_char(4);
  1255.       break;
  1256.     case 'L':                                   /*. == find     */
  1257.       find_flag = TRUE;
  1258.       move_char(6);
  1259.       break;
  1260.     case 'Y':                                   /*. == find     */
  1261.       find_flag = TRUE;
  1262.       move_char(7);
  1263.       break;
  1264.     case 'K':                                   /*. == find     */
  1265.       find_flag = TRUE;
  1266.       move_char(8);
  1267.       break;
  1268.     case 'U':                                   /*. == find     */
  1269.       find_flag = TRUE;
  1270.       move_char(9);
  1271.       break;
  1272.     case '/':                          /* / == identify */
  1273.       ident_char();
  1274.       reset_flag = TRUE;
  1275.       break;
  1276.     case '1':
  1277.       move_char(1);        /* Move dir 1    */
  1278.       break;
  1279.     case '2':
  1280.       move_char(2);        /* Move dir 2    */
  1281.       break;
  1282.     case '3':
  1283.       move_char(3);        /* Move dir 3    */
  1284.       break;
  1285.     case '4':
  1286.       move_char(4);        /* Move dir 4    */
  1287.       break;
  1288.     case '5':                          /* Rest one turn */
  1289.     case '.':
  1290.       move_char(5);
  1291. #ifdef SLOW
  1292.       (void) sleep(0);     /* Sleep 1/10 a second*/
  1293. #endif
  1294.       flush();
  1295.       break;
  1296.     case '6':
  1297.       move_char(6);        /* Move dir 6    */
  1298.       break;
  1299.     case '7':
  1300.       move_char(7);        /* Move dir 7    */
  1301.       break;
  1302.     case '8':
  1303.       move_char(8);        /* Move dir 8    */
  1304.       break;
  1305.     case '9':
  1306.       move_char(9);        /* Move dir 9    */
  1307.       break;
  1308.     case '<':
  1309.       go_up();                                  /*< == go up    */
  1310.       break;
  1311.     case '>':
  1312.       go_down();                                /*> == go down  */
  1313.       break;
  1314.     case '?':                                  /*? == help     */
  1315.       rogue_like_help();
  1316.       reset_flag = TRUE;   /* Free move     */
  1317.       break;
  1318.     case 'f':
  1319.       bash();                                   /*f == bash     */
  1320.       break;
  1321.     case 'C':                                   /*C == character*/
  1322.       if (get_com("Print to file? (Y/N)", &command))
  1323.     switch(command)
  1324.       {
  1325.       case 'y': case 'Y':
  1326.         file_character();
  1327.         break;
  1328.       case 'n': case 'N':
  1329.         change_name();
  1330.         draw_cave();
  1331.         break;
  1332.       default:
  1333.         break;
  1334.       }
  1335.       reset_flag = TRUE;   /* Free move     */
  1336.       break;
  1337.     case 'D':
  1338.       disarm_trap();                            /*D == disarm   */
  1339.       break;
  1340.     case 'E':
  1341.       eat();                                    /*E == eat      */
  1342.       break;
  1343.     case 'F':
  1344.       refill_lamp();                            /*F == refill   */
  1345.       break;
  1346.     case 'W':                                   /*W == location */
  1347.       if ((py.flags.blind > 0) || (no_light()))
  1348.     msg_print("You can't see your map.");
  1349.       else
  1350.     {
  1351.       (void) sprintf(out_val,
  1352.              "Section [%d,%d]; Location == [%d,%d]",
  1353.              (((char_row-1)/OUTPAGE_HEIGHT)+1),
  1354.              (((char_col-1)/OUTPAGE_WIDTH )+1),
  1355.              char_row, char_col);
  1356.       msg_print(out_val);
  1357.     }
  1358.       reset_flag = TRUE;   /* Free move     */
  1359.       break;
  1360.     case 'M':                                   /*M == print map*/
  1361.       if ((py.flags.blind > 0) || (no_light()))
  1362.     msg_print("You can't see to draw a map.");
  1363.       else
  1364.     print_map();
  1365.       reset_flag = TRUE;   /* Free move     */
  1366.       break;
  1367.     case 'R':
  1368.       rest();                                   /*R == rest     */
  1369.       break;
  1370.     case '#':
  1371.       if (search_flag)                    /*^S == srh mode */
  1372.     {
  1373.       search_off();
  1374.       reset_flag = TRUE; /* Free move     */
  1375.     }
  1376.       else if (py.flags.blind > 0)
  1377.     msg_print("You are incapable of searching while blind.");
  1378.       else
  1379.     {
  1380.       search_on();
  1381.       reset_flag = TRUE; /* Free move     */
  1382.     }
  1383.       break;
  1384.     case 25:  /* ^Y */
  1385.       x = char_row;
  1386.       y = char_col;
  1387.       (void) move(7, &x, &y);
  1388.       tunnel(x, y);
  1389.       break;
  1390.     case 11:  /* ^K */
  1391.       x = char_row;
  1392.       y = char_col;
  1393.       (void) move(8, &x, &y);
  1394.       tunnel(x, y);
  1395.       break;
  1396.     case 21: /* ^U */
  1397.       x = char_row;
  1398.       y = char_col;
  1399.       (void) move(9, &x, &y);
  1400.       tunnel(x, y);
  1401.       break;
  1402.     case 12:  /* ^L */
  1403.       x = char_row;
  1404.       y = char_col;
  1405.       (void) move(6, &x, &y);
  1406.       tunnel(x, y);
  1407.       break;
  1408.     case 14:  /* ^N */
  1409.       x = char_row;
  1410.       y = char_col;
  1411.       (void) move(3, &x, &y);
  1412.       tunnel(x, y);
  1413.       break;
  1414.     case 10:    /* ^J */
  1415.       x = char_row;
  1416.       y = char_col;
  1417.       (void) move(2, &x, &y);
  1418.       tunnel(x, y);
  1419.       break;
  1420.     case 2:  /* ^B */
  1421.       x = char_row;
  1422.       y = char_col;
  1423.       (void) move(1, &x, &y);
  1424.       tunnel(x, y);
  1425.       break;
  1426.     case 8:  /* ^H */
  1427.       x = char_row;
  1428.       y = char_col;
  1429.       (void) move(4, &x, &y);
  1430.       tunnel(x, y);
  1431.       break;
  1432.     case 'z':
  1433.      aim();                                    /*z == aim      */
  1434.       break;
  1435.     case 'P':
  1436.       examine_book();                           /*P == browse   */
  1437.       reset_flag = TRUE;
  1438.       break;
  1439.     case 'c':
  1440.       closeobject();                            /*c == close    */
  1441.       break;
  1442.     case 'd':
  1443.       drop();                                   /*d == drop     */
  1444.       break;
  1445.     case 'e':                                   /*e == equipment*/
  1446.       reset_flag = TRUE;   /* Free move     */
  1447.       if (inven_command('e', 0, 0))  draw_cave();
  1448.       break;
  1449.     case 't':
  1450.       throw_object();                           /*t == throw    */
  1451.       break;
  1452. #if 0
  1453.     case 104:                                 /*h == moria hlp */
  1454.       moria_help("");
  1455.       draw_cave();
  1456.       reset_flag = TRUE;   /* Free move    */
  1457.       break;
  1458. #endif
  1459.     case 'i':                                /*i == inventory*/
  1460.       reset_flag = TRUE;   /* Free move     */
  1461.       if (inven_command('i', 0, 0))  draw_cave();
  1462.       break;
  1463.     case 'S':
  1464.       jamdoor();                                /*S == jam      */
  1465.       break;
  1466.     case 'x':                                 /*l == look     */
  1467.       look();
  1468.       reset_flag = TRUE;   /* Free move     */
  1469.       break;
  1470.     case 'm':
  1471.       cast();                                   /*m == magick   */
  1472.       break;
  1473.     case 'o':
  1474.       openobject();                             /*o == open     */
  1475.       break;
  1476.     case 'p':
  1477.       pray();                                   /*p == pray     */
  1478.       break;
  1479.     case 'q':
  1480.       quaff();                                  /*q == quaff    */
  1481.       break;
  1482.     case 'r':
  1483.       read_scroll();                            /*r == read     */
  1484.       break;
  1485.     case 's':
  1486.       if (py.flags.blind > 0)             /*s == search   */
  1487.     msg_print("You are incapable of searching while blind.");
  1488.       else
  1489.     search(char_row, char_col, py.misc.srh);
  1490.       break;
  1491.     case 'T':                              /*T == unwear   */
  1492.       reset_flag = TRUE;
  1493.       if (inven_command('t', 0, 0))  draw_cave();
  1494.       break;
  1495.     case 'Z':
  1496.       use();                                    /*Z == use staff*/
  1497.       break;
  1498.     case 'v':
  1499.       game_version();                           /*v == version  */
  1500.       reset_flag = TRUE;
  1501.       break;
  1502.     case 'w':                                 /*w == wear     */
  1503.       reset_flag = TRUE;
  1504.       if (inven_command('w', 0, 0))  draw_cave();
  1505.       break;
  1506.     case 'X':                                 /*x == exchange */
  1507.       reset_flag = TRUE;
  1508.       if (inven_command('x', 0, 0))  draw_cave();
  1509.       break;
  1510.     default:
  1511.       if (wizard1)
  1512.     {
  1513.       reset_flag = TRUE; /* Wizard commands are free moves*/
  1514.       switch(*com_val)
  1515.         {
  1516.         case 1:                            /*^A == Cure all*/
  1517.           (void) remove_curse();
  1518.           (void) cure_blindness();
  1519.           (void) cure_confusion();
  1520.           (void) cure_poison();
  1521.           (void) remove_fear();
  1522.           s_ptr = &py.stats;
  1523.           s_ptr->cstr = s_ptr->str;
  1524.           s_ptr->cint = s_ptr->intel;
  1525.           s_ptr->cwis = s_ptr->wis;
  1526.           s_ptr->cdex = s_ptr->dex;
  1527.           s_ptr->ccon = s_ptr->con;
  1528.           s_ptr->cchr = s_ptr->chr;
  1529.           f_ptr = &py.flags;
  1530.           if (f_ptr->slow > 1)
  1531.         f_ptr->slow = 1;
  1532.           if (f_ptr->image > 1)
  1533.         f_ptr->image = 1;
  1534.           /* put_qio(); */
  1535.           /* adjust misc stats */
  1536.           py_bonuses(blank_treasure, 0);
  1537.           break;
  1538.         case 15:
  1539.           print_objects();                  /*^O == objects */
  1540.           break;
  1541.         case 4:                           /*^D == up/down */
  1542.           prt("Go to which level (0 -1200) ? ", 0, 0);
  1543.           i = -1;
  1544.           if (get_string(tmp_str, 0, 30, 10))
  1545.         (void) sscanf(tmp_str, "%d", &i);
  1546.           if (i > -1)
  1547.         {
  1548.           dun_level = i;
  1549.           if (dun_level > 1200)
  1550.             dun_level = 1200;
  1551.           moria_flag = TRUE;
  1552.         }
  1553.           else
  1554.         erase_line(MSG_LINE, 0);
  1555.           break;
  1556.         case 127: /* ^? DEL */
  1557.           rogue_like_wizard_help();         /*DEL == wizhelp */
  1558.           break;
  1559.         case 9:
  1560.           (void) ident_spell();             /*^I == identify*/
  1561.           break;
  1562.         case 13:
  1563.           print_monsters();                 /*^M == mon map */
  1564.           break;
  1565.         case '*':
  1566.           wizard_light();                   /*` == wizlight*/
  1567.           break;
  1568.         case 20:
  1569.           teleport(100);                    /*^T == teleport*/
  1570.           break;
  1571.         case 22:
  1572.           restore_char();                   /*^V == restore */
  1573.           prt_stat_block();
  1574.           moria_flag = TRUE;
  1575.           break;
  1576.         default:
  1577.           if (wizard2)
  1578.         switch(*com_val)
  1579.           {
  1580.           case 5:
  1581.             change_character();         /*^E == wizchar */
  1582.             break;
  1583.           case 6:
  1584.             (void) mass_genocide();     /*^F == genocide*/
  1585.             /* put_qio(); */
  1586.             break;
  1587.           case 7:                       /*^G == treasure*/
  1588.             alloc_object(set_floor, 5, 10);
  1589.             /* put_qio(); */
  1590.             break;
  1591.           case '+':                      /*+ == gain exp*/
  1592.             if (py.misc.exp == 0)
  1593.               py.misc.exp = 1;
  1594.             else
  1595.               py.misc.exp = py.misc.exp * 2;
  1596.             prt_experience();
  1597.             break;
  1598.           case 19:                    /*^S == summon  */
  1599.             y = char_row;
  1600.             x = char_col;
  1601.             (void) summon_monster(&y, &x, TRUE);
  1602.             creatures(FALSE);
  1603.             break;
  1604.           case '@':
  1605.             wizard_create();          /*^Q == create  */
  1606.             break;
  1607.           default:
  1608.             prt("Type '?' or DELETE for help...", 0, 0);
  1609.             break;
  1610.           }
  1611.           else
  1612.         prt("Type '?' or DELETE for help...", 0, 0);
  1613.         }
  1614.     }
  1615.       else
  1616.     {
  1617.       prt("Type '?' for help...", 0, 0);
  1618.       reset_flag = TRUE;
  1619.     }
  1620.     }
  1621. }
  1622.