[comp.sources.games] v08i093: castle - adventure game with character graphics, Part01/04

billr@saab.CNA.TEK.COM (Bill Randle) (02/23/90)

Submitted-by: Ted Wisniewski <unhd!psc90!pyr4@uunet.uu.net>
Posting-number: Volume 8, Issue 93
Archive-name: castle/Part01

	[As mentioned in the README file, I had to work on it to get
	 it to run. There are probably still bugs.  -br]

#! /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 1 (of 4)."
# Contents:  README MANIFEST FILES FILES/level_1 INCLUDE castle.c
#   store.c
# Wrapped by billr@saab on Thu Feb 22 15:57:01 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1188 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XImportant notes on setting this game up:
X
XThe save files are all saved in the same directory, which is owned
Xby the same account that owns the game.  This is for preventing
Xcheaters (save + copy).  For this reason the game is mode 4111, set uid
Xon execution.  Any files and directories associated with the game should
Xonly read + write to the owner.
X
X
X			This game has no implied warrantee, 
X			I have it running on BSD 4.4c.
X
XAny problems sent to me will be looked at, but I cannot Gaurantee that
XI will be able to respond.  (This is my last semester).  This game is 
Xthe result of my senior project, (1 semester course, due to time considerations
Xthis game may be a little inefficient in places).
X
X
X
X				~Ted Wisniewski
X				(The Wizard)
X
X===============================================
XI had to make several changes to get this game to compile, plus several
Xothers to get it to run. I have a hard time believing it ever worked. I
Xtried contacting the author, but got no reply. The source, as it is
Xhere, compiles and runs OK on a Sun 3/60 SunOS 3.5; I make no
Xgaurantees beyond that.
X
X	-Bill Randle
X	Moderator, comp.sources.games
X	Tektronix, Inc.
X	games@saab.CNA.TEK.COM
X	Feb. 22, 1990
END_OF_FILE
if test 1188 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(889 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X FILES                      1	
X FILES/cas_hours            4	
X FILES/castle.help          2	
X FILES/level_1              1	
X FILES/level_2              4	
X FILES/level_3              4	
X FILES/level_4              4	
X FILES/level_5              2	
X FILES/level_6              4	
X FILES/open.scr             3	
X FILES/scores               4	
X INCLUDE                    1	
X INCLUDE/castle.h           2	
X INCLUDE/items.h            2	
X INCLUDE/monst.h            3	
X INCLUDE/windows.h          4	
X MANIFEST                   1	This shipping list
X Makefile                   4	
X README                     1	
X castle.c                   1	
X files.c                    4	
X magic.c                    3	
X monster.c                  3	
X screens.c                  2	
X store.c                    1	
END_OF_FILE
if test 889 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
if test ! -d 'FILES' ; then
    echo shar: Creating directory \"'FILES'\"
    mkdir 'FILES'
fi
if test -f 'FILES/level_1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'FILES/level_1'\"
else
echo shar: Extracting \"'FILES/level_1'\" \(1748 characters\)
sed "s/^X//" >'FILES/level_1' <<'END_OF_FILE'
X###########################################################################
X#  -                        # /  #              #                 #     # #
X#?######################### #### # ########  #  # ############### #####   #
X#$#; #     $$$           #       # #      ##### # # >      &#   # #     # #
X#$#     # ##### ### #    ##### #########      # # #         #&# # #  #  # #
X#$#######?#   # #   ###### # # ## #    ### ## # # ############# # ####### #
X#   #     #$# # #####      #   #  #    #   ##   #               #         #
X#%#   #!#=# #       # ###### #### ###  ####### ################## ##### # #
X####### ########## ## #         #   #                      ?      #     # #
X#  $$ $$ $       #    # ####### ### ################################### # #
X# ############## ###### #         #    ?                 #              # #
X# 1#^          # !      #     # # ############# #####  # ################ #
X# ####!### ### # ###### ####### #    #          #   ####                  #
X# $- / #*   =#   #    #        @#### ############ #    # #### ########### #
X##################### ### #######  # #            #### # # ## # #   # ### #
X#                       # #          # ###### ### #    # #    #   # #   # #
X#      #####      ##### # # #### ### #          # #### # ########## ### # #
X#   #  #   #      #   # # # #      # ### #####  # #    #  #?  #   #     # #
X#      ## ##      # ### #@# #### # #   ###   ## # #### #### # # # ##### # #
X#                   #   # # #    # # #     #    #   #       # # #       # #
X#^################### ### # ###### # # ### ###### # ####### # # ######### #
X#$#$$$$         - -       #     ?    #            #         #             #
X###########################################################################
END_OF_FILE
if test 1748 -ne `wc -c <'FILES/level_1'`; then
    echo shar: \"'FILES/level_1'\" unpacked with wrong size!
fi
# end of 'FILES/level_1'
fi
if test ! -d 'INCLUDE' ; then
    echo shar: Creating directory \"'INCLUDE'\"
    mkdir 'INCLUDE'
fi
if test -f 'castle.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'castle.c'\"
else
echo shar: Extracting \"'castle.c'\" \(38358 characters\)
sed "s/^X//" >'castle.c' <<'END_OF_FILE'
X# include <stdio.h>
X# include <curses.h>
X# include <ctype.h>
X# include <signal.h>
X# include <fcntl.h>
X# include <sys/time.h> 	
X
X# include "INCLUDE/windows.h"
X# include "INCLUDE/castle.h"
X# include "INCLUDE/items.h"
X
X/*
X+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
X+   Routines in this module:                                                +
X+                                                                           +
X+     main()          - Runs the whole program.                             +
X+     set_windows()   - Sets up the windows for the screen.                 +
X+     show_scr()      - Show the current view screen.                       +
X+     print_stats()   - Update the character stats in the stat window.      +
X+     init()          - initialize the start configurations for the game.   +
X+     which_scr(r,c,l)- Determine which view screen to show.                +
X+     getint()        - Get an integer in from the message window.          +
X+     look_inv()      - Look at the character's inventory list.             +
X+     init_list()     - Initialize the inventory list as a double linked    +
X+                       List.                                               +
X+     find_item()     - Determine if an item is found, then tell which one  +
X+                       to add to the list.                                 +
X+     add_item()      - Add an Item to the list.                            +
X+     check_it()      - See if item to be worn has an item of same type     +
X+                       already worn.                                       +
X+     
X+                       exit from the game.                                 +
X+     disarm()        - Attempt to disarm a trap.                           +
X+     regen()         - Keep track of a characters status hp, spt and       +
X+                       and Regenerate them at the appropriate rate.        +
X+     gain_lvl()      - Determines when a player should gain an experience  +
X+                       level.                                              +
X+     clr_mess_win()  - An extra routine to clear the message window.       +
X+     rest()          - Allow player to rest, (regenerate with a lesser     +
X+                       chance of being attacked.                           +
X+     place_at()      - For use in some teleporters to a specific location. +
X+     create_wall()   - Create a wall in the player's location (Trap).      +
X+     god_mode()      - Primative checking to see if player has "god status"+
X+     death()         - Tells player what killed him.                       +
X+     end_game()      - Sets terminal back to non game state.               +
X+                                                                           +
X+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
X
X	This is a public domain program, I have no objection to modifications
Xmade on it or use for some other reason so long as this notice remains intact.
X
X	
X		Part of:  castle 	Ted Wisniewski
X		Author:			Plymouth State College
X					Plymouth NH,
X						    03264
X		Copyright() PSC
X*/
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X	int row,col,level;
X	unsigned char dir;
X	int g_mod,recov;
X	int catch();
X
X	if((p = (pos_stats *) malloc(sizeof(pos_stats))) == NULL) {
X	  fprintf(stderr,"can't malloc memory for pos_stats\n");
X	  exit(1);
X	}
X	strcpy(user.acct,getenv("USER"));       /* Find who the player is.   */
X  	strcpy(user.home,getenv("HOME"));	/* Find his Home Directory.  */
X	strcpy(char_stats.Name,user.acct);
X	if((strcmp(getenv("TERM"),"dumb")) == 0){
X	   fprintf(stderr,"dumb terminal: cannot run!\n");
X	   exit(1);
X	}
X
X	recov = FALSE;
X	if(argc > 2){
X	  fprintf(stderr,"Too many Arguments\n");
X	  fprintf(stderr,"Aborting program.\n");
X	  exit(1);
X	}else
X	  if(argc == 1)
X	    game_stat();			/* Find out if the game      */
X						/* operating hours are open. */
X	  else
X	    if(strcmp(argv[1],"-h") == 0)  /* If the option is "h"   */
X	      help_me();			          /* display the help file.   */
X	    else
X	      if(strcmp(argv[1],"-s") == 0) 	  /*  If the option is "s"    */
X		prn_scores();		     	  /*  display the score file. */
X	      else
X		if(strcmp(argv[1],"-r") == 0){
X		  game_stat();	
X		  recov = TRUE;
X		}
X
X	savetty();		/* Save The current status of the terminal.  */
X	srand(getpid());	/* Seed the random number generator.         */
X
X	monst();	 	/* Initialize monsters.			  */
X
X	initscr();              /* Set-up the screen for the game.        */
X	clear();
X	refresh();
X	dis_open_scr();		/* Display the opening screen.		  */
X	crmode(); noecho();
X
X	signal(SIGINT,catch);	/* Signals to catch.      		  */
X	signal(SIGILL,catch);
X	signal(SIGHUP,catch);
X	signal(SIGSEGV,catch);
X	signal(SIGTERM,catch);
X	signal(SIGFPE,catch);
X	signal(SIGBUS,catch);
X
X	set_windows();		/* Set-up the windows.			*/
X	if(!recov){
X	  get_levels();   	/* Read the levels in from their files.   */
X	  init_list();		/* initialize the inventory list.       */
X	  init();
X	}else{
X	    recover();
X	    show_scr();
X	}
X	print_stats();
X	for(;;){		/* begin the main loop.			*/
X		row = p->row;
X		col = p->col;
X		level = p->level;
X		if(which_one == ON)
X			which_one = OFF;
X		else
X			which_one = ON;
X
X		which_scr(row,col,level);
X		if(showit){		/* if the screen needs to be */
X			show_scr();	/* displayed, do so.         */
X			showit = FALSE;
X		}
X		if(p->compass_on)	/* if the compass is on display it.  */
X			compass();
X		if(detect == ON){	/* if trap detect is on warn player  */
X		  clr_mess_win();	/* if there is a trap ahead.         */
X		  detect_trap();
X	 	}
X		if(rand()%100 > 85){    /* Find out if the player encounters */
X		   combat();		/* a monster.			     */
X		}
X
X		find_item();
X		spell_counts();
X		wmove(command_win,0,0);
X		wrefresh(command_win);
X		dir = getch();
X		switch (dir){
X
X		case 'h':
X		case 52 :               	 /* Turn Left */
X		case 180: 
X			showit = TRUE;
X			if(p->face == NORTH)
X				p->face = WEST;
X			else
X				p->face--;
X			break;
X
X		case 'k':
X		case 56 :			/* Move forward              */
X		case 184: 			
X						/* make sure player does not 
X					  	   go through a wall.        */
X			switch (p->face){       
X			case NORTH: 
X			       if(levels[level][row-1][col]!=WALL && row != 1){
X					p->row--;
X					showit = TRUE;
X				}else
X				  	beep();
X				break;
X			case EAST: 
X			       if(levels[level][row][col+1]!=WALL && col != 73){
X					p->col++;
X					showit = TRUE;
X				}else
X					beep();
X				break;
X			case SOUTH: 
X			       if(levels[level][row+1][col]!=WALL && row !=22){
X					p->row++;
X					showit = TRUE;
X				}else
X					beep();
X				break;
X			case WEST: 
X			       if(levels[level][row][col-1]!=WALL && col != 1){
X					p->col--;
X					showit = TRUE;
X				}else
X					beep();
X				break;
X			}
X			break;
X
X		case 'j':
X		case 50 :			
X		case 178: 
X						/* Back up a space and also
X						   make sure he does not go
X						   through a wall.           */
X			switch (p->face){
X			case NORTH: 
X			       if(levels[level][row+1][col]!=WALL && row != 22){
X					p->row++;
X					showit = TRUE;
X				}else
X					beep();
X				break;
X			case EAST: 
X			       if(levels[level][row][col-1]!=WALL && col != 1){
X					p->col--;
X					showit = TRUE;
X				}else
X					beep();
X				break;
X			case SOUTH: 
X			      if(levels[level][row-1][col]!=WALL && row != 1){
X					p->row--;
X					showit = TRUE;
X				}else
X					beep();
X				break;
X			case WEST: 
X			      if(levels[level][row][col+1]!=WALL && col != 73){
X					p->col++;
X					showit = TRUE;
X				}else
X					beep();
X				break;
X			}
X			break;
X
X		case 'l':		/* Turn Right */
X		case 54 : 
X		case 182:
X			showit = TRUE;
X			if(p->face == WEST)
X				p->face = NORTH;
X			else
X			        p->face++;
X			break;
X		case '.': 		/* Turn Around. */
X			switch (p->face){
X			case NORTH: 
X				p->face = SOUTH;
X				break;
X			case WEST: 
X				p->face = EAST;
X				break;
X			case SOUTH: 
X				p->face = NORTH;
X				break;
X			case EAST: 
X				p->face = WEST;
X				break;
X			}
X			showit = TRUE;
X			break;
X
X		case UP: 		/* Go up a staircase   */
X			if(levels[level][row][col] == UP && p->level != 1){
X				p->level--;
X				showit = TRUE;
X			}
X			else{
X				print_mess("Can't Go up here!",0,0);
X				wrefresh(message_win);
X				sleep(1);
X				clr_mess_win();
X				wmove(message_win,0,0);
X				wrefresh(message_win);
X			}
X			break;
X		case DOWN: 		/* Go down a staircase. */
X			if(levels[level][row][col] == DOWN && p->level != 6){
X				p->level++;
X				level++;
X				showit = TRUE;
X			}
X			else{
X				print_mess("Can't Go down here!",0,0);
X				wrefresh(message_win);
X				sleep(1);
X				clr_mess_win();
X				wmove(message_win,0,0);
X				wrefresh(message_win);
X			}
X			break;
X		case 'c':		/* Cast Spells */
X		case 'C': 
X			clr_mess_win();
X			spells();
X			break;
X		case 'd':		/* Disarm a trap. */
X		case 'D':
X			clr_mess_win();
X		   	disarm();
X			break;
X		case 'i':		/* Look into your inventory.  */
X		case 'I': 
X			wclear(message_win);
X			wrefresh(message_win);
X			look_inv();
X			break;
X		case 'N':
X			wclear(message_win);
X			print_mess("Name -> ",0,0);
X			wrefresh(message_win);
X			get_str(0,9);
X			strcpy(char_stats.Name,string);
X			print_stats();
X			break;
X		case 'r':		/* Rest for some period.      */
X		case 'R':
X			wclear(message_win);
X			wrefresh(message_win);
X			rest();
X			break;
X		case 'S':
X			which_known();
X			break;
X		case 'q':		/* Quit the game.            */
X		case 'Q': 
X			wmove(message_win,0,0);
X			wclrtoeol(message_win);
X			print_mess("Quit (y/n)? ",0,0);
X			wrefresh(message_win);
X			if(wgetch(message_win) == 'y'){
X			  strcpy(tmp.death_by,"Cowardice");
X			  score_list();
X			  end_game();
X			}
X			break;
X		case 'u' :
X		case 'U' : 
X			use_it();
X			break;
X		case 'L':		/* Explain A spell	    */
X			wclear(message_win);
X			wrefresh(message_win);
X			exp_spell();
X		        break;
X		case RE_DRAW:		/* Redraw the screen (?)    */
X			redraw();
X		break;
X		case G_MODE:
X			god_mode();
X		break;
X		case SAVE:
X			save();
X		break;
X		case '?':
X			help_list();
X			break;
X		case '~': mail_help();
X			  break;
X		case 'v':		/* Print version and credits */
X			wclear(message_win);
X			wrefresh(message_win);
X			print_mess("Version 1.0",0,0);
X			print_mess("Screens:",1,0);
X			print_mess("Lauriannne Olcott &",2,5);
X			print_mess("Ted Wisniewski",3,10);
X			print_mess("Game by: Ted Wisniewski",4,0);
X			print_mess("Press a key.",5,0);
X			wrefresh(message_win);
X			wgetch(message_win);
X		break;
X			
X		}
X		location();
X		regen();
X		if(char_stats.hitpoints < 0)
X		  death();
X	}
X}
X
Xlocation()
X{
X	char spot;
X	int gold;
X
X	spot = levels[p->level][p->row][p->col];
X
X	wclear(message_win); 
X	wrefresh(message_win);
X
X	switch (spot){
X	case DOWN: 		/* Is the spot a down staircase?   */
X		print_mess("This is a down staircase.",0,0);
X		break;
X	case UP: 		/* Is the spot an up staircase?    */
X		print_mess("This is an up Staircase.",0,0);
X		break;
X	case TELE: 		/* Teleport the Player? 	   */
X		print_mess("You are Teleported.",0,0);
X		p->row = rand()%22 + 1;
X		p->col = rand()%72 + 1;
X		break;
X	case TRAP: 		/* Ouch you are on a trap!         */
X		print_mess("You Hit A Trap!",0,0);
X		char_stats.hitpoints -= rand() % 10 + 1;
X		levels[p->level][p->row][p->col] = BLANK;
X		if(char_stats.hitpoints < 0)
X		  strcpy(tmp.death_by,"A Trap");
X		print_stats();
X		break;
X	case T_DOOR:		/* A trap door to the next level.  */
X		print_mess("You fall through a trap door.",0,0);
X		p->level++;
X		showit = TRUE;
X		char_stats.hitpoints -= rand() % 5;
X		if(char_stats.hitpoints < 0)
X		  strcpy(tmp.death_by,"Falling");
X		print_stats();
X		break;
X	case GOLD: 		/* Find some extra Cash!!	   */
X		char_stats.gold += gold = rand() % (p->level * 50) + 25;
X		sprintf(buffer,"You Find %d gold!!",gold);
X		print_mess(buffer,0,0);
X		levels[p->level][p->row][p->col] = BLANK;
X		print_stats();
X		break;
X	case SPIN:		/* Spin to a random direction	  */
X		p->face = rand()%4;
X		print_mess("You feel Dizzy.",0,0);
X		showit = TRUE;
X	 	break;
X	case H_DRAIN:		/* Hurt em' a little.             */
X		print_mess("Ouch!!",0,0);
X		char_stats.hitpoints -= (3 * p->level);
X		if(char_stats.hitpoints < 0)
X		  strcpy(tmp.death_by,"Unknown force");
X		print_stats();
X		break;
X	case S_DRAIN:		/* Take some ability to cast spells */
X		print_mess("You Feel Uneasy.",0,0);
X		char_stats.spellpoints -= (2 * p->level);
X		if(char_stats.spellpoints < 0)
X		  char_stats.spellpoints = 0;
X		print_stats();
X		break;
X	case T_LOC:		/* Take them some place specific.  */
X		place_at();
X		break;
X	case C_WALL:		/* Create a wall here.		   */
X		create_wall();
X		break;
X	case STORE:		/* Enter the Store. 		   */
X	        the_store();
X		break;
X	case FOUNTAIN:
X		fountain();
X		break;
X	case SP_ITEM:
X		add_item(13);
X		levels[p->level][p->row][p->col] = BLANK;
X		print_mess("You Have found The Death Lance.",1,0);
X		beep();
X		wrefresh(message_win);
X		break;
X	case CLUE:
X		print_mess(clues[rand()%16],0,0);
X		wrefresh(message_win);
X		levels[p->level][p->row][p->col] = BLANK;
X		break;
X	case '1':
X		ask_ques(1);
X		break;
X	case '2':
X		ask_ques(2);
X		break;
X	case '3':
X		ask_ques(3);
X		break;
X	default: 		/* clean up.			      */
X		wclear(message_win);
X		wrefresh(message_win);
X	 	break;
X	}
X	wrefresh(message_win);
X}
X
Xset_windows() 
X{
X	stat_win = newwin(19,15,1,0);
X	view_win = newwin(12,27,0,20);
X	debug_win   = newwin(3,15,10,60);
X	message_win = newwin(7,40,16,20);
X	compass_win = newwin(9,9,14,70);
X	inv_win = newwin(8,26,4,54);
X	command_win = newwin(1,1,21,0);
X}
X
X
Xshow_scr()			/* Display the screen pointed to. */
X{
X	int row,col;
X
X	wmove(view_win,0,0);
X	for(row=0;row<=11;row++){
X		for(col=0;col<=26;col++){
X			wprintw(view_win,"%c",screens[p->screen][row][col]);
X		}
X	}
X	wrefresh(view_win);
X}
X
Xprint_stats()		/* Print the players Stats to the stat  */
X				/* Window. 				*/
X{
X	wclear(stat_win);
X	wmove(stat_win,0,0);
X	wprintw(stat_win,"Name: %s",char_stats.Name);
X	wmove(stat_win,2,0);
X	wprintw(stat_win,"Str: %d",char_stats.strength);
X	wmove(stat_win,3,0);
X	wprintw(stat_win,"Con: %d",char_stats.constitution);
X	wmove(stat_win,4,0);
X	wprintw(stat_win,"Dex: %d",char_stats.dexterity);
X	wmove(stat_win,5,0);
X	wprintw(stat_win,"Int: %d",char_stats.intelligence);
X	wmove(stat_win,6,0);
X	wprintw(stat_win,"Wis: %d",char_stats.wisdom);
X	wmove(stat_win,8,0);
X	wprintw(stat_win,"Lvl: %d",char_stats.level);
X	wmove(stat_win,9,0);
X	wprintw(stat_win,"Exp: %d",char_stats.experience);
X	wmove(stat_win,10,0);
X	wprintw(stat_win,"CSp: %d",char_stats.spellpoints);
X	wmove(stat_win,11,0);
X	wprintw(stat_win,"MSp: %d",char_stats.max_spt);
X	wmove(stat_win,12,0);
X	wprintw(stat_win,"CHP: %d",char_stats.hitpoints);
X	wmove(stat_win,13,0);
X	wprintw(stat_win,"MHP: %d",char_stats.max_hp);
X	wmove(stat_win,15,0);
X	wprintw(stat_win,"Gold : %d",char_stats.gold);
X	wmove(stat_win,16,0);
X	wprintw(stat_win,"AC : %d",char_stats.ac);
X	wrefresh(stat_win);
X}
X
Xinit()		/* Set the players stats and some other info.   */
X{
X	int x;
X
X	char_stats.m_str = char_stats.strength    = (rand()%16)+MIN_STAT;
X	char_stats.m_con = char_stats.constitution= (rand()%16)+MIN_STAT;
X	char_stats.m_dex = char_stats.dexterity   = (rand()%16)+MIN_STAT;
X	char_stats.m_int = char_stats.intelligence= (rand()%16)+MIN_STAT;
X	char_stats.m_wis = char_stats.wisdom      = (rand()%16)+MIN_STAT;
X	char_stats.max_spt = char_stats.spellpoints = 3;
X	char_stats.max_hp =  char_stats.hitpoints   = 12;
X	char_stats.gold        = 100;
X	char_stats.level       = 1;
X	char_stats.experience  = 0;
X	char_stats.ac = 0;
X	char_stats.num_items   = 0;
X	p->move_count = 0;
X	p->face = EAST;
X	p->compass_on = FALSE;
X	p->row = 9;
X	p->col = 1;
X	p->level = 1;
X	which_one = TRUE;
X	showit = TRUE;
X	detect = OFF;
X	d_val = HAND_DAM;
X	d_mod = HAND_MUL;
X	add_item(3);
X	for(x=0;x<=20;x++)
X	  known[x] = FALSE;
X	known[0] = known[1] = TRUE;
X}
X
Xwhich_scr(row,col,level)
Xint row,col,level;
X{
X	int number,wall;
X	char walls[7];
X/*
X	How wall configurations are determined:
X
X	                _____________     The 'X' is you.
X                        | 2 | 5 | 3 |     Spot 0 is to your left.
X		        -------------     Spot 1 is to your Right.
X                        | 4 |   | 6 |     Spot 2 is two spaces out front
X		        -------------            and to your left.
X                        | 0 | X | 1 |     Spot 3 is two spaces out front
X		        -------------            and to your right.
X                                          Spot 4 is one space out front
X                                                 and to your left.
X                                          Spot 5 is two spaces out front.
X                                          Spot 6 is one space out front
X                                                 and to your right.
X
X
X			 # #
X			##n##
X			 w e       You are at the 's' or south of viewing area.
X			##s##      As pointed to.
X		  	 #^#
X*/
X	for(wall=0;wall<=6;wall++)
X		walls[wall] = '0';
X
X	switch (p->face){
X	case NORTH:  
X		if(levels[level][row-1][col]!= WALL){
X			if(levels[level][row-2][col]   == WALL) 
X				walls[5] = '1';                
X			if(levels[level][row-1][col-1] == WALL)
X				walls[4] = '1';                
X			if(levels[level][row-1][col+1] == WALL)
X				walls[6] = '1';               
X			if(levels[level][row-2][col-1] == WALL) 
X				walls[3] = '1';                 
X			if(levels[level][row-2][col+1] == WALL) 
X				walls[2] = '1';                
X			if(levels[level][row][col-1]   == WALL) 
X				walls[0] = '1';  	       
X			if(levels[level][row][col+1]   == WALL) 
X				walls[1] = '1';                 
X			number = atoi(walls);
X		}
X		else{
X			number = -1;
X		}
X		break;
X		/*
X				 # #
X				##n##
X		                >w e    
X				##s## 
X				 # #
X		*/
X	case EAST:  
X		if(levels[level][row][col+1]!= WALL){
X			if(levels[level][row][col+2]   == WALL) 
X				walls[5] = '1';                
X			if(levels[level][row-1][col+1] == WALL)
X				walls[4] = '1';                
X			if(levels[level][row+1][col+1] == WALL)
X				walls[6] = '1';                
X			if(levels[level][row-1][col]   == WALL) 
X				walls[0] = '1';                 
X			if(levels[level][row-1][col+2] == WALL) 
X				walls[3] = '1';                 
X			if(levels[level][row+1][col]   == WALL) 
X				walls[1] = '1';                 
X			if(levels[level][row+1][col+2] == WALL) 
X				walls[2] = '1';                 
X			number = atoi(walls);
X		}
X		else{
X			number = -1;
X		}
X		break;
X		/*
X				#v#
X			       ##n## 
X		                w e  
X			       ##s##
X				# #
X		*/
X	case SOUTH: 
X		if(levels[level][row+1][col]!= WALL){
X			if(levels[level][row+2][col]   == WALL)	
X				walls[5] = '1';		       	
X			if(levels[level][row+1][col-1] == WALL)	
X				walls[6] = '1';		       	
X			if(levels[level][row+1][col+1] == WALL)	
X				walls[4] = '1';		       	
X			if(levels[level][row][col+1]   == WALL)	
X				walls[0] = '1';		       	
X			if(levels[level][row][col-1]   == WALL) 
X				walls[1] = '1';		       	
X			if(levels[level][row+2][col-1] == WALL)	
X				walls[2] = '1';		       	
X			if(levels[level][row+2][col+1] == WALL)	
X				walls[3] = '1';		       	
X			number = atoi(walls);
X		}
X		else{
X			number = -1;
X		}
X		break;
X		/*
X			 	 # #
X				##n##
X			         w e<  	
X				##s##
X				 # #
X		*/
X	case WEST: 
X		if(levels[level][row][col-1]!= WALL){
X			if(levels[level][row][col-2] == WALL)  
X				walls[5] = '1';		       
X			if(levels[level][row+1][col-1] == WALL)
X				walls[4] = '1';		        
X			if(levels[level][row-1][col-1] == WALL) 
X				walls[6] = '1';		        
X			if(levels[level][row+1][col]   == WALL) 
X				walls[0] = '1';		        
X			if(levels[level][row-1][col]   == WALL) 
X				walls[1] = '1';		        
X			if(levels[level][row-1][col-2] == WALL) 
X				walls[2] = '1';		        
X			if(levels[level][row+1][col-2] == WALL) 
X				walls[3] = '1';		        
X			number = atoi(walls);
X		}
X		else{
X			number = -1;
X		}
X		break;
X	}
X	switch (number){
X	case -1      : 
X		p->screen = 0;
X		break;
X	case 101     :		/* Basic hallway */
X	case 1101    :
X	case 10101   :
X	case 11101   :
X	case 100101  :
X	case 110101  :
X	case 101101  :
X	case 111101  :
X	case 1000101 :
X	case 1001101 :
X	case 1010101 :
X	case 1100101 :
X	case 1110101 :
X	case 1101101 :
X	case 1111101 :
X	case 1011101 :
X		if(which_one)
X			p->screen = 1;
X		else
X			p->screen = 2;
X		break;
X	case 11      : 
X	case 11011   :
X	case 110011  :
X	case 111011  :
X	case 100011  :
X	case 1010011 :
X		p->screen = 3;
X		break;
X	case 1110    :
X	case 11110   :		/* Left Wall & Wall Ahead 	*/
X	case 101110  :
X	case 1011110 :
X	case 1001110 :
X		p->screen = 4;
X		break;
X	case 1111010 :
X		p->screen = 5;   /* wall out front alone from passage	 */
X		break;
X	case 111     : 
X	case 1111    :
X	case 11111   :
X	case 111111  :
X	case 100111  :
X	case 101111  :
X	case 110111  :
X	case 1011111 :
X	case 1111111 :
X		p->screen = 6;
X		break;
X	case 0       : 
X		p->screen = 7;
X		break;
X	case 1100    :	  		/* Screen Full left		*/
X	case 1000100 :			/* none on Right		*/
X	case 11100   :
X	case 1011100 :
X	case 101100  :
X	case 1001100 :
X	case 111100  :
X	case 1110100 :
X	case 100100  : 
X	case 1100100 :
X		p->screen = 8;
X		break;
X	case 10001   :
X	case 11001   :
X	case 110001  :
X	case 111001  :	
X	case 100001  :
X	case 101001  :
X	case 1010001 :
X	case 1000001 :
X	case 1       : 
X		p->screen = 9;
X		break;
X	case 10      : 
X		p->screen = 10;
X		break;
X	case 1111000 : 
X		p->screen = 11;
X		break;
X	case 1100000 : 
X		p->screen = 12;
X		break;
X	case 1101000 :
X		p->screen = 13;
X	        break;
X	case 111000  : 
X		p->screen = 14;
X		break;
X	case 11010   : 
X		p->screen = 15;
X		break;
X	case 1111100 :      		/* Wall is partial on left      */
X	case 1101100 :		        /* Full on Right.		*/
X		p->screen = 16;
X		break;
X	case 1011001 : /* Full right wall partial on left  */
X	case 1111001 : 
X	case 1110001 :
X	case 1101001 :
X	case 1100001 :
X		p->screen = 17;
X		break;
X	case 1111011 :      		/*  Left corner with partial on left */
X	case 1110011 :			/*  Side.			     */
X	case 1011011 :
X		p->screen = 18;
X		break;
X	case 1111110 : 			/* Right corner with partial on      */
X	case 1101110 :			/* Right Side.			     */
X	case 111110  : 
X		p->screen = 19;
X		break;
X	case 110000  : 
X		p->screen = 20;
X		break;
X	case 1001000 : 
X		p->screen = 21;
X		break;
X	case 11000   : 
X		p->screen = 22;
X		break;
X	case 1000000 : 
X		p->screen = 23;
X		break;
X	case 111010  :
X		p->screen = 24;
X		break;
X	case 1011010 :
X		p->screen = 25;
X	        break;
X	case 10010   :
X		p->screen = 26;
X		break;
X	case 10011   :
X		p->screen = 27;
X		break;
X	case 1101010 :
X		p->screen = 28;
X	        break;
X	case 1110010 :
X		p->screen = 29;
X		break;
X	case 1001010 :
X		p->screen = 30;
X		break;
X	case 110010  :
X	 	p->screen = 31;
X		break;
X	case 101010  :
X		p->screen = 32;
X		break;
X	case 1011000 :
X		p->screen = 33;
X		break;
X	default      : 
X		p->screen = 7;
X	}
X# ifdef DEBUG
X	wmove(debug_win,0,0);
X	wclrtoeol(debug_win);
X	wrefresh(debug_win);
X	wprintw(debug_win,"num=%d",number);
X	wmove(debug_win,1,0);
X	wclrtoeol(debug_win);
X	wprintw(debug_win,"scr=%d",p->screen);
X	wrefresh(debug_win);
X# endif
X}
X
X
Xint getint(row,col)			/* routine to read an integer from */
Xint row,col;	 			/* the message window.		   */
X{
X	int integer;
X
X	get_str(row,col);
X	integer = atoi(string);
X	return(integer);
X}
X
Xlook_inv()		/* look at your inventory.   */
X{
X	unsigned char choice;
X
X	start = firstnode;
X	wclear(inv_win);
X	do
X	    {
X		wmove(inv_win,0,0);
X		wprintw(inv_win,"Inventory :");
X		wmove(inv_win,1,0);
X		wprintw(inv_win,"N)ext P)rev W)ield R)emove");
X		wmove(inv_win,2,0);
X		wprintw(inv_win,"U)se D)rop esc) to exit ");
X		wmove(inv_win,4,0);
X		wclrtoeol(inv_win);
X		wprintw(inv_win,"%s ",start->item);
X		wprintw(inv_win,"%d ",start->armor_val);
X		if(start->used == TRUE)
X			wprintw(inv_win,"*");
X		wmove(inv_win,2,24);
X		wrefresh(inv_win);
X		choice = getch();
X		switch (choice){
X	        case 'N':		/* Go to the next item.    */
X		case 'n': 
X			if(start->next != NULL)
X			   start = start->next;
X			break;
X		case 'P':		/* Go to the previous item. */
X		case 'p': 
X			if(start->prev != NULL)
X	  		  start = start->prev;
X			break;
X		case 'W':		/* Put on the item.	    */
X		case 'w': 
X			if(check_it(start->item_type) == FALSE){
X			  if(start->used == FALSE)
X			    char_stats.ac += start->armor_val;
X			  else{
X			    wclear(message_win);
X			    print_mess("You already are wearing this.",0,0);
X			    wrefresh(message_win);
X			  }
X			  start->used = TRUE;
X			  print_stats();
X			  if(start->item_type == 6){
X			     d_val = start->dam_val;
X			     d_mod = start->dam_mod;
X			  }
X			}
X			break;
X	     	case 'R':		/* Take off an item.       */
X		case 'r': 
X			if(start->used == TRUE){
X			      if(start->item_type == 6){
X			         d_val = HAND_DAM;
X			         d_mod = HAND_MUL;
X			      }
X				char_stats.ac -= start->armor_val;
X				start->used = FALSE;
X				print_stats();
X			}
X			break;
X		case 'D':		/* Drop an item.          */
X		case 'd': 
X			 if(start->used == TRUE){
X			   print_mess("Must take off item first.",0,0);
X			   wrefresh(message_win);
X			 }
X			 else
X			 if(start->next == NULL && start->prev == NULL){
X			   print_mess("Can't Drop Everything!!",0,0);
X			   wrefresh(message_win);
X			 }
X			 else				/* reset pointers. */
X			   if(start->next == NULL){
X			      start->prev->next = NULL;
X			      start = start->prev;
X			      char_stats.num_items--;
X		  	  }
X			    else
X			       if(start->prev == NULL){
X			         start->next->prev = NULL;
X			         start = start->next;
X				 firstnode = start;
X			         char_stats.num_items--;
X			       }
X			       else{
X				   start->next->prev = start->prev;
X				   start->prev->next = start->next;
X				   start = start->next;
X			           char_stats.num_items--;
X			       }   
X			break;
X		default: 
X			break;
X		}
X	}
X	while(choice != ESC);
X	wclear(inv_win);
X	wrefresh(inv_win);
X}
X
Xinit_list()
X{
X
X	oldnode = (list *) malloc(sizeof(list));
X	firstnode = oldnode;
X
X	oldnode->prev = NULL;
X	strcpy(oldnode->item,"Leather");
X	oldnode->armor_val = 3;
X	oldnode->item_type = 1;
X	oldnode->dam_val  = 0;
X	oldnode->dam_mod  = 0;
X	oldnode->item_no = 0;
X	oldnode->used  = FALSE;
X	oldnode->next = NULL;
X}
X
Xfind_item()
X{
X	int tmp;
X
X	if(rand()%100 > 97){
X	     if(char_stats.num_items < MAX_INV){
X		if(rand()%100 > 99)
X		  add_item(12);  /* Special Weapon  */
X		else{
X		    if(rand()%9 < 2)
X			add_item(15);
X		    else
X	                add_item(((rand()%3)+1) * p->level);
X		}
X	        char_stats.num_items++;
X	  	clr_mess_win();
X		sprintf(buffer,"You found something.");
X		print_mess(buffer,0,0);
X		wrefresh(message_win);
X	      }
X	}
X}
X
X
X
Xadd_item(item_no)
Xint item_no;
X{
X	   oldnode = firstnode;
X	   newnode = (list *) malloc(sizeof(list));
X	   if(item_no == 15){
X	     item_no = (14 + rand()%5);
X	     strcpy(newnode->item,armor[item_no].item);
X	     newnode->armor_val = 0;
X	     newnode->item_type = armor[item_no].item_type;
X	     newnode->dam_val = 0;
X	     newnode->dam_mod = 0;
X	     newnode->item_no = item_no;
X	     newnode->special = 1;
X	     newnode->used = FALSE;
X	     newnode->next = NULL;
X	   }else{
X	     strcpy(newnode->item,armor[item_no].item);
X	     newnode->armor_val = armor[item_no].armor_val;
X	     newnode->item_type = armor[item_no].item_type;
X	     newnode->dam_val = armor[item_no].dam_val;
X	     newnode->dam_mod = armor[item_no].dam_mod;
X	     newnode->item_no = item_no;
X	     newnode->special = 0;
X	     newnode->used = FALSE;
X	     newnode->next = NULL;
X	   }
X	   while(oldnode->next != NULL)
X	      oldnode = oldnode->next;
X	   newnode->prev = oldnode;
X	   oldnode->next = newnode;
X}
X
Xint check_it(type)
Xint type;
X{
X	int found;
X	int ct = 0;
X
X	temp = firstnode;
X	found = FALSE;
X	if(temp->next != NULL)
X	do
X	  {
X	    if((temp->item_type == type) && (temp->used == TRUE)){
X	      ct = 15;
X	      sprintf(buffer,"You must take off your %s ",temp->item);
X	      print_mess(buffer,0,0);
X	      print_mess("before you can wear this.",1,0);
X	      wrefresh(message_win);
X	      found = TRUE;
X	    }else{
X    	      temp = temp->next;
X	      ct++;
X	      found = FALSE;
X	    }
X	  }
X	while(temp->next != NULL && ct != 15 && !found);
Xreturn(found);
X}
X		
X
Xcatch(signo)		/* Catch a signal and handle it.  */
Xint signo;
X{
X	switch (signo){
X
X	case SIGINT : 
X		clr_mess_win();
X		print_mess("Really Quit?",0,0);
X		wrefresh(message_win);
X		if(wgetch(message_win) == 'y'){
X			strcpy(tmp.death_by,"quitting");
X			death();
X		}else
X		   	wclear(message_win);
X		break;
X
X	case SIGTERM:
X	case SIGHUP :
X	case SIGBUS :
X	case SIGSEGV:
X	case SIGILL :
X	case SIGFPE :
X		clr_mess_win();
X		print_mess("PANIC QUIT - SIGNAL ",0,0);
X		wmove(message_win,1,0);
X		wprintw("%d",signo);
X		wrefresh(message_win);
X		save();
X		sleep(1);
X		end_game();
X	break;
X	}
X	wrefresh(message_win);
X}
X
X	
X
Xdisarm()		/* disarm a trap.  */
X{
X	int rows,cols;
X	
X	rows = p->row;
X	cols = p->col;
X	switch (p->face){
X
X 	   case NORTH:
X 		     rows--;
X  	   break;
X	   case EAST :
X		     cols++;
X	   break;
X	   case SOUTH:
X		     rows++;
X	   break;
X	   case WEST :
X		     cols--;
X	   break;
X	}
X
X	if(levels[p->level][rows][cols] == TRAP)  /* Were you successful? */
X	  if((char_stats.level + 50) > rand()%99){
X	    print_mess("You disarmed the Trap!",0,0);
X	    char_stats.experience += 2;
X	    gain_lvl();
X	    levels[p->level][rows][cols] = BLANK; /* if so remove trap.   */
X	    p->row = rows;
X	    p->col = cols;
X	    showit = TRUE;
X	    print_stats();
X	  }else{
X	    wmove(message_win,0,0);
X	    wclrtoeol(message_win);
X						  /* else hurt you.       */
X	    print_mess("OUCH, you failed to disarm.",0,0);
X	    if(char_stats.dexterity > 16)	
X	      char_stats.hitpoints -= rand()%4 + 1;
X	    else
X	      char_stats.hitpoints -= rand()%10 + 1;
X	    print_stats();
X	  }
X	  else
X	     print_mess("No trap Here!",0,0);
X 	wrefresh(message_win);
Xsleep(1);
X}
X
Xregen()		/* regenerate character, rate depends on level */
X{
X	int hp_factor;
X	int sp_factor;
X
X	switch(char_stats.level){
X	   case 1:
X		   hp_factor = 10;
X		   sp_factor = 15;
X	   break;
X	   case 2:
X		   hp_factor = 20;
X		   sp_factor = 20;
X	   break;
X	   case 3:
X		   hp_factor = 25;
X		   sp_factor = 30;
X	   break;
X	   case 4:
X		   hp_factor = 35;
X		   sp_factor = 40;
X	   break;
X	   case 5:
X		   hp_factor = 45;
X		   sp_factor = 50;
X	   break;
X	   case 6:
X		   hp_factor = 55;
X		   sp_factor = 65;
X	   break;
X	   case 7:
X		   hp_factor = 65;
X		   sp_factor = 75;
X	   break;
X	   case 8:
X		   hp_factor = 75;
X		   sp_factor = 90;
X	   break;
X	   case 9:
X		   hp_factor = 95;
X		   sp_factor = 110;
X	   break;
X	   case 10:
X		   hp_factor = 110;
X		   sp_factor = 125;
X	   break;
X	   default: hp_factor = 150;
X		    sp_factor = 170;
X	}
X	p->move_count++;
X	if(p->move_count % (hp_factor / char_stats.level) == 0){
X		if(char_stats.hitpoints != char_stats.max_hp){
X			char_stats.hitpoints++;
X			print_stats();
X		}
X	}
X	if(p->move_count % (sp_factor / char_stats.level) == 0){
X		if(char_stats.spellpoints != char_stats.max_spt){
X			char_stats.spellpoints++;
X			print_stats();
X		}
X	}
X}
X
X	
Xgain_lvl()			/* gain an experience level */
X{
X	int hitpt, sppt;
X
X	if(char_stats.level < 35)
X	if(exp[char_stats.level + 1] <= char_stats.experience)
X	  if(lvl_att[char_stats.level + 1] != TRUE){
X	     hitpt = rand()%6 + 4;
X	     sppt  = rand()%2 + 1;
X	     char_stats.hitpoints  += hitpt;
X	     char_stats.max_hp += hitpt;
X	     char_stats.spellpoints += sppt;
X	     char_stats.max_spt += sppt;
X	     char_stats.level++;
X	     known[char_stats.level] = TRUE;
X	     lvl_att[char_stats.level] = TRUE;
X	     lvl_att[char_stats.level + 1] = FALSE;
X	     print_stats();
X	     beep();
X	     wrefresh(message_win);
X	  }
X}
X
Xclr_mess_win()
X{
X	int index;
X
X	wmove(message_win,0,0);
X	for(index=0;index<240;index++)
X	   wprintw(message_win,"%c",BLANK);
X	wmove(message_win,0,0);
X	wrefresh(message_win);
X}
X
Xrest()		/* Rest for a period */
X{
X	int turns,chance,x;
X
X	print_mess("Rest How long? ",0,0);
X	wrefresh(message_win);
X	turns = getint(0,16);
X	wclear(message_win);
X	wrefresh(message_win);
X	if(turns > 100)
X	  chance = 90;
X	else
X	  chance = 95;
X	for(x=0;x<=turns;x++){
X	  if(rand()%100 > chance){
X	    print_mess("Woke up.",0,0);
X	    wrefresh(message_win);
X	    combat();
X	    turns = 0;
X	  }
X	  if(turns%2 == 0)
X	    regen();
X	}
X	print_mess("Done Resting.",0,0);
X}
X
Xplace_at()			/* Teleport player to some exact location */
X{
X	switch(p->level){
X	  case 1: if(p->row == 4 && p->col == 61){
X		     p->row = 4;
X		     p->col = 55;
X		   }else{
X		     p->row = 1;
X		     p->col = 30;
X		   }
X	  break;
X	  case 2: if(p->row == 0 && p->col == 0){
X		     p->row = 0;
X		     p->col = 0;
X		   }else{
X		     p->row = 0;
X		     p->col = 0;
X		   }
X	  break;
X	  case 3: if(p->row == 6 && p->col == 10){
X		     p->row = 13;
X		     p->col = 63;
X		   }else{
X		     p->row = 7;
X		     p->col = 12;
X		   }
X	  break;
X	  case 4: if(p->row == 0 && p->col == 0){
X		     p->row = 0;
X		     p->col = 0;
X		   }else{
X		     p->row = 0;
X		     p->col = 0;
X		   }
X	  break;
X	  case 5: if(p->row == 0 && p->col == 0){
X		     p->row = 0;
X		     p->col = 0;
X		   }else{
X		     p->row = 0;
X		     p->col = 0;
X		   }
X	  break;
X	}
Xshowit = TRUE;
X}
X
Xcreate_wall()
X{
X	levels[p->level][p->row][p->col] = WALL;
X}
X
Xredraw()
X{
X	move(0,0);
X	clear();
X	refresh();
X	wclear(view_win);
X	wclear(message_win);
X	wclear(stat_win);
X	wclear(compass_win);
X	wclear(inv_win);
X	wrefresh(inv_win);
X	show_scr();
X	print_stats();
X        if(p->compass_on)
X          compass();
X}
X
Xfountain()
X{
X	char get_it;
X
X	print_mess("You see a Fountain.",0,0);
X	print_mess("Drink from the fountain? (y/n) ",1,0);
X	wrefresh(message_win);
X	get_it = wgetch(message_win);	
X	if(get_it == 'y'){
X	  levels[p->level][p->row][p->col] = BLANK;
X	switch(rand()%6){
X	  case 0:
X		  if(char_stats.dexterity < 18){
X		    char_stats.m_dex++;
X		    char_stats.dexterity++;
X		    print_mess("You feel more dexterous.",2,0);
X                    print_stats();
X		  }
X		  else
X		    print_mess("You feel more dexterous.",2,0);
X	          wrefresh(message_win);
X	  break;
X	  case 1:
X		  if(char_stats.constitution < 18){
X		    char_stats.m_con++;
X		    char_stats.constitution++;
X		    print_mess("You feel more healthy.",2,0);
X                    print_stats();
X		  }
X		  else
X		    print_mess("You feel more healthy.",2,0);
X	          wrefresh(message_win);
X	  break;
X	  case 2:
X		  if(char_stats.intelligence < 18){
X		    char_stats.m_int++;
X		    char_stats.intelligence++;
X		    print_mess("You feel more intelligent.",2,0);
X                    print_stats();
X		   }
X		   else
X		     print_mess("You feel more intelligent.",2,0);
X	          wrefresh(message_win);
X	  break;
X	  case 3:
X		  if(char_stats.wisdom < 18){
X		    char_stats.m_wis++;
X		    char_stats.wisdom++;
X		    print_mess("You feel more wise.",2,0);
X                    print_stats();
X		  }
X		  else
X		    print_mess("You feel more wise.",2,0);
X	          wrefresh(message_win);
X	  break;
X	  case 4:
X		  if(char_stats.strength < 18){
X		    char_stats.m_str++;
X		    char_stats.strength++;
X		    print_mess("You feel stronger.",2,0);
X                    print_stats();
X		  }
X		  else
X		    print_mess("You feel stronger.",2,0);
X	          wrefresh(message_win);
X	  break;
X	  case 5:
X		 if(char_stats.level < 33){
X		   char_stats.experience = exp[char_stats.level+1];
X		   gain_lvl();
X	           print_stats();
X		 }
X	         print_mess("You Feel More Skillful.",2,0);
X		 wrefresh(message_win);
X	  break;
X	}
X	}else
X	  print_mess("Left the Fountain alone.",2,0);
X}
X
Xgod_mode()
X{
X	char strin[20];
X	int test;
X	char ans;
X
X	print_mess("Password: ",0,0);
X	wmove(message_win,0,11);
X	wrefresh(message_win);
X	scanw("%s",strin);
X	if((test = strcmp(strin,"THE_WIZ")) != 0){
X	   print_mess("Sorry, You cannot enter 'god mode.'",1,0);
X	   wrefresh(message_win);
X	   sleep(1);
X	 }else{
X	   wclear(message_win);
X	   print_mess("Name: ",0,0);
X	   wmove(message_win,0,7);
X	   wrefresh(message_win);
X	   get_str(0,7);
X	   strcpy(char_stats.Name,string);
X	   print_stats();
X	   wclear(message_win);
X	   print_mess("Set Str to 18 (y/n)? ",0,0);
X	   wrefresh(message_win);
X	   ans = getch();
X	   if(ans == 'y'){
X	     char_stats.strength = 18;
X	     char_stats.m_str = 18;
X	     print_stats();
X	   }
X	   wclear(message_win);
X	   print_mess("Set Con to 18 (y/n)? ",0,0);
X	   wrefresh(message_win);
X	   ans = getch();
X	   if(ans == 'y'){
X	     char_stats.constitution = 18;
X	     char_stats.m_con = 18;
X	     print_stats();
X	   }
X	   wclear(message_win);
X	   print_mess("Set Dex to 18 (y/n)? ",0,0);
X	   wrefresh(message_win);
X	   ans = getch();
X	   if(ans == 'y'){
X	     char_stats.dexterity = 18;
X	     char_stats.m_dex = 18;
X	     print_stats();
X	   }
X	   wclear(message_win);
X	   print_mess("Set Int to 18 (y/n)? ",0,0);
X	   wrefresh(message_win);
X	   ans = getch();
X	   if(ans == 'y'){
X	     char_stats.intelligence = 18;
X	      char_stats.m_int = 18;
X	     print_stats();
X	   }
X	   wclear(message_win);
X	   print_mess("Set Wis to 18 (y/n)? ",0,0);
X	   wrefresh(message_win);
X	   ans = getch();
X	   if(ans == 'y'){
X	     char_stats.wisdom = 18;
X	     char_stats.m_wis = 18;
X	     print_stats();
X	   }
X	   do{
X	     wclear(message_win);
X	     print_mess("Raise level (y/n)? ",0,0);
X	     wrefresh(message_win);
X	     ans = getch();
X	     if(ans == 'y' && char_stats.level < 34){
X	       char_stats.experience = exp[char_stats.level+1];
X	       gain_lvl();
X	       print_mess("Welcome to the next level.",2,0);
X	       wrefresh(message_win);
X	       sleep(1);
X	     }
X	   }
X	   while(ans == 'y');
X	     
X	   wclear(message_win);
X	   print_mess("Add 3000 Gold (y/n)? ",0,0);
X	   wrefresh(message_win);
X	   ans = getch();
X	   if(ans == 'y'){
X             char_stats.gold += 3000;
X	     print_stats();
X	   }
X	   wclear(message_win);
X	   print_mess("Add item to inventory (y/n)? ",0,0);
X	   wrefresh(message_win);
X	   ans = getch();
X	   if(ans == 'y'){
X	     print_mess("What item number? ",2,0);
X	     wrefresh(message_win);
X	     test = getint(2,19);
X	     if(test < 15 && test >= 0)
X               add_item(test);
X	     else{
X	       beep();
X	       print_mess("No such Item.",3,0);
X	       wrefresh(message_win);
X	       sleep(1);
X	     }
X	}
X      }
X}
X
X
Xwhich_known()
X{
X	print_mess("+----------------+",0,0);
X	sprintf(buffer,"| a) [%d]  b) [%d] |",known[0],known[1]);
X	print_mess(buffer,1,0);
X	sprintf(buffer,"| c) [%d]  d) [%d] |",known[2],known[3]);
X	print_mess(buffer,2,0);
X	sprintf(buffer,"| e) [%d]  f) [%d] |",known[4],known[5]);
X	print_mess(buffer,3,0);
X	sprintf(buffer,"| g) [%d]  h) [%d] |",known[6],known[7]);
X	print_mess(buffer,4,0);
X	print_mess("+----------------+",5,0);
X	print_mess("Hit a key to Continue.",6,0);
X	wrefresh(message_win);
X	wgetch(message_win);
X}
X
Xdeath()
X{
X	score_list();
X	clear();
X	move(11,20);
X	printw("You were killed by %s.",tmp.death_by);
X	move(12,20);
X	printw("Better Luck Next Time!");
X	end_game();
X}
X
Xend_game()
X{
X	nl();
X	echo();
X	move(23,0);
X	refresh();
X	resetty();
X	exit(0);
X}
X
END_OF_FILE
if test 38358 -ne `wc -c <'castle.c'`; then
    echo shar: \"'castle.c'\" unpacked with wrong size!
fi
# end of 'castle.c'
fi
if test -f 'store.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'store.c'\"
else
echo shar: Extracting \"'store.c'\" \(7484 characters\)
sed "s/^X//" >'store.c' <<'END_OF_FILE'
X# include <stdio.h>
X# include <curses.h>
X
X# include "INCLUDE/castle.h"
X# include "INCLUDE/items.h"
X# include "INCLUDE/windows.h"
X/*
X
X	This is a public domain program, I have no objection to modifications
Xmade on it or use for some other reason so long as this notice remains intact.
X
X	
X		Part of:  castle 	Ted Wisniewski
X		Author:			Plymouth State College
X					Plymouth NH,
X						    03264
X		Copyright() PSC
X*/
X
Xstatic store[12][27] = {
X
X	{35,35,35,35,35,35,35,35,35,35,35,35,35,35,
X	35,35,35,35,35,35,35,35,35,35,35,35,35},
X	{35,35,92,92,92,47,124,32,62,45,45,45,45,45,
X	45,45,45,45,60,32,124,92,47,47,47,35,35},
X	{35,35,92,92,47,61,124,32,124,84,104,101,32,83,
X	116,111,114,101,124,32,124,61,92,47,47,35,35},
X	{35,35,92,47,61,61,124,32,62,45,45,45,45,45,
X	45,45,45,45,60,32,124,61,61,92,47,35,35},
X	{35,35,47,95,95,95,124,32,32,32,32,37,37,37,
X	37,37,32,32,32,32,124,95,95,95,92,35,35},
X	{35,35,32,32,32,32,32,32,32,32,41,124,79,32,
X	79,124,40,32,32,32,32,32,32,32,32,35,35},
X	{35,35,94,94,94,94,94,94,32,32,32,33,32,34,
X	32,33,32,32,32,94,94,94,94,94,94,35,35},
X	{35,35,124,124,124,124,124,124,32,32,32,92,32,61,
X	32,47,32,32,32,124,124,124,124,124,124,35,35},
X	{35,35,124,124,124,124,124,124,32,47,45,45,40,61,
X	41,45,45,92,32,124,124,124,124,124,124,35,35},
X	{35,35,124,124,124,124,124,124,32,124,124,32,47,42,
X	92,32,124,124,32,124,124,124,124,124,124,35,35},
X	{35,35,124,124,124,124,124,124,32,124,124,32,92,42,
X	47,32,124,124,32,124,124,124,124,124,124,35,35},
X	{35,35,35,35,35,35,35,35,35,35,35,35,35,35,
X	35,35,35,35,35,35,35,35,35,35,35,35,35}
X       };
Xthe_store()
X{
X	prt_store();
X	print_mess("Enter the store (y/n)?");
X	wrefresh(message_win);
X	if(getch() == 'y')
X	  buy_it();	
X	else{
X	  showit = TRUE;
X	  wclear(message_win);
X	  wrefresh(message_win);
X	}
X}
X
Xprt_store()
X{
X	int x,y;
X	
X	wmove(view_win,0,0);
X	for(y=0;y<=11;y++)
X	  for(x=0;x<=26;x++)
X	     wprintw(view_win,"%c",store[y][x]);
X        wrefresh(view_win);
X}
X
Xbuy_it()
X{
X    int on_sale = (rand()%NUM_ITEMS);
X    char choice;
X    int value,price = 100;
X
X    price = (armor[on_sale].armor_val + armor[on_sale].dam_val) * 100;
X    if(armor[on_sale].item_type == 1)
X       price = price * 3;
X    while(choice != 'L'){
X	print_mess("Restore A Stat to full? 'L' to leave ",0,0);
X	print_mess("S)tr D)ex C)on W)is I)nt ",1,0);
X	print_mess("1)hitpoints 2)spellpoints",2,0);
X	sprintf(buffer,"3)Sale item %s for %d gold.",armor[on_sale].item,price);
X	print_mess(buffer,3,0);
X	wmove(message_win,3,(strlen(buffer)+1));
X	wrefresh(message_win);
X	wmove(message_win,3,0);
X	choice = wgetch(message_win);
X	wclear(message_win);
X	switch(choice){
X	  case 'S' : if(char_stats.strength < char_stats.m_str){
X		       value = (char_stats.m_str - char_stats.strength)*100;
X			if(value > char_stats.gold)
X			  print_mess("Not Enough Gold, Sorry.",0,0);
X			else{
X			  sprintf(buffer,"It will cost %d gold.",value);
X			  print_mess(buffer,0,0);
X			  char_stats.strength = char_stats.m_str;
X			  char_stats.gold -= value;
X			  print_stats();
X			}
X		      }
X		break;
X	  case 'D' :
X	             if(char_stats.dexterity < char_stats.m_dex){
X		       value = (char_stats.m_dex - char_stats.dexterity)*100;
X			if(value > char_stats.gold)
X			  print_mess("Not Enough Gold, Sorry.",0,0);
X			else{
X			  sprintf(buffer,"It will cost %d gold.",value);
X			  print_mess(buffer,0,0);
X			  char_stats.dexterity = char_stats.m_dex;
X			  char_stats.gold -= value;
X			  print_stats();
X			}
X		      }
X		break;
X	  case 'C' :
X	  case 'W' :
X	  case 'I' :
X		     break;
X	  case '1' :if(char_stats.hitpoints < char_stats.max_hp){
X		      value = (char_stats.max_hp - char_stats.hitpoints) * 10;
X			if(value > char_stats.gold)
X			   print_mess("Not enuf gold.",0,0);
X			else{
X		           sprintf(buffer,"It will cost %d gold.",value);
X			   print_mess(buffer,0,0);
X			   char_stats.hitpoints = char_stats.max_hp;
X		           char_stats.gold -= value;
X			   print_stats();
X			  }
X			}
X	    	      break;
X	  case '2' :if(char_stats.spellpoints < char_stats.max_spt){
X		     value = (char_stats.max_spt - char_stats.spellpoints) * 20;
X			if(value > char_stats.gold)
X			   print_mess("Not enuf gold.",0,0);
X			else{
X		           sprintf(buffer,"It will cost %d gold.",value);
X		           print_mess(buffer,0,0);
X		           char_stats.spellpoints = char_stats.max_spt;
X		           char_stats.gold -= value;
X			   print_stats();
X	    	         }
X		     }
X		   break;
X	  case '3' : if(char_stats.gold >= price){
X			add_item(on_sale);
X			char_stats.gold -= price;
X			print_stats();
X		     }else
X			print_mess("Costs too much.",4,0);
X		     break;
X	}
X     wrefresh(message_win);
X     sleep(1);
X     }
X     switch(p->face){
X	case EAST: p->face = WEST;
X		   break;
X	case WEST: p->face = EAST;
X		   break;
X	case NORTH: p->face = SOUTH;
X		   break;
X	case SOUTH: p->face = NORTH;
X		   break;
X     }
X     showit = TRUE;
X}
X
Xhelp_list()
X{
X	clear();
X	mvaddstr(1,20,"Command Summary");
X	mvaddstr(3,5,"(h,4) - turn left           (l,6) - turn right");
X	mvaddstr(4,5,"(j,2) - back up             (k,8) - move forward");
X	mvaddstr(5,5,"(.)   - Turn around         (c,C) - Cast spells");
X	mvaddstr(6,5,"(r,R) - Rest                (i,I) - Goto Inventory");
X	mvaddstr(7,5,"(d,D) - Disarm a trap       (<,>) - Go up/down stairs");
X	mvaddstr(8,5,"(L)   - Lookup a spell      (S)   - Known spells");
X	mvaddstr(9,5,"(N)   - Change Name         ");
X	mvaddstr(11,17,"(?)  - This Help Summary.");
X	mvaddstr(13,17,"(ctrl e)  - save game");
X	mvaddstr(14,17,"(ctrl r)  - redraw screen");
X	mvaddstr(16,17,"Press a key to continue.");
X	refresh();
X	getch();
X	redraw();
X}
X
Xget_str(row,col)
Xint row,col;
X{
X	int i = 0,j;
X	char in;
X
X	for(j=0;j<=20;j++)
X	   string[j] = '\0';
X	wmove(message_win,row,col);
X	wrefresh(message_win);
X	do
X	  {
X	   in = string[i] = getch();
X	   if(in == 0x08 || in == 0x7f){
X	     i--;
X	     wmove(message_win,row,col+i);
X	     wprintw(message_win,"%c",' ');
X	     wmove(message_win,row,col+i);
X	     wrefresh(message_win);
X	     string[i] = ' ';
X	   }else{
X	     wmove(message_win,row,col+i);
X	     wprintw(message_win,"%c",string[i]);
X	     wrefresh(message_win);
X	     i++;
X	   }
X	}
X	while(in != 0x0a && in != 0x0d);
X}
X
Xask_ques(q)
Xint q;
X{
X	char word[];
X	int t;
X
X	switch(q){
X	  case 1: 
X	 	print_mess("What is anti life?",0,0);
X		wrefresh(message_win);
X		get_str(0,20);
X		strcpy(word,string);
X		if((strcmp(word,"death")) == 10){
X		  levels[p->level][p->row][p->col] = DOWN;
X	          print_mess("The Stairs are now visible.",2,0);
X		  wrefresh(message_win);
X		}else{
X		  print_mess("Too bad.",2,0);
X		  wrefresh(message_win);
X		} 
X		sleep(2);
X		wclear(message_win);
X		wrefresh(message_win);
X		break;
X	  case 2:
X	 	print_mess("What holds the power?",0,0);
X		wrefresh(message_win);
X		get_str(0,23);
X		strcpy(word,string);
X		if((strcmp(word,"lance")) == 10){
X		  levels[p->level][p->row][p->col] = DOWN;
X	          print_mess("The Stairs are now visible.",2,0);
X		  wrefresh(message_win);
X		}else{
X		  print_mess("Too bad.",2,0);
X		  wrefresh(message_win);
X		} 
X		sleep(2);
X		wclear(message_win);
X		wrefresh(message_win);
X		break;
X	  case 3:
X	 	print_mess("What is the key to survival?",0,0);
X		wrefresh(message_win);
X		get_str(0,30);
X		strcpy(word,string);
X		if((strcmp(word,"armor")) == 10){
X		  levels[p->level][p->row][p->col] = DOWN;
X	          print_mess("The Stairs are now visible.",2,0);
X		  wrefresh(message_win);
X		}else{
X		  print_mess("Too bad.",2,0);
X		  wrefresh(message_win);
X		} 
X		sleep(2);
X		wclear(message_win);
X		wrefresh(message_win);
X		break;
X	}
X}
END_OF_FILE
if test 7484 -ne `wc -c <'store.c'`; then
    echo shar: \"'store.c'\" unpacked with wrong size!
fi
# end of 'store.c'
fi
echo shar: End of archive 1 \(of 4\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0