home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / proglc / mor4873s.lzh / WIZARD.C < prev   
C/C++ Source or Header  |  1988-11-01  |  12KB  |  386 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.  
  19. /* Print Moria credits                    -RAK-    */
  20. game_version()
  21. {
  22.   vtype tmp_str;
  23.  
  24.   clear_screen(0, 0);
  25.   (void) sprintf(tmp_str, "               Moria Version %f", CUR_VERSION);
  26.   put_buffer(tmp_str, 0, 0);
  27.   put_buffer("Version 0.1  : 03/25/83", 1, 0);
  28.   put_buffer("Version 1.0  : 05/01/84", 2, 0);
  29.   put_buffer("Version 2.0  : 07/10/84", 3, 0);
  30.   put_buffer("Version 3.0  : 11/20/84", 4, 0);
  31.   put_buffer("Version 4.0  : 01/20/85", 5, 0);
  32.   put_buffer("Modules :", 7, 0);
  33.   put_buffer("     V1.0  Dungeon Generator      - RAK", 8, 0);
  34.   put_buffer("           Character Generator    - RAK & JWT", 9, 0);
  35.   put_buffer("           Moria Module           - RAK", 10, 0);
  36.   put_buffer("           Miscellaneous          - RAK & JWT", 11, 0);
  37.   put_buffer("     V2.0  Town Level & Misc      - RAK", 12, 0);
  38.   put_buffer("     V3.0  Internal Help & Misc   - RAK", 13, 0);
  39.   put_buffer("     V4.0  Source Release Version - RAK", 14, 0);
  40.   put_buffer("Robert Alan Koeneke               Jimmey Wayne Todd Jr.", 16, 0);
  41.  put_buffer("Student/University of Oklahoma    Student/University of Oklahoma",
  42.         17, 0);
  43.   put_buffer("119 Crystal Bend                  1912 Tiffany Dr.", 18, 0);
  44.   put_buffer("Norman, OK 73069                  Norman, OK  73071", 19, 0);
  45.   put_buffer("(405)-321-2925                    (405) 360-6792", 20, 0);
  46.   pause_line(23);
  47.   clear_screen(0, 0);
  48.   put_buffer("UNIX MORIA Port by James E. Wilson", 2, 0);
  49.   put_buffer("                   wilson@ernie.Berkeley.EDU", 3, 0);
  50.   put_buffer("                   ucbvax!ucbernie!wilson", 4, 0);
  51.   put_buffer("This version is based on the VMS version 4.8", 6, 0);
  52.   put_buffer("but is no longer identical to the original VMS program.", 7, 0);
  53.   put_buffer("Please use care when referring to this program.", 8, 0);
  54.   put_buffer("Please call it 'umoria' or 'UNIX MORIA' or something", 9, 0);
  55.   put_buffer("similar to avoid confusion.", 10, 0);
  56. #ifdef MSDOS
  57.   put_buffer("MSDOS MORIA port by D. G. Kneller", 12, 0);
  58.   put_buffer("                    1349 10th ave", 13, 0);
  59.   put_buffer("                    San Francisco, CA 94122", 14, 0);
  60. #endif
  61.   pause_line(23);
  62.   draw_cave();
  63. }
  64.  
  65.  
  66. /* Light up the dungeon                    -RAK-    */
  67. wizard_light()
  68. {
  69.   register cave_type *c_ptr;
  70.   register int k, l, i, j;
  71.   int flag;
  72.  
  73.   if (cave[char_row][char_col].pl)
  74.     flag = FALSE;
  75.   else
  76.     flag = TRUE;
  77.   for (i = 0; i < cur_height; i++)
  78.     for (j = 0; j < cur_width; j++)
  79.       if (set_floor(cave[i][j].fval))
  80.     for (k = i-1; k <= i+1; k++)
  81.       for (l = j-1; l <= j+1; l++)
  82.         {
  83.           c_ptr = &cave[k][l];
  84.           c_ptr->pl = flag;
  85.           if (!flag)
  86.         c_ptr->fm = FALSE;
  87.         }
  88.   prt_map();
  89. }
  90.  
  91.  
  92. /* Wizard routine for gaining on stats            -RAK-    */
  93. change_character()
  94. {
  95.   int tmp_val;
  96.   vtype tmp_str;
  97.   register struct stats *s_ptr;
  98.   register struct misc *m_ptr;
  99.  
  100.   s_ptr = &py.stats;
  101.   prt("(3 - 118) Strength     == ", 0, 0);
  102.   (void) get_string(tmp_str, 0, 25, 10);
  103.   tmp_val = -999;
  104.   (void) sscanf(tmp_str, "%d", &tmp_val);
  105.   if ((tmp_val > 2) && (tmp_val < 119))
  106.     {
  107.       s_ptr->str  = tmp_val;
  108.       s_ptr->cstr = tmp_val;
  109.       prt_strength();
  110.     }
  111.   prt("(3 - 118) Intelligence == ", 0, 0);
  112.   (void) get_string(tmp_str, 0, 25, 10);
  113.   tmp_val = -999;
  114.   (void) sscanf(tmp_str, "%d", &tmp_val);
  115.   if ((tmp_val > 2) && (tmp_val < 119))
  116.     {
  117.       s_ptr->intel  = tmp_val;
  118.       s_ptr->cint = tmp_val;
  119.       prt_intelligence();
  120.     }
  121.   prt("(3 - 118) Wisdom       == ", 0, 0);
  122.   (void) get_string(tmp_str, 0, 25, 10);
  123.   tmp_val = -999;
  124.   (void) sscanf(tmp_str, "%d", &tmp_val);
  125.   if ((tmp_val > 2) && (tmp_val < 119))
  126.     {
  127.       s_ptr->wis  = tmp_val;
  128.       s_ptr->cwis = tmp_val;
  129.       prt_wisdom();
  130.     }
  131.   prt("(3 - 118) Dexterity    == ", 0, 0);
  132.   (void) get_string(tmp_str, 0, 25, 10);
  133.   tmp_val = -999;
  134.   (void) sscanf(tmp_str, "%d", &tmp_val);
  135.   if ((tmp_val > 2) && (tmp_val < 119))
  136.     {
  137.       s_ptr->dex  = tmp_val;
  138.       s_ptr->cdex = tmp_val;
  139.       prt_dexterity();
  140.     }
  141.   prt("(3 - 118) Constitution == ", 0, 0);
  142.   (void) get_string(tmp_str, 0, 25, 10);
  143.   tmp_val = -999;
  144.   (void) sscanf(tmp_str, "%d", &tmp_val);
  145.   if ((tmp_val > 2) && (tmp_val < 119))
  146.     {
  147.       s_ptr->con  = tmp_val;
  148.       s_ptr->ccon = tmp_val;
  149.       prt_constitution();
  150.     }
  151.   prt("(3 - 118) Charisma     == ", 0, 0);
  152.   (void) get_string(tmp_str, 0, 25, 10);
  153.   tmp_val = -999;
  154.   (void) sscanf(tmp_str, "%d", &tmp_val);
  155.   if ((tmp_val > 2) && (tmp_val < 119))
  156.     {
  157.       s_ptr->chr  = tmp_val;
  158.       s_ptr->cchr = tmp_val;
  159.       prt_charisma();
  160.     }
  161.  
  162.   m_ptr = &py.misc;
  163.   prt("(1 - 32767) Hit points == ", 0, 0);
  164.   (void) get_string(tmp_str, 0, 25, 10);
  165.   tmp_val = -1;
  166.   (void) sscanf(tmp_str, "%d", &tmp_val);
  167.   if ((tmp_val > 0) && (tmp_val <= 32767))
  168.     {
  169.       m_ptr->mhp  = tmp_val;
  170.       m_ptr->chp  = (double)tmp_val;
  171.       prt_mhp();
  172.       prt_chp();
  173.     }
  174.   prt("(0 - 32767) Mana       == ", 0, 0);
  175.   (void) get_string(tmp_str, 0, 25, 10);
  176.   tmp_val = -999;
  177.   (void) sscanf(tmp_str, "%d", &tmp_val);
  178.   if ((tmp_val > -1) && (tmp_val <= 32767))
  179.     {
  180.       m_ptr->mana  = tmp_val;
  181.       m_ptr->cmana = (double)tmp_val;
  182.       prt_cmana();
  183.     }
  184.   (void) sprintf(tmp_str, "Current==%d  (0-200) Searching == ", m_ptr->srh);
  185.   tmp_val = strlen(tmp_str);
  186.   prt(tmp_str, 0, 0);
  187.   (void) get_string(tmp_str, 0, tmp_val, 10);
  188.   tmp_val = -999;
  189.   (void) sscanf(tmp_str, "%d", &tmp_val);
  190.   if ((tmp_val > -1) && (tmp_val < 201))
  191.     m_ptr->srh  = tmp_val;
  192.   (void) sprintf(tmp_str, "Current==%d  (0-10) Stealth == ", m_ptr->stl);
  193.   tmp_val = strlen(tmp_str);
  194.   prt(tmp_str, 0, 0);
  195.   (void) get_string(tmp_str, 0, tmp_val, 10);
  196.   tmp_val = -999;
  197.   (void) sscanf(tmp_str, "%d", &tmp_val);
  198.   if ((tmp_val > -1) && (tmp_val < 11))
  199.     m_ptr->stl  = tmp_val;
  200.   (void) sprintf(tmp_str, "Current==%d  (0-200) Disarming == ", m_ptr->disarm);
  201.   tmp_val = strlen(tmp_str);
  202.   prt(tmp_str, 0, 0);
  203.   (void) get_string(tmp_str, 0, tmp_val, 10);
  204.   tmp_val = -999;
  205.   (void) sscanf(tmp_str, "%d", &tmp_val);
  206.   if ((tmp_val > -1) && (tmp_val < 201))
  207.     m_ptr->disarm = tmp_val;
  208.   (void) sprintf(tmp_str, "Current==%d  (0-100) Save == ", m_ptr->save);
  209.   tmp_val = strlen(tmp_str);
  210.   prt(tmp_str, 0, 0);
  211.   (void) get_string(tmp_str, 0, tmp_val, 10);
  212.   tmp_val = -999;
  213.   (void) sscanf(tmp_str, "%d", &tmp_val);
  214.   if ((tmp_val > -1) && (tmp_val < 201))
  215.     m_ptr->save = tmp_val;
  216.   (void) sprintf(tmp_str, "Current==%d  (0-200) Base to hit == ", m_ptr->bth);
  217.   tmp_val = strlen(tmp_str);
  218.   prt(tmp_str, 0, 0);
  219.   (void) get_string(tmp_str, 0, tmp_val, 10);
  220.   tmp_val = -999;
  221.   (void) sscanf(tmp_str, "%d", &tmp_val);
  222.   if ((tmp_val > -1) && (tmp_val < 201))
  223.     m_ptr->bth  = tmp_val;
  224.   (void) sprintf(tmp_str, "Current==%d  (0-200) Bows/Throwing == ",
  225.          m_ptr->bthb);
  226.   tmp_val = strlen(tmp_str);
  227.   prt(tmp_str, 0, 0);
  228.   (void) get_string(tmp_str, 0, tmp_val, 10);
  229.   tmp_val = -999;
  230.   (void) sscanf(tmp_str, "%d", &tmp_val);
  231.   if ((tmp_val > -1) && (tmp_val < 201))
  232.     m_ptr->bthb = tmp_val;
  233.   (void) sprintf(tmp_str, "Current==%ld  Gold == ", m_ptr->au);
  234.   tmp_val = strlen(tmp_str);
  235.   prt(tmp_str, 0, 0);
  236.   (void) get_string(tmp_str, 0, tmp_val, 10);
  237.   tmp_val = -999;
  238.   (void) sscanf(tmp_str, "%d", &tmp_val);
  239.   if (tmp_val > -1)
  240.     {
  241.       m_ptr->au = tmp_val;
  242.       prt_gold();
  243.     }
  244.  
  245.   erase_line(MSG_LINE, 0);
  246.   py_bonuses(blank_treasure, 0);
  247. }
  248.  
  249.  
  250. /* Wizard routine for creating objects            -RAK-    */
  251. wizard_create()
  252. {
  253.   int tmp_val;
  254.   vtype tmp_str;
  255.   register int flag;
  256.   register treasure_type *i_ptr;
  257.   register cave_type *c_ptr;
  258.   char command;
  259.  
  260.   msg_print("Warning: This routine can cause fatal error.");
  261.   /* make sure player sees the message */
  262.   msg_print(" ");
  263.   msg_flag = FALSE;
  264.   i_ptr = &inventory[INVEN_MAX];
  265.   prt("Name   : ", 0, 0);
  266.   if (get_string(tmp_str, 0, 9, 80))
  267.     (void) strcpy(i_ptr->name, tmp_str);
  268.   else
  269.     (void) strcpy(i_ptr->name, "& Wizard Object!");
  270.   do
  271.     {
  272.       prt("Tval   : ", 0, 0);
  273.       (void) get_string(tmp_str, 0, 9, 10);
  274.       tmp_val = 0;
  275.       (void) sscanf(tmp_str, "%d", &tmp_val);
  276.       flag = TRUE;
  277.       switch(tmp_val)
  278.     {
  279.     case 1: case 13: case 15 :    i_ptr->tchar = '~'; break;
  280.     case 2:     i_ptr->tchar = '&'; break;
  281.     case 10:    i_ptr->tchar = '{'; break;
  282.     case 11:    i_ptr->tchar = '{'; break;
  283.     case 12:    i_ptr->tchar = '{'; break;
  284.     case 20:    i_ptr->tchar = '}'; break;
  285.     case 21:    i_ptr->tchar = '/'; break;
  286.     case 22:    i_ptr->tchar = '\\'; break;
  287.     case 23:    i_ptr->tchar = '|'; break;
  288.     case 25:    i_ptr->tchar = '\\'; break;
  289.     case 30:    i_ptr->tchar = ']'; break;
  290.     case 31:    i_ptr->tchar = ']'; break;
  291.     case 32:    i_ptr->tchar = '('; break;
  292.     case 33:    i_ptr->tchar = ']'; break;
  293.     case 34:    i_ptr->tchar = ')'; break;
  294.     case 35:    i_ptr->tchar = '['; break;
  295.     case 36:    i_ptr->tchar = '('; break;
  296.     case 40:    i_ptr->tchar = '\''; break;
  297.     case 45:    i_ptr->tchar = '='; break;
  298.     case 55:    i_ptr->tchar = '_'; break;
  299.     case 60:    i_ptr->tchar = '-'; break;
  300.     case 65:    i_ptr->tchar = '-'; break;
  301.     case 70: case 71:    i_ptr->tchar = '?'; break;
  302.     case 75: case 76: case 77:    i_ptr->tchar = '!'; break;
  303.     case 80:    i_ptr->tchar = ','; break;
  304.     case 90:    i_ptr->tchar = '?'; break;
  305.     case 91:    i_ptr->tchar = '?'; break;
  306.     default:    flag = FALSE; break;
  307.     }
  308.     }
  309.   while (!flag);
  310.   i_ptr->tval = tmp_val;
  311.   prt("Subval : ", 0, 0);
  312.   (void) get_string(tmp_str, 0, 9, 10);
  313.   tmp_val = 1;
  314.   (void) sscanf(tmp_str, "%d", &tmp_val);
  315.   i_ptr->subval = tmp_val;
  316.   prt("Weight : ", 0, 0);
  317.   (void) get_string(tmp_str, 0, 9, 10);
  318.   tmp_val = 1;
  319.   (void) sscanf(tmp_str, "%d", &tmp_val);
  320.   i_ptr->weight = tmp_val;
  321.   prt("Number : ", 0, 0);
  322.   (void) get_string(tmp_str, 0, 9, 10);
  323.   tmp_val = 1;
  324.   (void) sscanf(tmp_str, "%d", &tmp_val);
  325.   i_ptr->number = tmp_val;
  326.   prt("Damage : ", 0, 0);
  327.   (void) get_string(tmp_str, 0, 9, 5);
  328.   (void) strcpy(i_ptr->damage, tmp_str);
  329.   prt("+To hit: ", 0, 0);
  330.   (void) get_string(tmp_str, 0, 9, 10);
  331.   tmp_val = 0;
  332.   (void) sscanf(tmp_str, "%d", &tmp_val);
  333.   i_ptr->tohit = tmp_val;
  334.   prt("+To dam: ", 0, 0);
  335.   (void) get_string(tmp_str, 0, 9, 10);
  336.   tmp_val = 0;
  337.   (void) sscanf(tmp_str, "%d", &tmp_val);
  338.   i_ptr->todam = tmp_val;
  339.   prt("AC     : ", 0, 0);
  340.   (void) get_string(tmp_str, 0, 9, 10);
  341.   tmp_val = 0;
  342.   (void) sscanf(tmp_str, "%d", &tmp_val);
  343.   i_ptr->ac = tmp_val;
  344.   prt("+To AC : ", 0, 0);
  345.   (void) get_string(tmp_str, 0, 9, 10);
  346.   tmp_val = 0;
  347.   (void) sscanf(tmp_str, "%d", &tmp_val);
  348.   i_ptr->toac = tmp_val;
  349.   prt("P1     : ", 0, 0);
  350.   (void) get_string(tmp_str, 0, 9, 10);
  351.   tmp_val = 0;
  352.   (void) sscanf(tmp_str, "%d", &tmp_val);
  353.   i_ptr->p1 = tmp_val;
  354.   prt("Flags (In HEX): ", 0, 0);
  355.   i_ptr->flags = get_hex_value(0, 16, 8);
  356.   prt("Cost : ", 0, 0);
  357.   (void) get_string(tmp_str, 0, 9, 10);
  358.   tmp_val = 0;
  359.   (void) sscanf(tmp_str, "%d", &tmp_val);
  360.   i_ptr->cost = tmp_val;
  361.  
  362.   prt("Level : ", 0, 0);
  363.   (void) get_string(tmp_str, 0, 10, 10);
  364.   tmp_val = 0;
  365.   (void) sscanf(tmp_str, "%d", &tmp_val);
  366.   i_ptr->level = tmp_val;
  367.  
  368.   if (get_com("Allocate? (Y/N)", &command))
  369.     switch(command)
  370.       {
  371.       case 'y': case 'Y':
  372.     popt(&tmp_val);
  373.     t_list[tmp_val] = inventory[INVEN_MAX];
  374.     c_ptr = &cave[char_row][char_col];
  375.     if (c_ptr->tptr != 0)
  376.       (void) delete_object(char_row, char_col);
  377.     c_ptr->tptr = tmp_val;
  378.     msg_print("Allocated...");
  379.     break;
  380.       default:
  381.     msg_print("Aborted...");
  382.     break;
  383.       }
  384.   inventory[INVEN_MAX] = blank_treasure;
  385. }
  386.