[comp.sources.games] v01i015: rogue - a rogue 5.3 clone, Part05/05

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

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

#! /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 5 (of 5)."
# Contents:  Makefile init.c play.c random.c trap.c
# Wrapped by billr@tekred on Mon May 11 12:19:23 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f Makefile -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"Makefile\"
else
echo shar: Extracting \"Makefile\" \(1769 characters\)
sed "s/^X//" >Makefile <<'END_OF_Makefile'
XROGUE_OBJS = curses.o hit.o init.o inventory.o level.o machdep.o main.o \
X    message.o monster.o move.o object.o pack.o play.o random.o ring.o \
X    room.o save.o score.o spec_hit.o throw.o trap.o use.o zap.o
X
XCC = cc
X
X# Remember to remove the "-lcurses -ltermlib" if compiling with -DCURSES.
X# Put into CFLAGS those UNIX "defines" which apply to your system.  Their
X# should be at least two.
X# -DCURSES enables a self-contained curses emulation package.  See notes
X# in curses.c for more info.
X
XCFLAGS = -c -DUNIX -DUNIX_BSD4_2
X
Xrogue: $(ROGUE_OBJS)
X	$(CC) $(ROGUE_OBJS) -lcurses -ltermlib -o rogue
X
Xcurses.o: curses.c rogue.h
X	$(CC) $(CFLAGS) curses.c
X
Xhit.o: hit.c rogue.h
X	$(CC) $(CFLAGS) hit.c
X
Xinit.o: init.c rogue.h
X	$(CC) $(CFLAGS) init.c
X
Xinventory.o: inventory.c rogue.h
X	$(CC) $(CFLAGS) inventory.c
X
Xlevel.o: level.c rogue.h
X	$(CC) $(CFLAGS) level.c
X
Xmachdep.o: machdep.c rogue.h
X	$(CC) $(CFLAGS) machdep.c
X
Xmain.o: main.c rogue.h
X	$(CC) $(CFLAGS) main.c
X
Xmessage.o: message.c rogue.h
X	$(CC) $(CFLAGS) message.c
X
Xmonster.o: monster.c rogue.h
X	$(CC) $(CFLAGS) monster.c
X
Xmove.o: move.c rogue.h
X	$(CC) $(CFLAGS) move.c
X
Xobject.o: object.c rogue.h
X	$(CC) $(CFLAGS) object.c
X
Xpack.o: pack.c rogue.h
X	$(CC) $(CFLAGS) pack.c
X
Xplay.o: play.c rogue.h
X	$(CC) $(CFLAGS) play.c
X
Xrandom.o: random.c
X	$(CC) $(CFLAGS) random.c
X
Xring.o: ring.c rogue.h
X	$(CC) $(CFLAGS) ring.c
X
Xroom.o: room.c rogue.h
X	$(CC) $(CFLAGS) room.c
X
Xsave.o: save.c rogue.h
X	$(CC) $(CFLAGS) save.c
X
Xscore.o: score.c rogue.h
X	$(CC) $(CFLAGS) score.c
X
Xspec_hit.o: spec_hit.c rogue.h
X	$(CC) $(CFLAGS) spec_hit.c
X
Xthrow.o: throw.c rogue.h
X	$(CC) $(CFLAGS) throw.c
X
Xtrap.o: trap.c rogue.h
X	$(CC) $(CFLAGS) trap.c
X
Xuse.o: use.c rogue.h
X	$(CC) $(CFLAGS) use.c
X
Xzap.o: zap.c rogue.h
X	$(CC) $(CFLAGS) zap.c
END_OF_Makefile
if test 1769 -ne `wc -c <Makefile`; then
    echo shar: \"Makefile\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f init.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"init.c\"
else
echo shar: Extracting \"init.c\" \(4987 characters\)
sed "s/^X//" >init.c <<'END_OF_init.c'
X/*
X * init.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 <stdio.h>
X#include "rogue.h"
X
Xchar login_name[30];
Xchar *nick_name = "";
Xchar *restore_file = 0;
Xboolean cant_int = 0, did_int = 0, score_only, init_curses = 0;
Xboolean save_is_interactive = 1;
Xboolean ask_quit = 1, show_skull = 1;
Xchar *error_file = "rogue.esave";
Xchar *byebye_string = "Okay, bye bye!";
X
Xextern char *fruit;
Xextern char *save_file;
Xextern short party_room, party_counter;
Xextern boolean jump;
X
Xinit(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	char *pn;
X	int seed;
X
X	do_args(argc, argv);
X	do_opts();
X
X	pn = md_gln();
X	if ((!pn) || (strlen(pn) >= 30)) {
X		clean_up("Hey!  Who are you?");
X	}
X	(void) strcpy(login_name, pn);
X
X	if (!score_only && !restore_file) {
X		printf("Hello %s, just a moment while I dig the dungeon...",
X		((nick_name[0]) ? nick_name : login_name));
X		fflush(stdout);
X	}
X
X	initscr();
X	if ((LINES < DROWS) || (COLS < DCOLS)) {
X		clean_up("must be played on 24 x 80 screen");
X	}
X	start_window();
X	init_curses = 1;
X
X	md_heed_signals();
X
X	if (score_only) {
X		put_scores((object *) 0, 0);
X	}
X	seed = md_gseed();
X	(void) srrandom(seed);
X	if (restore_file) {
X		restore(restore_file);
X		return(1);
X	}
X	mix_colors();
X	get_wand_and_ring_materials();
X	make_scroll_titles();
X
X	level_objects.next_object = 0;
X	level_monsters.next_monster = 0;
X	player_init();
X	party_counter = get_rand(1, PARTY_TIME);
X	ring_stats(0);
X	return(0);
X}
X
Xplayer_init()
X{
X	object *obj;
X
X	rogue.pack.next_object = 0;
X
X	obj = alloc_object();
X	get_food(obj, 1);
X	(void) add_to_pack(obj, &rogue.pack, 1);
X
X	obj = alloc_object();		/* initial armor */
X	obj->what_is = ARMOR;
X	obj->which_kind = RINGMAIL;
X	obj->class = RINGMAIL+2;
X	obj->is_protected = 0;
X	obj->d_enchant = 1;
X	(void) add_to_pack(obj, &rogue.pack, 1);
X	do_wear(obj);
X
X	obj = alloc_object();		/* initial weapons */
X	obj->what_is = WEAPON;
X	obj->which_kind = MACE;
X	obj->damage = "2d3";
X	obj->hit_enchant = obj->d_enchant = 1;
X	obj->identified = 1;
X	(void) add_to_pack(obj, &rogue.pack, 1);
X	do_wield(obj);
X
X	obj = alloc_object();
X	obj->what_is = WEAPON;
X	obj->which_kind = BOW;
X	obj->damage = "1d2";
X	obj->hit_enchant = 1;
X	obj->d_enchant = 0;
X	obj->identified = 1;
X	(void) add_to_pack(obj, &rogue.pack, 1);
X
X	obj = alloc_object();
X	obj->what_is = WEAPON;
X	obj->which_kind = ARROW;
X	obj->quantity = get_rand(25, 35);
X	obj->damage = "1d2";
X	obj->hit_enchant = 0;
X	obj->d_enchant = 0;
X	obj->identified = 1;
X	(void) add_to_pack(obj, &rogue.pack, 1);
X}
X
Xclean_up(estr)
Xchar *estr;
X{
X	if (save_is_interactive) {
X		if (init_curses) {
X			move(DROWS-1, 0);
X			refresh();
X			stop_window();
X		}
X		printf("\n%s\n", estr);
X	}
X	md_exit(0);
X}
X
Xstart_window()
X{
X	crmode();
X	noecho();
X	nonl();
X	md_control_keybord(0);
X}
X
Xstop_window()
X{
X	endwin();
X	md_control_keybord(1);
X}
X
Xbyebye()
X{
X	md_ignore_signals();
X	if (ask_quit) {
X		quit(1);
X	} else {
X		clean_up(byebye_string);
X	}
X	md_heed_signals();
X}
X
Xonintr()
X{
X	md_ignore_signals();
X	if (cant_int) {
X		did_int = 1;
X	} else {
X		check_message();
X		message("interrupt", 1);
X	}
X	md_heed_signals();
X}
X
Xerror_save()
X{
X	save_is_interactive = 0;
X	save_into_file(error_file);
X	clean_up("");
X}
X
Xdo_args(argc, argv)
Xint argc;
Xchar *argv[];
X{
X	short i, j;
X
X	for (i = 1; i < argc; i++) {
X		if (argv[i][0] == '-') {
X			for (j = 1; argv[i][j]; j++) {
X				switch(argv[i][j]) {
X				case 's':
X					score_only = 1;
X					break;
X				}
X			}
X		} else {
X			restore_file = argv[i];
X		}
X	}
X}
X
Xdo_opts()
X{
X	char *eptr;
X
X	if (eptr = md_getenv("ROGUEOPTS")) {
X		for (;;) {
X			while ((*eptr) == ' ') {
X				eptr++;
X			}
X			if (!(*eptr)) {
X				break;
X			}
X			if (!strncmp(eptr, "fruit=", 6)) {
X				eptr += 6;
X				env_get_value(&fruit, eptr, 1);
X			} else if (!strncmp(eptr, "file=", 5)) {
X				eptr += 5;
X				env_get_value(&save_file, eptr, 0);
X			} else if (!strncmp(eptr, "nojump", 6)) {
X				jump = 0;
X			} else if (!strncmp(eptr, "name=", 5)) {
X				eptr += 5;
X				env_get_value(&nick_name, eptr, 0);
X			} else if (!strncmp(eptr, "noaskquit", 9)) {
X				ask_quit = 0;
X			} else if (!strncmp(eptr, "noskull", 5) ||
X					!strncmp(eptr,"notomb", 6)) {
X				show_skull = 0;
X			}
X			while ((*eptr) && (*eptr != ',')) {
X				eptr++;
X			}
X			if (!(*(eptr++))) {
X				break;
X			}
X		}
X	}
X}
X
Xenv_get_value(s, e, add_blank)
Xchar **s, *e;
Xboolean add_blank;
X{
X	short i = 0;
X	char *t;
X
X	t = e;
X
X	while ((*e) && (*e != ',')) {
X		if (*e == ':') {
X			*e = ';';		/* ':' reserved for score file purposes */
X		}
X		e++;
X		if (++i >= 30) {
X			break;
X		}
X	}
X	if (!(*s = md_malloc(i + (add_blank ? 2 : 1)))) {
X		clean_up("cannot alloc() memory");
X	}
X	(void) strncpy(*s, t, i);
X	if (add_blank) {
X		(*s)[i++] = ' ';
X	}
X	(*s)[i] = '\0';
X}
END_OF_init.c
if test 4987 -ne `wc -c <init.c`; then
    echo shar: \"init.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f play.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"play.c\"
else
echo shar: Extracting \"play.c\" \(3756 characters\)
sed "s/^X//" >play.c <<'END_OF_play.c'
X/*
X * play.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
Xboolean interrupted = 0;
Xchar *unknown_command = "unknown command";
X
Xextern short party_room, bear_trap;
Xextern char hit_message[];
Xextern boolean wizard, trap_door;
X
Xplay_level()
X{
X	short ch;
X	int count;
X
X	for (;;) {
X		interrupted = 0;
X		if (hit_message[0]) {
X			message(hit_message, 1);
X			hit_message[0] = 0;
X		}
X		if (trap_door) {
X			trap_door = 0;
X			return;
X		}
X		move(rogue.row, rogue.col);
X		refresh();
X
X		ch = rgetchar();
X		check_message();
X		count = 0;
XCH:
X		switch(ch) {
X		case '.':
X			rest((count > 0) ? count : 1);
X			break;
X		case 's':
X			search(((count > 0) ? count : 1), 0);
X			break;
X		case 'i':
X			inventory(&rogue.pack, ALL_OBJECTS);
X			break;
X		case 'f':
X			fight(0);
X			break;
X		case 'F':
X			fight(1);
X			break;
X		case 'h':
X		case 'j':
X		case 'k':
X		case 'l':
X		case 'y':
X		case 'u':
X		case 'n':
X		case 'b':
X			(void) one_move_rogue(ch, 1);
X			break;
X		case 'H':
X		case 'J':
X		case 'K':
X		case 'L':
X		case 'B':
X		case 'Y':
X		case 'U':
X		case 'N':
X		case '\010':
X		case '\012':
X		case '\013':
X		case '\014':
X		case '\031':
X		case '\025':
X		case '\016':
X		case '\002':
X			multiple_move_rogue(ch);
X			break;
X		case 'e':
X			eat();
X			break;
X		case 'q':
X			quaff();
X			break;
X		case 'r':
X			read_scroll();
X			break;
X		case 'm':
X			move_onto();
X			break;
X		case 'd':
X			drop();
X			break;
X		case 'P':
X			put_on_ring();
X			break;
X		case 'R':
X			remove_ring();
X			break;
X		case '\020':
X			remessage();
X			break;
X		case '\027':
X			wizardize();
X			break;
X		case '>':
X			if (drop_check()) {
X				return;
X			}
X			break;
X		case '<':
X			if (check_up()) {
X				return;
X			}
X			break;
X		case ')':
X		case ']':
X			inv_armor_weapon(ch == ')');
X			break;
X		case '=':
X			inv_rings();
X			break;
X		case '^':
X			id_trap();
X			break;
X		case 'I':
X			single_inv(0);
X			break;
X		case 'T':
X			take_off();
X			break;
X		case 'W':
X			wear();
X			break;
X		case 'w':
X			wield();
X			break;
X		case 'c':
X			call_it();
X			break;
X		case 'z':
X			zapp();
X			break;
X		case 't':
X			throw();
X			break;
X		case 'v':
X			message("rogue-clone: Version II. (Tim Stoehr was here), tektronix!zeus!tims", 0);
X			break;
X		case 'Q':
X			quit(0);
X		case '0':
X		case '1':
X		case '2':
X		case '3':
X		case '4':
X		case '5':
X		case '6':
X		case '7':
X		case '8':
X		case '9':
X			move(rogue.row, rogue.col);
X			refresh();
X			do {
X				if (count < 100) {
X					count = (10 * count) + (ch - '0');
X				}
X				ch = rgetchar();
X			} while (is_digit(ch));
X			if (ch != CANCEL) {
X				goto CH;
X			}
X			break;
X		case ' ':
X			break;
X		case '\011':
X			if (wizard) {
X				inventory(&level_objects, ALL_OBJECTS);
X			} else {
X				message(unknown_command, 0);
X			}
X			break;
X		case '\023':
X			if (wizard) {
X				draw_magic_map();
X			} else {
X				message(unknown_command, 0);
X			}
X			break;
X		case '\024':
X			if (wizard) {
X				show_traps();
X			} else {
X				message(unknown_command, 0);
X			}
X			break;
X		case '\017':
X			if (wizard) {
X				show_objects();
X			} else {
X				message(unknown_command, 0);
X			}
X			break;
X		case '\001':
X			show_average_hp();
X			break;
X		case '\003':
X			if (wizard) {
X				new_object_for_wizard();
X			} else {
X				message(unknown_command, 0);
X			}
X			break;
X		case '\015':
X			if (wizard) {
X				show_monsters();
X			} else {
X				message(unknown_command, 0);
X			}
X			break;
X		case 'S':
X			save_game();
X			break;
X		default:
X			message(unknown_command, 0);
X			break;
X		}
X	}
X}
END_OF_play.c
if test 3756 -ne `wc -c <play.c`; then
    echo shar: \"play.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f random.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"random.c\"
else
echo shar: Extracting \"random.c\" \(1555 characters\)
sed "s/^X//" >random.c <<'END_OF_random.c'
Xstatic long rntb[32] = {
X	         3, 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 
X	0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb, 0x7449e56b,
X	0xbeb1dbb0, 0xab5c5918, 0x946554fd, 0x8c2e680f, 0xeb3d799f,
X	0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88, 0xe369735d,
X	0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc, 
X	0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e,
X	0x8999220b, 0x27fb47b9
X};
X
Xstatic long *fptr = &rntb[4];
Xstatic long *rptr = &rntb[1];
Xstatic long *state = &rntb[1];
Xstatic int rand_type = 3;
Xstatic int rand_deg = 31;
Xstatic int rand_sep = 3;
Xstatic long *end_ptr = &rntb[32];
X
Xsrrandom(x)
Xint x;
X{
X	register int i;
X	long rrandom();
X
X	state[0] = (long) x;
X	if (rand_type != 0) {
X		for (i = 1; i < rand_deg; i++) {
X			state[i] = 1103515245 * state[i - 1] + 12345;
X		}
X		fptr = &state[rand_sep];
X		rptr = &state[0];
X		for (i = 0; i < 10*rand_deg; i++) {
X			(void) rrandom();
X		}
X	}
X}
X
Xlong
Xrrandom()
X{
X	long i;
X	
X	if (rand_type == 0) {
X		i = state[0] = (state[0]*1103515245 + 12345) & 0x7fffffff;
X	} else {
X		*fptr += *rptr;
X		i = (*fptr >> 1) & 0x7fffffff;
X		if (++fptr >= end_ptr) {
X			fptr = state;
X			++rptr;
X		} else {
X			if (++rptr >= end_ptr) {
X				rptr = state;
X			}
X		}
X	}
X	return(i);
X}
X
Xget_rand(x, y)
Xregister int x, y;
X{
X	register int r, t;
X
X	if (x > y) {
X		t = y;
X		y = x;
X		x = t;
X	}
X	r = (int) rrandom();
X	r = (r % ((y-x)+1)) + x;
X	return(r);
X}
X
Xrand_percent(percentage)
Xregister int percentage;
X{
X	return(get_rand(1, 100) <= percentage);
X}
X
Xcoin_toss()
X{
X
X	return(((rrandom() & 01) ? 1 : 0));
X}
END_OF_random.c
if test 1555 -ne `wc -c <random.c`; then
    echo shar: \"random.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f trap.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"trap.c\"
else
echo shar: Extracting \"trap.c\" \(5280 characters\)
sed "s/^X//" >trap.c <<'END_OF_trap.c'
X/*
X * trap.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
Xtrap traps[MAX_TRAPS];
Xboolean trap_door = 0;
Xshort bear_trap = 0;
X
Xchar *trap_strings[TRAPS * 2] = {
X	"trap door",
X			"you fell down a trap",
X	"bear trap",
X			"you are caught in a bear trap",
X	"teleport trap",
X			"teleport",
X	"poison dart trap",
X			"a small dart just hit you in the shoulder",
X	"sleeping gas trap",
X			"a strange white mist envelops you and you fall asleep",
X	"rust trap",
X			"a gush of water hits you on the head"
X};
X
Xextern short cur_level, party_room;
Xextern char *new_level_message;
Xextern boolean interrupted;
Xextern short ring_exp;
Xextern boolean sustain_strength;
Xextern short blind;
X
Xtrap_at(row, col)
Xregister row, col;
X{
X	short i;
X
X	for (i = 0; ((i < MAX_TRAPS) && (traps[i].trap_type != NO_TRAP)); i++) {
X		if ((traps[i].trap_row == row) && (traps[i].trap_col == col)) {
X			return(traps[i].trap_type);
X		}
X	}
X	return(NO_TRAP);
X}
X
Xtrap_player(row, col)
Xshort row, col;
X{
X	short t;
X
X	if ((t = trap_at(row, col)) == NO_TRAP) {
X		return;
X	}
X	dungeon[row][col] &= (~HIDDEN);
X	if (rand_percent(rogue.exp + ring_exp)) {
X		message("the trap failed", 1);
X		return;
X	}
X	switch(t) {
X	case TRAP_DOOR:
X		trap_door = 1;
X		new_level_message = trap_strings[(t*2)+1];
X		break;
X	case BEAR_TRAP:
X		message(trap_strings[(t*2)+1], 1);
X		bear_trap = get_rand(4, 7);
X		break;
X	case TELE_TRAP:
X		mvaddch(rogue.row, rogue.col, '^');
X		tele();
X		break;
X	case DART_TRAP:
X		message(trap_strings[(t*2)+1], 1);
X		rogue.hp_current -= get_damage("1d6", 1);
X		if (rogue.hp_current <= 0) {
X			rogue.hp_current = 0;
X		}
X		if ((!sustain_strength) && rand_percent(40) &&
X			(rogue.str_current >= 3)) {
X			rogue.str_current--;
X		}
X		print_stats(STAT_HP | STAT_STRENGTH);
X		if (rogue.hp_current <= 0) {
X			killed_by((object *) 0, POISON_DART);
X		}
X		break;
X	case SLEEPING_GAS_TRAP:
X		message(trap_strings[(t*2)+1], 1);
X		take_a_nap();
X		break;
X	case RUST_TRAP:
X		message(trap_strings[(t*2)+1], 1);
X		rust((object *) 0);
X		break;
X	}
X}
X
Xadd_traps()
X{
X	short i, n, tries = 0;
X	short row, col;
X
X	if (cur_level <= 2) {
X		n = 0;
X	} else if (cur_level <= 7) {
X		n = get_rand(0, 2);
X	} else if (cur_level <= 11) {
X		n = get_rand(1, 2);
X	} else if (cur_level <= 16) {
X		n = get_rand(2, 3);
X	} else if (cur_level <= 21) {
X		n = get_rand(2, 4);
X	} else if (cur_level <= (AMULET_LEVEL + 2)) {
X		n = get_rand(3, 5);
X	} else {
X		n = get_rand(5, MAX_TRAPS);
X	}
X	for (i = 0; i < n; i++) {
X		traps[i].trap_type = get_rand(0, (TRAPS - 1));
X
X		if ((i == 0) && (party_room != NO_ROOM)) {
X			do {
X				row = get_rand((rooms[party_room].top_row+1),
X						(rooms[party_room].bottom_row-1));
X				col = get_rand((rooms[party_room].left_col+1),
X						(rooms[party_room].right_col-1));
X				tries++;
X			} while (((dungeon[row][col] & (OBJECT|STAIRS|TRAP|TUNNEL)) ||
X					(dungeon[row][col] == NOTHING)) && (tries < 15));
X			if (tries >= 15) {
X				gr_row_col(&row, &col, (FLOOR | MONSTER));
X			}
X		} else {
X			gr_row_col(&row, &col, (FLOOR | MONSTER));
X		}
X		traps[i].trap_row = row;
X		traps[i].trap_col = col;
X		dungeon[row][col] |= (TRAP | HIDDEN);
X	}
X}
X
Xid_trap()
X{
X	short dir, row, col;
X	short t;
X
X	message("direction? ", 0);
X
X	while (!is_direction(dir = rgetchar())) {
X		sound_bell();
X	}
X	check_message();
X
X	if (dir == CANCEL) {
X		return;
X	}
X	row = rogue.row;
X	col = rogue.col;
X
X	get_dir_rc(dir, &row, &col, 0);
X
X	if ((dungeon[row][col] & TRAP) && (!(dungeon[row][col] & HIDDEN))) {
X		t = trap_at(row, col);
X		message(trap_strings[t*2], 0);
X	} else {
X		message("no trap there", 0);
X	}
X}
X
Xshow_traps()
X{
X	short i, j;
X
X	for (i = 0; i < DROWS; i++) {
X		for (j = 0; j < DCOLS; j++) {
X			if (dungeon[i][j] & TRAP) {
X				mvaddch(i, j, '^');
X			}
X		}
X	}
X}
X
Xsearch(n, is_auto)
Xshort n;
Xboolean is_auto;
X{
X	short s, i, j, row, col, t;
X	short shown = 0, found = 0;
X	static boolean reg_search;
X
X	for (i = -1; i <= 1; i++) {
X		for (j = -1; j <= 1; j++) {
X			row = rogue.row + i;
X			col = rogue.col + j;
X			if ((row < MIN_ROW) || (row >= (DROWS-1)) ||
X					(col < 0) || (col >= DCOLS)) {
X				continue;
X			}
X			if (dungeon[row][col] & HIDDEN) {
X				found++;
X			}
X		}
X	}
X	for (s = 0; s < n; s++) {
X		for (i = -1; i <= 1; i++) {
X			for (j = -1; j <= 1; j++) {
X				row = rogue.row + i;
X				col = rogue.col + j ;
X				if ((row < MIN_ROW) || (row >= (DROWS-1)) ||
X						(col < 0) || (col >= DCOLS)) {
X					continue;
X				}
X				if (dungeon[row][col] & HIDDEN) {
X					if (rand_percent(17 + (rogue.exp + ring_exp))) {
X						dungeon[row][col] &= (~HIDDEN);
X						if ((!blind) && ((row != rogue.row) ||
X								(col != rogue.col))) {
X							mvaddch(row, col, get_dungeon_char(row, col));
X						}
X						shown++;
X						if (dungeon[row][col] & TRAP) {
X							t = trap_at(row, col);
X							message(trap_strings[t*2], 1);
X						}
X					}
X				}
X				if (((shown == found) && (found > 0)) || interrupted) {
X					return;
X				}
X			}
X		}
X		if ((!is_auto) && (reg_search = !reg_search)) {
X			(void) reg_move();
X		}
X	}
X}
END_OF_trap.c
if test 5280 -ne `wc -c <trap.c`; then
    echo shar: \"trap.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 5 \(of 5\).
cp /dev/null ark5isdone
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