[comp.sources.games] v01i011: rogue - a rogue 5.3 clone, Part01/05

games-request@tekred.TEK.COM (05/11/87)

Submitted by: Tim Stoehr <tims@zues.TEK.COM>
Comp.sources.games: Volume 1, Issue 11
Archive-name: rogue/Part01

#! /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 5)."
# Contents:  README MANIFEST level.c main.c monster.c use.c
# Wrapped by billr@tekred on Mon May 11 12:19:15 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f README -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"README\"
else
echo shar: Extracting \"README\" \(3092 characters\)
sed "s/^X//" >README <<'END_OF_README'
X
XYes, folks, this is the same old rogue 5.3-clone source that I've posted
Xhere before.  So why do it again?  Well, I got many complaints/inquisitions
Xabout whether this code was ported to a number of different UNIX/ULTRIX/VMS
Xsystems.  The answer is still "no."  BUTTTT..., I would like to first port
Xit to as may of the different UNIX systems as I can, and go from there.
X
XMy problem is that I'm not particularly familiar with the ins and outs of
Xother UNIX systems besides the one I work on. (BSD 4.[23])  So what I've
Xdone is set up the rogue source code so that all of the machine dependent
Xstuff is localized in one source file, machdep.c.  Enclosed in machdep.c
Xare all of the routines that I thought were even slightly machine-dependent.
XAlso enclosed in machdep.c is a copious set of comments describing what's
Xgoing on in there.  Now, most of these routines I believe will run most
XUNIX systems without modification, but then again, some won't.
XThat's where I need some help.  I need folks who have access to other
XUNIX systems to make modifications to machdep.c that will effectively
Xport the entire rogue program to their particular UNIX system.  Enough
Xinstructions are included in machdep.c to do this.  The modified machdep.c
Xcan be e-mailed to me, whereby I can incorporate the changes, and post
Xversions of machdep.c to comp.sources.games as it becomes more complete.
X
XDoes this sound remotely interesting to you?  Please give me a hand.
X
XIf you can't do it yourself, maybe you know someone who can.  A little
Xthumbing through your system documentation is all you probably need.
X
XI am hoping all the system-dependencies are in machdep.c, but I suspect
Xthere may be some 'C' constructs that various compilers out there don't
Xsupport or treat differently.  I need to know about these too.  I'm not
Xexpecting much of this on UNIX systems, though.
X
XThe code runs through 'lint' fine on my system.  All identifiers are unique
Xwithin their first eight characters.  Function names are unique within
Xtheir first seven characters.  All file names are under 14 characters.
X
X
XPrerequisites of the operating system:
X
X	32-bit long integer. (at least)
X	16-bit short integer. (at least)
X
X	Standard I/O library providing the following:
X		stdio.h (include file),
X		getchar(),
X		fopen(),
X		fclose(),
X		fread(),
X		fwrite(),
X		fgets(),
X		printf(),
X		sprintf(),
X		fflush(),
X		rewind().
X
X	String library providing the following:
X		strcpy(),
X		strncpy(),
X		strcmp(),
X		strncmp().
X
X	The curses/termlib libraries are desireable, but not strictly necessary.
X	The rogue source can be compiled with -DCURSES.  This will enable a
X	self-contained curses/termlib emulation package.  This package has some
X	restrictions which are outined in the comments near the top of the
X	enclosed source file curses.c.  This curses emulation package was put
X	into the source for systems that may not have curses available, or have
X	very buggy versions.  If your system has usable working curses/termlib
X	libraries, it is suggested that you use them instead of the enclosed
X	curses library.
X
X
XTim Stoehr
Xtims@zeus.TEK.COM
END_OF_README
if test 3092 -ne `wc -c <README`; then
    echo shar: \"README\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f MANIFEST -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"MANIFEST\"
else
echo shar: Extracting \"MANIFEST\" \(924 characters\)
sed "s/^X//" >MANIFEST <<'END_OF_MANIFEST'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X MANIFEST                  1	This shipping list
X Makefile                  5	
X README                    1	
X curses.c                  2	
X hit.c                     4	
X init.c                    5	
X inventory.c               4	
X level.c                   1	
X machdep.c                 2	
X main.c                    1	
X message.c                 4	
X monster.c                 1	
X move.c                    3	
X object.c                  2	
X pack.c                    4	
X play.c                    5	
X random.c                  5	
X ring.c                    4	
X rogue.h                   3	
X room.c                    4	
X save.c                    3	
X score.c                   3	
X spec_hit.c                3	
X throw.c                   2	
X trap.c                    5	
X use.c                     1	
X zap.c                     4	
END_OF_MANIFEST
if test 924 -ne `wc -c <MANIFEST`; then
    echo shar: \"MANIFEST\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f level.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"level.c\"
else
echo shar: Extracting \"level.c\" \(17490 characters\)
sed "s/^X//" >level.c <<'END_OF_level.c'
X/*
X * level.c
X *
X * This source herein may be modified and/or distributed by anybody who
X * so desires, with the following restrictions:
X *    1.)  No portion of this notice shall be removed.
X *    2.)  Credit shall not be taken for the creation of this source.
X *    3.)  This code is not to be traded, sold, or used for personal
X *         gain or profit.
X *
X */
X
X#ifndef CURSES
X#include <curses.h>
X#endif CURSES
X#include "rogue.h"
X
X#define swap(x,y) {t = x; x = y; y = t;}
X
Xshort cur_level = 0, max_level = 1, cur_room;
Xchar *new_level_message = 0;
Xshort party_room = NO_ROOM;
Xshort r_de;
X
Xlong level_points[MAX_EXP_LEVEL] = {
X		  10L,
X		  20L,
X		  40L,
X		  80L,
X		 160L,
X		 320L,
X		 640L,
X		1300L,
X		2600L,
X		5200L,
X	   10000L,
X	   20000L,
X	   40000L,
X	   80000L,
X	  160000L,
X	  320000L,
X	 1000000L,
X	 3333333L,
X	 6666666L,
X	  MAX_EXP,
X	99900000L
X};
X
Xchar random_rooms[MAXROOMS+1] = "\003\007\005\002\010\006\001\004\0";
X
Xextern boolean being_held, wizard, detect_monster;
Xextern boolean see_invisible;
Xextern short bear_trap, levitate, extra_hp, less_hp, cur_room;
Xextern short party_counter;
X
Xmake_level()
X{
X	short i, j;
X	short must_exist1, must_exist2, must_exist3;
X	boolean big_room;
X
X	if (cur_level < LAST_DUNGEON) {
X		cur_level++;
X	}
X	if (cur_level > max_level) {
X		max_level = cur_level;
X	}
X	must_exist1 = get_rand(0, 5);
X
X	switch(must_exist1) {
X	case 0:
X		must_exist1 = 0;
X		must_exist2 = 1;
X		must_exist3 = 2;
X		break;
X	case 1:
X		must_exist1 = 3;
X		must_exist2 = 4;
X		must_exist3 = 5;
X		break;
X	case 2:
X		must_exist1 = 6;
X		must_exist2 = 7;
X		must_exist3 = 8;
X		break;
X	case 3:
X		must_exist1 = 0;
X		must_exist2 = 3;
X		must_exist3 = 6;
X		break;
X	case 4:
X		must_exist1 = 1;
X		must_exist2 = 4;
X		must_exist3 = 7;
X		break;
X	case 5:
X		must_exist1 = 2;
X		must_exist2 = 5;
X		must_exist3 = 8;
X		break;
X	}
X	big_room = ((cur_level == party_counter) && rand_percent(1));
X	if (big_room) {
X		make_room(BIG_ROOM, 0, 0, 0);
X	} else {
X		for (i = 0; i < MAXROOMS; i++) {
X			make_room(i, must_exist1, must_exist2, must_exist3);
X		}
X	}
X	if (!big_room) {
X		add_mazes();
X
X		mix_random_rooms();
X
X		for (j = 0; j < MAXROOMS; j++) {
X
X			i = random_rooms[j];
X
X			if (i < (MAXROOMS-1)) {
X				(void) connect_rooms(i, i+1);
X			}
X			if (i < (MAXROOMS-3)) {
X				(void) connect_rooms(i, i+3);
X			}
X			if (i < (MAXROOMS-2)) {
X				if (rooms[i+1].is_room & R_NOTHING) {
X					if (connect_rooms(i, i+2)) {
X						rooms[i+1].is_room = R_CROSS;
X					}
X				}
X			}
X			if (i < (MAXROOMS-6)) {
X				if (rooms[i+3].is_room & R_NOTHING) {
X					if (connect_rooms(i, i+6)) {
X						rooms[i+3].is_room = R_CROSS;
X					}
X				}
X			}
X			if (is_all_connected()) {
X				break;
X			}
X		}
X		fill_out_level();
X	}
X	if (!has_amulet() && (cur_level >= AMULET_LEVEL)) {
X		put_amulet();
X	}
X}
X
Xmake_room(rn, r1, r2, r3)
Xshort rn, r1, r2, r3;
X{
X	short left_col, right_col, top_row, bottom_row;
X	short width, height;
X	short row_offset, col_offset;
X	short i, j;
X	short ch;
X
X	switch(rn) {
X	case 0:
X		left_col = 0;
X		right_col = COL1-1;
X		top_row = MIN_ROW;
X		bottom_row = ROW1-1;
X		break;
X	case 1:
X		left_col = COL1+1;
X		right_col = COL2-1;
X		top_row = MIN_ROW;
X		bottom_row = ROW1-1;
X		break;
X	case 2:
X		left_col = COL2+1;
X		right_col = DCOLS-1;
X		top_row = MIN_ROW;
X		bottom_row = ROW1-1;
X		break;
X	case 3:
X		left_col = 0;
X		right_col = COL1-1;
X		top_row = ROW1+1;
X		bottom_row = ROW2-1;
X		break;
X	case 4:
X		left_col = COL1+1;
X		right_col = COL2-1;
X		top_row = ROW1+1;
X		bottom_row = ROW2-1;
X		break;
X	case 5:
X		left_col = COL2+1;
X		right_col = DCOLS-1;
X		top_row = ROW1+1;
X		bottom_row = ROW2-1;
X		break;
X	case 6:
X		left_col = 0;
X		right_col = COL1-1;
X		top_row = ROW2+1;
X		bottom_row = DROWS - 2;
X		break;
X	case 7:
X		left_col = COL1+1;
X		right_col = COL2-1;
X		top_row = ROW2+1;
X		bottom_row = DROWS - 2;
X		break;
X	case 8:
X		left_col = COL2+1;
X		right_col = DCOLS-1;
X		top_row = ROW2+1;
X		bottom_row = DROWS - 2;
X		break;
X	case BIG_ROOM:
X		top_row = get_rand(MIN_ROW, MIN_ROW+5);
X		bottom_row = get_rand(DROWS-7, DROWS-2);
X		left_col = get_rand(0, 10);;
X		right_col = get_rand(DCOLS-11, DCOLS-1);
X		rn = 0;
X		goto B;
X	}
X	height = get_rand(4, (bottom_row-top_row+1));
X	width = get_rand(7, (right_col-left_col-2));
X
X	row_offset = get_rand(0, ((bottom_row-top_row)-height+1));
X	col_offset = get_rand(0, ((right_col-left_col)-width+1));
X
X	top_row += row_offset;
X	bottom_row = top_row + height - 1;
X
X	left_col += col_offset;
X	right_col = left_col + width - 1;
X
X	if ((rn != r1) && (rn != r2) && (rn != r3) && rand_percent(40)) {
X		goto END;
X	}
XB:
X	rooms[rn].is_room = R_ROOM;
X
X	for (i = top_row; i <= bottom_row; i++) {
X		for (j = left_col; j <= right_col; j++) {
X			if ((i == top_row) || (i == bottom_row)) {
X				ch = HORWALL;
X			} else if (((i != top_row) && (i != bottom_row)) &&
X			((j == left_col) || (j == right_col))) {
X				ch = VERTWALL;
X			} else {
X				ch = FLOOR;
X			}
X			dungeon[i][j] = ch;
X		}
X	}
XEND:
X	rooms[rn].top_row = top_row;
X	rooms[rn].bottom_row = bottom_row;
X	rooms[rn].left_col = left_col;
X	rooms[rn].right_col = right_col;
X}
X
Xconnect_rooms(room1, room2)
Xshort room1, room2;
X{
X	short row1, col1, row2, col2, dir;
X
X	if ((!(rooms[room1].is_room & (R_ROOM | R_MAZE))) ||
X		(!(rooms[room2].is_room & (R_ROOM | R_MAZE)))) {
X		return(0);
X	}
X	if (same_row(room1, room2) &&
X		(rooms[room1].left_col > rooms[room2].right_col)) {
X		put_door(&rooms[room1], LEFT, &row1, &col1);
X		put_door(&rooms[room2], RIGHT, &row2, &col2);
X		dir = LEFT;
X	} else if (same_row(room1, room2) &&
X		(rooms[room2].left_col > rooms[room1].right_col)) {
X		put_door(&rooms[room1], RIGHT, &row1, &col1);
X		put_door(&rooms[room2], LEFT, &row2, &col2);
X		dir = RIGHT;
X	} else if (same_col(room1, room2) &&
X		(rooms[room1].top_row > rooms[room2].bottom_row)) {
X		put_door(&rooms[room1], UP, &row1, &col1);
X		put_door(&rooms[room2], DOWN, &row2, &col2);
X		dir = UP;
X	} else if (same_col(room1, room2) &&
X		(rooms[room2].top_row > rooms[room1].bottom_row)) {
X		put_door(&rooms[room1], DOWN, &row1, &col1);
X		put_door(&rooms[room2], UP, &row2, &col2);
X		dir = DOWN;
X	} else {
X		return(0);
X	}
X
X	do {
X		draw_simple_passage(row1, col1, row2, col2, dir);
X	} while (rand_percent(4));
X
X	rooms[room1].doors[dir/2].oth_room = room2;
X	rooms[room1].doors[dir/2].oth_row = row2;
X	rooms[room1].doors[dir/2].oth_col = col2;
X
X	rooms[room2].doors[(((dir+4)%DIRS)/2)].oth_room = room1;
X	rooms[room2].doors[(((dir+4)%DIRS)/2)].oth_row = row1;
X	rooms[room2].doors[(((dir+4)%DIRS)/2)].oth_col = col1;
X	return(1);
X}
X
Xclear_level()
X{
X	short i, j;
X
X	for (i = 0; i < MAXROOMS; i++) {
X		rooms[i].is_room = R_NOTHING;
X		for (j = 0; j < 4; j++) {
X			rooms[i].doors[j].oth_room = NO_ROOM;
X		}
X	}
X
X	for (i = 0; i < MAX_TRAPS; i++) {
X		traps[i].trap_type = NO_TRAP;
X	}
X	for (i = 0; i < DROWS; i++) {
X		for (j = 0; j < DCOLS; j++) {
X			dungeon[i][j] = NOTHING;
X		}
X	}
X	detect_monster = see_invisible = 0;
X	being_held = bear_trap = 0;
X	party_room = NO_ROOM;
X	rogue.row = rogue.col = -1;
X	clear();
X}
X
Xput_door(rm, dir, row, col)
Xroom *rm;
Xshort dir;
Xshort *row, *col;
X{
X	short wall_width;
X
X	wall_width = (rm->is_room & R_MAZE) ? 0 : 1;
X
X	switch(dir) {
X	case UP:
X	case DOWN:
X		*row = ((dir == UP) ? rm->top_row : rm->bottom_row);
X		do {
X			*col = get_rand(rm->left_col+wall_width,
X				rm->right_col-wall_width);
X		} while (!(dungeon[*row][*col] & (HORWALL | TUNNEL)));
X		break;
X	case RIGHT:
X	case LEFT:
X		*col = (dir == LEFT) ? rm->left_col : rm->right_col;
X		do {
X			*row = get_rand(rm->top_row+wall_width,
X				rm->bottom_row-wall_width);
X		} while (!(dungeon[*row][*col] & (VERTWALL | TUNNEL)));
X		break;
X	}
X	if (rm->is_room & R_ROOM) {
X		dungeon[*row][*col] = DOOR;
X	}
X	if ((cur_level > 2) && rand_percent(HIDE_PERCENT)) {
X		dungeon[*row][*col] |= HIDDEN;
X	}
X	rm->doors[dir/2].door_row = *row;
X	rm->doors[dir/2].door_col = *col;
X}
X
Xdraw_simple_passage(row1, col1, row2, col2, dir)
Xshort row1, col1, row2, col2, dir;
X{
X	short i, middle, t;
X
X	if ((dir == LEFT) || (dir == RIGHT)) {
X		if (col1 > col2) {
X			swap(row1, row2);
X			swap(col1, col2);
X		}
X		middle = get_rand(col1+1, col2-1);
X		for (i = col1+1; i != middle; i++) {
X			dungeon[row1][i] = TUNNEL;
X		}
X		for (i = row1; i != row2; i += (row1 > row2) ? -1 : 1) {
X			dungeon[i][middle] = TUNNEL;
X		}
X		for (i = middle; i != col2; i++) {
X			dungeon[row2][i] = TUNNEL;
X		}
X	} else {
X		if (row1 > row2) {
X			swap(row1, row2);
X			swap(col1, col2);
X		}
X		middle = get_rand(row1+1, row2-1);
X		for (i = row1+1; i != middle; i++) {
X			dungeon[i][col1] = TUNNEL;
X		}
X		for (i = col1; i != col2; i += (col1 > col2) ? -1 : 1) {
X			dungeon[middle][i] = TUNNEL;
X		}
X		for (i = middle; i != row2; i++) {
X			dungeon[i][col2] = TUNNEL;
X		}
X	}
X	if (rand_percent(HIDE_PERCENT)) {
X		hide_boxed_passage(row1, col1, row2, col2, 1);
X	}
X}
X
Xsame_row(room1, room2)
X{
X	return((room1 / 3) == (room2 / 3));
X}
X
Xsame_col(room1, room2)
X{
X	return((room1 % 3) == (room2 % 3));
X}
X
Xadd_mazes()
X{
X	short i, j;
X	short start;
X	short maze_percent;
X
X	if (cur_level > 1) {
X		start = get_rand(0, (MAXROOMS-1));
X		maze_percent = (cur_level * 5) / 4;
X
X		if (cur_level > 15) {
X			maze_percent += cur_level;
X		}
X		for (i = 0; i < MAXROOMS; i++) {
X			j = ((start + i) % MAXROOMS);
X			if (rooms[j].is_room & R_NOTHING) {
X				if (rand_percent(maze_percent)) {
X				rooms[j].is_room = R_MAZE;
X				make_maze(get_rand(rooms[j].top_row+1, rooms[j].bottom_row-1),
X					get_rand(rooms[j].left_col+1, rooms[j].right_col-1),
X					rooms[j].top_row, rooms[j].bottom_row,
X					rooms[j].left_col, rooms[j].right_col);
X				hide_boxed_passage(rooms[j].top_row, rooms[j].left_col,
X					rooms[j].bottom_row, rooms[j].right_col,
X					get_rand(0, 2));
X				}
X			}
X		}
X	}
X}
X
Xfill_out_level()
X{
X	short i, rn;
X
X	mix_random_rooms();
X
X	r_de = NO_ROOM;
X
X	for (i = 0; i < MAXROOMS; i++) {
X		rn = random_rooms[i];
X		if ((rooms[rn].is_room & R_NOTHING) ||
X			((rooms[rn].is_room & R_CROSS) && coin_toss())) {
X			fill_it(rn, 1);
X		}
X	}
X	if (r_de != NO_ROOM) {
X		fill_it(r_de, 0);
X	}
X}
X
Xfill_it(rn, do_rec_de)
Xint rn;
Xboolean do_rec_de;
X{
X	short i, tunnel_dir, door_dir, drow, dcol;
X	short target_room, rooms_found = 0;
X	short srow, scol, t;
X	static short offsets[4] = {-1, 1, 3, -3};
X	boolean did_this = 0;
X
X	for (i = 0; i < 10; i++) {
X		srow = get_rand(0, 3);
X		scol = get_rand(0, 3);
X		t = offsets[srow];
X		offsets[srow] = offsets[scol];
X		offsets[scol] = t;
X	}
X	for (i = 0; i < 4; i++) {
X
X		target_room = rn + offsets[i];
X
X		if (((target_room < 0) || (target_room >= MAXROOMS)) ||
X			(!(same_row(rn,target_room) || same_col(rn,target_room))) ||
X			(!(rooms[target_room].is_room & (R_ROOM | R_MAZE)))) {
X			continue;
X		}
X		if (same_row(rn, target_room)) {
X			tunnel_dir = (rooms[rn].left_col < rooms[target_room].left_col) ?
X				RIGHT : LEFT;
X		} else {
X			tunnel_dir = (rooms[rn].top_row < rooms[target_room].top_row) ?
X				DOWN : UP;
X		}
X		door_dir = ((tunnel_dir + 4) % DIRS);
X		if (rooms[target_room].doors[door_dir/2].oth_room != NO_ROOM) {
X			continue;
X		}
X		if (((!do_rec_de) || did_this) ||
X			(!mask_room(rn, &srow, &scol, TUNNEL))) {
X			srow = (rooms[rn].top_row + rooms[rn].bottom_row) / 2;
X			scol = (rooms[rn].left_col + rooms[rn].right_col) / 2;
X		}
X		put_door(&rooms[target_room], door_dir, &drow, &dcol);
X		rooms_found++;
X		draw_simple_passage(srow, scol, drow, dcol, tunnel_dir);
X		rooms[rn].is_room = R_DEADEND;
X		dungeon[srow][scol] = TUNNEL;
X
X		if ((i < 3) && (!did_this)) {
X			did_this = 1;
X			if (coin_toss()) {
X				continue;
X			}
X		}
X		if ((rooms_found < 2) && do_rec_de) {
X			recursive_deadend(rn, offsets, srow, scol);
X		}
X		break;
X	}
X}
X
Xrecursive_deadend(rn, offsets, srow, scol)
Xshort rn;
Xshort *offsets;
Xshort srow, scol;
X{
X	short i, de;
X	short drow, dcol, tunnel_dir;
X
X	rooms[rn].is_room = R_DEADEND;
X	dungeon[srow][scol] = TUNNEL;
X
X	for (i = 0; i < 4; i++) {
X		de = rn + offsets[i];
X		if (((de < 0) || (de >= MAXROOMS)) ||
X			(!(same_row(rn, de) || same_col(rn, de)))) {
X			continue;
X		}
X		if (!(rooms[de].is_room & R_NOTHING)) {
X			continue;
X		}
X		drow = (rooms[de].top_row + rooms[de].bottom_row) / 2;
X		dcol = (rooms[de].left_col + rooms[de].right_col) / 2;
X		if (same_row(rn, de)) {
X			tunnel_dir = (rooms[rn].left_col < rooms[de].left_col) ?
X				RIGHT : LEFT;
X		} else {
X			tunnel_dir = (rooms[rn].top_row < rooms[de].top_row) ?
X				DOWN : UP;
X		}
X		draw_simple_passage(srow, scol, drow, dcol, tunnel_dir);
X		r_de = de;
X		recursive_deadend(de, offsets, drow, dcol);
X	}
X}
X
Xboolean
Xmask_room(rn, row, col, mask)
Xshort rn;
Xshort *row, *col;
Xunsigned short mask;
X{
X	short i, j;
X
X	for (i = rooms[rn].top_row; i <= rooms[rn].bottom_row; i++) {
X		for (j = rooms[rn].left_col; j <= rooms[rn].right_col; j++) {
X			if (dungeon[i][j] & mask) {
X				*row = i;
X				*col = j;
X				return(1);
X			}
X		}
X	}
X	return(0);
X}
X
Xmake_maze(r, c, tr, br, lc, rc)
Xshort r, c, tr, br, lc, rc;
X{
X	char dirs[4];
X	short i, t;
X
X	dirs[0] = UP;
X	dirs[1] = DOWN;
X	dirs[2] = LEFT;
X	dirs[3] = RIGHT;
X
X	dungeon[r][c] = TUNNEL;
X
X	if (rand_percent(33)) {
X		for (i = 0; i < 10; i++) {
X			short t1, t2;
X
X			t1 = get_rand(0, 3);
X			t2 = get_rand(0, 3);
X
X			swap(dirs[t1], dirs[t2]);
X		}
X	}
X	for (i = 0; i < 4; i++) {
X		switch(dirs[i]) {
X		case UP:
X			if (((r-1) >= tr) &&
X				(dungeon[r-1][c] != TUNNEL) &&
X				(dungeon[r-1][c-1] != TUNNEL) &&
X				(dungeon[r-1][c+1] != TUNNEL) &&
X				(dungeon[r-2][c] != TUNNEL)) {
X				make_maze((r-1), c, tr, br, lc, rc);
X			}
X			break;
X		case DOWN:
X			if (((r+1) <= br) &&
X				(dungeon[r+1][c] != TUNNEL) &&
X				(dungeon[r+1][c-1] != TUNNEL) &&
X				(dungeon[r+1][c+1] != TUNNEL) &&
X				(dungeon[r+2][c] != TUNNEL)) {
X				make_maze((r+1), c, tr, br, lc, rc);
X			}
X			break;
X		case LEFT:
X			if (((c-1) >= lc) &&
X				(dungeon[r][c-1] != TUNNEL) &&
X				(dungeon[r-1][c-1] != TUNNEL) &&
X				(dungeon[r+1][c-1] != TUNNEL) &&
X				(dungeon[r][c-2] != TUNNEL)) {
X				make_maze(r, (c-1), tr, br, lc, rc);
X			}
X			break;
X		case RIGHT:
X			if (((c+1) <= rc) &&
X				(dungeon[r][c+1] != TUNNEL) &&
X				(dungeon[r-1][c+1] != TUNNEL) &&
X				(dungeon[r+1][c+1] != TUNNEL) &&
X				(dungeon[r][c+2] != TUNNEL)) {
X				make_maze(r, (c+1), tr, br, lc, rc);
X			}
X			break;
X		}
X	}
X}
X
Xhide_boxed_passage(row1, col1, row2, col2, n)
Xshort row1, col1, row2, col2, n;
X{
X	short i, j, t;
X	short row, col, row_cut, col_cut;
X	short h, w;
X
X	if (cur_level > 2) {
X		if (row1 > row2) {
X			swap(row1, row2);
X		}
X		if (col1 > col2) {
X			swap(col1, col2);
X		}
X		h = row2 - row1;
X		w = col2 - col1;
X
X		if ((w >= 5) || (h >= 5)) {
X			row_cut = ((h >= 2) ? 1 : 0);
X			col_cut = ((w >= 2) ? 1 : 0);
X
X			for (i = 0; i < n; i++) {
X				for (j = 0; j < 10; j++) {
X					row = get_rand(row1 + row_cut, row2 - row_cut);
X					col = get_rand(col1 + col_cut, col2 - col_cut);
X					if (dungeon[row][col] == TUNNEL) {
X						dungeon[row][col] |= HIDDEN;
X						break;
X					}
X				}
X			}
X		}
X	}
X}
X
Xput_player(nr)
Xshort nr;		/* try not to put in this room */
X{
X	short rn = nr, misses;
X	short row, col;
X
X	for (misses = 0; ((misses < 2) && (rn == nr)); misses++) {
X		gr_row_col(&row, &col, (FLOOR | TUNNEL | OBJECT | STAIRS));
X		rn = get_room_number(row, col);
X	}
X	rogue.row = row;
X	rogue.col = col;
X
X	if (dungeon[rogue.row][rogue.col] & TUNNEL) {
X		cur_room = PASSAGE;
X	} else {
X		cur_room = rn;
X	}
X	if (cur_room != PASSAGE) {
X		light_up_room(cur_room);
X	} else {
X		light_passage(rogue.row, rogue.col);
X	}
X	wake_room(get_room_number(rogue.row, rogue.col), 1, rogue.row, rogue.col);
X	if (new_level_message) {
X		message(new_level_message, 0);
X		new_level_message = 0;
X	}
X	mvaddch(rogue.row, rogue.col, rogue.fchar);
X}
X
Xdrop_check()
X{
X	if (wizard) {
X		return(1);
X	}
X	if (dungeon[rogue.row][rogue.col] & STAIRS) {
X		if (levitate) {
X			message("you're floating in the air!", 0);
X			return(0);
X		}
X		return(1);
X	}
X	message("I see no way down", 0);
X	return(0);
X}
X
Xcheck_up()
X{
X	if (!wizard) {
X		if (!(dungeon[rogue.row][rogue.col] & STAIRS)) {
X			message("I see no way up", 0);
X			return(0);
X		}
X		if (!has_amulet()) {
X			message("your way is magically blocked", 0);
X			return(0);
X		}
X	}
X	new_level_message = "you feel a wrenching sensation in your gut";
X	if (cur_level == 1) {
X		win();
X	} else {
X		cur_level -= 2;
X		return(1);
X	}
X	return(0);
X}
X
Xadd_exp(e, promotion)
Xint e;
Xboolean promotion;
X{
X	char mbuf[40];
X	short new_exp;
X	short i, hp;
X
X	rogue.exp_points += e;
X
X	if (rogue.exp_points >= level_points[rogue.exp-1]) {
X		new_exp = get_exp_level(rogue.exp_points);
X		if (rogue.exp_points > MAX_EXP) {
X			rogue.exp_points = MAX_EXP + 1;
X		}
X		for (i = rogue.exp+1; i <= new_exp; i++) {
X			sprintf(mbuf, "welcome to level %d", i);
X			message(mbuf, 0);
X			if (promotion) {
X				hp = hp_raise();
X				rogue.hp_current += hp;
X				rogue.hp_max += hp;
X			}
X			rogue.exp = i;
X			print_stats(STAT_HP | STAT_EXP);
X		}
X	} else {
X		print_stats(STAT_EXP);
X	}
X}
X
Xget_exp_level(e)
Xlong e;
X{
X	short i;
X
X	for (i = 0; i < (MAX_EXP_LEVEL - 1); i++) {
X		if (level_points[i] > e) {
X			break;
X		}
X	}
X	return(i+1);
X}
X
Xhp_raise()
X{
X	int hp;
X
X	hp = (wizard ? 10 : get_rand(3, 10));
X	return(hp);
X}
X
Xshow_average_hp()
X{
X	char mbuf[80];
X	float real_average;
X	float effective_average;
X
X	if (rogue.exp == 1) {
X		real_average = effective_average = 0.00;
X	} else {
X		real_average = (float)
X			((rogue.hp_max - extra_hp - INIT_HP) + less_hp) / (rogue.exp - 1);
X		effective_average = (float) (rogue.hp_max - INIT_HP) / (rogue.exp - 1);
X
X	}
X	sprintf(mbuf, "R-Hp: %.2f, E-Hp: %.2f (!: %d, V: %d)", real_average,
X		effective_average, extra_hp, less_hp);
X	message(mbuf, 0);
X}
X
Xmix_random_rooms()
X{
X	short i, t;
X	short x, y;
X
X	for (i = 0; i < (3 * MAXROOMS); i++) {
X		do {
X			x = get_rand(0, (MAXROOMS-1));
X			y = get_rand(0, (MAXROOMS-1));
X		} while (x == y);
X		swap(random_rooms[x], random_rooms[y]);
X	}
X}
END_OF_level.c
if test 17490 -ne `wc -c <level.c`; then
    echo shar: \"level.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f main.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"main.c\"
else
echo shar: Extracting \"main.c\" \(761 characters\)
sed "s/^X//" >main.c <<'END_OF_main.c'
X/*
X * main.c
X *
X * This source herein may be modified and/or distributed by anybody who
X * so desires, with the following restrictions:
X *    1.)  No portion of this notice shall be removed.
X *    2.)  Credit shall not be taken for the creation of this source.
X *    3.)  This code is not to be traded, sold, or used for personal
X *         gain or profit.
X *
X */
X
X#include "rogue.h"
X
Xextern short party_room;
X
Xmain(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	if (init(argc, argv)) {		/* restored game */
X		goto PL;
X	}
X
X	for (;;) {
X		clear_level();
X		make_level();
X		put_objects();
X		put_stairs();
X		add_traps();
X		put_mons();
X		put_player(party_room);
X		print_stats(STAT_ALL);
XPL:		
X		play_level();
X		free_stuff(&level_objects);
X		free_stuff(&level_monsters);
X	}
X}
END_OF_main.c
if test 761 -ne `wc -c <main.c`; then
    echo shar: \"main.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f monster.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"monster.c\"
else
echo shar: Extracting \"monster.c\" \(17882 characters\)
sed "s/^X//" >monster.c <<'END_OF_monster.c'
X/*
X * monster.c
X *
X * This source herein may be modified and/or distributed by anybody who
X * so desires, with the following restrictions:
X *    1.)  No portion of this notice shall be removed.
X *    2.)  Credit shall not be taken for the creation of this source.
X *    3.)  This code is not to be traded, sold, or used for personal
X *         gain or profit.
X *
X */
X
X#ifndef CURSES
X#include <curses.h>
X#endif CURSES
X#include "rogue.h"
X
Xobject level_monsters;
Xboolean mon_disappeared;
X
Xchar *m_names[] = {
X	"aquatar",
X	"bat",
X	"centaur",
X	"dragon",
X	"emu",
X	"venus fly-trap",
X	"griffin",
X	"hobgoblin",
X	"ice monster",
X	"jabberwock",
X	"kestrel",
X	"leprechaun",
X	"medusa",
X	"nymph",
X	"orc",
X	"phantom",
X	"quasit",
X	"rattlesnake",
X	"snake",
X	"troll",
X	"black unicorn",
X	"vampire",
X	"wraith",
X	"xeroc",
X	"yeti",
X	"zombie"
X};
X
Xobject mon_tab[MONSTERS] = {
X	{(ASLEEP|WAKENS|WANDERS|RUSTS),"0d0",25,'A',20,9,18,100,0,0,0,0,0},
X	{(ASLEEP|WANDERS|FLITS),"1d3",10,'B',2,1,8,60,0,0,0,0,0},
X	{(ASLEEP|WANDERS),"3d3/2d5",32,'C',15,7,16,85,0,10,0,0,0},
X	{(ASLEEP|WAKENS|FLAMES),"4d6/4d9",145,'D',5000,21,126,100,0,90,0,0,0},
X	{(ASLEEP|WAKENS),"1d3",11,'E',2,1,7,65,0,0,0,0,0},
X	{(HOLDS|STATIONARY),"5d5",73,'F',91,12,126,80,0,0,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS|FLIES),"5d5/5d5",115,'G',
X			2000,20,126,85,0,10,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS),"1d3/1d2",15,'H',3,1,10,67,0,0,0,0,0},
X	{(ASLEEP|FREEZES),"0d0",15,'I',5,2,11,68,0,0,0,0,0},
X	{(ASLEEP|WANDERS),"3d10/4d5",132,'J',3000,21,126,100,0,0,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS|FLIES),"1d4",10,'K',2,1,6,60,0,0,0,0,0},
X	{(ASLEEP|STEALS_GOLD),"0d0",25,'L',21,6,16,75,0,0,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS|CONFUSES),"4d4/3d7",97,'M',
X			250,18,126,85,0,25,0,0,0},
X	{(ASLEEP|STEALS_ITEM),"0d0",25,'N',39,10,19,75,0,100,0,0,0},
X	{(ASLEEP|WANDERS|WAKENS|SEEKS_GOLD),"1d6",25,'O',5,4,13,70,0,10,0,0,0},
X	{(ASLEEP|INVISIBLE|WANDERS|FLITS),"5d4",76,'P',120,15,24,80,0,50,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS),"3d5",30,'Q',20,8,17,78,0,20,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS|STINGS),"2d5",19,'R',10,3,12,70,0,0,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS),"1d3",8,'S',2,1,9,50,0,0,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS),"4d6/1d4",75,'T',125,13,22,75,0,33,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS),"4d10",90,'U',
X			200,17,26,85,0,33,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS|DRAINS_LIFE),"1d14/1d4",55,'V',
X			350,19,126,85,0,18,0,0,0},
X	{(ASLEEP|WANDERS|DROPS_LEVEL),"2d8",45,'W',55,14,23,75,0,0,0,0,0},
X	{(ASLEEP|IMITATES),"4d6",42,'X',110,16,25,75,0,0,0,0,0},
X	{(ASLEEP|WANDERS),"3d6",35,'Y',50,11,20,80,0,20,0,0,0},
X	{(ASLEEP|WAKENS|WANDERS),"1d7",21,'Z',8,5,14,69,0,0,0,0,0}
X};
X
Xextern short cur_level;
Xextern short cur_room, party_room;
Xextern short blind, halluc, haste_self;
Xextern boolean detect_monster, see_invisible, r_see_invisible;
Xextern short stealthy;
X
Xput_mons()
X{
X	short i;
X	short n;
X	object *monster;
X	short row, col;
X
X	n = get_rand(4, 6);
X
X	for (i = 0; i < n; i++) {
X		monster = gr_monster((object *) 0, 0);
X		if ((monster->m_flags & WANDERS) && coin_toss()) {
X			wake_up(monster);
X		}
X		gr_row_col(&row, &col, (FLOOR | TUNNEL | STAIRS | OBJECT));
X		put_m_at(row, col, monster);
X	}
X}
X
Xobject *
Xgr_monster(monster, mn)
Xregister object *monster;
Xregister mn;
X{
X	if (!monster) {
X		monster = alloc_object();
X
X		for (;;) {
X			mn = get_rand(0, MONSTERS-1);
X			if ((cur_level >= mon_tab[mn].first_level) &&
X			(cur_level <= mon_tab[mn].last_level)) {
X				break;
X			}
X		}
X	}
X	*monster = mon_tab[mn];
X	if (monster->m_flags & IMITATES) {
X		monster->disguise = gr_obj_char();
X	}
X	if (cur_level > (AMULET_LEVEL + 2)) {
X		monster->m_flags |= HASTED;
X	}
X	monster->trow = NO_ROOM;
X	return(monster);
X}
X
Xmv_mons()
X{
X	register object *monster, *next_monster;
X	boolean flew;
X
X	if (haste_self % 2) {
X		return;
X	}
X
X	monster = level_monsters.next_monster;
X
X	while (monster) {
X		next_monster = monster->next_monster;
X		if (monster->m_flags & HASTED) {
X			mon_disappeared = 0;
X			mv_monster(monster, rogue.row, rogue.col);
X			if (mon_disappeared) {
X				goto NM;
X			}
X		} else if (monster->m_flags & SLOWED) {
X			monster->slowed_toggle = !monster->slowed_toggle;
X			if (monster->slowed_toggle) {
X				goto NM;
X			}
X		}
X		if ((monster->m_flags & CONFUSED) && move_confused(monster)) {
X			goto NM;
X		}
X		flew = 0;
X		if ((monster->m_flags & FLIES) && !(monster->m_flags & NAPPING) &&
X			 !mon_can_go(monster, rogue.row, rogue.col)) {
X			flew = 1;
X			mv_monster(monster, rogue.row, rogue.col);
X		}
X		if (!(flew && mon_can_go(monster, rogue.row, rogue.col))) {
X			mv_monster(monster, rogue.row, rogue.col);
X		}
XNM:		monster = next_monster;
X	}
X}
X
Xparty_monsters(rn, n)
Xint rn, n;
X{
X	short i, j;
X	short row, col;
X	object *monster;
X	boolean found;
X
X	n += n;
X
X	for (i = 0; i < MONSTERS; i++) {
X		mon_tab[i].first_level -= (cur_level % 3);
X	}
X	for (i = 0; i < n; i++) {
X		if (no_room_for_monster(rn)) {
X			break;
X		}
X		for (j = found = 0; ((!found) && (j < 250)); j++) {
X			row = get_rand(rooms[rn].top_row+1,
X				rooms[rn].bottom_row-1);
X			col = get_rand(rooms[rn].left_col+1,
X				rooms[rn].right_col-1);
X			if ((!(dungeon[row][col] & MONSTER)) &&
X				(dungeon[row][col] & (FLOOR | TUNNEL))) {
X				found = 1;
X			}
X		}
X		if (found) {
X			monster = gr_monster((object *) 0, 0);
X			if (!(monster->m_flags & IMITATES)) {
X				monster->m_flags |= WAKENS;
X			}
X			put_m_at(row, col, monster);
X		}
X	}
X	for (i = 0; i < MONSTERS; i++) {
X		mon_tab[i].first_level += (cur_level % 3);
X	}
X}
X
Xgmc_row_col(row, col)
Xregister row, col;
X{
X	register object *monster;
X	short retval;
X
X	if (monster = object_at(&level_monsters, row, col)) {
X		if ((!(detect_monster || see_invisible || r_see_invisible) &&
X			(monster->m_flags & INVISIBLE)) || blind) {
X			retval = monster->trail_char;
X			return(retval);
X		}
X		if (monster->m_flags & IMITATES) {
X			return(monster->disguise);
X		}
X		return(monster->m_char);
X	} else {
X		return('&');	/* BUG if this ever happens */
X	}
X}
X
Xgmc(monster)
Xobject *monster;
X{
X	if ((!(detect_monster || see_invisible || r_see_invisible) &&
X		(monster->m_flags & INVISIBLE))
X		|| blind) {
X		return(monster->trail_char);
X	}
X	if (monster->m_flags & IMITATES) {
X		return(monster->disguise);
X	}
X	return(monster->m_char);
X}
X
Xmv_monster(monster, row, col)
Xregister object *monster;
Xshort row, col;
X{
X	short i, n;
X	boolean tried[6];
X
X	if (monster->m_flags & ASLEEP) {
X		if (monster->m_flags & NAPPING) {
X			if (--monster->nap_length <= 0) {
X				monster->m_flags &= (~(NAPPING | ASLEEP));
X			}
X			return;
X		}
X		if ((monster->m_flags & WAKENS) &&
X			 rogue_is_around(monster->row, monster->col) &&
X			 rand_percent(((stealthy > 0) ?
X			 	(WAKE_PERCENT / (STEALTH_FACTOR + stealthy)) :
X				WAKE_PERCENT))) {
X			wake_up(monster);
X		}
X		return;
X	} else if (monster->m_flags & ALREADY_MOVED) {
X		monster->m_flags &= (~ALREADY_MOVED);
X		return;
X	}
X	if ((monster->m_flags & FLITS) && flit(monster)) {
X		return;
X	}
X	if ((monster->m_flags & STATIONARY) &&
X		(!mon_can_go(monster, rogue.row, rogue.col))) {
X		return;
X	}
X	if (monster->m_flags & FREEZING_ROGUE) {
X		return;
X	}
X	if ((monster->m_flags & CONFUSES) && m_confuse(monster)) {
X		return;
X	}
X	if (mon_can_go(monster, rogue.row, rogue.col)) {
X		mon_hit(monster, (char *) 0, 0);
X		return;
X	}
X	if ((monster->m_flags & FLAMES) && flame_broil(monster)) {
X		return;
X	}
X	if ((monster->m_flags & SEEKS_GOLD) && seek_gold(monster)) {
X		return;
X	}
X	if ((monster->trow == monster->row) &&
X		   (monster->tcol == monster->col)) {
X		monster->trow = NO_ROOM;
X	} else if (monster->trow != NO_ROOM) {
X		row = monster->trow;
X		col = monster->tcol;
X	}
X	if (monster->row > row) {
X		row = monster->row - 1;
X	} else if (monster->row < row) {
X		row = monster->row + 1;
X	}
X	if ((dungeon[row][monster->col] & DOOR) &&
X		 mtry(monster, row, monster->col)) {
X		return;
X	}
X	if (monster->col > col) {
X		col = monster->col - 1;
X	} else if (monster->col < col) {
X		col = monster->col + 1;
X	}
X	if ((dungeon[monster->row][col] & DOOR) &&
X		 mtry(monster, monster->row, col)) {
X		return;
X	}
X	if (mtry(monster, row, col)) {
X		return;
X	}
X
X	for (i = 0; i <= 5; i++) tried[i] = 0;
X
X	for (i = 0; i < 6; i++) {
XNEXT_TRY:	n = get_rand(0, 5);
X		switch(n) {
X		case 0:
X			if (!tried[n] && mtry(monster, row, monster->col-1)) {
X				goto O;
X			}
X			break;
X		case 1:
X			if (!tried[n] && mtry(monster, row, monster->col)) {
X				goto O;
X			}
X			break;
X		case 2:
X			if (!tried[n] && mtry(monster, row, monster->col+1)) {
X				goto O;
X			}
X			break;
X		case 3:
X			if (!tried[n] && mtry(monster, monster->row-1, col)) {
X				goto O;
X			}
X			break;
X		case 4:
X			if (!tried[n] && mtry(monster, monster->row, col)) {
X				goto O;
X			}
X			break;
X		case 5:
X			if (!tried[n] && mtry(monster, monster->row+1, col)) {
X				goto O;
X			}
X			break;
X		}
X		if (!tried[n]) {
X			tried[n] = 1;
X		} else {
X			goto NEXT_TRY;
X		}
X	}
XO:
X	if ((monster->row == monster->o_row) && (monster->col == monster->o_col)) {
X		if (++(monster->o) > 4) {
X			if ((monster->trow == NO_ROOM) &&
X					(!mon_sees(monster, rogue.row, rogue.col))) {
X				monster->trow = get_rand(1, (DROWS - 2));
X				monster->tcol = get_rand(0, (DCOLS - 1));
X			} else {
X				monster->trow = NO_ROOM;
X				monster->o = 0;
X			}
X		}
X	} else {
X		monster->o_row = monster->row;
X		monster->o_col = monster->col;
X		monster->o = 0;
X	}
X}
X
Xmtry(monster, row, col)
Xregister object *monster;
Xregister short row, col;
X{
X	if (mon_can_go(monster, row, col)) {
X		move_mon_to(monster, row, col);
X		return(1);
X	}
X	return(0);
X}
X
Xmove_mon_to(monster, row, col)
Xregister object *monster;
Xregister short row, col;
X{
X	short c;
X	register mrow, mcol;
X
X	mrow = monster->row;
X	mcol = monster->col;
X
X	dungeon[mrow][mcol] &= ~MONSTER;
X	dungeon[row][col] |= MONSTER;
X
X	c = mvinch(mrow, mcol);
X
X	if ((c >= 'A') && (c <= 'Z')) {
X		if (!detect_monster) {
X			mvaddch(mrow, mcol, monster->trail_char);
X		} else {
X			if (rogue_can_see(mrow, mcol)) {
X				mvaddch(mrow, mcol, monster->trail_char);
X			} else {
X				if (monster->trail_char == '.') {
X					monster->trail_char = ' ';
X				}
X				mvaddch(mrow, mcol, monster->trail_char);
X			}
X		}
X	}
X	monster->trail_char = mvinch(row, col);
X	if (!blind && (detect_monster || rogue_can_see(row, col))) {
X		if ((!(monster->m_flags & INVISIBLE) ||
X			(detect_monster || see_invisible || r_see_invisible))) {
X			mvaddch(row, col, gmc(monster));
X		}
X	}
X	if ((dungeon[row][col] & DOOR) &&
X		(get_room_number(row, col) != cur_room) &&
X		(dungeon[mrow][mcol] == FLOOR) && !blind) {
X			mvaddch(mrow, mcol, ' ');
X	}
X	if (dungeon[row][col] & DOOR) {
X			dr_course(monster, ((dungeon[mrow][mcol] & TUNNEL) ? 1 : 0),
X				row, col);
X	} else {
X		monster->row = row;
X		monster->col = col;
X	}
X}
X
Xmon_can_go(monster, row, col)
Xregister object *monster;
Xregister short row, col;
X{
X	object *obj;
X	short dr, dc;
X
X	dr = monster->row - row;	/* check if move distance > 1 */
X	if ((dr >= 2) || (dr <= -2)) {
X		return(0);
X	}
X	dc = monster->col - col;
X	if ((dc >= 2) || (dc <= -2)) {
X		return(0);
X	}
X	if ((!dungeon[monster->row][col]) || (!dungeon[row][monster->col])) {
X		return(0);
X	}
X	if ((!is_passable(row, col)) || (dungeon[row][col] & MONSTER)) {
X		return(0);
X	}
X	if ((monster->row!=row)&&(monster->col!=col)&&((dungeon[row][col]&DOOR) ||
X		(dungeon[monster->row][monster->col]&DOOR))) {
X		return(0);
X	}
X	if (!(monster->m_flags & (FLITS | CONFUSED | CAN_FLIT)) &&
X		(monster->trow == NO_ROOM)) {
X		if ((monster->row < rogue.row) && (row < monster->row)) return(0);
X		if ((monster->row > rogue.row) && (row > monster->row)) return(0);
X		if ((monster->col < rogue.col) && (col < monster->col)) return(0);
X		if ((monster->col > rogue.col) && (col > monster->col)) return(0);
X	}
X	if (dungeon[row][col] & OBJECT) {
X		obj = object_at(&level_objects, row, col);
X		if ((obj->what_is == SCROLL) && (obj->which_kind == SCARE_MONSTER)) {
X			return(0);
X		}
X	}
X	return(1);
X}
X
Xwake_up(monster)
Xobject *monster;
X{
X	if (!(monster->m_flags & NAPPING)) {
X		monster->m_flags &= (~(ASLEEP | IMITATES | WAKENS));
X	}
X}
X
Xwake_room(rn, entering, row, col)
Xshort rn;
Xboolean entering;
Xshort row, col;
X{
X	object *monster;
X	short wake_percent;
X	boolean in_room;
X
X	wake_percent = (rn == party_room) ? PARTY_WAKE_PERCENT : WAKE_PERCENT;
X	if (stealthy > 0) {
X		wake_percent /= (STEALTH_FACTOR + stealthy);
X	}
X
X	monster = level_monsters.next_monster;
X
X	while (monster) {
X		in_room = (rn == get_room_number(monster->row, monster->col));
X		if (in_room) {
X			if (entering) {
X				monster->trow = NO_ROOM;
X			} else {
X				monster->trow = row;
X				monster->tcol = col;
X			}
X		}
X		if ((monster->m_flags & WAKENS) &&
X			(rn == get_room_number(monster->row, monster->col))) {
X			if (rand_percent(wake_percent)) {
X				wake_up(monster);
X			}
X		}
X		monster = monster->next_monster;
X	}
X}
X
Xchar *
Xmon_name(monster)
Xobject *monster;
X{
X	short ch;
X
X	if (blind || ((monster->m_flags & INVISIBLE) &&
X		!(detect_monster || see_invisible || r_see_invisible))) {
X		return("something");
X	}
X	if (halluc) {
X		ch = get_rand('A', 'Z') - 'A';
X		return(m_names[ch]);
X	}
X	ch = monster->m_char - 'A';
X	return(m_names[ch]);
X}
X
Xrogue_is_around(row, col)
Xregister row, col;
X{
X	short rdif, cdif, retval;
X
X	rdif = row - rogue.row;
X	cdif = col - rogue.col;
X
X	retval = (rdif >= -1) && (rdif <= 1) && (cdif >= -1) && (cdif <= 1);
X	return(retval);
X}
X
Xwanderer()
X{
X	object *monster;
X	short row, col, i;
X	boolean found = 0;
X
X	for (i = 0; ((i < 15) && (!found)); i++) {
X		monster = gr_monster((object *) 0, 0);
X		if (!(monster->m_flags & (WAKENS | WANDERS))) {
X			free_object(monster);
X		} else {
X			found = 1;
X		}
X	}
X	if (found) {
X		found = 0;
X		wake_up(monster);
X		for (i = 0; ((i < 25) && (!found)); i++) {
X			gr_row_col(&row, &col, (FLOOR | TUNNEL | STAIRS | OBJECT));
X			if (!rogue_can_see(row, col)) {
X				put_m_at(row, col, monster);
X				found = 1;
X			}
X		}
X		if (!found) {
X			free_object(monster);
X		}
X	}
X}
X
Xshow_monsters()
X{
X	object *monster;
X
X	detect_monster = 1;
X
X	if (blind) {
X		return;
X	}
X	monster = level_monsters.next_monster;
X
X	while (monster) {
X		mvaddch(monster->row, monster->col, monster->m_char);
X		if (monster->m_flags & IMITATES) {
X			monster->m_flags &= (~IMITATES);
X			monster->m_flags |= WAKENS;
X		}
X		monster = monster->next_monster;
X	}
X}
X
Xcreate_monster()
X{
X	short row, col;
X	short i;
X	boolean found = 0;
X	object *monster;
X
X	row = rogue.row;
X	col = rogue.col;
X
X	for (i = 0; i < 9; i++) {
X		rand_around(i, &row, &col);
X		if (((row == rogue.row) && (col = rogue.col)) ||
X				(row < MIN_ROW) || (row > (DROWS-2)) ||
X				(col < 0) || (col > (DCOLS-1))) {
X			continue;
X		}
X		if ((!(dungeon[row][col] & MONSTER)) &&
X			  (dungeon[row][col] & (FLOOR|TUNNEL|STAIRS|DOOR))) {
X			found = 1;
X			break;
X		}
X	}
X	if (found) {
X		monster = gr_monster((object *) 0, 0);
X		put_m_at(row, col, monster);
X		mvaddch(row, col, gmc(monster));
X		if (monster->m_flags & (WANDERS | WAKENS)) {
X			wake_up(monster);
X		}
X	} else {
X		message("you hear a faint cry of anguish in the distance", 0);
X	}
X}
X
Xput_m_at(row, col, monster)
Xshort row, col;
Xobject *monster;
X{
X	monster->row = row;
X	monster->col = col;
X	dungeon[row][col] |= MONSTER;
X	monster->trail_char = mvinch(row, col);
X	(void) add_to_pack(monster, &level_monsters, 0);
X	aim_monster(monster);
X}
X
Xaim_monster(monster)
Xobject *monster;
X{
X	short i, rn, d, r;
X
X	rn = get_room_number(monster->row, monster->col);
X	r = get_rand(0, 12);
X
X	for (i = 0; i < 4; i++) {
X		d = (r + i) % 4;
X		if (rooms[rn].doors[d].oth_room != NO_ROOM) {
X			monster->trow = rooms[rn].doors[d].door_row;
X			monster->tcol = rooms[rn].doors[d].door_col;
X			break;
X		}
X	}
X}
X
Xrogue_can_see(row, col)
Xregister row, col;
X{
X	register retval;
X
X	retval = !blind &&
X			(((get_room_number(row, col) == cur_room) &&
X					!(rooms[cur_room].is_room & R_MAZE)) ||
X			rogue_is_around(row, col));
X
X	return(retval);
X}
X
Xmove_confused(monster)
Xobject *monster;
X{
X	short i, row, col;
X
X	if (!(monster->m_flags & ASLEEP)) {
X		if (--monster->moves_confused <= 0) {
X			monster->m_flags &= (~CONFUSED);
X		}
X		if (monster->m_flags & STATIONARY) {
X			return(coin_toss() ? 1 : 0);
X		} else if (rand_percent(15)) {
X			return(1);
X		}
X		row = monster->row;
X		col = monster->col;
X
X		for (i = 0; i < 9; i++) {
X			rand_around(i, &row, &col);
X			if ((row == rogue.row) && (col == rogue.col)) {
X				return(0);
X			}
X			if (mtry(monster, row, col)) {
X				return(1);
X			}
X		}
X	}
X	return(0);
X}
X
Xflit(monster)
Xobject *monster;
X{
X	short i, row, col;
X
X	if (!rand_percent(FLIT_PERCENT)) {
X		return(0);
X	}
X	if (rand_percent(10)) {
X		return(1);
X	}
X	row = monster->row;
X	col = monster->col;
X
X	for (i = 0; i < 9; i++) {
X		rand_around(i, &row, &col);
X		if ((row == rogue.row) && (col == rogue.col)) {
X			continue;
X		}
X		if (mtry(monster, row, col)) {
X			return(1);
X		}
X	}
X	return(1);
X}
X
Xgr_obj_char()
X{
X	short r;
X	char *rs = "%!?]=/):*";
X
X	r = get_rand(0, 8);
X
X	return(rs[r]);
X}
X
Xno_room_for_monster(rn)
Xint rn;
X{
X	short i, j;
X
X	for (i = rooms[rn].top_row+1; i < rooms[rn].bottom_row; i++) {
X		for (j = rooms[rn].left_col+1; j < rooms[rn].right_col; j++) {
X			if (!(dungeon[i][j] & MONSTER)) {
X				return(0);
X			}
X		}
X	}
X	return(1);
X}
X
Xaggravate()
X{
X	object *monster;
X
X	message("you hear a high pitched humming noise", 0);
X
X	monster = level_monsters.next_monster;
X
X	while (monster) {
X		wake_up(monster);
X		monster->m_flags &= (~IMITATES);
X		if (rogue_can_see(monster->row, monster->col)) {
X			mvaddch(monster->row, monster->col, monster->m_char);
X		}
X		monster = monster->next_monster;
X	}
X}
X
Xboolean
Xmon_sees(monster, row, col)
Xobject *monster;
X{
X	short rn, rdif, cdif, retval;
X
X	rn = get_room_number(row, col);
X
X	if (	(rn != NO_ROOM) &&
X			(rn == get_room_number(monster->row, monster->col)) &&
X			!(rooms[rn].is_room & R_MAZE)) {
X		return(1);
X	}
X	rdif = row - monster->row;
X	cdif = col - monster->col;
X
X	retval = (rdif >= -1) && (rdif <= 1) && (cdif >= -1) && (cdif <= 1);
X	return(retval);
X}
X
Xmv_aquatars()
X{
X	object *monster;
X
X	monster = level_monsters.next_monster;
X
X	while (monster) {
X		if ((monster->m_char == 'A') &&
X			mon_can_go(monster, rogue.row, rogue.col)) {
X			mv_monster(monster, rogue.row, rogue.col);
X			monster->m_flags |= ALREADY_MOVED;
X		}
X		monster = monster->next_monster;
X	}
X}
END_OF_monster.c
if test 17882 -ne `wc -c <monster.c`; then
    echo shar: \"monster.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f use.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"use.c\"
else
echo shar: Extracting \"use.c\" \(11577 characters\)
sed "s/^X//" >use.c <<'END_OF_use.c'
X/*
X * use.c
X *
X * This source herein may be modified and/or distributed by anybody who
X * so desires, with the following restrictions:
X *    1.)  No portion of this notice shall be removed.
X *    2.)  Credit shall not be taken for the creation of this source.
X *    3.)  This code is not to be traded, sold, or used for personal
X *         gain or profit.
X *
X */
X
X#ifndef CURSES
X#include <curses.h>
X#endif CURSES
X#include "rogue.h"
X
Xshort halluc = 0;
Xshort blind = 0;
Xshort confused = 0;
Xshort levitate = 0;
Xshort haste_self = 0;
Xboolean see_invisible = 0;
Xshort extra_hp = 0;
Xboolean detect_monster = 0;
Xchar *strange_feeling = "you have a strange feeling for a moment, then it passes";
X
Xextern short bear_trap;
Xextern char hunger_str[];
Xextern short cur_room;
Xextern long level_points[];
Xextern boolean being_held;
Xextern char *fruit, *you_can_move_again;
Xextern boolean sustain_strength;
X
Xquaff()
X{
X	short ch;
X	char buf[80];
X	object *obj;
X
X	ch = pack_letter("quaff what?", POTION);
X
X	if (ch == CANCEL) {
X		return;
X	}
X	if (!(obj = get_letter_object(ch))) {
X		message("no such item.", 0);
X		return;
X	}
X	if (obj->what_is != POTION) {
X		message("you can't drink that", 0);
X		return;
X	}
X	switch(obj->which_kind) {
X		case INCREASE_STRENGTH:
X			message("you feel stronger now, what bulging muscles!",
X			0);
X			rogue.str_current++;
X			if (rogue.str_current > rogue.str_max) {
X				rogue.str_max = rogue.str_current;
X			}
X			break;
X		case RESTORE_STRENGTH:
X			rogue.str_current = rogue.str_max;
X			message("this tastes great, you feel warm all over", 0);
X			break;
X		case HEALING:
X			message("you begin to feel better", 0);
X			potion_heal(0);
X			break;
X		case EXTRA_HEALING:
X			message("you begin to feel much better", 0);
X			potion_heal(1);
X			break;
X		case POISON:
X			if (!sustain_strength) {
X				rogue.str_current -= get_rand(1, 3);
X				if (rogue.str_current < 1) {
X					rogue.str_current = 1;
X				}
X			}
X			message("you feel very sick now", 0);
X			if (halluc) {
X				unhallucinate();
X			}
X			break;
X		case RAISE_LEVEL:
X			rogue.exp_points = level_points[rogue.exp - 1];
X			add_exp(1, 1);
X			break;
X		case BLINDNESS:
X			go_blind();
X			break;
X		case HALLUCINATION:
X			message("oh wow, everything seems so cosmic", 0);
X			halluc += get_rand(500, 800);
X			break;
X		case DETECT_MONSTER:
X			show_monsters();
X			if (!(level_monsters.next_monster)) {
X				message(strange_feeling, 0);
X			}
X			break;
X		case DETECT_OBJECTS:
X			if (level_objects.next_object) {
X				if (!blind) {
X					show_objects();
X				}
X			} else {
X				message(strange_feeling, 0);
X			}
X			break;
X		case CONFUSION:
X			message((halluc ? "what a trippy feeling" :
X			"you feel confused"), 0);
X			confuse();
X			break;
X		case LEVITATION:
X			message("you start to float in the air", 0);
X			levitate += get_rand(15, 30);
X			being_held = bear_trap = 0;
X			break;
X		case HASTE_SELF:
X			message("you feel yourself moving much faster", 0);
X			haste_self += get_rand(11, 21);
X			if (!(haste_self % 2)) {
X				haste_self++;
X			}
X			break;
X		case SEE_INVISIBLE:
X			sprintf(buf, "hmm, this potion tastes like %sjuice", fruit);
X			message(buf, 0);
X			if (blind) {
X				unblind();
X			}
X			see_invisible = 1;
X			relight();
X			break;
X	}
X	print_stats((STAT_STRENGTH | STAT_HP));
X	if (id_potions[obj->which_kind].id_status != CALLED) {
X		id_potions[obj->which_kind].id_status = IDENTIFIED;
X	}
X	vanish(obj, 1, &rogue.pack);
X}
X
Xread_scroll()
X{
X	short ch;
X	object *obj;
X	char msg[DCOLS];
X
X	ch = pack_letter("read what?", SCROLL);
X
X	if (ch == CANCEL) {
X		return;
X	}
X	if (!(obj = get_letter_object(ch))) {
X		message("no such item.", 0);
X		return;
X	}
X	if (obj->what_is != SCROLL) {
X		message("you can't read that", 0);
X		return;
X	}
X	switch(obj->which_kind) {
X		case SCARE_MONSTER:
X			message("you hear a maniacal laughter in the distance",
X			0);
X			break;
X		case HOLD_MONSTER:
X			hold_monster();
X			break;
X		case ENCH_WEAPON:
X			if (rogue.weapon) {
X				if (rogue.weapon->what_is == WEAPON) {
X					sprintf(msg, "your %sglow%s %sfor a moment",
X					name_of(rogue.weapon),
X					((rogue.weapon->quantity <= 1) ? "s" : ""),
X					get_ench_color());
X					message(msg, 0);
X					if (coin_toss()) {
X						rogue.weapon->hit_enchant++;
X					} else {
X						rogue.weapon->d_enchant++;
X					}
X				}
X				rogue.weapon->is_cursed = 0;
X			} else {
X				message("your hands tingle", 0);
X			}
X			break;
X		case ENCH_ARMOR:
X			if (rogue.armor) {
X				sprintf(msg, "your armor glows %sfor a moment",
X				get_ench_color());
X				message(msg, 0);
X				rogue.armor->d_enchant++;
X				rogue.armor->is_cursed = 0;
X				print_stats(STAT_ARMOR);
X			} else {
X				message("your skin crawls", 0);
X			}
X			break;
X		case IDENTIFY:
X			message("this is a scroll of identify", 0);
X			obj->identified = 1;
X			id_scrolls[obj->which_kind].id_status = IDENTIFIED;
X			idntfy();
X			break;
X		case TELEPORT:
X			tele();
X			break;
X		case SLEEP:
X			message("you fall asleep", 0);
X			take_a_nap();
X			break;
X		case PROTECT_ARMOR:
X			if (rogue.armor) {
X				message( "your armor is covered by a shimmering gold shield",0);
X				rogue.armor->is_protected = 1;
X				rogue.armor->is_cursed = 0;
X			} else {
X				message("your acne seems to have disappeared", 0);
X			}
X			break;
X		case REMOVE_CURSE:
X				message((!halluc) ?
X					"you feel as though someone is watching over you" :
X					"you feel in touch with the universal oneness", 0);
X			uncurse_all();
X			break;
X		case CREATE_MONSTER:
X			create_monster();
X			break;
X		case AGGRAVATE_MONSTER:
X			aggravate();
X			break;
X		case MAGIC_MAPPING:
X			message("this scroll seems to have a map on it", 0);
X			draw_magic_map();
X			break;
X	}
X	if (id_scrolls[obj->which_kind].id_status != CALLED) {
X		id_scrolls[obj->which_kind].id_status = IDENTIFIED;
X	}
X	vanish(obj, (obj->which_kind != SLEEP), &rogue.pack);
X}
X
X/* vanish() does NOT handle a quiver of weapons with more than one
X   arrow (or whatever) in the quiver.  It will only decrement the count.
X*/
X
Xvanish(obj, rm, pack)
Xobject *obj;
Xshort rm;
Xobject *pack;
X{
X	if (obj->quantity > 1) {
X		obj->quantity--;
X	} else {
X		if (obj->in_use_flags & BEING_WIELDED) {
X			unwield(obj);
X		} else if (obj->in_use_flags & BEING_WORN) {
X			unwear(obj);
X		} else if (obj->in_use_flags & ON_EITHER_HAND) {
X			un_put_on(obj);
X		}
X		take_from_pack(obj, pack);
X		free_object(obj);
X	}
X	if (rm) {
X		(void) reg_move();
X	}
X}
X
Xpotion_heal(extra)
X{
X	float ratio;
X	short add;
X
X	rogue.hp_current += rogue.exp;
X
X	ratio = ((float)rogue.hp_current) / rogue.hp_max;
X
X	if (ratio >= 1.00) {
X		rogue.hp_max += (extra ? 2 : 1);
X		extra_hp += (extra ? 2 : 1);
X		rogue.hp_current = rogue.hp_max;
X	} else if (ratio >= 0.90) {
X		rogue.hp_max += (extra ? 1 : 0);
X		extra_hp += (extra ? 1 : 0);
X		rogue.hp_current = rogue.hp_max;
X	} else {
X		if (ratio < 0.33) {
X			ratio = 0.33;
X		}
X		if (extra) {
X			ratio += ratio;
X		}
X		add = (short)(ratio * ((float)rogue.hp_max - rogue.hp_current));
X		rogue.hp_current += add;
X		if (rogue.hp_current > rogue.hp_max) {
X			rogue.hp_current = rogue.hp_max;
X		}
X	}
X	if (blind) {
X		unblind();
X	}
X	if (confused && extra) {
X			unconfuse();
X	} else if (confused) {
X		confused = (confused / 2) + 1;
X	}
X	if (halluc && extra) {
X		unhallucinate();
X	} else if (halluc) {
X		halluc = (halluc / 2) + 1;
X	}
X}
X
Xidntfy()
X{
X	short ch;
X	object *obj;
X	struct id *id_table;
X	char desc[DCOLS];
XAGAIN:
X	ch = pack_letter("what would you like to identify?", ALL_OBJECTS);
X
X	if (ch == CANCEL) {
X		return;
X	}
X	if (!(obj = get_letter_object(ch))) {
X		message("no such item, try again", 0);
X		message("", 0);
X		check_message();
X		goto AGAIN;
X	}
X	obj->identified = 1;
X	if (obj->what_is & (SCROLL | POTION | WEAPON | ARMOR | WAND | RING)) {
X		id_table = get_id_table(obj);
X		id_table[obj->which_kind].id_status = IDENTIFIED;
X	}
X	get_desc(obj, desc);
X	message(desc, 0);
X}
X
Xeat()
X{
X	short ch;
X	short moves;
X	object *obj;
X	char buf[70];
X
X	ch = pack_letter("eat what?", FOOD);
X
X	if (ch == CANCEL) {
X		return;
X	}
X	if (!(obj = get_letter_object(ch))) {
X		message("no such item.", 0);
X		return;
X	}
X	if (obj->what_is != FOOD) {
X		message("you can't eat that", 0);
X		return;
X	}
X	if ((obj->which_kind == FRUIT) || rand_percent(60)) {
X		moves = get_rand(900, 1100);
X		if (obj->which_kind == RATION) {
X			message("yum, that tasted good", 0);
X		} else {
X			sprintf(buf, "my, that was a yummy %s", fruit);
X			message(buf, 0);
X		}
X	} else {
X		moves = get_rand(700, 900);
X		message("yuk, that food tasted awful", 0);
X		add_exp(2, 1);
X	}
X	rogue.moves_left /= 3;
X	rogue.moves_left += moves;
X	hunger_str[0] = 0;
X	print_stats(STAT_HUNGER);
X
X	vanish(obj, 1, &rogue.pack);
X}
X
Xhold_monster()
X{
X	short i, j;
X	short mcount = 0;
X	object *monster;
X	short row, col;
X
X	for (i = -2; i <= 2; i++) {
X		for (j = -2; j <= 2; j++) {
X			row = rogue.row + i;
X			col = rogue.col + j;
X			if ((row < MIN_ROW) || (row > (DROWS-2)) || (col < 0) ||
X				 (col > (DCOLS-1))) {
X				continue;
X			}
X			if (dungeon[row][col] & MONSTER) {
X				monster = object_at(&level_monsters, row, col);
X				monster->m_flags |= ASLEEP;
X				monster->m_flags &= (~WAKENS);
X				mcount++;
X			}
X		}
X	}
X	if (mcount == 0) {
X		message("you feel a strange sense of loss", 0);
X	} else if (mcount == 1) {
X		message("the monster freezes", 0);
X	} else {
X		message("the monsters around you freeze", 0);
X	}
X}
X
Xtele()
X{
X	mvaddch(rogue.row, rogue.col, get_dungeon_char(rogue.row, rogue.col));
X
X	if (cur_room >= 0) {
X		darken_room(cur_room);
X	}
X	put_player(get_room_number(rogue.row, rogue.col));
X	being_held = 0;
X	bear_trap = 0;
X}
X
Xhallucinate()
X{
X	object *obj, *monster;
X	short ch;
X
X	if (blind) return;
X
X	obj = level_objects.next_object;
X
X	while (obj) {
X		ch = mvinch(obj->row, obj->col);
X		if (((ch < 'A') || (ch > 'Z')) &&
X			((obj->row != rogue.row) || (obj->col != rogue.col)))
X		if ((ch != ' ') && (ch != '.') && (ch != '#') && (ch != '+')) {
X			addch(gr_obj_char());
X		}
X		obj = obj->next_object;
X	}
X	monster = level_monsters.next_monster;
X
X	while (monster) {
X		ch = mvinch(monster->row, monster->col);
X		if ((ch >= 'A') && (ch <= 'Z')) {
X			addch(get_rand('A', 'Z'));
X		}
X		monster = monster->next_monster;
X	}
X}
X
Xunhallucinate()
X{
X	halluc = 0;
X	relight();
X	message("everything looks SO boring now", 1);
X}
X
Xunblind()
X{
X	blind = 0;
X	message("the veil of darkness lifts", 1);
X	relight();
X	if (halluc) {
X		hallucinate();
X	}
X	if (detect_monster) {
X		show_monsters();
X	}
X}
X
Xrelight()
X{
X	if (cur_room == PASSAGE) {
X		light_passage(rogue.row, rogue.col);
X	} else {
X		light_up_room(cur_room);
X	}
X	mvaddch(rogue.row, rogue.col, rogue.fchar);
X}
X
Xtake_a_nap()
X{
X	short i;
X
X	i = get_rand(2, 5);
X	md_sleep(1);
X
X	while (i--) {
X		mv_mons();
X	}
X	md_sleep(1);
X	message(you_can_move_again, 0);
X}
X
Xgo_blind()
X{
X	short i, j;
X
X	if (!blind) {
X		message("a cloak of darkness falls around you", 0);
X	}
X	blind += get_rand(500, 800);
X
X	if (detect_monster) {
X		object *monster;
X
X		monster = level_monsters.next_monster;
X
X		while (monster) {
X			mvaddch(monster->row, monster->col, monster->trail_char);
X			monster = monster->next_monster;
X		}
X	}
X	if (cur_room >= 0) {
X		for (i = rooms[cur_room].top_row + 1;
X			 i < rooms[cur_room].bottom_row; i++) {
X			for (j = rooms[cur_room].left_col + 1;
X				 j < rooms[cur_room].right_col; j++) {
X				mvaddch(i, j, ' ');
X			}
X		}
X	}
X	mvaddch(rogue.row, rogue.col, rogue.fchar);
X}
X
Xchar *
Xget_ench_color()
X{
X	if (halluc) {
X		return(id_potions[get_rand(0, POTIONS-1)].title);
X	}
X	return("blue ");
X}
X
Xconfuse()
X{
X	confused += get_rand(12, 22);
X}
X
Xunconfuse()
X{
X	char msg[80];
X
X	confused = 0;
X	sprintf(msg, "you feel less %s now", (halluc ? "trippy" : "confused"));
X	message(msg, 1);
X}
X
Xuncurse_all()
X{
X	object *obj;
X
X	obj = rogue.pack.next_object;
X
X	while (obj) {
X		obj->is_cursed = 0;
X		obj = obj->next_object;
X	}
X}
END_OF_use.c
if test 11577 -ne `wc -c <use.c`; then
    echo shar: \"use.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 1 \(of 5\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 5 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 5 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