[comp.sources.games] v05i049: umoria2 - single player dungeon simulation

games@tekred.TEK.COM (07/29/88)

Submitted by: "James E. Wilson" <wilson@ji.berkeley.edu>
Comp.sources.games: Volume 5, Issue 49
Archive-name: umoria2/Part15



#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 15 (of 18)."
# Contents:  create.c files.c scrolls.c
# Wrapped by billr@saab on Wed Jul 13 11:16:34 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'create.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'create.c'\"
else
echo shar: Extracting \"'create.c'\" \(11911 characters\)
sed "s/^X//" >'create.c' <<'END_OF_FILE'
X#include <stdio.h>
X
X#include "constants.h"
X#include "config.h"
X#include "types.h"
X#include "externs.h"
X
X#ifdef USG
X#include <string.h>
X#else
X#include <strings.h>
X#endif
X
X#ifdef sun   /* correct SUN stupidity in the stdio.h file */
Xchar *sprintf();
X#endif
X
X#ifdef USG
Xunsigned sleep();
X#endif
X
X#ifdef ultrix
Xvoid sleep();
X#endif
X
X/* Generates character's stats				-JWT-	*/
Xint get_stat()
X{
X  register int i;
X
X  i = randint(4) + randint(4) + randint(4) + 5;
X  return(i);
X}
X
X
X/* Changes stats by given amount				-JWT-	*/
Xbyteint change_stat(cur_stat, amount)
Xbyteint cur_stat;
Xint amount;
X{
X  register int i;
X
X  if (amount < 0)
X    for (i = 0; i > amount; i--)
X      cur_stat = de_statp(cur_stat);
X  else
X    for (i = 0; i < amount; i++)
X      cur_stat = in_statp(cur_stat);
X  return(cur_stat);
X}
X
X
X/* generate all stats and modify for race... needed in a separate module so
X   looping of character selection would be allowed     -RGM- */
Xvoid get_stats ()
X{
X  register player_type *p_ptr;
X  register race_type *r_ptr;
X
X  p_ptr = &py;
X  r_ptr = &race[p_ptr->misc.prace];
X  p_ptr->stats.str    = get_stat();
X  p_ptr->stats.intel  = get_stat();
X  p_ptr->stats.wis    = get_stat();
X  p_ptr->stats.dex    = get_stat();
X  p_ptr->stats.con    = get_stat();
X  p_ptr->stats.chr    = get_stat();
X  p_ptr->stats.str    = change_stat(p_ptr->stats.str, r_ptr->str_adj);
X  p_ptr->stats.intel  = change_stat(p_ptr->stats.intel, r_ptr->int_adj);
X  p_ptr->stats.wis    = change_stat(p_ptr->stats.wis, r_ptr->wis_adj);
X  p_ptr->stats.dex    = change_stat(p_ptr->stats.dex, r_ptr->dex_adj);
X  p_ptr->stats.con    = change_stat(p_ptr->stats.con, r_ptr->con_adj);
X  p_ptr->stats.chr    = change_stat(p_ptr->stats.chr, r_ptr->chr_adj);
X  p_ptr->stats.cstr   = p_ptr->stats.str;
X  p_ptr->stats.cint   = p_ptr->stats.intel;
X  p_ptr->stats.cwis   = p_ptr->stats.wis;
X  p_ptr->stats.cdex   = p_ptr->stats.dex;
X  p_ptr->stats.ccon   = p_ptr->stats.con;
X  p_ptr->stats.cchr   = p_ptr->stats.chr;
X  p_ptr->misc.srh    = r_ptr->srh;
X  p_ptr->misc.bth    = r_ptr->bth;
X  p_ptr->misc.bthb   = r_ptr->bthb;
X  p_ptr->misc.fos    = r_ptr->fos;
X  p_ptr->misc.stl    = r_ptr->stl;
X  p_ptr->misc.save   = r_ptr->bsav;
X  p_ptr->misc.hitdie = r_ptr->bhitdie;
X  p_ptr->misc.lev    = 1;
X  p_ptr->misc.ptodam = todam_adj();
X  p_ptr->misc.ptohit = tohit_adj();
X  p_ptr->misc.ptoac  = 0;
X  p_ptr->misc.pac    = toac_adj();
X  p_ptr->misc.expfact = r_ptr->b_exp;
X  p_ptr->flags.see_infra = r_ptr->infra;
X}
X
X
X/* Allows player to select a race			-JWT-	*/
Xint choose_race()
X{
X  register int j, k;
X  int l, m;
X  char s;
X  int exit_flag;
X  char tmp_str[80];
X  register player_type *p_ptr;
X  register race_type *r_ptr;
X  int res;
X
X  j = 0;
X  k = 0;
X  l = 2;
X  m = 21;
X  clear_screen(20, 0);
X/*  help is unimplemented */
X/*  prt("Choose a race (? for Help):", 20, 2); */
X  prt("Choose a race:", 20, 2);
X  do
X    {
X      (void) sprintf(tmp_str, "%c) %s", k+97, race[j].trace);
X      put_buffer(tmp_str, m, l);
X      k++;
X      l += 15;
X      if (l > 70)
X	{
X	  l = 2;
X	  m++;
X	}
X      j++;
X    }
X  while (j < MAX_RACES);
X  /* clear race string */
X  py.misc.race[0] = '\0';
X  move_cursor (20, 18);
X  exit_flag = FALSE;
X  do
X    {
X      inkey(&s);
X      j = s - 97;
X      if ((j < MAX_RACES) && (j >= 0))
X	{
X	  p_ptr = &py;
X	  r_ptr = &race[j];
X	  p_ptr->misc.prace  = j;
X	  (void) strcpy(p_ptr->misc.race, r_ptr->trace);
X	  get_stats();                  /* We don't need the code twice. */
X	  exit_flag = TRUE;             /* so use function get_stats -RGM- */
X	  res = TRUE;
X	  put_buffer(py.misc.race, 3, 14);
X	}
X    }
X  while (!exit_flag);
X  return(res);
X}
X
X
X/* Will print the history of a character			-JWT-	*/
Xprint_history()
X{
X  register int i;
X
X  put_buffer("Character Background", 13, 27);
X  for(i = 0; i < 5; i++)
X    put_buffer(py.misc.history[i], i+14, 4);
X}
X
X
X/* Get the racial history, determines social class	-RAK-	*/
X/* Assumptions:	Each race has init history beginning at 	*/
X/*		(race-1)*3+1					*/
X/*		All history parts are in ascending order	*/
Xget_history()
X{
X  int hist_ptr, cur_ptr, test_roll;
X  register int start_pos, end_pos, cur_len;
X  int line_ctr, new_start, social_class;
X  char history_block[400];
X  vtype tmp_str;
X  int flag;
X  register background_type *b_ptr;
X
X  /* Get a block of history text				*/
X  hist_ptr = py.misc.prace*3 + 1;
X  history_block[0] = '\0';
X  social_class = randint(4);
X  cur_ptr = 0;
X  do
X    {
X      flag = FALSE;
X      do
X	{
X	  if (background[cur_ptr].chart == hist_ptr)
X	    {
X	      test_roll = randint(100);
X	      while (test_roll > background[cur_ptr].roll)
X		cur_ptr++;
X	      b_ptr = &background[cur_ptr];
X	      (void) strcat(history_block, b_ptr->info);
X	      social_class += b_ptr->bonus;
X	      if (hist_ptr > b_ptr->next)
X		cur_ptr = 0;
X	      hist_ptr = b_ptr->next;
X	      flag = TRUE;
X	    }
X	  else
X	    cur_ptr++;
X	}
X      while (!flag);
X    }
X  while (hist_ptr >= 1);
X
X  /* Process block of history text for pretty output	*/
X  start_pos = 0;
X  end_pos   = strlen(history_block) - 1;
X  line_ctr  = 0;
X  flag = FALSE;
X  while (history_block[end_pos] == ' ')
X    end_pos--;
X  do
X    {
X      while (history_block[start_pos] == ' ')
X	start_pos++;
X      cur_len = end_pos - start_pos + 1;
X      if (cur_len > 70)
X	{
X	  cur_len = 70;
X	  while (history_block[start_pos+cur_len-1] != ' ')
X	    cur_len--;
X	  new_start = start_pos + cur_len;
X	  while (history_block[start_pos+cur_len-1] == ' ')
X	    cur_len--;
X	}
X      else
X	flag = TRUE;
X      (void) strncpy(tmp_str, &history_block[start_pos], cur_len);
X      tmp_str[cur_len] = '\0';
X      (void) strcpy(py.misc.history[line_ctr], tmp_str);
X      line_ctr++;
X      start_pos = new_start;
X    }
X  while (!flag);
X
X  /* Compute social class for player			*/
X  if (social_class > 100)
X    social_class = 100;
X  else if (social_class < 1)
X    social_class = 1;
X  py.misc.sc = social_class;
X}
X
X
X/* Gets the character's sex				-JWT-	*/
Xint get_sex()
X{
X  char s;
X  int exit_flag;
X  int sex;
X
X  py.misc.sex[0] = '\0';
X  clear_screen(20, 0);
X/* help is unimplemented */
X/*  prt("Choose a sex (? for Help):", 20, 2); */
X  prt("Choose a sex:", 20, 2);
X  prt("m) Male       f) Female", 21, 2);
X  move_cursor (20, 16);
X  do
X    {
X      inkey(&s);
X      switch(s)
X	{
X	case 'f': case 'F':
X	  (void) strcpy(py.misc.sex, "Female");
X	  prt(py.misc.sex, 4, 14);
X	  exit_flag = TRUE;
X	  sex = TRUE;
X	  break;
X	case 'm': case 'M':
X	  (void) strcpy(py.misc.sex, "Male");
X	  prt(py.misc.sex, 4, 14);
X	  exit_flag = TRUE;
X	  sex = TRUE;
X	  break;
X	default:
X	  sex = FALSE;
X	  exit_flag = FALSE;
X	  break;
X	}
X    }
X  while (!exit_flag);
X  return(sex);
X}
X
X
X/* Computes character's age, height, and weight		-JWT-	*/
Xget_ahw()
X{
X  register int i;
X
X  i = py.misc.prace;
X  py.misc.age = race[i].b_age + randint((int)race[i].m_age);
X  switch(py.misc.sex[0])
X    {
X    case 'F': case 'f':
X      py.misc.ht = randnor((int)race[i].f_b_ht, (int)race[i].f_m_ht);
X      py.misc.wt = randnor((int)race[i].f_b_wt, (int)race[i].f_m_wt);
X      break;
X    case 'M': case 'm':
X      py.misc.ht = randnor((int)race[i].m_b_ht, (int)race[i].m_m_ht);
X      py.misc.wt = randnor((int)race[i].m_b_wt, (int)race[i].m_m_wt);
X      break;
X    }
X  py.misc.disarm = race[i].b_dis + todis_adj();
X}
X
X
X/* Gets a character class				-JWT-	*/
Xint get_class()
X{
X  register int i, j;
X  int k, l, m;
X  int cl[MAX_CLASS];
X  char s;
X  int exit_flag;
X  int res;
X  register struct misc *m_ptr;
X  register player_type *p_ptr;
X  char tmp_str[80];
X
X  for (j = 0; j < MAX_CLASS; j++)
X    cl[j] = 0;
X  i = py.misc.prace;
X  j = 0;
X  k = 0;
X  l = 2;
X  m = 21;
X  clear_screen(20, 0);
X/* help is unimplemented */
X/* prt("Choose a class (? for Help):", 20, 2); */
X  prt("Choose a class:", 20, 2);
X  do
X    {
X      if (race[i].tclass & bit_array[j])
X	{
X	  (void) sprintf(tmp_str, "%c) %s", k+97, class[j].title);
X	  put_buffer(tmp_str, m, l);
X	  cl[k] = j;
X	  l += 15;
X	  if (l > 70)
X	    {
X	      l = 2;
X	      m++;
X	    }
X	  k++;
X	}
X      j++;
X    }
X  while (j < MAX_CLASS);
X  py.misc.pclass = 0;
X  move_cursor (20, 19);
X  exit_flag = FALSE;
X  do
X    {
X      inkey(&s);
X      j = s - 97;
X      if ((j < k) && (j >= 0))
X	{
X	  (void) strcpy(py.misc.tclass, class[cl[j]].title);
X	  py.misc.pclass = cl[j];
X	  exit_flag = TRUE;
X	  res = TRUE;
X	  clear_screen(20, 0);
X	  put_buffer(py.misc.tclass, 5, 14);
X
X	  /* Adjust the stats for the class adjustment		-RAK-	*/
X	  p_ptr = &py;
X	  p_ptr->stats.str  = change_stat(p_ptr->stats.str,
X					 class[p_ptr->misc.pclass].madj_str);
X	  p_ptr->stats.intel= change_stat(p_ptr->stats.intel,
X					 class[p_ptr->misc.pclass].madj_int);
X	  p_ptr->stats.wis  = change_stat(p_ptr->stats.wis,
X					 class[p_ptr->misc.pclass].madj_wis);
X	  p_ptr->stats.dex  = change_stat(p_ptr->stats.dex,
X					 class[p_ptr->misc.pclass].madj_dex);
X	  p_ptr->stats.con  = change_stat(p_ptr->stats.con,
X					 class[p_ptr->misc.pclass].madj_con);
X	  p_ptr->stats.chr  = change_stat(p_ptr->stats.chr,
X					 class[p_ptr->misc.pclass].madj_chr);
X	  p_ptr->stats.cstr = p_ptr->stats.str;
X	  p_ptr->stats.cint = p_ptr->stats.intel;
X	  p_ptr->stats.cwis = p_ptr->stats.wis;
X	  p_ptr->stats.cdex = p_ptr->stats.dex;
X	  p_ptr->stats.ccon = p_ptr->stats.con;
X	  p_ptr->stats.cchr = p_ptr->stats.chr;
X	  p_ptr->misc.ptodam = todam_adj();	/* Real values		*/
X	  p_ptr->misc.ptohit = tohit_adj();
X	  p_ptr->misc.ptoac  = toac_adj();
X	  p_ptr->misc.pac    = 0;
X	  p_ptr->misc.dis_td = p_ptr->misc.ptodam; /* Displayed values	*/
X	  p_ptr->misc.dis_th = p_ptr->misc.ptohit;
X	  p_ptr->misc.dis_tac= p_ptr->misc.ptoac;
X	  p_ptr->misc.dis_ac = p_ptr->misc.pac;
X
X	  /* now set misc stats, do this after setting stats because
X	     of con_adj() for hitpoints */
X	  m_ptr = &py.misc;
X	  m_ptr->hitdie += class[m_ptr->pclass].adj_hd;
X	  m_ptr->mhp = con_adj() + m_ptr->hitdie;
X	  m_ptr->chp = (double)m_ptr->mhp;
X	  m_ptr->bth += class[m_ptr->pclass].mbth;
X	  m_ptr->bthb += class[m_ptr->pclass].mbthb;	/*RAK*/
X	  m_ptr->srh += class[m_ptr->pclass].msrh;
X	  m_ptr->disarm += class[m_ptr->pclass].mdis;
X	  m_ptr->fos += class[m_ptr->pclass].mfos;
X	  m_ptr->stl += class[m_ptr->pclass].mstl;
X	  m_ptr->save += class[m_ptr->pclass].msav;
X	  (void) strcat(m_ptr->title, player_title[m_ptr->pclass][0]);
X	  m_ptr->expfact += class[m_ptr->pclass].m_exp;
X
X	}
X    }
X  while (!exit_flag);
X  return(res);
X}
X
X
Xget_money()
X{
X  register int tmp;
X  register struct stats *p_ptr;
X  register struct misc *m_ptr;
X
X  p_ptr = &py.stats;
X  tmp = p_ptr->cstr + p_ptr->cint + p_ptr->cwis +
X    p_ptr->cdex + p_ptr->ccon + p_ptr->cchr;
X  m_ptr = &py.misc;
X  m_ptr->au = m_ptr->sc*6 + randint(25) + 325;	/* Social Class adj	*/
X  m_ptr->au = m_ptr->au - tmp;			/* Stat adj		*/
X  m_ptr->au = m_ptr->au + p_ptr->cchr;		/* Charisma adj	*/
X  if (m_ptr->au < 80)  m_ptr->au = 80;		/* Minimum		*/
X}
X
X
X/* ---------- M A I N  for Character Creation Routine ---------- */
X/*							-JWT-	*/
Xcreate_character()
X{
X  char s;
X  register int exit_flag = 1;
X
X  put_character();
X  (void) choose_race();
X  (void) get_sex();
X
X  /* here we start a loop giving a player a choice of characters -RGM- */
X  get_stats ();
X  get_history();
X  get_ahw();
X  put_character();
X  print_history();
X  put_misc1();
X  put_stats();
X  exit_flag = 1;
X  do
X    {
X      prt("Hit space to reroll or ESC to accept characteristics: ", 20, 2);
X      inkey(&s);
X      switch (s)
X	{
X	case 27:
X	  exit_flag = 0;
X	  break;
X	case ' ':
X	  get_stats ();
X	  get_history();
X	  get_ahw();
X	  put_character();
X	  print_history();
X	  put_misc1();
X	  put_stats();
X#ifdef SLOW
X	  (void) sleep (0);
X#endif	  
X	  break;
X	default:
X	  break;
X	}
X    }               /* done with stats generation */
X  while (exit_flag == 1);
X
X  (void) get_class();
X  get_money();
X  put_stats();
X  put_misc2();
X  put_misc3();
X  get_name();
X
X  /* This delay may be reduced, but is recommended to keep players	*/
X  /* from continuously rolling up characters, which can be VERY	*/
X  /* expensive CPU wise.						*/
X  pause_exit(23, PLAYER_EXIT_PAUSE);
X}
X
END_OF_FILE
if test 11911 -ne `wc -c <'create.c'`; then
    echo shar: \"'create.c'\" unpacked with wrong size!
fi
# end of 'create.c'
fi
if test -f 'files.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'files.c'\"
else
echo shar: Extracting \"'files.c'\" \(26055 characters\)
sed "s/^X//" >'files.c' <<'END_OF_FILE'
X#include <stdio.h>
X
X#include "constants.h"
X#include "config.h"
X#include "types.h"
X#include "externs.h"
X
X#ifdef USG
X#include <string.h>
X#include <fcntl.h>
X#else
X#include <strings.h>
X#include <sys/file.h>
X#endif
X
X#ifdef sun   /* correct SUN stupidity in the stdio.h file */
Xchar *sprintf();
X#endif
X
X#if defined(ultrix) || defined(USG)
Xvoid exit();
X#endif
X
X/*
X *  init_scorefile
X *  Open the score file while we still have the setuid privileges.  Later
X *  when the score is being written out, you must be sure to flock the file
X *  so we don't have multiple people trying to write to it at the same time.
X *  Craig Norborg (doc)		Mon Aug 10 16:41:59 EST 1987
X */
Xinit_scorefile()
X{
X  if (1 > (highscore_fd = open(MORIA_TOP, O_RDWR | O_CREAT, 0644)))
X    {
X      (void) fputs("Can't open score file!\n", stderr);
X      exit(1);
X    }
X}
X
X/* Attempt to open the intro file			-RAK-	 */
X/* This routine also checks the hours file vs. what time it is	-Doc */
Xintro(finam)
Xchar *finam;
X{
X  register int xpos, i;
X  vtype in_line;
X  FILE *file1;
X  register char *string;
X
X  /* Attempt to read hours.dat.  If it does not exist,     */
X  /* inform the user so he can tell the wizard about it	 */
X  if ((file1 = fopen(MORIA_HOU, "r")) != NULL)
X    {
X      while (fgets(in_line, 80, file1) != NULL)
X	if (strlen(in_line) > 3)
X	  {
X	    if (!strncmp(in_line, "SUN:", 4))
X	      (void) strcpy(days[0], in_line);
X	    else if (!strncmp(in_line, "MON:", 4))
X	      (void) strcpy(days[1], in_line);
X	    else if (!strncmp(in_line, "TUE:", 4))
X	      (void) strcpy(days[2], in_line);
X	    else if (!strncmp(in_line, "WED:", 4))
X	      (void) strcpy(days[3], in_line);
X	    else if (!strncmp(in_line, "THU:", 4))
X	      (void) strcpy(days[4], in_line);
X	    else if (!strncmp(in_line, "FRI:", 4))
X	      (void) strcpy(days[5], in_line);
X	    else if (!strncmp(in_line, "SAT:", 4))
X	      (void) strcpy(days[6], in_line);
X	  }
X      (void) fclose(file1);
X    }
X  else
X    {
X      (void) fprintf(stderr, "There is no hours file.\nPlease inform the wizard, %s, so he can correct this!\n", WIZARD);
X      exit_game();
X    }
X
X  /* Check the hours, if closed  require password	 */
X  string = index(finam, '^');
X  if (string)
X    xpos = strlen(finam) - strlen(string);
X  else
X    xpos = -1;
X  if (xpos >= 0)
X    if (check_pswd())
X      insert_str(finam, "^", "");
X  if (!check_time())
X    {
X      if (!wizard1)
X	{
X	  if ((file1 = fopen(MORIA_HOU, "r")) != NULL)
X	    {
X	      clear_screen(0, 0);
X	      for (i = 0; fgets(in_line, 80, file1) != NULL; i++)
X		prt(in_line, i, 0);
X	      (void) fclose(file1);
X	    }
X	  exit_game();
X	}
X    }
X
X  /* Print the introduction message, news, ect...		 */
X  if ((file1 = fopen(MORIA_MOR, "r")) != NULL)
X    {
X      clear_screen(0, 0);
X      for (i = 0; fgets(in_line, 80, file1) != NULL; i++)
X	prt(in_line, i, 0);
X      pause_line(23);
X      (void) fclose(file1);
X    }
X}
X
X
X/* Prints dungeon map to external file			-RAK-	 */
Xprint_map()
X{
X  register int i, j, m, n;
X  register k, l;
X  register i7, i8;
X  char dun_line[MAX_WIDTH];
X  char *dun_ptr;
X  vtype filename1;
X  char tmp_str[80];
X  FILE *file1;
X  int page_width = OUTPAGE_WIDTH;
X  int page_height = OUTPAGE_HEIGHT;
X
X  /* this allows us to strcat each character in the inner loop,
X     instead of using the expensive sprintf */
X  prt("File name: ", 0, 0);
X  if (get_string(filename1, 0, 11, 64))
X    {
X      if (strlen(filename1) == 0)
X	(void) strcpy(filename1, "MORIAMAP.DAT");
X      if ((file1 = fopen(filename1, "w")) == NULL)
X	{
X	  (void) sprintf(dun_line, "Cannot open file %s", filename1);
X	  prt(dun_line, 0, 0);
X	  put_qio();
X	  return;
X	}
X      (void) sprintf(tmp_str, "section width (default = %d char):", page_width);
X      prt(tmp_str, 0, 0);
X      (void) get_string(tmp_str, 0, strlen(tmp_str), 10);
X      (void) sscanf(tmp_str, "%d", &page_width);
X      if (page_width < 10)
X	page_width = 10;
X
X      (void) sprintf(tmp_str, "section height (default = %d lines):", page_height);
X      prt(tmp_str, 0, 0);
X      (void) get_string(tmp_str, 0, strlen(tmp_str), 10);
X      (void) sscanf(tmp_str, "%d", &page_height);
X      if (page_height < 10)
X	page_height = 10;
X
X      prt("Writing Moria Dungeon Map...", 0, 0);
X      put_qio();
X
X      i = 0;
X      i7 = 0;
X      do
X	{
X	  j = 0;
X	  k = i + page_height - 1;
X	  if (k >= cur_height)
X	    k = cur_height - 1;
X	  i7++;
X	  i8 = 0;
X	  do
X	    {
X	      l = j + page_width - 1;
X	      if (l >= cur_width)
X		l = cur_width - 1;
X	      i8++;
X	      (void) fprintf(file1, "%c\n", 12);
X	      (void) fprintf(file1, "Section[%d,%d];     ", i7, i8);
X	      (void) fprintf(file1, "Depth : %d (feet)\n\n   ",
X			     (dun_level * 50));
X	      for (m = j; m <= l; m++)
X		{
X		  n = (m / 100);
X		  (void) fprintf(file1, "%d", n);
X		}
X	      (void) fputs("\n   ", file1);
X	      for (m = j; m <= l; m++)
X		{
X		  n = (m / 10) - (m / 100) * 10;
X		  (void) fprintf(file1, "%d", n);
X		}
X	      (void) fputs("\n   ", file1);
X	      for (m = j; m <= l; m++)
X		{
X		  n = m - (m / 10) * 10;
X		  (void) fprintf(file1, "%d", n);
X		}
X	      (void) fprintf(file1, "\n");
X	      for (m = i; m <= k; m++)
X		{
X		  (void) sprintf(dun_line, "%2d ", m);
X		  dun_ptr = &dun_line[3];
X		  for (n = j; n <= l; n++)
X		    {
X		      if (test_light(m, n))
X			loc_symbol(m, n, dun_ptr++);
X		      else
X			*dun_ptr++ = ' ';
X		    }
X		  *dun_ptr++ = '\n';
X		  (void) fputs(dun_line, file1);
X		}
X	      j += page_width;
X	    }
X	  while (j < cur_width);
X	  i += page_height;
X	}
X      while (i < cur_height);
X      (void) fclose(file1);
X      prt("Completed.", 0, 0);
X    }
X}
X
X
X/* Prints a list of random objects to a file.  Note that -RAK-	 */
X/* the objects produced is a sampling of objects which           */
X/* be expected to appear on that level.                          */
Xprint_objects()
X{
X  register int i;
X  int nobj, j, level;
X  vtype filename1, tmp_str;
X  register FILE *file1;
X  register treasure_type *i_ptr;
X
X  prt("Produce objects on what level?: ", 0, 0);
X  level = 0;
X  if (get_string(tmp_str, 0, 32, 10))
X    (void) sscanf(tmp_str, "%d", &level);
X  prt("Produce how many objects?: ", 0, 0);
X  nobj = 0;
X  if (get_string(tmp_str, 0, 27, 10))
X    (void) sscanf(tmp_str, "%d", &nobj);
X  if ((nobj > 0) && (level > -1) && (level < 1201))
X    {
X      if (nobj > 9999)
X	nobj = 9999;
X      prt("File name: ", 0, 0);
X      if (get_string(filename1, 0, 11, 64))
X	{
X	  if (strlen(filename1) == 0)
X	    (void) strcpy(filename1, "MORIAOBJ.DAT");
X	  if ((file1 = fopen(filename1, "w")) != NULL)
X	    {
X	      (void) sprintf(tmp_str, "%d", nobj);
X	      prt(strcat(tmp_str, " random objects being produced..."), 0, 0);
X	      put_qio();
X	      (void) fprintf(file1, "*** Random Object Sampling:\n");
X	      (void) fprintf(file1, "*** %d objects\n", nobj);
X	      (void) fprintf(file1, "*** For Level %d\n", level);
X	      (void) fprintf(file1, "\n");
X	      (void) fprintf(file1, "\n");
X	      popt(&j);
X	      for (i = 0; i < nobj; i++)
X		{
X		  t_list[j] = object_list[get_obj_num(level)];
X		  magic_treasure(j, level);
X		  inventory[INVEN_MAX] = t_list[j];
X		  i_ptr = &inventory[INVEN_MAX];
X		  unquote(i_ptr->name);
X		  known1(i_ptr->name);
X		  known2(i_ptr->name);
X		  objdes(tmp_str, INVEN_MAX, TRUE);
X		  (void) fprintf(file1, "%s\n", tmp_str);
X		}
X	      pusht(j);
X	      (void) fclose(file1);
X	      prt("Completed.", 0, 0);
X	    }
X	  else
X	    prt("File could not be opened.", 0, 0);
X	}
X    }
X}
X
X
X/* Prints a listing of monsters				-RAK-	 */
Xprint_monsters()
X{
X  register int i;
X  int j, xpos, attype, adesc;
X  register FILE *file1;
X  vtype out_val, filename1;
X  vtype attstr, attx;
X  dtype damstr;
X  register creature_type *c_ptr;
X  register char *string;
X
X  prt("File name: ", 0, 0);
X  if (get_string(filename1, 0, 11, 64))
X    {
X      if (strlen(filename1) == 0)
X	(void) strcpy(filename1, "MORIAMON.DAT");
X      if ((file1 = fopen(filename1, "w")) != NULL)
X	{
X	  prt("Writing Monster Dictionary...", 0, 0);
X	  put_qio();
X	  for (i = 0; i < MAX_CREATURES; i++)
X	    {
X	      c_ptr = &c_list[i];
X	      /* Begin writing to file                                 */
X	      (void) fprintf(file1, "--------------------------------------------\n");
X	      (void) strcpy(out_val, c_ptr->name);
X	      (void) strcat(out_val, "                              ");
X	      (void) fprintf(file1, "%d  %s     (%c)\n", i, out_val, c_ptr->cchar);
X	      (void) fprintf(file1, "     Speed ==%d  Level     ==%d  Exp ==%d\n",
X		      c_ptr->speed, c_ptr->level, (int)c_ptr->mexp);
X	      (void) fprintf(file1, "     AC    ==%d  Eye-sight ==%d  HD  ==%s\n",
X		      c_ptr->ac, c_ptr->aaf, c_ptr->hd);
X	      if (0x80000000 & c_ptr->cmove)
X		(void) fprintf(file1, "     Creature is a ***Win Creature***\n");
X	      if (0x00080000 & c_ptr->cmove)
X		(void) fprintf(file1, "     Creature Eats/kills other creatures.\n");
X	      if (0x0001 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature is a dragon.\n");
X	      if (0x0002 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature is a monster.\n");
X	      if (0x0004 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature is evil.\n");
X	      if (0x0008 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature is undead.\n");
X	      if (0x0010 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature harmed by cold.\n");
X	      if (0x0020 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature harmed by fire.\n");
X	      if (0x0040 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature harmed by poison.\n");
X	      if (0x0080 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature harmed by acid.\n");
X	      if (0x0100 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature harmed by blue light.\n");
X	      if (0x0200 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature harmed by Stone-to-Mud.\n");
X	      if (0x1000 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature cannot be charmed or slept.\n");
X	      if (0x2000 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature seen with Infra-Vision.\n");
X	      if (0x4000 & c_ptr->cdefense)
X		(void) fprintf(file1, "     Creature has MAX hit points.\n");
X	      if (0x00010000 & c_ptr->cmove)
X		(void) fprintf(file1, "     Creature is invisible.\n");
X	      if (0x00100000 & c_ptr->cmove)
X		(void) fprintf(file1, "     Creature picks up objects.\n");
X	      if (0x00200000 & c_ptr->cmove)
X		(void) fprintf(file1, "     Creature multiplies.\n");
X	      if (0x01000000 & c_ptr->cmove)
X		(void) fprintf(file1, "     Carries object(s).\n");
X	      if (0x02000000 & c_ptr->cmove)
X		(void) fprintf(file1, "     Carries gold, gems, etc.\n");
X	      if (0x04000000 & c_ptr->cmove)
X		(void) fprintf(file1, "       Has object/gold 60%% of time.\n");
X	      if (0x08000000 & c_ptr->cmove)
X		(void) fprintf(file1, "       Has object/gold 90%% of time.\n");
X	      if (0x10000000 & c_ptr->cmove)
X		(void) fprintf(file1, "       Has 1d2 object(s)/gold.\n");
X	      if (0x20000000 & c_ptr->cmove)
X		(void) fprintf(file1, "       Has 2d2 object(s)/gold.\n");
X	      if (0x40000000 & c_ptr->cmove)
X		(void) fprintf(file1, "       Has 4d2 object(s)/gold.\n");
X	      /*
X	       * Creature casts spells / Breathes Dragon
X	       * breath...
X	       */
X	      if (c_ptr->spells != 0)
X		{
X		  (void) fprintf(file1, "   --Spells/Dragon Breath ==\n");
X		  (void) fprintf(file1, "       Casts spells 1 out of %d turns.\n",
X			  (int)(0xF & c_ptr->spells));
X		  if (0x00000010 & c_ptr->spells)
X		    (void) fprintf(file1, "       Can teleport short.\n");
X		  if (0x00000020 & c_ptr->spells)
X		    (void) fprintf(file1, "       Can teleport long.\n");
X		  if (0x00000040 & c_ptr->spells)
X		    (void) fprintf(file1, "       Teleport player to itself.\n");
X		  if (0x00000080 & c_ptr->spells)
X		    (void) fprintf(file1, "       Cause light wounds.\n");
X		  if (0x00000100 & c_ptr->spells)
X		    (void) fprintf(file1, "       Cause serious wounds.\n");
X		  if (0x00000200 & c_ptr->spells)
X		    (void) fprintf(file1, "       Hold person.\n");
X		  if (0x00000400 & c_ptr->spells)
X		    (void) fprintf(file1, "       Cause blindness.\n");
X		  if (0x00000800 & c_ptr->spells)
X		    (void) fprintf(file1, "       Cause confusion.\n");
X		  if (0x00001000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Cause fear.\n");
X		  if (0x00002000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Summon a monster.\n");
X		  if (0x00004000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Summon an undead.\n");
X		  if (0x00008000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Slow person.\n");
X		  if (0x00010000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Drains mana for healing.\n");
X		  if (0x00020000 & c_ptr->spells)
X		    (void) fprintf(file1, "       **Unknown spell value**\n");
X		  if (0x00040000 & c_ptr->spells)
X		    (void) fprintf(file1, "       **Unknown spell value**\n");
X		  if (0x00080000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Breathes Lightning Dragon Breath.\n");
X		  if (0x00100000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Breathes Gas Dragon Breath.\n");
X		  if (0x00200000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Breathes Acid Dragon Breath.\n");
X		  if (0x00400000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Breathes Frost Dragon Breath.\n");
X		  if (0x00800000 & c_ptr->spells)
X		    (void) fprintf(file1, "       Breathes Fire Dragon Breath.\n");
X		}
X	      /* Movement for creature                                 */
X	      (void) fprintf(file1, "   --Movement ==\n");
X	      if (0x00000001 & c_ptr->cmove)
X		(void) fprintf(file1, "       Move only to attack.\n");
X	      if (0x00000002 & c_ptr->cmove)
X		(void) fprintf(file1, "       Move and attack normally.\n");
X	      if (0x00000008 & c_ptr->cmove)
X		(void) fprintf(file1, "       20%% random movement.\n");
X	      if (0x00000010 & c_ptr->cmove)
X		(void) fprintf(file1, "       40%% random movement.\n");
X	      if (0x00000020 & c_ptr->cmove)
X		(void) fprintf(file1, "       75%% random movement.\n");
X	      if (0x00020000 & c_ptr->cmove)
X		(void) fprintf(file1, "       Can open doors.\n");
X	      if (0x00040000 & c_ptr->cmove)
X		(void) fprintf(file1, "       Can phase through walls.\n");
X	
X	      (void) fprintf(file1, "   --Creature attacks ==\n");
X	      (void) strcpy(attstr, c_ptr->damage);
X	      while (strlen(attstr) > 0)
X		{
X		  string = index(attstr, '|');
X		  if (string)
X		    xpos = strlen(attstr) - strlen(string);
X		  else
X		    xpos = -1;
X		  if (xpos >= 0)
X		    {
X		      (void) strncpy(attx, attstr, xpos);
X		      attx[xpos] = '\0';
X		      (void) strcpy(attstr, &attstr[xpos + 1]);
X		    }
X		  else
X		    {
X		      (void) strcpy(attx, attstr);
X		      attstr[0] = '\0';
X		    }
X		  (void) sscanf(attx, "%d%d%s", &attype, &adesc, damstr);
X		  out_val[0] = '\0';
X		  switch (adesc)
X		    {
X		    case 1:
X		      (void) strcpy(out_val, "       Hits for ");
X		      break;
X		    case 2:
X		      (void) strcpy(out_val, "       Bites for ");
X		      break;
X		    case 3:
X		      (void) strcpy(out_val, "       Claws for ");
X		      break;
X		    case 4:
X		      (void) strcpy(out_val, "       Stings for ");
X		      break;
X		    case 5:
X		      (void) strcpy(out_val, "       Touches for ");
X		      break;
X		    case 6:
X		      (void) strcpy(out_val, "       Kicks for ");
X		      break;
X		    case 7:
X		      (void) strcpy(out_val, "       Gazes for ");
X		      break;
X		    case 8:
X		      (void) strcpy(out_val, "       Breathes for ");
X		      break;
X		    case 9:
X		      (void) strcpy(out_val, "       Spits for ");
X		      break;
X		    case 10:
X		      (void) strcpy(out_val, "       Wails for ");
X		      break;
X		    case 11:
X		      (void) strcpy(out_val, "       Embraces for ");
X		      break;
X		    case 12:
X		      (void) strcpy(out_val, "       Crawls on you for ");
X		      break;
X		    case 13:
X		      (void) strcpy(out_val, "       Shoots spores for ");
X		      break;
X		    case 14:
X		      (void) strcpy(out_val, "       Begs for money for ");
X		      break;
X		    case 15:
X		      (void) strcpy(out_val, "       Slimes you for ");
X		      break;
X		    case 16:
X		      (void) strcpy(out_val, "       Crushes you for ");
X		      break;
X		    case 17:
X		      (void) strcpy(out_val, "       Tramples you for ");
X		      break;
X		    case 18:
X		      (void) strcpy(out_val, "       Drools on you for ");
X		      break;
X		    case 19:
X		      (void) strcpy(out_val, "       Insults you for ");
X		      break;
X		    case 99:
X		      (void) strcpy(out_val, "       Is repelled...");
X		      break;
X		    default:
X		      (void) strcpy(out_val, "     **Unknown value** ");
X		      break;
X		    }
X		  switch (attype)
X		    {
X		    case 1:
X		      (void) strcat(out_val, "normal damage.");
X		      break;
X		    case 2:
X		      (void) strcat(out_val, "lowering strength.");
X		      break;
X		    case 3:
X		      (void) strcat(out_val, "confusion.");
X		      break;
X		    case 4:
X		      (void) strcat(out_val, "fear.");
X		      break;
X		    case 5:
X		      (void) strcat(out_val, "fire damage.");
X		      break;
X		    case 6:
X		      (void) strcat(out_val, "acid damage.");
X		      break;
X		    case 7:
X		      (void) strcat(out_val, "cold damage.");
X		      break;
X		    case 8:
X		      (void) strcat(out_val, "lightning damage.");
X		      break;
X		    case 9:
X		      (void) strcat(out_val, "corrosion damage.");
X		      break;
X		    case 10:
X		      (void) strcat(out_val, "blindness.");
X		      break;
X		    case 11:
X		      (void) strcat(out_val, "paralyzation.");
X		      break;
X		    case 12:
X		      (void) strcat(out_val, "stealing money.");
X		      break;
X		    case 13:
X		      (void) strcat(out_val, "stealing object.");
X		      break;
X		    case 14:
X		      (void) strcat(out_val, "poison damage.");
X		      break;
X		    case 15:
X		      (void) strcat(out_val, "lose dexterity.");
X		      break;
X		    case 16:
X		      (void) strcat(out_val, "lose constitution.");
X		      break;
X		    case 17:
X		      (void) strcat(out_val, "lose intelligence.");
X		      break;
X		    case 18:
X		      (void) strcat(out_val, "lose wisdom.");
X		      break;
X		    case 19:
X		      (void) strcat(out_val, "lose experience.");
X		      break;
X		    case 20:
X		      (void) strcat(out_val, "aggravates monsters.");
X		      break;
X		    case 21:
X		      (void) strcat(out_val, "disenchants objects.");
X		      break;
X		    case 22:
X		      (void) strcat(out_val, "eating food.");
X		      break;
X		    case 23:
X		      (void) strcat(out_val, "eating light source.");
X		      break;
X		    case 24:
X		      (void) strcat(out_val, "absorbing charges.");
X		      break;
X		    case 99:
X		      (void) strcat(out_val, "blank message.");
X		      break;
X		    default:
X		      (void) strcat(out_val, "**Unknown value**");
X		      break;
X		    }
X		  (void) fprintf(file1, "%s (%s)\n", out_val, damstr);
X		}
X	      for (j = 0; j < 2; j++)
X		(void) fprintf(file1, "\n");
X	    }
X	  /* End writing to file                                   */
X	  (void) fclose(file1);
X	  prt("Completed.", 0, 0);
X	}
X    }
X}
X
X
X/* Print the character to a file or device		-RAK-	 */
Xfile_character()
X{
X  register int i;
X  int j, xbth, xbthb, xfos, xsrh, xstl, xdis, xsave, xdev;
X  vtype xinfra;
X  register FILE *file1;
X  vtype out_val, filename1, prt1, prt2;
X  stat_type out_str, out_int, out_wis, out_dex, out_con, out_chr;
X  register struct misc *p_ptr;
X  register treasure_type *i_ptr;
X
X  prt("File name: ", 0, 0);
X  if (get_string(filename1, 0, 11, 64))
X    {
X      if (strlen(filename1) == 0)
X	(void) strcpy(filename1, "MORIACHR.DAT");
X      if ((file1 = fopen(filename1, "w")) != NULL)
X	{
X	  prt("Writing character sheet...", 0, 0);
X	  put_qio();
X	  (void) fprintf(file1, "%c", 12);
X	  cnv_stat(py.stats.cstr, out_str);
X	  cnv_stat(py.stats.cint, out_int);
X	  cnv_stat(py.stats.cwis, out_wis);
X	  cnv_stat(py.stats.cdex, out_dex);
X	  cnv_stat(py.stats.ccon, out_con);
X	  cnv_stat(py.stats.cchr, out_chr);
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "  Name  :%s", pad(py.misc.name, " ", 25));
X	  (void) fprintf(file1, "  Age         :%4d", (int)py.misc.age);
X	  (void) fprintf(file1, "     Strength     :%s\n", out_str);
X	  (void) fprintf(file1, "  Race  :%s", pad(py.misc.race, " ", 25));
X	  (void) fprintf(file1, "  Height      :%4d", (int)py.misc.ht);
X	  (void) fprintf(file1, "     Intelligence :%s\n", out_int);
X	  (void) fprintf(file1, "  Sex   :%s", pad(py.misc.sex, " ", 25));
X	  (void) fprintf(file1, "  Weight      :%4d", (int)py.misc.wt);
X	  (void) fprintf(file1, "     Wisdom       :%s\n", out_wis);
X	  (void) fprintf(file1, "  Class :%s", pad(py.misc.tclass, " ", 25));
X	  (void) fprintf(file1, "  Social Class:%4d", py.misc.sc);
X	  (void) fprintf(file1, "     Dexterity    :%s\n", out_dex);
X	  (void) fprintf(file1, "  Title :%s", pad(py.misc.title, " ", 25));
X	  (void) fprintf(file1, "                   ");
X	  (void) fprintf(file1, "     Constitution :%s\n", out_con);
X	  (void) fprintf(file1, "                                  ");
X	  (void) fprintf(file1, "                   ");
X	  (void) fprintf(file1, "     Charisma     :%s\n", out_chr);
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	
X	  (void) fprintf(file1, "  + To Hit    :%6d", py.misc.dis_th);
X	  (void) fprintf(file1, "     Level      :%6d", (int)py.misc.lev);
X	  (void) fprintf(file1, "     Max Hit Points :%6d\n", py.misc.mhp);
X	  (void) fprintf(file1, "  + To Damage :%6d", py.misc.dis_td);
X	  (void) fprintf(file1, "     Experience :%6d", py.misc.exp);
X	  (void) fprintf(file1, "     Cur Hit Points :%6d\n", (int) (py.misc.chp));
X	  (void) fprintf(file1, "  + To AC     :%6d", py.misc.dis_tac);
X	  (void) fprintf(file1, "     Gold       :%6d", py.misc.au);
X	  (void) fprintf(file1, "     Max Mana       :%6d\n", py.misc.mana);
X	  (void) fprintf(file1, "    Total AC  :%6d", py.misc.dis_ac);
X	  (void) fprintf(file1, "                       ");
X	  (void) fprintf(file1, "     Cur Mana       :%6d\n", (int) (py.misc.cmana));
X	
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  p_ptr = &py.misc;
X	  xbth = p_ptr->bth + p_ptr->lev * BTH_LEV_ADJ +
X	    p_ptr->ptohit * BTH_PLUS_ADJ;
X	  xbthb = p_ptr->bthb + p_ptr->lev * BTH_LEV_ADJ +
X	    p_ptr->ptohit * BTH_PLUS_ADJ;
X	  /* this results in a range from 0 to 29 */
X	  xfos = 40 - p_ptr->fos;
X	  if (xfos < 0)
X	    xfos = 0;
X	  xsrh = p_ptr->srh + int_adj();
X	  /* this results in a range from 0 to 9 */
X	  xstl = p_ptr->stl + 1;
X	  xdis = p_ptr->disarm + p_ptr->lev + 2 * todis_adj() + int_adj();
X	  xsave = p_ptr->save + p_ptr->lev + wis_adj();
X	  xdev = p_ptr->save + p_ptr->lev + int_adj();
X	  (void) sprintf(xinfra, "%d feet", py.flags.see_infra * 10);
X
X	  (void) fprintf(file1, "(Miscellaneous Abilities)\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "  Fighting    : %s", pad(likert(xbth, 12), " ", 10));
X	  (void) fprintf(file1, "  Stealth     : %s", pad(likert(xstl, 1), " ", 10));
X	  (void) fprintf(file1, "  Perception  : %s\n", pad(likert(xfos, 3), " ", 10));
X	  (void) fprintf(file1, "  Throw/Bows  : %s", pad(likert(xbthb, 12), " ", 10));
X	  (void) fprintf(file1, "  Disarming   : %s", pad(likert(xdis, 8), " ", 10));
X	  (void) fprintf(file1, "  Searching   : %s\n", pad(likert(xsrh, 6), " ", 10));
X	  (void) fprintf(file1, "  Saving Throw: %s", pad(likert(xsave, 6), " ", 10));
X	  (void) fprintf(file1, "  Magic Device: %s", pad(likert(xdev, 6), " ", 10));
X	  (void) fprintf(file1, "  Infra-Vision: %s\n", pad(xinfra, " ", 10));
X	  /* Write out the character's history     */
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "Character Background\n");
X	  for (i = 0; i < 5; i++)
X	    (void) fprintf(file1, "%s\n", pad(py.misc.history[i], " ", 71));
X	  /* Write out the equipment list...       */
X	  j = 0;
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "  [Character's Equipment List]\n");
X	  (void) fprintf(file1, "\n");
X	  if (equip_ctr == 0)
X	    (void) fprintf(file1, "  Character has no equipment in use.\n");
X	  else
X	    for (i = 22; i < INVEN_MAX; i++)
X	      {
X		i_ptr = &inventory[i];
X		if (i_ptr->tval != 0)
X		  {
X		    switch (i)
X		      {
X		      case 22:
X			(void) strcpy(prt1, ") You are wielding   : ");
X			break;
X		      case 23:
X			(void) strcpy(prt1, ") Worn on head       : ");
X			break;
X		      case 24:
X			(void) strcpy(prt1, ") Worn around neck   : ");
X			break;
X		      case 25:
X			(void) strcpy(prt1, ") Worn on body       : ");
X			break;
X		      case 26:
X			(void) strcpy(prt1, ") Worn on shield arm : ");
X			break;
X		      case 27:
X			(void) strcpy(prt1, ") Worn on hands      : ");
X			break;
X		      case 28:
X			(void) strcpy(prt1, ") Right ring finger  : ");
X			break;
X		      case 29:
X			(void) strcpy(prt1, ") Left  ring finger  : ");
X			break;
X		      case 30:
X			(void) strcpy(prt1, ") Worn on feet       : ");
X			break;
X		      case 31:
X			(void) strcpy(prt1, ") Worn about body    : ");
X			break;
X		      case 32:
X			(void) strcpy(prt1, ") Light source is    : ");
X			break;
X		      case 33:
X			(void) strcpy(prt1, ") Secondary weapon   : ");
X			break;
X		      default:
X			(void) strcpy(prt1, ") *Unknown value*    : ");
X			break;
X		      }
X		    objdes(prt2, i, TRUE);
X		    (void) sprintf(out_val, "  %c%s%s", j + 97, prt1, prt2);
X		    (void) fprintf(file1, "%s\n", out_val);
X		    j++;
X		  }
X	      }
X	
X	  /* Write out the character's inventory...        */
X	  (void) fprintf(file1, "%c", 12);
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "\n");
X	  (void) fprintf(file1, "  [General Inventory List]\n");
X	  (void) fprintf(file1, "\n");
X	  if (inven_ctr == 0)
X	    (void) fprintf(file1, "  Character has no objects in inventory.\n");
X	  else
X	    {
X	      for (i = 0; i < inven_ctr; i++)
X		{
X		  objdes(prt1, i, TRUE);
X		  (void) sprintf(out_val, "%c) %s", i + 97, prt1);
X		  (void) fprintf(file1, "%s\n", out_val);
X		}
X	    }
X	  (void) fprintf(file1, "%c", 12);
X	  (void) fclose(file1);
X	  prt("Completed.", 0, 0);
X	}
X    }
X}
END_OF_FILE
if test 26055 -ne `wc -c <'files.c'`; then
    echo shar: \"'files.c'\" unpacked with wrong size!
fi
# end of 'files.c'
fi
if test -f 'scrolls.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'scrolls.c'\"
else
echo shar: Extracting \"'scrolls.c'\" \(11936 characters\)
sed "s/^X//" >'scrolls.c' <<'END_OF_FILE'
X#include <stdio.h>
X
X#include "constants.h"
X#include "config.h"
X#include "types.h"
X#include "externs.h"
X
X#ifdef sun   /* correct SUN stupidity in the stdio.h file */
Xchar *sprintf();
X#endif
X
Xextern int moria_flag;
X
X
X/* Scrolls for the reading				-RAK-	*/
Xread_scroll()
X{
X  unsigned int i;
X  int j, k, l, item_val;
X  int y, x;
X  int tmp[6];
X  vtype out_val, tmp_str;
X  int redraw, ident, first, flag;
X  register treasure_type *i_ptr;
X  register struct misc *m_ptr;
X
X  first = TRUE;
X  reset_flag = TRUE;
X  if (inven_ctr > 0)
X    {
X      if (find_range(70, 71, &j, &k))
X	if (py.flags.blind > 0)
X	  msg_print("You can't see to read the scroll.");
X	else if (no_light())
X	  msg_print("You have no light to read by.");
X	else if (py.flags.confused > 0)
X	  {
X	    msg_print("The text seems to swim about the page!");
X	    msg_print("You are too confused to read...");
X	  }
X	else
X	  {
X	    redraw = FALSE;
X	    if (get_item(&item_val, "Read which scroll?", &redraw, j, k))
X	      {
X		i_ptr = &inventory[item_val];
X		if (redraw)  draw_cave();
X		reset_flag = FALSE;
X		i = i_ptr->flags;
X		ident = FALSE;
X
X		while (i != 0)
X		  {
X		    j = bit_pos(&i) + 1;
X		    if (i_ptr->tval == 71)
X		      j += 31;
X		    if (first)
X		      if ((j != 4) && (j != 25))
X			{
X			  msg_print("As you read the scroll it vanishes.");
X			  first = FALSE;
X			}
X
X		    /* Scrolls...			*/
X		    switch(j)
X		      {
X		      case 1:
X			i_ptr = &inventory[INVEN_WIELD];
X			if (i_ptr->tval != 0)
X			  {
X			    objdes(tmp_str, INVEN_WIELD, FALSE);
X			    (void) sprintf(out_val, "Your %s glows faintly!",
X					   tmp_str);
X			    msg_print(out_val);
X			    if (enchant(&i_ptr->tohit))
X			      {
X				i_ptr->flags &= 0x7FFFFFFF;
X				py_bonuses(blank_treasure, 0);
X			      }
X			    else
X			      msg_print("The enchantment fails...");
X			  }
X			ident = TRUE;
X			break;
X		      case 2:
X			i_ptr = &inventory[INVEN_WIELD];
X			if (i_ptr->tval != 0)
X			  {
X			    objdes(tmp_str, INVEN_WIELD, FALSE);
X			    (void) sprintf(out_val, "Your %s glows faintly!",
X					   tmp_str);
X			    msg_print(out_val);
X			    if (enchant(&i_ptr->todam))
X			      {
X				i_ptr->flags &= 0x7FFFFFFF;
X				py_bonuses(blank_treasure, 0);
X			      }
X			    else
X			      msg_print("The enchantment fails...");
X			  }
X			ident = TRUE;
X			break;
X		      case 3:
X			k = 0;
X			l = 0;
X			if (inventory[INVEN_BODY].tval != 0)
X			  tmp[k++] = INVEN_BODY;
X			if (inventory[INVEN_ARM].tval != 0)
X			  tmp[k++] = INVEN_ARM;
X			if (inventory[INVEN_OUTER].tval != 0)
X			  tmp[k++] = INVEN_OUTER;
X			if (inventory[INVEN_HANDS].tval != 0)
X			  tmp[k++] = INVEN_HANDS;
X			if (inventory[INVEN_HEAD].tval != 0)
X			  tmp[k++] = INVEN_HEAD;
X			/* also enchant boots */
X			if (inventory[INVEN_FEET].tval != 0)
X			  tmp[k++] = INVEN_FEET;
X
X			if (k > 0)  l = tmp[randint(k)-1];
X
X			if (0x80000000 & inventory[INVEN_BODY].flags)
X			  l = INVEN_BODY;
X			else if (0x80000000 & inventory[INVEN_ARM].flags)
X			  l = INVEN_ARM;
X			else if (0x80000000 & inventory[INVEN_OUTER].flags)
X			  l = INVEN_OUTER;
X			else if (0x80000000 & inventory[INVEN_HEAD].flags)
X			  l = INVEN_HEAD;
X			else if (0x80000000 & inventory[INVEN_HANDS].flags)
X			  l = INVEN_HANDS;
X			else if (0x80000000 & inventory[INVEN_FEET].flags)
X			  l = INVEN_FEET;
X
X			if (l > 0)
X			  {
X			    i_ptr = &inventory[l];
X			    objdes(tmp_str, l, FALSE);
X			    (void) sprintf(out_val, "Your %s glows faintly!",
X					   tmp_str);
X			    msg_print(out_val);
X			    if (enchant(&i_ptr->toac))
X			      {
X				i_ptr->flags &= 0x7FFFFFFF;
X				py_bonuses(blank_treasure, 0);
X			      }
X			    else
X			      msg_print("The enchantment fails...");
X			    ident = TRUE;
X			  }
X			break;
X		      case 4:
X			identify(inventory[item_val]);
X			msg_print("This is an identify scroll");
X			/* make sure player sees message before ident_spell */
X			msg_print(" ");
X			if (ident_spell())  first = FALSE;
X			break;
X		      case 5:
X			if (remove_curse())
X			  {
X		     msg_print("You feel as if someone is watching over you.");
X			    ident = TRUE;
X			  }
X			break;
X		      case 6:
X			ident = light_area(char_row, char_col);
X			break;
X		      case 7:
X			ident = FALSE;
X			for (k = 0; k < randint(3); k++)
X			  {
X			    y = char_row;
X			    x = char_col;
X			    ident |= summon_monster(&y, &x, FALSE);
X			  }
X			break;
X		      case 8:
X			teleport(10);
X			ident = TRUE;
X			break;
X		      case 9:
X			teleport(100);
X			ident = TRUE;
X			break;
X		      case 10:
X			dun_level += (-3) + 2*randint(2);
X			if (dun_level < 1)
X			  dun_level = 1;
X			moria_flag = TRUE;
X			ident = TRUE;
X			break;
X		      case 11:
X			msg_print("Your hands begin to glow.");
X			py.flags.confuse_monster = TRUE;
X			ident = TRUE;
X			break;
X		      case 12:
X			ident = map_area();
X			break;
X		      case 13:
X			ident = sleep_monsters1(char_row, char_col);
X			break;
X		      case 14:
X			ident = warding_glyph();
X			break;
X		      case 15:
X			ident = detect_treasure();
X			break;
X		      case 16:
X			ident = detect_object();
X			break;
X		      case 17:
X			ident = detect_trap();
X			break;
X		      case 18:
X			ident = detect_sdoor();
X			break;
X		      case 19:
X			msg_print("This is a mass genocide scroll.");
X			ident = mass_genocide();
X			break;
X		      case 20:
X			ident = detect_invisible();
X			break;
X		      case 21:
X			ident = aggravate_monster(20);
X			msg_print("There is a high pitched humming noise");
X			break;
X		      case 22:
X			ident = trap_creation();
X			break;
X		      case 23:
X			ident = td_destroy();
X			break;
X		      case 24:
X			ident = door_creation();
X			break;
X		      case 25:
X			identify(inventory[item_val]);
X			msg_print("This is a Recharge-Item scroll.");
X			/* make sure player see message before recharge */
X			msg_print(" ");
X			if (recharge(60))  first = FALSE;
X			break;
X		      case 26:
X			msg_print("This is a genocide scroll.");
X			/* make sure player sees message before genocide() */
X			msg_print(" ");
X			ident = genocide();
X			break;
X		      case 27:
X			ident = unlight_area(char_row, char_col);
X			break;
X		      case 28:
X			ident = protect_evil();
X			break;
X		      case 29:
X			ident = create_food();
X			break;
X		      case 30:
X			ident = dispell_creature(0x0008, 60);
X			break;
X		      case 31:
X			msg_print("That scroll appeared to be blank.");
X			ident = TRUE;
X			break;
X		      case 32:
X			i_ptr = &inventory[INVEN_WIELD];
X			if (i_ptr->tval != 0)
X			  {
X			    objdes(tmp_str, INVEN_WIELD, FALSE);
X			    (void) sprintf(out_val, "Your %s glows brightly!",
X				    tmp_str);
X			    msg_print(out_val);
X			    flag = FALSE;
X			    for (k = 0; k < randint(2); k++)
X			      if (enchant(&i_ptr->tohit))
X				flag = TRUE;
X			    for (k = 0; k < randint(2); k++)
X			      if (enchant(&i_ptr->todam))
X				flag = TRUE;
X			    if (flag)
X			      {
X				i_ptr->flags &= 0x7FFFFFFF;
X				py_bonuses(blank_treasure, 0);
X			      }
X			    else
X			      msg_print("The enchantment fails...");
X			    ident = TRUE;
X			  }
X			break;
X		      case 33:
X			i_ptr = &inventory[INVEN_WIELD];
X			if (i_ptr->tval != 0)
X			  {
X			    inventory[INVEN_MAX] = inventory[INVEN_WIELD];
X			    objdes(tmp_str, INVEN_WIELD, FALSE);
X			    (void)sprintf(out_val,"Your %s glows black, fades",
X				    tmp_str);
X			    msg_print(out_val);
X			    i_ptr->tohit = -randint(5) - randint(5);
X			    i_ptr->todam = -randint(5) - randint(5);
X			    i_ptr->flags = 0x80000000;
X			    py_bonuses(inventory[INVEN_MAX], -1);
X			    ident = TRUE;
X			  }
X			break;
X		      case 34:
X			k = 0;
X			l = 0;
X			if (inventory[INVEN_BODY].tval != 0)
X			  tmp[k++] = INVEN_BODY;
X			if (inventory[INVEN_ARM].tval != 0)
X			  tmp[k++] = INVEN_ARM;
X			if (inventory[INVEN_OUTER].tval != 0)
X			  tmp[k++] = INVEN_OUTER;
X			if (inventory[INVEN_HANDS].tval != 0)
X			  tmp[k++] = INVEN_HANDS;
X			if (inventory[INVEN_HEAD].tval != 0)
X			  tmp[k++] = INVEN_HEAD;
X			/* also enchant boots */
X			if (inventory[INVEN_FEET].tval != 0)
X			  tmp[k++] = INVEN_FEET;
X
X			if (k > 0)  l = tmp[randint(k)-1];
X
X			if (0x80000000 & inventory[INVEN_BODY].flags)
X			  l = INVEN_BODY;
X			else if (0x80000000 & inventory[INVEN_ARM].flags)
X			  l = INVEN_ARM;
X			else if (0x80000000 & inventory[INVEN_OUTER].flags)
X			  l = INVEN_OUTER;
X			else if (0x80000000 & inventory[INVEN_HEAD].flags)
X			  l = INVEN_HEAD;
X			else if (0x80000000 & inventory[INVEN_HANDS].flags)
X			  l = INVEN_HANDS;
X			else if (0x80000000 & inventory[INVEN_FEET].flags)
X			  l = INVEN_FEET;
X
X			if (l > 0)
X			  {
X			    i_ptr = &inventory[l];
X			    objdes(tmp_str, l, FALSE);
X			    (void) sprintf(out_val,"Your %s glows brightly!",
X					   tmp_str);
X			    msg_print(out_val);
X			    flag = FALSE;
X			    for (k = 0; k < randint(2) + 1; k++)
X			      if (enchant(&i_ptr->toac))
X				flag = TRUE;
X			    if (flag)
X			      {
X				i_ptr->flags &= 0x7FFFFFFF;
X				py_bonuses(blank_treasure, 0);
X			      }
X			    else
X			      msg_print("The enchantment fails...");
X			    ident = TRUE;
X			  }
X			break;
X		      case 35:
X			if ((inventory[INVEN_BODY].tval != 0) && (randint(4) == 1))
X			  k = INVEN_BODY;
X			else if ((inventory[INVEN_ARM].tval != 0) && (randint(3) ==1))
X			  k = INVEN_ARM;
X			else if ((inventory[INVEN_OUTER].tval != 0) && (randint(3) ==1))
X			  k = INVEN_OUTER;
X			else if ((inventory[INVEN_HEAD].tval != 0) && (randint(3) ==1))
X			  k = INVEN_HEAD;
X			else if ((inventory[INVEN_HANDS].tval != 0) && (randint(3) ==1))
X			  k = INVEN_HANDS;
X			else if ((inventory[INVEN_FEET].tval != 0) && (randint(3) ==1))
X			  k = INVEN_FEET;
X			else if (inventory[INVEN_BODY].tval != 0)
X			  k = INVEN_BODY;
X			else if (inventory[INVEN_ARM].tval != 0)
X			  k = INVEN_ARM;
X			else if (inventory[INVEN_OUTER].tval != 0)
X			  k = INVEN_OUTER;
X			else if (inventory[INVEN_HEAD].tval != 0)
X			  k = INVEN_HEAD;
X			else if (inventory[INVEN_HANDS].tval != 0)
X			  k = INVEN_HANDS;
X			else if (inventory[INVEN_FEET].tval != 0)
X			  k = INVEN_FEET;
X			else
X			  k = 0;
X			if (k > 0)
X			  {
X			    i_ptr = &inventory[k];
X			    inventory[INVEN_MAX] = inventory[k];
X			    objdes(tmp_str, k, FALSE);
X			   (void)sprintf(out_val,"Your %s glows black, fades.",
X				    tmp_str);
X			    msg_print(out_val);
X			    i_ptr->flags = 0x80000000;
X			    i_ptr->toac = -randint(5) - randint(5);
X			    py_bonuses(inventory[INVEN_MAX], -1);
X			    ident = TRUE;
X			  }
X			break;
X		      case 36:
X			ident = FALSE;
X			for (k = 0; k < randint(3); k++)
X			  {
X			    y = char_row;
X			    x = char_col;
X			    ident |= summon_undead(&y, &x);
X			  }
X			break;
X		      case 37:
X			ident = bless(randint(12)+6);
X			break;
X		      case 38:
X			ident = bless(randint(24)+12);
X			break;
X		      case 39:
X			ident = bless(randint(48)+24);
X			break;
X		      case 40:
X			ident = TRUE;
X			py.flags.word_recall = 25 + randint(30);
X			msg_print("The air about you becomes charged...");
X			break;
X		      case 41:
X			ident = destroy_area(char_row, char_col);
X			break;
X		      case 42:
X			break;
X		      case 43:
X			break;
X		      case 44:
X			break;
X		      case 45:
X			break;
X		      case 46:
X			break;
X		      case 47:
X			break;
X		      case 48:
X			break;
X		      case 49:
X			break;
X		      case 50:
X			break;
X		      case 51:
X			break;
X		      case 52:
X			break;
X		      case 53:
X			break;
X		      case 54:
X			break;
X		      case 55:
X			break;
X		      case 56:
X			break;
X		      case 57:
X			break;
X		      case 58:
X			break;
X		      case 59:
X			break;
X		      case 60:
X			break;
X		      case 61:
X			break;
X		      case 62:
X			break;
X		      default:
X			break;
X		      }
X		    /* End of Scrolls...                         */
X		  }
X		if (!reset_flag)
X		  {
X		    if (ident)
X		      identify(inventory[item_val]);
X		    if (!first)
X		      {
X			desc_remain(item_val);
X			inven_destroy(item_val);
X			if (i_ptr->flags != 0)
X			  {
X			    m_ptr = &py.misc;
X			    m_ptr->exp += (i_ptr->level/m_ptr->lev);
X			    prt_experience();
X			  }
X		      }
X		  }
X	      }
X	    else
X	      if (redraw)  draw_cave();
X	  }
X      else
X	msg_print("You are not carrying any scrolls.");
X    }
X  else
X    msg_print("But you are not carrying anything.");
X}
END_OF_FILE
if test 11936 -ne `wc -c <'scrolls.c'`; then
    echo shar: \"'scrolls.c'\" unpacked with wrong size!
fi
# end of 'scrolls.c'
fi
echo shar: End of archive 15 \(of 18\).
cp /dev/null ark15isdone
MISSING=""
for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 18 archives.
    rm -f ark[1-9]isdone ark[1-9][0-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0