[comp.sources.games] v01i014: rogue - a rogue 5.3 clone, Part04/05

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

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

#! /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 4 (of 5)."
# Contents:  hit.c inventory.c message.c pack.c ring.c room.c zap.c
# Wrapped by billr@tekred on Mon May 11 12:19:21 1987
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f hit.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"hit.c\"
else
echo shar: Extracting \"hit.c\" \(7923 characters\)
sed "s/^X//" >hit.c <<'END_OF_hit.c'
X/*
X * hit.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 *fight_monster = 0;
Xboolean detect_monster;
Xchar hit_message[80] = "";
X
Xextern short halluc, blind, cur_level;
Xextern short add_strength, ring_exp, r_rings;
Xextern boolean being_held, interrupted, wizard;
X
Xmon_hit(monster, other, flame)
Xregister object *monster;
Xchar *other;
Xboolean flame;
X{
X	short damage, hit_chance;
X	char *mn;
X	float minus;
X
X	if (fight_monster && (monster != fight_monster)) {
X		fight_monster = 0;
X	}
X	monster->trow = NO_ROOM;
X	if (cur_level >= (AMULET_LEVEL * 2)) {
X		hit_chance = 100;
X	} else {
X		hit_chance = monster->m_hit_chance;
X		hit_chance -= (((2 * rogue.exp) + (2 * ring_exp)) - r_rings);
X	}
X	if (wizard) {
X		hit_chance /= 2;
X	}
X	if (!fight_monster) {
X		interrupted = 1;
X	}
X	mn = mon_name(monster);
X
X	if (other) {
X		hit_chance -= ((rogue.exp + ring_exp) - r_rings);
X	}
X
X	if (!rand_percent(hit_chance)) {
X		if (!fight_monster) {
X			sprintf(hit_message + strlen(hit_message),
X			"the %s misses", (other ? other : mn));
X			message(hit_message, 1);
X			hit_message[0] = 0;
X		}
X		return;
X	}
X	if (!fight_monster) {
X		sprintf(hit_message + strlen(hit_message), "the %s hit",
X			(other ? other : mn));
X		message(hit_message, 1);
X		hit_message[0] = 0;
X	}
X	if (!(monster->m_flags & STATIONARY)) {
X		damage = get_damage(monster->m_damage, 1);
X		if (other) {
X			if (flame) {
X				if ((damage -= get_armor_class(rogue.armor)) < 0) {
X					damage = 1;
X				}
X			}
X		}
X		if (cur_level >= (AMULET_LEVEL * 2)) {
X			minus = (float) ((AMULET_LEVEL * 2) - cur_level);
X		} else {
X			minus = (float) get_armor_class(rogue.armor) * 3.00;
X			minus = minus/100.00 * (float) damage;
X		}
X		damage -= (short) minus;
X	} else {
X		damage = monster->stationary_damage++;
X	}
X	if (wizard) {
X		damage /= 3;
X	}
X	if (damage > 0) {
X		rogue_damage(damage, monster);
X	}
X	if (monster->m_flags & SPECIAL_HIT) {
X		special_hit(monster);
X	}
X}
X
Xrogue_hit(monster, force_hit)
Xregister object *monster;
Xboolean force_hit;
X{
X	short damage, hit_chance;
X
X	if (monster) {
X		if (check_imitator(monster)) {
X			return;
X		}
X		hit_chance = force_hit ? 100 : get_hit_chance(rogue.weapon);
X
X		if (wizard) {
X			hit_chance *= 2;
X		}
X		if (!rand_percent(hit_chance)) {
X			if (!fight_monster) {
X				(void) strcpy(hit_message, "you miss  ");
X			}
X			goto RET;
X		}
X		damage = get_weapon_damage(rogue.weapon);
X		if (wizard) {
X			damage *= 3;
X		}
X		if (mon_damage(monster, damage)) {	/* still alive? */
X			if (!fight_monster) {
X				(void) strcpy(hit_message, "you hit  ");
X			}
X		}
XRET:	check_gold_seeker(monster);
X		wake_up(monster);
X	}
X}
X
Xrogue_damage(d, monster)
Xshort d;
Xobject *monster;
X{
X	if (d >= rogue.hp_current) {
X		rogue.hp_current = 0;
X		print_stats(STAT_HP);
X		killed_by(monster, 0);
X	}
X	rogue.hp_current -= d;
X	print_stats(STAT_HP);
X}
X
Xget_damage(ds, r)
Xchar *ds;
Xboolean r;
X{
X	register i = 0, j, n, d, total = 0;
X
X	while (ds[i]) {
X		n = get_number(ds+i);
X		while (ds[i++] != 'd') ;
X		d = get_number(ds+i);
X		while ((ds[i] != '/') && ds[i]) i++;
X
X		for (j = 0; j < n; j++) {
X			if (r) {
X				total += get_rand(1, d);
X			} else {
X				total += d;
X			}
X		}
X		if (ds[i] == '/') {
X			i++;
X		}
X	}
X	return(total);
X}
X
Xget_w_damage(obj)
Xobject *obj;
X{
X	char new_damage[12];
X	register to_hit, damage;
X	register i = 0;
X
X	if ((!obj) || (obj->what_is != WEAPON)) {
X		return(-1);
X	}
X	to_hit = get_number(obj->damage) + obj->hit_enchant;
X	while (obj->damage[i++] != 'd') ;
X	damage = get_number(obj->damage + i) + obj->d_enchant;
X
X	sprintf(new_damage, "%dd%d", to_hit, damage);
X
X	return(get_damage(new_damage, 1));
X}
X
Xget_number(s)
Xregister char *s;
X{
X	register i = 0;
X	register total = 0;
X
X	while ((s[i] >= '0') && (s[i] <= '9')) {
X		total = (10 * total) + (s[i] - '0');
X		i++;
X	}
X	return(total);
X}
X
Xlong
Xlget_number(s)
Xregister char *s;
X{
X	register long i = 0;
X	register long total = 0;
X
X	while ((s[i] >= '0') && (s[i] <= '9')) {
X		total = (10 * total) + (s[i] - '0');
X		i++;
X	}
X	return(total);
X}
X
Xto_hit(obj)
Xobject *obj;
X{
X	if (!obj) {
X		return(1);
X	}
X	return(get_number(obj->damage) + obj->hit_enchant);
X}
X
Xdamage_for_strength()
X{
X	short strength;
X
X	strength = rogue.str_current + add_strength;
X
X	if (strength <= 6) {
X		return(strength-5);
X	}
X	if (strength <= 14) {
X		return(1);
X	}
X	if (strength <= 17) {
X		return(3);
X	}
X	if (strength <= 18) {
X		return(4);
X	}
X	if (strength <= 20) {
X		return(5);
X	}
X	if (strength <= 21) {
X		return(6);
X	}
X	if (strength <= 30) {
X		return(7);
X	}
X	return(8);
X}
X
Xmon_damage(monster, damage)
Xobject *monster;
X{
X	char *mn;
X	short row, col;
X
X	monster->hp_to_kill -= damage;
X
X	if (monster->hp_to_kill <= 0) {
X		row = monster->row;
X		col = monster->col;
X		dungeon[row][col] &= ~MONSTER;
X		mvaddch(row, col, (int) get_dungeon_char(row, col));
X
X		fight_monster = 0;
X		cough_up(monster);
X		mn = mon_name(monster);
X		sprintf(hit_message+strlen(hit_message), "defeated the %s", mn);
X		message(hit_message, 1);
X		hit_message[0] = 0;
X		add_exp(monster->kill_exp, 1);
X		take_from_pack(monster, &level_monsters);
X
X		if (monster->m_flags & HOLDS) {
X			being_held = 0;
X		}
X		free_object(monster);
X		return(0);
X	}
X	return(1);
X}
X
Xfight(to_the_death)
Xboolean to_the_death;
X{
X	short ch, c;
X	short row, col;
X	boolean first_miss = 1;
X	short possible_damage;
X	object *monster;
X
X	while (!is_direction(ch = rgetchar())) {
X		sound_bell();
X		if (first_miss) {
X			message("direction?", 0);
X			first_miss = 0;
X		}
X	}
X	check_message();
X	if (ch == CANCEL) {
X		return;
X	}
X	row = rogue.row; col = rogue.col;
X	get_dir_rc(ch, &row, &col, 0);
X
X	c = mvinch(row, col);
X	if (((c < 'A') || (c > 'Z')) ||
X		(!can_move(rogue.row, rogue.col, row, col))) {
X		message("I see no monster there", 0);
X		return;
X	}
X	if (!(fight_monster = object_at(&level_monsters, row, col))) {
X		return;
X	}
X	if (!(fight_monster->m_flags & STATIONARY)) {
X		possible_damage = ((get_damage(fight_monster->m_damage, 0) * 2) / 3);
X	} else {
X		possible_damage = fight_monster->stationary_damage - 1;
X	}
X	while (fight_monster) {
X		(void) one_move_rogue(ch, 0);
X		if (((!to_the_death) && (rogue.hp_current <= possible_damage)) ||
X			interrupted || (!(dungeon[row][col] & MONSTER))) {
X			fight_monster = 0;
X		} else {
X			monster = object_at(&level_monsters, row, col);
X			if (monster != fight_monster) {
X				fight_monster = 0;
X			}
X		}
X	}
X}
X
Xget_dir_rc(dir, row, col, allow_off_screen)
Xshort dir;
Xshort *row, *col;
Xshort allow_off_screen;
X{
X	switch(dir) {
X	case 'h':
X		if (allow_off_screen || (*col > 0)) {
X			(*col)--;
X		}
X		break;
X	case 'j':
X		if (allow_off_screen || (*row < (DROWS-2))) {
X			(*row)++;
X		}
X		break;
X	case 'k':
X		if (allow_off_screen || (*row > MIN_ROW)) {
X			(*row)--;
X		}
X		break;
X	case 'l':
X		if (allow_off_screen || (*col < (DCOLS-1))) {
X			(*col)++;
X		}
X		break;
X	case 'y':
X		if (allow_off_screen || ((*row > MIN_ROW) && (*col > 0))) {
X			(*row)--;
X			(*col)--;
X		}
X		break;
X	case 'u':
X		if (allow_off_screen || ((*row > MIN_ROW) && (*col < (DCOLS-1)))) {
X			(*row)--;
X			(*col)++;
X		}
X		break;
X	case 'n':
X		if (allow_off_screen || ((*row < (DROWS-2)) && (*col < (DCOLS-1)))) {
X			(*row)++;
X			(*col)++;
X		}
X		break;
X	case 'b':
X		if (allow_off_screen || ((*row < (DROWS-2)) && (*col > 0))) {
X			(*row)++;
X			(*col)--;
X		}
X		break;
X	}
X}
X
Xget_hit_chance(weapon)
Xobject *weapon;
X{
X	short hit_chance;
X
X	hit_chance = 40;
X	hit_chance += 3 * to_hit(weapon);
X	hit_chance += (((2 * rogue.exp) + (2 * ring_exp)) - r_rings);
X	return(hit_chance);
X}
X
Xget_weapon_damage(weapon)
Xobject *weapon;
X{
X	short damage;
X
X	damage = get_w_damage(weapon);
X	damage += damage_for_strength();
X	damage += ((((rogue.exp + ring_exp) - r_rings) + 1) / 2);
X	return(damage);
X}
END_OF_hit.c
if test 7923 -ne `wc -c <hit.c`; then
    echo shar: \"hit.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f inventory.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"inventory.c\"
else
echo shar: Extracting \"inventory.c\" \(8637 characters\)
sed "s/^X//" >inventory.c <<'END_OF_inventory.c'
X/*
X * inventory.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_string(x,y) {t = x; x = y; y = t;}
X
Xboolean is_wood[WANDS];
X
Xchar *wand_materials[WAND_MATERIALS] = {
X	"steel ",
X	"bronze ",
X	"gold ",
X	"silver ",
X	"copper ",
X	"nickel ",
X	"cobalt ",
X	"tin ",
X	"iron ",
X	"magnesium ",
X	"chrome ",
X	"carbon ",
X	"platinum ",
X	"silicon ",
X	"titanium ",
X
X	"teak ",
X	"oak ",
X	"cherry ",
X	"birch ",
X	"pine ",
X	"cedar ",
X	"redwood ",
X	"balsa ",
X	"ivory ",
X	"walnut ",
X	"maple ",
X	"mahogany ",
X	"elm ",
X	"palm ",
X	"wooden "
X};
X
Xchar *gems[GEMS] = {
X	"diamond ",
X	"stibotantalite ",
X	"lapi-lazuli ",
X	"ruby ",
X	"emerald ",
X	"sapphire ",
X	"amethyst ",
X	"quartz ",
X	"tiger-eye ",
X	"opal ",
X	"agate ",
X	"turquoise ",
X	"pearl ",
X	"garnet "
X};
X
Xchar *syllables[MAXSYLLABLES] = {
X	"blech ",
X	"foo ",
X	"barf ",
X	"rech ",
X	"bar ",
X	"blech ",
X	"quo ",
X	"bloto ",
X	"woh ",
X	"caca ",
X	"blorp ",
X	"erp ",
X	"festr ",
X	"rot ",
X	"slie ",
X	"snorf ",
X	"iky ",
X	"yuky ",
X	"ooze ",
X	"ah ",
X	"bahl ",
X	"zep ",
X	"druhl ",
X	"flem ",
X	"behil ",
X	"arek ",
X	"mep ",
X	"zihr ",
X	"grit ",
X	"kona ",
X	"kini ",
X	"ichi ",
X	"niah ",
X	"ogr ",
X	"ooh ",
X	"ighr ",
X	"coph ",
X	"swerr ",
X	"mihln ",
X	"poxi "
X};
X
Xextern boolean wizard;
X
Xinventory(pack, mask)
Xobject *pack;
Xunsigned short mask;
X{
X	object *obj;
X	short i = 0, j, maxlen = 0, n;
X	char descs[MAX_PACK_COUNT+1][DCOLS];
X	short row, col;
X
X	obj = pack->next_object;
X
X	if (!obj) {
X		message("your pack is empty", 0);
X		return;
X	}
X	while (obj) {
X		if (obj->what_is & mask) {
X			descs[i][0] = ' ';
X			descs[i][1] = obj->ichar;
X			descs[i][2] = ((obj->what_is & ARMOR) && obj->is_protected)
X				? '}' : ')';
X			descs[i][3] = ' ';
X			get_desc(obj, descs[i]+4);
X			if ((n = strlen(descs[i])) > maxlen) {
X				maxlen = n;
X			}
X		i++;
X		}
X		obj = obj->next_object;
X	}
X	(void) strcpy(descs[i++], " --press space to continue--");
X	if (maxlen < 27) maxlen = 27;
X	col = DCOLS - (maxlen + 2);
X
X	for (row = 0; ((row < i) && (row < DROWS)); row++) {
X		if (row > 0) {
X			for (j = col; j < DCOLS; j++) {
X				descs[row-1][j-col] = mvinch(row, j);
X			}
X			descs[row-1][j-col] = 0;
X		}
X		mvaddstr(row, col, descs[row]);
X		clrtoeol();
X	}
X	refresh();
X	wait_for_ack();
X
X	move(0, 0);
X	clrtoeol();
X
X	for (j = 1; j < i; j++) {
X		mvaddstr(j, col, descs[j-1]);
X	}
X}
X
Xmix_colors()
X{
X	short i, j, k;
X	char *t;
X
X	for (i = 0; i <= 32; i++) {
X		j = get_rand(0, (POTIONS - 1));
X		k = get_rand(0, (POTIONS - 1));
X		swap_string(id_potions[j].title, id_potions[k].title);
X	}
X}
X
Xmake_scroll_titles()
X{
X	short i, j, n;
X	short sylls, s;
X
X	for (i = 0; i < SCROLLS; i++) {
X		sylls = get_rand(2, 5);
X		(void) strcpy(id_scrolls[i].title, "'");
X
X		for (j = 0; j < sylls; j++) {
X			s = get_rand(1, (MAXSYLLABLES-1));
X			(void) strcat(id_scrolls[i].title, syllables[s]);
X		}
X		n = strlen(id_scrolls[i].title);
X		(void) strcpy(id_scrolls[i].title+(n-1), "' ");
X	}
X}
X
Xget_desc(obj, desc)
Xobject *obj;
Xchar *desc;
X{
X	char *item_name;
X	struct id *id_table;
X	char more_info[32];
X	short i;
X
X	if (obj->what_is == AMULET) {
X		(void) strcpy(desc, "the amulet of Yendor ");
X		return;
X	}
X	item_name = name_of(obj);
X
X	if (obj->what_is == GOLD) {
X		sprintf(desc, "%d pieces of gold", obj->quantity);
X		return;
X	}
X
X	if (obj->what_is != ARMOR) {
X		if (obj->quantity == 1) {
X			(void) strcpy(desc, "a ");
X		} else {
X			sprintf(desc, "%d ", obj->quantity);
X		}
X	}
X	if (obj->what_is == FOOD) {
X		if (obj->which_kind == RATION) {
X			if (obj->quantity > 1) {
X				sprintf(desc, "%d rations of ", obj->quantity);
X			} else {
X				(void) strcpy(desc, "some ");
X			}
X		} else {
X			(void) strcpy(desc, "a ");
X		}
X		(void) strcat(desc, item_name);
X		goto ANA;
X	}
X	id_table = get_id_table(obj);
X
X	if (wizard) {
X		goto ID;
X	}
X	if (obj->what_is & (WEAPON | ARMOR | WAND | RING)) {
X		goto CHECK;
X	}
X
X	switch(id_table[obj->which_kind].id_status) {
X	case UNIDENTIFIED:
XCHECK:
X		switch(obj->what_is) {
X		case SCROLL:
X			(void) strcat(desc, item_name);
X			(void) strcat(desc, "entitled: ");
X			(void) strcat(desc, id_table[obj->which_kind].title);
X			break;
X		case POTION:
X			(void) strcat(desc, id_table[obj->which_kind].title);
X			(void) strcat(desc, item_name);
X			break;
X		case WAND:
X		case RING:
X			if (obj->identified ||
X			(id_table[obj->which_kind].id_status == IDENTIFIED)) {
X				goto ID;
X			}
X			if (id_table[obj->which_kind].id_status == CALLED) {
X				goto CALL;
X			}
X			(void) strcat(desc, id_table[obj->which_kind].title);
X			(void) strcat(desc, item_name);
X			break;
X		case ARMOR:
X			if (obj->identified) {
X				goto ID;
X			}
X			(void) strcpy(desc, id_table[obj->which_kind].title);
X			break;
X		case WEAPON:
X			if (obj->identified) {
X				goto ID;
X			}
X			(void) strcat(desc, name_of(obj));
X			break;
X		}
X		break;
X	case CALLED:
XCALL:	switch(obj->what_is) {
X		case SCROLL:
X		case POTION:
X		case WAND:
X		case RING:
X			(void) strcat(desc, item_name);
X			(void) strcat(desc, "called ");
X			(void) strcat(desc, id_table[obj->which_kind].title);
X			break;
X		}
X		break;
X	case IDENTIFIED:
XID:		switch(obj->what_is) {
X		case SCROLL:
X		case POTION:
X			(void) strcat(desc, item_name);
X			(void) strcat(desc, id_table[obj->which_kind].real);
X			break;
X		case RING:
X			if (wizard || obj->identified) {
X				if ((obj->which_kind == DEXTERITY) ||
X					(obj->which_kind == ADD_STRENGTH)) {
X					sprintf(more_info, "%s%d ", ((obj->class > 0) ? "+" : ""),
X						obj->class);
X					(void) strcat(desc, more_info);
X				}
X			}
X			(void) strcat(desc, item_name);
X			(void) strcat(desc, id_table[obj->which_kind].real);
X			break;
X		case WAND:
X			(void) strcat(desc, item_name);
X			(void) strcat(desc, id_table[obj->which_kind].real);
X			if (wizard || obj->identified) {
X				sprintf(more_info, "[%d]", obj->class);
X				(void) strcat(desc, more_info);
X			}
X			break;
X		case ARMOR:
X			sprintf(desc, "%s%d ", ((obj->d_enchant >= 0) ? "+" : ""),
X			obj->d_enchant);
X			(void) strcat(desc, id_table[obj->which_kind].title);
X			sprintf(more_info, "[%d] ", get_armor_class(obj));
X			(void) strcat(desc, more_info);
X			break;
X		case WEAPON:
X			sprintf(desc+strlen(desc), "%s%d,%s%d ",
X			((obj->hit_enchant >= 0) ? "+" : ""),
X			obj->hit_enchant,
X			((obj->d_enchant >= 0) ? "+" : ""),
X			obj->d_enchant);
X			(void) strcat(desc, name_of(obj));
X			break;
X		}
X		break;
X	}
XANA:
X	if (!strncmp(desc, "a ", 2)) {
X		if (is_vowel(desc[2])) {
X			for (i = strlen(desc) + 1; i > 1; i--) {
X				desc[i] = desc[i-1];
X			}
X			desc[1] = 'n';
X		}
X	}
X	if (obj->in_use_flags & BEING_WIELDED) {
X		(void) strcat(desc, "in hand");
X	} else if (obj->in_use_flags & BEING_WORN) {
X		(void) strcat(desc, "being worn");
X	} else if (obj->in_use_flags & ON_LEFT_HAND) {
X		(void) strcat(desc, "on left hand");
X	} else if (obj->in_use_flags & ON_RIGHT_HAND) {
X		(void) strcat(desc, "on right hand");
X	}
X}
X
Xget_wand_and_ring_materials()
X{
X	short i, j;
X	boolean used[WAND_MATERIALS];
X
X	for (i = 0; i < WAND_MATERIALS; i++) {
X		used[i] = 0;
X	}
X	for (i = 0; i < WANDS; i++) {
X		do {
X			j = get_rand(0, WAND_MATERIALS-1);
X		} while (used[j]);
X		used[j] = 1;
X		(void) strcpy(id_wands[i].title, wand_materials[j]);
X		is_wood[i] = (j > MAX_METAL);
X	}
X	for (i = 0; i < GEMS; i++) {
X		used[i] = 0;
X	}
X	for (i = 0; i < RINGS; i++) {
X		do {
X			j = get_rand(0, GEMS-1);
X		} while (used[j]);
X		used[j] = 1;
X		(void) strcpy(id_rings[i].title, gems[j]);
X	}
X}
X
Xsingle_inv(ichar)
Xshort ichar;
X{
X	short ch;
X	char desc[DCOLS];
X	object *obj;
X
X	ch = ichar ? ichar : pack_letter("inventory what?", ALL_OBJECTS);
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	desc[0] = ch;
X	desc[1] = ((obj->what_is & ARMOR) && obj->is_protected) ? '}' : ')';
X	desc[2] = ' ';
X	desc[3] = 0;
X	get_desc(obj, desc+3);
X	message(desc, 0);
X}
X
Xstruct id *
Xget_id_table(obj)
Xobject *obj;
X{
X	switch(obj->what_is) {
X	case SCROLL:
X		return(id_scrolls);
X	case POTION:
X		return(id_potions);
X	case WAND:
X		return(id_wands);
X	case RING:
X		return(id_rings);
X	case WEAPON:
X		return(id_weapons);
X	case ARMOR:
X		return(id_armors);
X	}
X	return((struct id *) 0);
X}
X
Xinv_armor_weapon(is_weapon)
Xboolean is_weapon;
X{
X	if (is_weapon) {
X		if (rogue.weapon) {
X			single_inv(rogue.weapon->ichar);
X		} else {
X			message("not wielding anything", 0);
X		}
X	} else {
X		if (rogue.armor) {
X			single_inv(rogue.armor->ichar);
X		} else {
X			message("not wearing anything", 0);
X		}
X	}
X}
END_OF_inventory.c
if test 8637 -ne `wc -c <inventory.c`; then
    echo shar: \"inventory.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f message.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"message.c\"
else
echo shar: Extracting \"message.c\" \(5682 characters\)
sed "s/^X//" >message.c <<'END_OF_message.c'
X/*
X * message.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 msg_line[DCOLS] = "";
Xshort msg_col = 0;
Xboolean msg_cleared = 1;
Xchar hunger_str[8] = "";
X
Xextern boolean cant_int, did_int, interrupted, save_is_interactive;
Xextern short add_strength;
Xextern short cur_level;
X
Xmessage(msg, intrpt)
Xchar *msg;
Xboolean intrpt;
X{
X	if (!save_is_interactive) {
X		return;
X	}
X	if (intrpt) {
X		interrupted = 1;
X		md_slurp();
X	}
X	cant_int = 1;
X
X	if (!msg_cleared) {
X		mvaddstr(MIN_ROW-1, msg_col, MORE);
X		refresh();
X		wait_for_ack();
X		check_message();
X	}
X	(void) strcpy(msg_line, msg);
X	mvaddstr(MIN_ROW-1, 0, msg);
X	addch(' ');
X	refresh();
X	msg_cleared = 0;
X	msg_col = strlen(msg);
X
X	if (did_int) {
X		onintr();
X	}
X	cant_int = 0;
X}
X
Xremessage()
X{
X	if (msg_line[0]) {
X		message(msg_line, 0);
X	}
X}
X
Xcheck_message()
X{
X	if (msg_cleared) {
X		return;
X	}
X	move(MIN_ROW-1, 0);
X	clrtoeol();
X	refresh();
X	msg_cleared = 1;
X}
X
Xget_input_line(prompt, insert, buf, if_cancelled, add_blank, do_echo)
Xchar *prompt, *buf, *insert;
Xchar *if_cancelled;
Xboolean add_blank;
Xboolean do_echo;
X{
X	short ch;
X	short i = 0, n;
X
X	message(prompt, 0);
X	n = strlen(prompt);
X
X	if (insert[0]) {
X		mvaddstr(0, n + 1, insert);
X		(void) strcpy(buf, insert);
X		i = strlen(insert);
X		move(0, (n + i + 1));
X		refresh();
X	}
X
X	while (((ch = rgetchar()) != '\r') && (ch != '\n') && (ch != CANCEL)) {
X		if ((ch >= ' ') && (ch <= '~') && (i < MAX_TITLE_LENGTH-2)) {
X			if ((ch != ' ') || (i > 0)) {
X				buf[i++] = ch;
X				if (do_echo) {
X					addch(ch);
X				}
X			}
X		}
X		if ((ch == '\b') && (i > 0)) {
X			if (do_echo) {
X				mvaddch(0, i + n, ' ');
X				move(MIN_ROW-1, i+n);
X			}
X			i--;
X		}
X		refresh();
X	}
X	check_message();
X	if (add_blank) {
X		buf[i++] = ' ';
X	} else {
X		while ((i > 0) && (buf[i-1] == ' ')) {
X			i--;
X		}
X	}
X
X	buf[i] = 0;
X
X	if ((ch == CANCEL) || (i == 0) || ((i == 1) && add_blank)) {
X		if (if_cancelled) {
X			message(if_cancelled, 0);
X		}
X		return(0);
X	}
X	return(i);
X}
X
Xrgetchar()
X{
X	register ch;
X
X	for(;;) {
X		ch = getchar();
X
X		switch(ch) {
X		case '\022':
X			wrefresh(curscr);
X			break;
X#ifdef UNIX_BSD4_2
X		case '\032':
X			printf(CL);
X			fflush(stdout);
X			tstp();
X			break;
X#endif UNIX_BSD4_2
X		case 'X':
X			save_screen();
X			break;
X		default:
X			return(ch);
X		}
X	}
X}
X/*
XLevel: 99 Gold: 999999 Hp: 999(999) Str: 99(99) Arm: 99 Exp: 21/10000000 Hungry
X0    5    1    5    2    5    3    5    4    5    5    5    6    5    7    5
X*/
X
Xprint_stats(stat_mask)
Xregister stat_mask;
X{
X	char buf[16];
X	boolean label;
X	int row = DROWS - 1;
X
X	label = (stat_mask & STAT_LABEL) ? 1 : 0;
X
X	if (stat_mask & STAT_LEVEL) {
X		if (label) {
X			mvaddstr(row, 0, "Level: ");
X		}
X		/* max level taken care of in make_level() */
X		sprintf(buf, "%d", cur_level);
X		mvaddstr(row, 7, buf);
X		pad(buf, 2);
X	}
X	if (stat_mask & STAT_GOLD) {
X		if (label) {
X			if (rogue.gold > MAX_GOLD) {
X				rogue.gold = MAX_GOLD;
X			}
X			mvaddstr(row, 10, "Gold: ");
X		}
X		sprintf(buf, "%d", rogue.gold);
X		mvaddstr(row, 16, buf);
X		pad(buf, 6);
X	}
X	if (stat_mask & STAT_HP) {
X		if (label) {
X			mvaddstr(row, 23, "Hp: ");
X			if (rogue.hp_max > MAX_HP) {
X				rogue.hp_current -= (rogue.hp_max - MAX_HP);
X				rogue.hp_max = MAX_HP;
X			}
X		}
X		sprintf(buf, "%d(%d)", rogue.hp_current, rogue.hp_max);
X		mvaddstr(row, 27, buf);
X		pad(buf, 8);
X	}
X	if (stat_mask & STAT_STRENGTH) {
X		if (label) {
X			mvaddstr(row, 36, "Str: ");
X		}
X		if (rogue.str_max > MAX_STRENGTH) {
X			rogue.str_current -= (rogue.str_max - MAX_STRENGTH);
X			rogue.str_max = MAX_STRENGTH;
X		}
X		sprintf(buf, "%d(%d)", (rogue.str_current + add_strength),
X			rogue.str_max);
X		mvaddstr(row, 41, buf);
X		pad(buf, 6);
X	}
X	if (stat_mask & STAT_ARMOR) {
X		if (label) {
X			mvaddstr(row, 48, "Arm: ");
X		}
X		if (rogue.armor && (rogue.armor->d_enchant > MAX_ARMOR)) {
X			rogue.armor->d_enchant = MAX_ARMOR;
X		}
X		sprintf(buf, "%d", get_armor_class(rogue.armor));
X		mvaddstr(row, 53, buf);
X		pad(buf, 2);
X	}
X	if (stat_mask & STAT_EXP) {
X		if (label) {
X			mvaddstr(row, 56, "Exp: ");
X		}
X		/*  Max exp taken care of in add_exp() */
X		sprintf(buf, "%d/%D", rogue.exp, rogue.exp_points);
X		mvaddstr(row, 61, buf);
X		pad(buf, 11);
X	}
X	if (stat_mask & STAT_HUNGER) {
X		mvaddstr(row, 73, hunger_str);
X		clrtoeol();
X	}
X	refresh();
X}
X
Xpad(s, n)
Xchar *s;
Xshort n;
X{
X	short i;
X
X	for (i = strlen(s); i < n; i++) {
X		addch(' ');
X	}
X}
X
Xsave_screen()
X{
X	FILE *fp;
X	short i, j, row, col;
X	char buf[DCOLS+2];
X	boolean found_non_blank;
X
X	row = curscr->_cury;
X	col = curscr->_curx;
X
X	if ((fp = fopen("rogue.screen", "w")) != NULL) {
X		for (i = 0; i < DROWS; i++) {
X			found_non_blank = 0;
X			for (j = (DCOLS - 1); j >= 0; j--) {
X				buf[j] = mvinch(i, j);
X				if (!found_non_blank) {
X					if ((buf[j] != ' ') || (j == 0)) {
X						buf[j + ((j == 0) ? 0 : 1)] = 0;
X						found_non_blank = 1;
X					}
X				}
X			}
X			fputs(buf, fp);
X			putc('\n', fp);
X		}
X		fclose(fp);
X	} else {
X		sound_bell();
X	}
X	move(row, col);
X	refresh();
X}
X
Xsound_bell()
X{
X	putchar(7);
X	fflush(stdout);
X}
X
Xboolean
Xis_digit(ch)
Xshort ch;
X{
X	return((ch >= '0') && (ch <= '9'));
X}
X
Xr_index(str, ch, last)
Xchar *str;
Xint ch;
Xboolean last;
X{
X	int i = 0;
X
X	if (last) {
X		for (i = strlen(str) - 1; i >= 0; i--) {
X			if (str[i] == ch) {
X				return(i);
X			}
X		}
X	} else {
X		for (i = 0; str[i]; i++) {
X			if (str[i] == ch) {
X				return(i);
X			}
X		}
X	}
X	return(-1);
X}
END_OF_message.c
if test 5682 -ne `wc -c <message.c`; then
    echo shar: \"message.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f pack.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"pack.c\"
else
echo shar: Extracting \"pack.c\" \(9072 characters\)
sed "s/^X//" >pack.c <<'END_OF_pack.c'
X/*
X * pack.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
Xchar *curse_message = "you can't, it appears to be cursed";
X
Xobject *
Xadd_to_pack(obj, pack, condense)
Xobject *obj, *pack;
X{
X	object *op;
X
X	if (condense) {
X		if (op = check_duplicate(obj, pack)) {
X			free_object(obj);
X			return(op);
X		} else {
X			obj->ichar = next_avail_ichar();
X		}
X	}
X	if (pack->next_object == 0) {
X		pack->next_object = obj;
X	} else {
X		op = pack->next_object;
X
X		while (op->next_object) {
X			op = op->next_object;
X		}
X		op->next_object = obj;
X	}
X	obj->next_object = 0;
X	return(obj);
X}
X
Xtake_from_pack(obj, pack)
Xobject *obj, *pack;
X{
X	while (pack->next_object != obj) {
X		pack = pack->next_object;
X	}
X	pack->next_object = pack->next_object->next_object;
X}
X
Xobject *
Xpick_up(row, col, status)
Xshort *status;
X{
X	object *obj;
X
X	obj = object_at(&level_objects, row, col);
X	*status = 1;
X
X	if ((obj->what_is == SCROLL) && (obj->which_kind == SCARE_MONSTER) &&
X		obj->picked_up) {
X		message("the scroll turns to dust as you pick it up", 0);
X		dungeon[row][col] &= (~OBJECT);
X		vanish(obj, 0, &level_objects);
X		*status = 0;
X		if (id_scrolls[SCARE_MONSTER].id_status == UNIDENTIFIED) {
X			id_scrolls[SCARE_MONSTER].id_status = IDENTIFIED;
X		}
X		return(0);
X	}
X	if (obj->what_is == GOLD) {
X		rogue.gold += obj->quantity;
X		dungeon[row][col] &= ~(OBJECT);
X		take_from_pack(obj, &level_objects);
X		print_stats(STAT_GOLD);
X		return(obj);	/* obj will be free_object()ed in one_move_rogue() */
X	}
X	if (pack_count(obj) >= MAX_PACK_COUNT) {
X		message("pack too full", 1);
X		return(0);
X	}
X	dungeon[row][col] &= ~(OBJECT);
X	take_from_pack(obj, &level_objects);
X	obj = add_to_pack(obj, &rogue.pack, 1);
X	obj->picked_up = 1;
X	return(obj);
X}
X
Xdrop()
X{
X	object *obj, *new;
X	short ch;
X	char desc[DCOLS];
X
X	if (dungeon[rogue.row][rogue.col] & (OBJECT | STAIRS | TRAP)) {
X		message("there's already something there", 0);
X		return;
X	}
X	if (!rogue.pack.next_object) {
X		message("you have nothing to drop", 0);
X		return;
X	}
X	if ((ch = pack_letter("drop what?", ALL_OBJECTS)) == CANCEL) {
X		return;
X	}
X	if (!(obj = get_letter_object(ch))) {
X		message("no such item.", 0);
X		return;
X	}
X	if (obj->in_use_flags & BEING_WIELDED) {
X		if (obj->is_cursed) {
X			message(curse_message, 0);
X			return;
X		}
X		unwield(rogue.weapon);
X	} else if (obj->in_use_flags & BEING_WORN) {
X		if (obj->is_cursed) {
X			message(curse_message, 0);
X			return;
X		}
X		mv_aquatars();
X		unwear(rogue.armor);
X		print_stats(STAT_ARMOR);
X	} else if (obj->in_use_flags & ON_EITHER_HAND) {
X		if (obj->is_cursed) {
X			message(curse_message, 0);
X			return;
X		}
X		un_put_on(obj);
X	}
X	obj->row = rogue.row;
X	obj->col = rogue.col;
X
X	if ((obj->quantity > 1) && (obj->what_is != WEAPON)) {
X		obj->quantity--;
X		new = alloc_object();
X		*new = *obj;
X		new->quantity = 1;
X		obj = new;
X	} else {
X		obj->ichar = 'L';
X		take_from_pack(obj, &rogue.pack);
X	}
X	place_at(obj, rogue.row, rogue.col);
X	(void) strcpy(desc, "dropped ");
X	get_desc(obj, desc+8);
X	message(desc, 0);
X	(void) reg_move();
X}
X
Xobject *
Xcheck_duplicate(obj, pack)
Xobject *obj, *pack;
X{
X	object *op;
X
X	if (!(obj->what_is & (WEAPON | FOOD | SCROLL | POTION))) {
X		return(0);
X	}
X	if ((obj->what_is == FOOD) && (obj->which_kind == FRUIT)) {
X		return(0);
X	}
X	op = pack->next_object;
X
X	while (op) {
X		if ((op->what_is == obj->what_is) && 
X			(op->which_kind == obj->which_kind)) {
X
X			if ((obj->what_is != WEAPON) ||
X			((obj->what_is == WEAPON) &&
X			((obj->which_kind == ARROW) ||
X			(obj->which_kind == DAGGER) ||
X			(obj->which_kind == DART) ||
X			(obj->which_kind == SHURIKEN)) &&
X			(obj->quiver == op->quiver))) {
X				op->quantity += obj->quantity;
X				return(op);
X			}
X		}
X		op = op->next_object;
X	}
X	return(0);
X}
X
Xnext_avail_ichar()
X{
X	register object *obj;
X	register i;
X	boolean ichars[26];
X
X	for (i = 0; i < 26; i++) {
X		ichars[i] = 0;
X	}
X	obj = rogue.pack.next_object;
X	while (obj) {
X		ichars[(obj->ichar - 'a')] = 1;
X		obj = obj->next_object;
X	}
X	for (i = 0; i < 26; i++) {
X		if (!ichars[i]) {
X			return(i + 'a');
X		}
X	}
X	return('?');
X}
X
Xwait_for_ack()
X{
X	while (rgetchar() != ' ') ;
X}
X
Xpack_letter(prompt, mask)
Xchar *prompt;
Xunsigned short mask;
X{
X	short ch;
X	unsigned short tmask = mask;
X
X	if (!mask_pack(&rogue.pack, mask)) {
X		message("nothing appropriate", 0);
X		return(CANCEL);
X	}
X	for (;;) {
X
X		message(prompt, 0);
X
X		for (;;) {
X			ch = rgetchar();
X			if (!is_pack_letter(&ch, &mask)) {
X				sound_bell();
X			} else {
X				break;
X			}
X		}
X
X		if (ch == LIST) {
X			check_message();
X			inventory(&rogue.pack, mask);
X		} else {
X			break;
X		}
X		mask = tmask;
X	}
X	check_message();
X	return(ch);
X}
X
Xtake_off()
X{
X	char desc[DCOLS];
X	object *obj;
X
X	if (rogue.armor) {
X		if (rogue.armor->is_cursed) {
X			message(curse_message, 0);
X		} else {
X			mv_aquatars();
X			obj = rogue.armor;
X			unwear(rogue.armor);
X			(void) strcpy(desc, "was wearing ");
X			get_desc(obj, desc+12);
X			message(desc, 0);
X			print_stats(STAT_ARMOR);
X			(void) reg_move();
X		}
X	} else {
X		message("not wearing any", 0);
X	}
X}
X
Xwear()
X{
X	short ch;
X	register object *obj;
X	char desc[DCOLS];
X
X	if (rogue.armor) {
X		message("your already wearing some", 0);
X		return;
X	}
X	ch = pack_letter("wear what?", ARMOR);
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 != ARMOR) {
X		message("you can't wear that", 0);
X		return;
X	}
X	obj->identified = 1;
X	(void) strcpy(desc, "wearing ");
X	get_desc(obj, desc + 8);
X	message(desc, 0);
X	do_wear(obj);
X	print_stats(STAT_ARMOR);
X	(void) reg_move();
X}
X
Xunwear(obj)
Xobject *obj;
X{
X	if (obj) {
X		obj->in_use_flags &= (~BEING_WORN);
X	}
X	rogue.armor = (object *) 0;
X}
X
Xdo_wear(obj)
Xobject *obj;
X{
X	rogue.armor = obj;
X	obj->in_use_flags |= BEING_WORN;
X	obj->identified = 1;
X}
X
Xwield()
X{
X	short ch;
X	register object *obj;
X	char desc[DCOLS];
X
X	if (rogue.weapon && rogue.weapon->is_cursed) {
X		message(curse_message, 0);
X		return;
X	}
X	ch = pack_letter("wield what?", WEAPON);
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 & (ARMOR | RING)) {
X		sprintf(desc, "you can't wield %s",
X			((obj->what_is == ARMOR) ? "armor" : "rings"));
X		message(desc, 0);
X		return;
X	}
X	if (obj->in_use_flags & BEING_WIELDED) {
X		message("in use", 0);
X	} else {
X		unwield(rogue.weapon);
X		(void) strcpy(desc, "wielding ");
X		get_desc(obj, desc + 9);
X		message(desc, 0);
X		do_wield(obj);
X		(void) reg_move();
X	}
X}
X
Xdo_wield(obj)
Xobject *obj;
X{
X	rogue.weapon = obj;
X	obj->in_use_flags |= BEING_WIELDED;
X}
X
Xunwield(obj)
Xobject *obj;
X{
X	if (obj) {
X		obj->in_use_flags &= (~BEING_WIELDED);
X	}
X	rogue.weapon = (object *) 0;
X}
X
Xcall_it()
X{
X	short ch;
X	register object *obj;
X	struct id *id_table;
X	char buf[MAX_TITLE_LENGTH+2];
X
X	ch = pack_letter("call what?", (SCROLL | POTION | WAND | RING));
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 | POTION | WAND | RING))) {
X		message("surely you already know what that's called", 0);
X		return;
X	}
X	id_table = get_id_table(obj);
X
X	if (get_input_line("call it:","",buf,id_table[obj->which_kind].title,1,1)) {
X		id_table[obj->which_kind].id_status = CALLED;
X		(void) strcpy(id_table[obj->which_kind].title, buf);
X	}
X}
X
Xpack_count(new_obj)
Xobject *new_obj;
X{
X	object *obj;
X	short count = 0;
X
X	obj = rogue.pack.next_object;
X
X	while (obj) {
X		if (obj->what_is != WEAPON) {
X			count += obj->quantity;
X		} else if (!new_obj) {
X			count++;
X		} else if ((new_obj->what_is != WEAPON) ||
X			((obj->which_kind != ARROW) &&
X			(obj->which_kind != DAGGER) &&
X			(obj->which_kind != DART) &&
X			(obj->which_kind != SHURIKEN)) ||
X			(new_obj->which_kind != obj->which_kind) ||
X			(obj->quiver != new_obj->quiver)) {
X			count++;
X		}
X		obj = obj->next_object;
X	}
X	return(count);
X}
X
Xboolean
Xmask_pack(pack, mask)
Xobject *pack;
Xunsigned short mask;
X{
X	while (pack->next_object) {
X		pack = pack->next_object;
X		if (pack->what_is & mask) {
X			return(1);
X		}
X	}
X	return(0);
X}
X
Xis_pack_letter(c, mask)
Xshort *c;
Xunsigned short *mask;
X{
X	if (((*c == '?') || (*c == '!') || (*c == ':') || (*c == '=') ||
X		(*c == ')') || (*c == ']') || (*c == '/') || (*c == ','))) {
X		switch(*c) {
X		case '?':
X			*mask = SCROLL;
X			break;
X		case '!':
X			*mask = POTION;
X			break;
X		case ':':
X			*mask = FOOD;
X			break;
X		case ')':
X			*mask = WEAPON;
X			break;
X		case ']':
X			*mask = ARMOR;
X			break;
X		case '/':
X			*mask = WAND;
X			break;
X		case '=':
X			*mask = RING;
X			break;
X		case ',':
X			*mask = AMULET;
X			break;
X		}
X		*c = LIST;
X		return(1);
X	}
X	return(((*c >= 'a') && (*c <= 'z')) || (*c == CANCEL) || (*c == LIST));
X}
X
Xhas_amulet()
X{
X	return(mask_pack(&rogue.pack, AMULET));
X}
END_OF_pack.c
if test 9072 -ne `wc -c <pack.c`; then
    echo shar: \"pack.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f ring.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"ring.c\"
else
echo shar: Extracting \"ring.c\" \(5692 characters\)
sed "s/^X//" >ring.c <<'END_OF_ring.c'
X/*
X * ring.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
Xchar *left_or_right = "left or right hand?";
Xchar *no_ring = "there's no ring on that hand";
Xshort stealthy, r_rings, add_strength, e_rings, regeneration, ring_exp;
Xshort auto_search;
Xboolean r_teleport, r_see_invisible, sustain_strength, maintain_armor;
X
Xextern char *curse_message;
Xextern boolean wizard;
X
Xput_on_ring()
X{
X	short ch;
X	char desc[DCOLS];
X	object *ring;
X
X	if (r_rings == 2) {
X		message("wearing two rings already", 0);
X		return;
X	}
X	if ((ch = pack_letter("put on what?", RING)) == CANCEL) {
X		return;
X	}
X	if (!(ring = get_letter_object(ch))) {
X		message("no such item.", 0);
X		return;
X	}
X	if (!(ring->what_is & RING)) {
X		message("that's not a ring", 0);
X		return;
X	}
X	if (ring->in_use_flags & (ON_LEFT_HAND | ON_RIGHT_HAND)) {
X		message("that ring is already being worn", 0);
X		return;
X	}
X	if (r_rings == 1) {
X		ch = (rogue.left_ring ? 'r' : 'l');
X	} else {
X		message(left_or_right, 0);
X		do {
X			ch = rgetchar();
X		} while ((ch != CANCEL) && (ch != 'l') && (ch != 'r') && (ch != '\n') &&
X			 	(ch != '\r'));
X	}
X	if ((ch != 'l') && (ch != 'r')) {
X		check_message();
X		return;
X	}
X	if (((ch == 'l') && rogue.left_ring)||((ch == 'r') && rogue.right_ring)) {
X		check_message();
X		message("there's already a ring on that hand", 0);
X		return;
X	}
X	if (ch == 'l') {
X		do_put_on(ring, 1);
X	} else {
X		do_put_on(ring, 0);
X	}
X	ring_stats(1);
X	check_message();
X	get_desc(ring, desc);
X	message(desc, 0);
X	(void) reg_move();
X}
X
X/*
X * Do not call ring_stats() from within do_put_on().  It will cause
X * serious problems when do_put_on() is called from read_pack() in restore().
X */
X
Xdo_put_on(ring, on_left)
Xobject *ring;
Xboolean on_left;
X{
X	if (on_left) {
X		ring->in_use_flags |= ON_LEFT_HAND;
X		rogue.left_ring = ring;
X	} else {
X		ring->in_use_flags |= ON_RIGHT_HAND;
X		rogue.right_ring = ring;
X	}
X}
X
Xremove_ring()
X{
X	boolean left = 0, right = 0;
X	short ch;
X	char buf[DCOLS];
X	object *ring;
X
X	if (r_rings == 0) {
X		inv_rings();
X	} else if (rogue.left_ring && !rogue.right_ring) {
X		left = 1;
X	} else if (!rogue.left_ring && rogue.right_ring) {
X		right = 1;
X	} else {
X		message(left_or_right, 0);
X		do {
X			ch = rgetchar();
X		} while ((ch != CANCEL) && (ch != 'l') && (ch != 'r') &&
X			(ch != '\n') && (ch != '\r'));
X		left = (ch == 'l');
X		right = (ch == 'r');
X		check_message();
X	}
X	if (left || right) {
X		if (left) {
X			if (rogue.left_ring) {
X				ring = rogue.left_ring;
X			} else {
X				message(no_ring, 0);
X			}
X		} else {
X			if (rogue.right_ring) {
X				ring = rogue.right_ring;
X			} else {
X				message(no_ring, 0);
X			}
X		}
X		if (ring->is_cursed) {
X			message(curse_message, 0);
X		} else {
X			un_put_on(ring);
X			(void) strcpy(buf, "removed ");
X			get_desc(ring, buf + 8);
X			message(buf, 0);
X			(void) reg_move();
X		}
X	}
X}
X
Xun_put_on(ring)
Xobject *ring;
X{
X	if (ring && (ring->in_use_flags & ON_LEFT_HAND)) {
X		ring->in_use_flags &= (~ON_LEFT_HAND);
X		rogue.left_ring = 0;
X	} else if (ring && (ring->in_use_flags & ON_RIGHT_HAND)) {
X		ring->in_use_flags &= (~ON_RIGHT_HAND);
X		rogue.right_ring = 0;
X	}
X	ring_stats(1);
X}
X
Xgr_ring(ring, assign_wk)
Xobject *ring;
Xboolean assign_wk;
X{
X	ring->what_is = RING;
X	if (assign_wk) {
X		ring->which_kind = get_rand(0, (RINGS - 1));
X	}
X	ring->class = 0;
X
X	switch(ring->which_kind) {
X	/*
X	case STEALTH:
X		break;
X	case SLOW_DIGEST:
X		break;
X	case REGENERATION:
X		break;
X	case R_SEE_INVISIBLE:
X		break;
X	case SUSTAIN_STRENGTH:
X		break;
X	case R_MAINTAIN_ARMOR:
X		break;
X	case SEARCHING:
X		break;
X	*/
X	case R_TELEPORT:
X		ring->is_cursed = 1;
X		break;
X	case ADD_STRENGTH:
X	case DEXTERITY:
X		while ((ring->class = (get_rand(0, 4) - 2)) == 0) ;
X		ring->is_cursed = (ring->class < 0);
X		break;
X	case ADORNMENT:
X		ring->is_cursed = coin_toss();
X		break;
X	}
X}
X
Xinv_rings()
X{
X	char buf[DCOLS];
X
X	if (r_rings == 0) {
X		message("not wearing any rings", 0);
X	} else {
X		if (rogue.left_ring) {
X			get_desc(rogue.left_ring, buf);
X			message(buf, 0);
X		}
X		if (rogue.right_ring) {
X			get_desc(rogue.right_ring, buf);
X			message(buf, 0);
X		}
X	}
X	if (wizard) {
X		sprintf(buf, "ste %d, r_r %d, e_r %d, r_t %d, s_s %d, a_s %d, reg %d, r_e %d, s_i %d, m_a %d, aus %d",
X			stealthy, r_rings, e_rings, r_teleport, sustain_strength,
X			add_strength, regeneration, ring_exp, r_see_invisible,
X			maintain_armor, auto_search);
X		message(buf, 0);
X	}
X}
X
Xring_stats(pr)
Xboolean pr;
X{
X	short i;
X	object *ring;
X
X	stealthy = 0;
X	r_rings = 0;
X	e_rings = 0;
X	r_teleport = 0;
X	sustain_strength = 0;
X	add_strength = 0;
X	regeneration = 0;
X	ring_exp = 0;
X	r_see_invisible = 0;
X	maintain_armor = 0;
X	auto_search = 0;
X
X	for (i = 0; i < 2; i++) {
X		if (!(ring = ((i == 0) ? rogue.left_ring : rogue.right_ring))) {
X			continue;
X		}
X		r_rings++;
X		e_rings++;
X		switch(ring->which_kind) {
X		case STEALTH:
X			stealthy++;
X			break;
X		case R_TELEPORT:
X			r_teleport = 1;
X			break;
X		case REGENERATION:
X			regeneration++;
X			break;
X		case SLOW_DIGEST:
X			e_rings -= 2;
X			break;
X		case ADD_STRENGTH:
X			add_strength += ring->class;
X			break;
X		case SUSTAIN_STRENGTH:
X			sustain_strength = 1;
X			break;
X		case DEXTERITY:
X			ring_exp += ring->class;
X			break;
X		case ADORNMENT:
X			break;
X		case R_SEE_INVISIBLE:
X			r_see_invisible = 1;
X			break;
X		case MAINTAIN_ARMOR:
X			maintain_armor = 1;
X			break;
X		case SEARCHING:
X			auto_search += 2;
X			break;
X		}
X	}
X	if (pr) {
X		print_stats(STAT_STRENGTH);
X		relight();
X	}
X}
END_OF_ring.c
if test 5692 -ne `wc -c <ring.c`; then
    echo shar: \"ring.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f room.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"room.c\"
else
echo shar: Extracting \"room.c\" \(8628 characters\)
sed "s/^X//" >room.c <<'END_OF_room.c'
X/*
X * room.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
Xroom rooms[MAXROOMS];
Xboolean rooms_visited[MAXROOMS];
X
Xextern short blind;
Xextern boolean detect_monster;
X
Xlight_up_room(rn)
Xint rn;
X{
X	short i, j;
X
X	if (!blind) {
X		for (i = rooms[rn].top_row;
X			i <= rooms[rn].bottom_row; i++) {
X			for (j = rooms[rn].left_col;
X				j <= rooms[rn].right_col; j++) {
X				if (dungeon[i][j] & MONSTER) {
X					object *monster;
X
X					if (monster = object_at(&level_monsters, i, j)) {
X						dungeon[monster->row][monster->col] &= (~MONSTER);
X						monster->trail_char =
X							get_dungeon_char(monster->row, monster->col);
X						dungeon[monster->row][monster->col] |= MONSTER;
X					}
X				}
X				mvaddch(i, j, get_dungeon_char(i, j));
X			}
X		}
X		mvaddch(rogue.row, rogue.col, rogue.fchar);
X	}
X}
X
Xlight_passage(row, col)
X{
X	short i, j, i_end, j_end;
X
X	if (blind) {
X		return;
X	}
X	i_end = (row < (DROWS-2)) ? 1 : 0;
X	j_end = (col < (DCOLS-1)) ? 1 : 0;
X
X	for (i = ((row > MIN_ROW) ? -1 : 0); i <= i_end; i++) {
X		for (j = ((col > 0) ? -1 : 0); j <= j_end; j++) {
X			if (can_move(row, col, row+i, col+j)) {
X				mvaddch(row+i, col+j, get_dungeon_char(row+i, col+j));
X			}
X		}
X	}
X}
X
Xdarken_room(rn)
Xshort 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 (blind) {
X				mvaddch(i, j, ' ');
X			} else {
X				if (!(dungeon[i][j] & (OBJECT | STAIRS)) &&
X					!(detect_monster && (dungeon[i][j] & MONSTER))) {
X					if (!imitating(i, j)) {
X						mvaddch(i, j, ' ');
X					}
X					if ((dungeon[i][j] & TRAP) && (!(dungeon[i][j] & HIDDEN))) {
X						mvaddch(i, j, '^');
X					}
X				}
X			}
X		}
X	}
X}
X
Xget_dungeon_char(row, col)
Xregister row, col;
X{
X	register unsigned short mask = dungeon[row][col];
X
X	if (mask & MONSTER) {
X		return(gmc_row_col(row, col));
X	}
X	if (mask & OBJECT) {
X		object *obj;
X
X		obj = object_at(&level_objects, row, col);
X		return(get_mask_char(obj->what_is));
X	}
X	if (mask & (TUNNEL | STAIRS | HORWALL | VERTWALL | FLOOR | DOOR)) {
X		if ((mask & (TUNNEL| STAIRS)) && (!(mask & HIDDEN))) {
X			return(((mask & STAIRS) ? '%' : '#'));
X		}
X		if (mask & HORWALL) {
X			return('-');
X		}
X		if (mask & VERTWALL) {
X			return('|');
X		}
X		if (mask & FLOOR) {
X			if (mask & TRAP) {
X				if (!(dungeon[row][col] & HIDDEN)) {
X					return('^');
X				}
X			}
X			return('.');
X		}
X		if (mask & DOOR) {
X			if (mask & HIDDEN) {
X				if (((col > 0) && (dungeon[row][col-1] & HORWALL)) ||
X					((col < (DCOLS-1)) && (dungeon[row][col+1] & HORWALL))) {
X					return('-');
X				} else {
X					return('|');
X				}
X			} else {
X				return('+');
X			}
X		}
X	}
X	return(' ');
X}
X
Xget_mask_char(mask)
Xregister unsigned short mask;
X{
X		switch(mask) {
X		case SCROLL:
X			return('?');
X		case POTION:
X			return('!');
X		case GOLD:
X			return('*');
X		case FOOD:
X			return(':');
X		case WAND:
X			return('/');
X		case ARMOR:
X			return(']');
X		case WEAPON:
X			return(')');
X		case RING:
X			return('=');
X		case AMULET:
X			return(',');
X		default:
X			return('~');	/* unknown, something is wrong */
X		}
X}
X
Xgr_row_col(row, col, mask)
Xshort *row, *col;
Xunsigned short mask;
X{
X	short rn;
X	short r, c;
X
X	do {
X		r = get_rand(MIN_ROW, DROWS-2);
X		c = get_rand(0, DCOLS-1);
X		rn = get_room_number(r, c);
X	} while ((rn == NO_ROOM) ||
X		(!(dungeon[r][c] & mask)) ||
X		(dungeon[r][c] & (~mask)) ||
X		(!(rooms[rn].is_room & (R_ROOM | R_MAZE))) ||
X		((r == rogue.row) && (c == rogue.col)));
X
X	*row = r;
X	*col = c;
X}
X
Xgr_room()
X{
X	short i;
X
X	do {
X		i = get_rand(0, MAXROOMS-1);
X	} while (!(rooms[i].is_room & (R_ROOM | R_MAZE)));
X
X	return(i);
X}
X
Xparty_objects(rn)
X{
X	short i, j, nf = 0;
X	object *obj;
X	short n, N, row, col;
X	boolean found;
X
X	N = ((rooms[rn].bottom_row - rooms[rn].top_row) - 1) *
X		((rooms[rn].right_col - rooms[rn].left_col) - 1);
X	n =  get_rand(5, 10);
X	if (n > N) {
X		n = N - 2;
X	}
X	for (i = 0; i < n; i++) {
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] == FLOOR) || (dungeon[row][col] == TUNNEL)) {
X				found = 1;
X			}
X		}
X		if (found) {
X			obj = gr_object();
X			place_at(obj, row, col);
X			nf++;
X		}
X	}
X	return(nf);
X}
X
Xget_room_number(row, col)
Xregister row, col;
X{
X	short i;
X
X	for (i = 0; i < MAXROOMS; i++) {
X		if ((row >= rooms[i].top_row) && (row <= rooms[i].bottom_row) &&
X			(col >= rooms[i].left_col) && (col <= rooms[i].right_col)) {
X			return(i);
X		}
X	}
X	return(NO_ROOM);
X}
X
Xis_all_connected()
X{
X	short i, starting_room;
X
X	for (i = 0; i < MAXROOMS; i++) {
X		rooms_visited[i] = 0;
X		if (rooms[i].is_room & (R_ROOM | R_MAZE)) {
X			starting_room = i;
X		}
X	}
X
X	visit_rooms(starting_room);
X
X	for (i = 0; i < MAXROOMS; i++) {
X		if ((rooms[i].is_room & (R_ROOM | R_MAZE)) && (!rooms_visited[i])) {
X			return(0);
X		}
X	}
X	return(1);
X}
X
Xvisit_rooms(rn)
Xint rn;
X{
X	short i;
X	short oth_rn;
X
X	rooms_visited[rn] = 1;
X
X	for (i = 0; i < 4; i++) {
X		oth_rn = rooms[rn].doors[i].oth_room;
X		if ((oth_rn >= 0) && (!rooms_visited[oth_rn])) {
X			visit_rooms(oth_rn);
X		}
X	}
X}
X
Xdraw_magic_map()
X{
X	short i, j, ch, och;
X	unsigned short mask = (HORWALL | VERTWALL | DOOR | TUNNEL | TRAP | STAIRS |
X			MONSTER);
X	unsigned short s;
X
X	for (i = 0; i < DROWS; i++) {
X		for (j = 0; j < DCOLS; j++) {
X			s = dungeon[i][j];
X			if (s & mask) {
X				if (((ch = mvinch(i, j)) == ' ') ||
X					((ch >= 'A') && (ch <= 'Z')) || (s & (TRAP | HIDDEN))) {
X					och = ch;
X					dungeon[i][j] &= (~HIDDEN);
X					if (s & HORWALL) {
X						ch = '-';
X					} else if (s & VERTWALL) {
X						ch = '|';
X					} else if (s & DOOR) {
X						ch = '+';
X					} else if (s & TRAP) {
X						ch = '^';
X					} else if (s & STAIRS) {
X						ch = '%';
X					} else if (s & TUNNEL) {
X						ch = '#';
X					} else {
X						continue;
X					}
X					if ((!(s & MONSTER)) || (och == ' ')) {
X						addch(ch);
X					}
X					if (s & MONSTER) {
X						object *monster;
X
X						if (monster = object_at(&level_monsters, i, j)) {
X							monster->trail_char = ch;
X						}
X					}
X				}
X			}
X		}
X	}
X}
X
Xdr_course(monster, entering, row, col)
Xobject *monster;
Xboolean entering;
Xshort row, col;
X{
X	short i, j, k, rn;
X	short r, rr;
X
X	monster->row = row;
X	monster->col = col;
X
X	if (mon_sees(monster, rogue.row, rogue.col)) {
X		monster->trow = NO_ROOM;
X		return;
X	}
X	rn = get_room_number(row, col);
X
X	if (entering) {		/* entering room */
X		/* look for door to some other room */
X		r = get_rand(0, MAXROOMS-1);
X		for (i = 0; i < MAXROOMS; i++) {
X			rr = (r + i) % MAXROOMS;
X			if ((!(rooms[rr].is_room & (R_ROOM | R_MAZE))) || (rr == rn)) {
X				continue;
X			}
X			for (k = 0; k < 4; k++) {
X				if (rooms[rr].doors[k].oth_room == rn) {
X					monster->trow = rooms[rr].doors[k].oth_row;
X					monster->tcol = rooms[rr].doors[k].oth_col;
X					if ((monster->trow == row) &&
X						(monster->tcol == col)) {
X						continue;
X					}
X					return;
X				}
X			}
X		}
X		/* look for door to dead end */
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 ((i != monster->row) && (j != monster->col) &&
X					(dungeon[i][j] & DOOR)) {
X					monster->trow = i;
X					monster->tcol = j;
X					return;
X				}
X			}
X		}
X		/* return monster to room that he came from */
X		for (i = 0; i < MAXROOMS; i++) {
X			for (j = 0; j < 4; j++) {
X				if (rooms[i].doors[j].oth_room == rn) {
X					for (k = 0; k < 4; k++) {
X						if (rooms[rn].doors[k].oth_room == i) {
X							monster->trow = rooms[rn].doors[k].oth_row;
X							monster->tcol = rooms[rn].doors[k].oth_col;
X							return;
X						}
X					}
X				}
X			}
X		}
X		/* no place to send monster */
X		monster->trow = -1;
X	} else {		/* exiting room */
X		if (!get_oth_room(rn, &row, &col)) {
X			monster->trow = NO_ROOM;
X		} else {
X			monster->trow = row;
X			monster->tcol = col;
X		}
X	}
X}
X
Xget_oth_room(rn, row, col)
Xshort rn, *row, *col;
X{
X	short d = -1;
X
X	if (*row == rooms[rn].top_row) {
X		d = UP/2;
X	} else if (*row == rooms[rn].bottom_row) {
X		d = DOWN/2;
X	} else if (*col == rooms[rn].left_col) {
X		d = LEFT/2;
X	} else if (*col == rooms[rn].right_col) {
X		d = RIGHT/2;
X	}
X	if ((d != -1) && (rooms[rn].doors[d].oth_room >= 0)) {
X		*row = rooms[rn].doors[d].oth_row;
X		*col = rooms[rn].doors[d].oth_col;
X		return(1);
X	}
X	return(0);
X}
END_OF_room.c
if test 8628 -ne `wc -c <room.c`; then
    echo shar: \"room.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f zap.c -a "${1}" != "-c" ; then 
  echo shar: Will not over-write existing file \"zap.c\"
else
echo shar: Extracting \"zap.c\" \(4133 characters\)
sed "s/^X//" >zap.c <<'END_OF_zap.c'
X/*
X * zap.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 wizard = 0;
X
Xextern boolean being_held, score_only;
X
Xzapp()
X{
X	short wch;
X	boolean first_miss = 1;
X	object *wand;
X	short dir, row, col;
X	object *monster;
X
X	while (!is_direction(dir = rgetchar())) {
X		sound_bell();
X		if (first_miss) {
X			message("direction? ", 0);
X			first_miss = 0;
X		}
X	}
X	check_message();
X	if (dir == CANCEL) {
X		return;
X	}
X	if ((wch = pack_letter("zap with what?", WAND)) == CANCEL) {
X		return;
X	}
X	check_message();
X
X	if (!(wand = get_letter_object(wch))) {
X		message("no such item.", 0);
X		return;
X	}
X	if (wand->what_is != WAND) {
X		message("you can't zap with that", 0);
X		return;
X	}
X	if (wand->class <= 0) {
X		message("nothing happens", 0);
X	} else {
X		wand->class--;
X		row = rogue.row; col = rogue.col;
X		monster = get_zapped_monster(dir, &row, &col);
X		if (monster) {
X			wake_up(monster);
X			zap_monster(monster, wand->which_kind);
X			relight();
X		}
X	}
X	(void) reg_move();
X}
X
Xobject *
Xget_zapped_monster(dir, row, col)
Xshort dir;
Xshort *row, *col;
X{
X	short orow, ocol;
X
X	for (;;) {
X		orow = *row; ocol = *col;
X		get_dir_rc(dir, row, col, 0);
X		if (((*row == orow) && (*col == ocol)) ||
X		   (dungeon[*row][*col] & (HORWALL | VERTWALL)) ||
X		   (dungeon[*row][*col] == NOTHING)) {
X			return(0);
X		}
X		if (dungeon[*row][*col] & MONSTER) {
X			if (!imitating(*row, *col)) {
X				return(object_at(&level_monsters, *row, *col));
X			}
X		}
X	}
X}
X
Xzap_monster(monster, kind)
Xobject *monster;
Xunsigned short kind;
X{
X	short row, col;
X	object *nm;
X	short tc;
X
X	row = monster->row;
X	col = monster->col;
X
X	switch(kind) {
X	case SLOW_MONSTER:
X		if (monster->m_flags & HASTED) {
X			monster->m_flags &= (~HASTED);
X		} else {
X			monster->slowed_toggle = 0;
X			monster->m_flags |= SLOWED;
X		}
X		break;
X	case HASTE_MONSTER:
X		if (monster->m_flags & SLOWED) {
X			monster->m_flags &= (~SLOWED);
X		} else {
X			monster->m_flags |= HASTED;
X		}
X		break;
X	case TELE_AWAY:
X		tele_away(monster);
X		break;
X	case CONFUSE_MONSTER:
X		monster->m_flags |= CONFUSED;
X		monster->moves_confused += get_rand(12, 22);
X		break;
X	case INVISIBILITY:
X		monster->m_flags |= INVISIBLE;
X		break;
X	case POLYMORPH:
X		if (monster->m_flags & HOLDS) {
X			being_held = 0;
X		}
X		nm = monster->next_monster;
X		tc = monster->trail_char;
X		(void) gr_monster(monster, get_rand(0, MONSTERS-1));
X		monster->row = row;
X		monster->col = col;
X		monster->next_monster = nm;
X		monster->trail_char = tc;
X		if (!(monster->m_flags & IMITATES)) {
X			wake_up(monster);
X		}
X		break;
X	case PUT_TO_SLEEP:
X		monster->m_flags |= (ASLEEP | NAPPING);
X		monster->nap_length = get_rand(3, 6);
X		break;
X	case MAGIC_MISSILE:
X		rogue_hit(monster, 1);
X		break;
X	case CANCELLATION:
X		if (monster->m_flags & HOLDS) {
X			being_held = 0;
X		}
X		if (monster->m_flags & STEALS_ITEM) {
X			monster->drop_percent = 0;
X		}
X		monster->m_flags &= (~(FLIES | FLITS | SPECIAL_HIT | INVISIBLE |
X			FLAMES | IMITATES | CONFUSES | SEEKS_GOLD | HOLDS));
X		break;
X	case DO_NOTHING:
X		message("nothing happens", 0);
X		break;
X	}
X}
X
Xtele_away(monster)
Xobject *monster;
X{
X	short row, col;
X
X	if (monster->m_flags & HOLDS) {
X		being_held = 0;
X	}
X	gr_row_col(&row, &col, (FLOOR | TUNNEL | STAIRS | OBJECT));
X	dungeon[monster->row][monster->col] &= ~MONSTER;
X
X	monster->row = row; monster->col = col;
X	dungeon[row][col] |= MONSTER;
X	monster->trail_char = mvinch(row, col);
X}
X
Xwizardize()
X{
X	char buf[100];
X
X	if (wizard) {
X		wizard = 0;
X		message("not wizard anymore", 0);
X	} else {
X		if (get_input_line("wizard's password:", "", buf, "", 0, 0)) {
X			(void) xxx(1);
X			xxxx(buf, strlen(buf));
X			if (!strncmp(buf, "\247\104\126\272\115\243\027", 7)) {
X				wizard = 1;
X				score_only = 1;
X				message("Welcome, mighty wizard!", 0);
X			} else {
X				message("sorry", 0);
X			}
X		}
X	}
X}
END_OF_zap.c
if test 4133 -ne `wc -c <zap.c`; then
    echo shar: \"zap.c\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of archive 4 \(of 5\).
cp /dev/null ark4isdone
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