[net.sources.games] vms extended rogue part3 of 4

rich@sdcsvax.UUCP (rich) (08/04/86)

#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	object.c
#	object.h
#	oldxio.c
#	pack.c
#	play.c
# This archive created: Mon Aug  4 11:42:12 1986
# By:	rich ( lack of)
export PATH; PATH=/bin:/usr/bin:$PATH
if test -f 'object.c'
then
	echo shar: "will not over-write existing file 'object.c'"
else
cat << \SHAR_EOF > 'object.c'
#include curses.h
#include "object.h"
#include "room.h"

object level_objects;
unsigned short screen[SROWS][SCOLS];

extern short current_level, max_level;
extern short party_room;

short has_amulet = 0;
short foods = 0;

fighter rogue = {
	0, 0,		/* armor, weapon */
	12, 12,		/* Hp */
	16, 16,		/* Str */
	{0},		/* pack */
	0,		/* gold */
	1, 0,		/* exp, exp_points */
	0, 0,		/* row, col */
	'@',		/* char */
	1200		/* moves */
};

struct identify id_potions[POTIONS] = {
{100, "blue \0                           ", "of increase strength ",0},
{250, "red \0                            ", "of restore strength ",0},
{100, "green \0                          ", "of healing ",0},
{200, "grey \0                           ", "of extra healing ",0},
 {10, "brown \0                          ", "of poison ",0},
{300, "clear \0                          ", "of raise level ",0},
 {10, "pink \0                           ", "of blindness ",0},
 {25, "white \0                          ", "of hallucination ",0},
{100, "purple \0                         ", "of detect monster ",0},
{100, "black \0                          ", "of detect things ",0},
 {10, "yellow \0                         ", "of confusion ",0}
};

struct identify id_scrolls[SCROLLS] = {
{505, "                                   ", "of protect armor ", 0},
{200, "                                   ", "of hold monster ", 0},
{235, "                                   ", "of enchant weapon ", 0},
{235, "                                   ", "of enchant armor ", 0},
{175, "                                   ", "of identify ", 0},
{190, "                                   ", "of teleportation ", 0},
 {25, "                                   ", "of sleep ", 0},
{610, "                                   ", "of scare monster ", 0},
{210, "                                   ", "of remove curse ", 0},
{100, "                                   ", "of create monster ",0},
 {25, "                                   ", "of aggravate monster ",0}
};

struct identify id_weapons[WEAPONS] = {

	{ 15, "arrows ", "", 0},
	{100, "battle axe ", "", 0},
	{140, "bardiche ", "", 0},
	{120, "bec de corbin ", "", 0},
	{120, "bill-guisarme ", "", 0},
	{200, "long bow ", "", 0},
	{150, "short bow ", "", 0},
	{160, "fauchard ", "", 0},
	{ 60, "flail ", "", 0},
	{120, "glaive ", "", 0},
	{100, "guisarme ", "", 0},
	{180, "halberd ", "", 0},
	{140, "lucern hammer ", "", 0},
	{ 40, "hammer ", "", 0},
	{ 20, "javelin ", "", 0},
	{160, "mace ", "", 0},
	{100, "morning star ", "", 0},
	{200, "partisan ", "", 0},
	{ 60, "pike ", "", 0},
	{100, "ranseur ", "", 0},
	{300, "sabre ", "", 0},
	{300, "scimitar ", "", 0},
	{300, "cutlass ", "", 0},
	{ 40, "shurikens ", "", 0},
	{ 30, "spear ", "", 0},
	{ 60, "spetum ", "", 0},
	{500, "bastard sword ", "", 0},
	{200, "broad sword ", "", 0},
	{300, "long sword ", "", 0},
	{200, "short sword ", "", 0},
	{600, "two-handed sword ", "", 0},
	{ 80, "trident ", "", 0},
	{ 40, "voulge ", "", 0},
	{ 20, "whip ", "", 0}

};

struct identify id_armors[ARMORS] = {
	{300, "leather armor ", "", (UNIDENTIFIED)},
	{300, "ring mail ", "", (UNIDENTIFIED)},
	{400, "scale mail ", "", (UNIDENTIFIED)},
	{500, "chain mail ", "", (UNIDENTIFIED)},
	{600, "banded mail ", "", (UNIDENTIFIED)},
	{600, "splint mail ", "", (UNIDENTIFIED)},
	{700, "plate mail ", "", (UNIDENTIFIED)}
};

struct identify id_wands[WANDS] = {
	 {25, "                                 ", "of teleport away ",0},
	 {50, "                                 ", "of slow monster ", 0},
	 {45, "                                 ", "of kill monster ",0},
	  {8, "                                 ", "of invisibility ",0},
	 {55, "                                 ", "of polymorph ",0},
	  {2, "                                 ", "of haste monster ",0},
	 {25, "                                 ", "of put to sleep ",0},
	  {0, "                                 ", "of do nothing ",0}
};

put_objects()
{
	short row, col, i, n;
	char *malloc();
	object *obj, *get_rand_object();

	if (current_level < max_level) return;

	n = get_rand(2, 4);
	if (rand_percent(35)) n++;

	if (rand_percent(50)) {
		strcpy(id_weapons[SHURIKEN].title, "daggers ");
	}
	if (rand_percent(9)) {
		make_party();
	}
	for (i = 0; i < n; i++) {
		obj = get_rand_object();
		put_object_rand_location(obj);
		add_to_pack(obj, &level_objects, 0);
	}
	put_gold();
}

put_gold()
{
	short i, j;
	short row,col;
	object *obj;

	for (i = 0; i < MAXROOMS; i++) {
		if (rooms[i].is_room && rand_percent(GOLD_PERCENT)) {
			for (j = 0; j < 25; j++) {
				row = get_rand(rooms[i].top_row+1,
				rooms[i].bottom_row-1);
				col = get_rand(rooms[i].left_col+1,
				rooms[i].right_col-1);
				if ((screen[row][col] == FLOOR) ||
				    (screen[row][col] == PASSAGE)) {
					put_gold_at(row, col);
					break;
				}
			}
		continue;
		}
	}
}

put_gold_at(row, col)
{
	object *obj;
        object *get_an_object();

	obj = get_an_object();
	obj->row = row; obj->col = col;
	obj->what_is = GOLD;
	obj->quantity = get_rand((2*current_level), (16*current_level));
	add_mask(row, col, GOLD);
	add_to_pack(obj, &level_objects, 0);
}

put_object_at(obj, row, col)
object *obj;
{
	obj->row = row;
	obj->col = col;
	add_mask(row, col, obj->what_is);
	add_to_pack(obj, &level_objects, 0);
}

object *object_at(pack, row, col)
object *pack;
{
	object *obj;

	obj = pack->next_object;

	while (obj && (obj->row != row) || (obj->col != col)) {
		obj = obj->next_object;
	}
	return(obj);
}

object *get_letter_object(ch)
{
	object *obj;

	obj = rogue.pack.next_object;

	while (obj && (obj->ichar != ch)) {
		obj = obj->next_object;
	}
	return(obj);
}

free_stuff(objlist)
object *objlist;
{
	object *obj;

	while (objlist->next_object) {
		obj = objlist->next_object;
		objlist->next_object =
			objlist->next_object->next_object;
		free(obj);
	}
}

char *name_of(obj)
object *obj;
{
	char *retstring;

	switch(obj->what_is) {
	case SCROLL:
		retstring = obj->quantity > 1 ? "scrolls " : "scroll ";
		break;
	case POTION:
		retstring = obj->quantity > 1 ? "potions " : "potion ";
		break;
	case FOOD:
		retstring = obj->quantity > 1 ? "rations " : "ration ";
		break;
	case WAND:
		retstring = "wand ";
		break;
	case WEAPON:
		switch(obj->which_kind) {
		case ARROW:
			retstring=obj->quantity > 1 ? "arrows " : "arrow ";
			break;
		case SHURIKEN:
			if (id_weapons[SHURIKEN].title[0] == 'd') {
			retstring=obj->quantity > 1 ? "daggers " : "dagger ";
			} else {
			retstring=obj->quantity > 1?"shurikens ":"shuriken ";
			}
			break;
		default:
			retstring = id_weapons[obj->which_kind].title;
		}
		break;
	default:
		retstring = "unknown ";
		break;
	}
	return(retstring);
}

object *get_rand_object()
{
	object *obj, *get_an_object();

	obj = get_an_object();

	if (foods < (current_level/2)) {
		obj->what_is = FOOD;
	} else {
		obj->what_is = get_rand_what_is();
	}
	obj->identified = 0;

	switch(obj->what_is) {
	case SCROLL:
		get_rand_scroll(obj);
		break;
	case POTION:
		get_rand_potion(obj);
		break;
	case WEAPON:
		get_rand_weapon(obj);
		break;
	case ARMOR:
		get_rand_armor(obj);
		break;
	case WAND:
		get_rand_wand(obj);
		break;
	case FOOD:
		foods++;
		get_food(obj);
		break;
	}
	return(obj);
}

get_rand_what_is()
{
	short percent;
	short what_is;

	percent = get_rand(1, 92);

	if (percent <= 25) {
		what_is = SCROLL;
	} else if (percent <= 55) {
		what_is = POTION;
	} else if (percent <= 61) {
		what_is = WAND;
	} else if (percent <= 73) {
		what_is = WEAPON;
	} else if (percent <= 83) {
		what_is = ARMOR;
	} else {
		what_is = FOOD;
	}
	return(what_is);
}

get_rand_scroll(obj)
object *obj;
{
	short percent;

	percent = get_rand(0, 82);

	if (percent <= 5) {
		obj->which_kind = PROTECT_ARMOR;
	} else if (percent <= 11) {
		obj->which_kind = HOLD_MONSTER;
	} else if (percent <= 20) {
		obj->which_kind = CREATE_MONSTER;
	} else if (percent <= 35) {
		obj->which_kind = IDENTIFY;
	} else if (percent <= 43) {
		obj->which_kind = TELEPORT;
	} else if (percent <= 52) {
		obj->which_kind = SLEEP;
	} else if (percent <= 57) {
		obj->which_kind = SCARE_MONSTER;
	} else if (percent <= 66) {
		obj->which_kind = REMOVE_CURSE;
	} else if (percent <= 71) {
		obj->which_kind = ENCHANT_ARMOR;
	} else if (percent <= 76) {
		obj->which_kind = ENCHANT_WEAPON;
	} else {
		obj->which_kind = AGGRAVATE_MONSTER;
	}
}

get_rand_potion(obj)
object *obj;
{
	short percent;

	percent = get_rand(1, 105);

	if (percent <= 5) {
		obj->which_kind = RAISE_LEVEL;
	} else if (percent <= 15) {
		obj->which_kind = DETECT_OBJECTS;
	} else if (percent <= 25) {
		obj->which_kind = DETECT_MONSTER;
	} else if (percent <= 35) {
		obj->which_kind = INCREASE_STRENGTH;
	} else if (percent <= 45) {
		obj->which_kind = RESTORE_STRENGTH;
	} else if (percent <= 55) {
		obj->which_kind = HEALING;
	} else if (percent <= 65) {
		obj->which_kind = EXTRA_HEALING;
	} else if (percent <= 75) {
		obj->which_kind = BLINDNESS;
	} else if (percent <= 85) {
		obj->which_kind = HALLUCINATION;
	} else if (percent <= 95) {
		obj->which_kind = CONFUSION;
	} else {
		obj->which_kind = POISON;
	}
}

get_rand_weapon(obj)
object *obj;
{
	short percent;
	short i;
	short blessing, cursed, increment;
	short how_bad;

	obj->which_kind = get_rand(0, (WEAPONS-1));

	if ((obj->which_kind == ARROW) || (obj->which_kind == SHURIKEN)) {
		obj->quantity = get_rand(3, 15);
		obj->quiver = get_rand(0, 126);
	} else {
		obj->quantity = 1;
	}
	obj->identified = 0;
	obj->to_hit_enchantment = obj->damage_enchantment = 0;
	get_weapon_thd(obj);

	/* notice, the exciting weapons are ALWAYS cursed or blessed */
	switch(obj->which_kind){
		case BARDICHE:
		case RANSEUR:
		case SABRE:
		case SCIMITAR:
		case CUTLASS:
		case BASTARD_SWORD:
		case BROAD_SWORD:
		case LONG_SWORD:
		case SHORT_SWORD:
			how_bad=32;
			break;
		default: how_bad=96;
		}

	percent = get_rand(1, how_bad);
	blessing = get_rand(1, 3);
	obj->is_cursed = 0;

	if (percent <= 16) {
		increment = 1;
	} else if (percent <= 32) {
		increment = -1;
		obj->is_cursed = 1;
	}
	if (percent <= 32) {
		for (i = 0; i < blessing; i++) {
			if (rand_percent(50)) {
				obj->to_hit_enchantment += increment;
			} else {
				obj->damage_enchantment += increment;
			}
		}
	}
	switch(obj->which_kind) {
	case ARROW:
		obj->damage = "1d2";
		break;
	case BATTLE_AXE:
		obj->damage = "1d8";
		break;
	case BARDICHE:
		obj->damage = "3d5";
		break;
	case BEC_DE_CORBIN:
		obj->damage = "2d3";
		break;
	case BILL_GUISARME:
		obj->damage = "2d5";
		break;
	case LONG_BOW:
		obj->damage = "1d6";
		break;
	case SHORT_BOW:
		obj->damage = "1d4";
		break;
	case FAUCHARD:
		obj->damage = "1d8";
		break;
	case FLAIL:
		obj->damage = "2d3";
		break;
	case GLAIVE:
		obj->damage = "1d10";
		break;
	case GUISARME:
		obj->damage = "2d4";
		break;
	case HALBERD:
		obj->damage = "2d6";
		break;
	case LUCERN_HAMMER:
		obj->damage = "2d4";
		break;
	case HAMMER:
		obj->damage = "1d4";
		break;
	case JAVELIN:
		obj->damage = "1d6";
		break;
	case MACE:
		obj->damage = "2d3";
		break;
	case MORNING_STAR:
		obj->damage = "2d4";
		break;
	case PARTISAN:
		obj->damage = "2d3";
		break;
	case PIKE:
		obj->damage = "2d4";
		break;
	case RANSEUR:
		obj->damage = "2d4";
		break;
	case SABRE:
		obj->damage = "2d4";
		break;
	case SCIMITAR:
		obj->damage = "1d8";
		break;
	case CUTLASS:
		obj->damage = "1d10";
		break;
	case SHURIKEN:
		obj->damage = "2d2";
		break;
	case SPEAR:
		obj->damage = "2d3";
		break;
	case SPETUM:
		obj->damage = "2d6";
		break;
	case BASTARD_SWORD:
		obj->damage = "2d8";
		break;
	case BROAD_SWORD:
		obj->damage = "3d4";
		break;
	case LONG_SWORD:
		obj->damage = "4d3";
		break;
	case SHORT_SWORD:
		obj->damage = "1d6";
		break;
	case TWO_HANDED_SWORD:
		obj->damage = "3d6";
		break;
	case TRIDENT:
		obj->damage = "3d4";
		break;
	case VOULGE:
		obj->damage = "2d4";
		break;
	case WHIP:
		obj->damage = "1d2";
		break;
	}
}
get_rand_weapon2(obj)
object *obj;
{

redo:	obj->which_kind = get_rand(0, (WEAPONS-1));

	obj->quantity = 1;

	obj->identified = 0;
	obj->to_hit_enchantment = obj->damage_enchantment = 0;
	get_weapon_thd(obj);

	obj->is_cursed = 0;


	obj->damage_enchantment ++;
	obj->to_hit_enchantment ++;
	if (rand_percent(50)) 
		obj->damage_enchantment ++;
	if (rand_percent(50)) 
		obj->to_hit_enchantment ++;

	switch(obj->which_kind) {
	case BATTLE_AXE:
		obj->damage = "1d8";
		break;
	case BEC_DE_CORBIN:
		obj->damage = "2d3";
		break;
	case BILL_GUISARME:
		obj->damage = "2d5";
		break;
	case FAUCHARD:
		obj->damage = "1d8";
		break;
	case FLAIL:
		obj->damage = "2d3";
		break;
	case GLAIVE:
		obj->damage = "1d10";
		break;
	case GUISARME:
		obj->damage = "2d4";
		break;
	case HALBERD:
		obj->damage = "2d6";
		break;
	case LUCERN_HAMMER:
		obj->damage = "2d4";
		break;
	case JAVELIN:
		obj->damage = "1d6";
		break;
	case MACE:
		obj->damage = "2d3";
		break;
	case MORNING_STAR:
		obj->damage = "2d4";
		break;
	case PARTISAN:
		obj->damage = "2d3";
		break;
	case PIKE:
		obj->damage = "2d4";
		break;
	case RANSEUR:
		obj->damage = "2d4";
		break;
	case SABRE:
		obj->damage = "2d4";
		break;
	case SCIMITAR:
		obj->damage = "1d8";
		break;
	case CUTLASS:
		obj->damage = "1d10";
		break;
	case SPEAR:
		obj->damage = "2d3";
		break;
	case SPETUM:
		obj->damage = "2d6";
		break;
	case SHORT_SWORD:
		obj->damage = "1d6";
		break;
	case VOULGE:
		obj->damage = "2d4";
		break;
	case WHIP:
		obj->damage = "1d2";
		break;
	default: goto redo;
	}
}

get_rand_armor(obj)
object *obj;
{
	short percent;
	short blessing;

	obj->which_kind = get_rand(0, (ARMORS-1));
	obj->class = obj->which_kind + 2;
	if ((obj->which_kind == PLATE) || (obj->which_kind == SPLINT)) {
		obj->class--;
	}
	obj->is_cursed = 0;
	obj->is_protected = 0;
	obj->damage_enchantment = 0;

	percent = get_rand(1, 100);
	blessing = get_rand(1, 3);

	if (percent <= 16) {
		obj->is_cursed = 1;
		obj->damage_enchantment -= blessing;
	} else if (percent <= 33) {
		obj->damage_enchantment += blessing;
	}
}



get_rand_armor2(obj)
object *obj;
{
	short percent;
	short blessing;

	while ((obj->which_kind = get_rand(0, (ARMORS-1)))==PLATE);
	obj->class = obj->which_kind + 2;
	
	if (obj->which_kind == SPLINT) {
		obj->class--;
	}
	obj->is_cursed = 0;
	obj->is_protected = 0;
	obj->damage_enchantment = 0;

	percent = get_rand(1, 100);
	blessing = get_rand(1, 3);

	if (percent <= 66) {
		obj->damage_enchantment += blessing;
	}
}

get_rand_wand(obj)
object *obj;
{
	obj->which_kind = get_rand(0, (WANDS-1));
	obj->class = get_rand(3, 7);
}

get_food(obj)
object *obj;
{
	obj->which_kind = obj->what_is = FOOD;
}

put_stairs()
{
	short row, col;

	get_rand_row_col(&row, &col, (FLOOR | TUNNEL));
	screen[row][col] = STAIRS;
}

get_weapon_thd(obj)
object *obj;
{
	switch(obj->which_kind) {
	case LONG_BOW:
		break;
	case SHORT_BOW:
		break;
	case ARROW:
		break;
	case SHURIKEN:
		break;
	case MACE:
		break;
	case LONG_SWORD:
		break;
	case TWO_HANDED_SWORD:
		break;
	}
}

get_armor_class(obj)
object *obj;
{
	if (obj) {
		return(obj->class + obj->damage_enchantment);
	}
	return(0);
}

object *get_an_object()
{
	object *obj;
	char *malloc();

	if (!(obj = (object *) malloc(sizeof(object)))) {
		clean_up("Cannot allocate item");
	}
	obj->quantity = 1;
	obj->ichar = 'L';
	obj->picked_up = 0;		/* not picked up yet */
	return(obj);
}

make_party()
{
	object *obj;
	short n;

	party_room = get_rand_room();
	n = fill_room_with_objects(party_room);
	fill_room_with_monsters(party_room, n);
}

show_objects()
{
	object *obj;

	obj = level_objects.next_object;

	while (obj) {
		mvaddch(obj->row, obj->col, get_room_char(obj->what_is));
		obj = obj->next_object;
	}
}

put_amulet()
{
	short row, col;
	object *obj, *get_an_object();

	obj = get_an_object();
	obj->what_is = AMULET;
	put_object_rand_location(obj);
	add_to_pack(obj, &level_objects, 0);
}

put_object_rand_location(obj)
object *obj;
{
	short row, col;

	get_rand_row_col(&row, &col, (FLOOR | TUNNEL));
	add_mask(row, col, obj->what_is);
	obj->row = row;
	obj->col = col;

}
SHAR_EOF
fi
if test -f 'object.h'
then
	echo shar: "will not over-write existing file 'object.h'"
else
cat << \SHAR_EOF > 'object.h'
#define BLANK ((unsigned short) 0)
#define ARMOR ((unsigned short) 01)
#define WEAPON ((unsigned short) 02)
#define SCROLL ((unsigned short) 04)
#define POTION ((unsigned short) 010)
#define GOLD ((unsigned short) 020)
#define FOOD ((unsigned short) 040)
#define WAND ((unsigned short) 0100)
#define STAIRS ((unsigned short) 0200)
#define AMULET ((unsigned short) 0400)
#define MONSTER ((unsigned short) 01000)
#define HORWALL ((unsigned short) 02000)
#define VERTWALL ((unsigned short) 04000)
#define DOOR ((unsigned short) 010000)
#define FLOOR ((unsigned short) 020000)
#define TUNNEL ((unsigned short) 040000)
#define UNUSED ((unsigned short) 0100000)
#define IS_OBJECT ((unsigned short) 0777)  /* all object masks or'd together */
#define CAN_PICK_UP ((unsigned short) 0577)

#define LEATHER 0
#define RING 1
#define SCALE 2
#define CHAIN 3
#define BANDED 4
#define SPLINT 5
#define PLATE 6
#define ARMORS 7

#define ARROW 0
#define BATTLE_AXE 1
#define BARDICHE 2
#define BEC_DE_CORBIN 3
#define BILL_GUISARME 4
#define LONG_BOW 5
#define SHORT_BOW 6
#define FAUCHARD 7
#define FLAIL 8
#define GLAIVE 9
#define GUISARME 10
#define HALBERD 11
#define LUCERN_HAMMER 12
#define HAMMER 13
#define JAVELIN 14
#define MACE 15
#define MORNING_STAR 16
#define PARTISAN 17
#define PIKE 18
#define RANSEUR 19
#define SABRE 20
#define SCIMITAR 21
#define CUTLASS 22
#define SHURIKEN 23
#define SPEAR 24
#define SPETUM 25
#define BASTARD_SWORD 26
#define BROAD_SWORD 27
#define LONG_SWORD 28
#define SHORT_SWORD 29
#define TWO_HANDED_SWORD 30
#define TRIDENT 31
#define VOULGE 32
#define WHIP 33

#define WEAPONS 34

#define MAX_PACK_COUNT 24

#define PROTECT_ARMOR 0
#define HOLD_MONSTER 1
#define ENCHANT_WEAPON 2
#define ENCHANT_ARMOR 3
#define IDENTIFY 4
#define TELEPORT 5
#define SLEEP 6
#define SCARE_MONSTER 7
#define REMOVE_CURSE 8
#define CREATE_MONSTER 9
#define AGGRAVATE_MONSTER 10
#define SCROLLS 11

#define INCREASE_STRENGTH 0
#define RESTORE_STRENGTH 1
#define HEALING 2
#define EXTRA_HEALING 3
#define POISON 4
#define RAISE_LEVEL 5
#define BLINDNESS 6
#define HALLUCINATION 7
#define DETECT_MONSTER 8
#define DETECT_OBJECTS 9
#define CONFUSION 10
#define POTIONS 11

#define TELEPORT_AWAY 0
#define SLOW_MONSTER 1
#define KILL_MONSTER 2
#define INVISIBILITY 3
#define POLYMORPH 4
#define HASTE_MONSTER 5
#define PUT_TO_SLEEP 6
#define DO_NOTHING 7
#define WANDS 8

#define UNIDENTIFIED ((unsigned char) 0)	/* MUST BE ZERO! */
#define IDENTIFIED ((unsigned char) 01)
#define CALLED ((unsigned char) 02)

#define SROWS 24
#define SCOLS 80
#define MAX_TITLE_LENGTH 30
#define MORE "-more-"
#define MAXSYLLABLES 40
#define MAXMETALS 15

#define GOLD_PERCENT 46
#define MAX_EP 10000000

struct identify {
	short value;
	char *title;
	char *real;
	unsigned char id_status;
};

struct object {				/* comment is monster meaning */
	unsigned short m_flags;		/* monster flags */
	char *damage;			/* damage it does */
	short quantity;			/* hit points to kill */
	char ichar;			/* 'A' is for aquatar */
	short kill_exp;			/* exp for killing it */
	char is_protected;		/* level starts */
	char is_cursed;			/* level ends */
	char class;			/* chance of hitting you */
	char identified;		/* F%d/Arwarn/Og/If/Mc/Xc */
	unsigned char which_kind;	/* item carry/drop % */
	char row, col;			/* current row,col */
	char damage_enchantment;	/* fly-trap,medusa,etc */
	char quiver;			/* monster slowed toggle */
	char trow, tcol;		/* target row, col */
	char to_hit_enchantment;
	unsigned short what_is;
	char picked_up;
	struct object *next_object;	/* next monster */
};

typedef struct object object;

struct fighter {
	object *armor;
	object *weapon;
	short hp_current;
	short hp_max;
	char strength_current;
	char strength_max;
	object pack;
	int gold;
	char exp;
	int exp_points;
	short row, col;
	char fchar;
	short moves_left;
};

typedef struct fighter fighter;

struct door {
	char other_room;
	char other_row,
	     other_col;
};

typedef struct door door;

struct room {
	char bottom_row, right_col, left_col, top_row;
	char width, height;
	door doors[4];
	char is_room;
};

typedef struct room room;

extern fighter rogue;
extern room rooms[];
unsigned extern short screen[SROWS][SCOLS];
extern object level_objects;

extern struct identify id_scrolls[];
extern struct identify id_potions[];
extern struct identify id_wands[];
extern struct identify id_weapons[];
extern struct identify id_armors[];

extern object monster_tab[];
extern object level_monsters;
SHAR_EOF
fi
if test -f 'oldxio.c'
then
	echo shar: "will not over-write existing file 'oldxio.c'"
else
cat << \SHAR_EOF > 'oldxio.c'
#include descrip
#include iodef
extern short chan;
char getchartt()
        {
        int status;
        short iosb[4];
        char buf[1];
        status = sys$qiow(0,chan,IO$_READLBLK | IO$M_NOECHO | IO$M_INTERRUPT,
                iosb,0,0,buf,1,32767,0,0,0,0);
        if (status != 1)
                LIB$STOP(status);
        if (iosb[0] != 1)
                LIB$STOP(iosb[0]);
        if (buf[0] == '\r')
                buf[0] = '\n';  /* emulate UNIX */
        return(buf[0]);
        }

/*
 * returns a channel
 */

 ttopen()
        {
        register int status;
        struct dsc$descriptor dev_name;

        dev_name.dsc$w_length = 4;
        dev_name.dsc$a_pointer = "TT:";
        dev_name.dsc$b_class = DSC$K_CLASS_S;
        dev_name.dsc$b_dtype = DSC$K_DTYPE_T;
        status = sys$assign(&dev_name,&chan,0,0,0);
        if (status != 1)
                LIB$STOP(status);
        return;
        }


spawn_command(command)
   char *command;
          {

#include jpidef
#include descrip
#include ssdef
        struct dsc$descriptor descr_command;
               
               /*
                * make the character strings
                */
               
      char the_command[40];

	if((!strcmp("sh",command)) || command[0]=='!' || command[0]=='\0'){
	printf("suspending rogue, type 'logout' to return\n");

        lib$spawn(0,
                  0,
                  0, 
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0,
                  0);
	return;
       }


         sprintf(the_command,"%s",command);
                
               /*
                * Give descriptors the number of printable ascii  
                * characters
                */
                
                 descr_command.dsc$w_length=strlen(the_command);
            
                /*
                 * Give descriptors the addresses of the strings
               	 */
            
                 descr_command.dsc$a_pointer=the_command;
                    
                /*
                 * Define the string descriptor class
                 */
             
                 descr_command.dsc$b_class=DSC$K_CLASS_S;
                    
                /*
                 * Explain that it is an ascii string.
                 */
             
                 descr_command.dsc$b_dtype=DSC$K_DTYPE_T;




        lib$spawn(&descr_command,
                          0,
                          0, 
                          0,
                          0,
                          0,
                          0,
                          0,
                          0,
                          0,
                          0,
                          0);

}

/*
 * this is here because vms curses sucks.
 * the curser was following hidden monsters about.
 */

#include curses
refresh_vms(){
static int old_x,old_y;
static int odd=0;

getyx(stdscr,old_y,old_x);
move(LINES -2,COLS-1);
 if(odd==0){
odd=1;

addch(' ');
 }else{
odd=0;
addch('.');
} 
refresh();
move(old_y,old_x);
}


SHAR_EOF
fi
if test -f 'pack.c'
then
	echo shar: "will not over-write existing file 'pack.c'"
else
cat << \SHAR_EOF > 'pack.c'
#include curses.h
#include "move.h"
#include "object.h"

char *CURSE_MESSAGE = "you can't, it appears to be cursed";
char ichars[26];

extern short has_amulet;

object *add_to_pack(obj, pack, condense)
object *obj, *pack;
{
	object *op, *check_duplicate();

	if (condense) {
		if (op = check_duplicate(obj, pack)) {
			free(obj);
			return(op);
		} else {
			obj->ichar = next_avail_ichar();
		}
	}

	if (pack->next_object == 0) {
		pack->next_object = obj;
	} else {
		op = pack->next_object;

		while (op->next_object) {
			op = op->next_object;
		}
		op->next_object = obj;
	}
	obj->next_object = 0;
	return(obj);
}

remove_from_pack(obj, pack)
object *obj, *pack;
{
	while (pack->next_object != obj) {
		pack = pack->next_object;
	}
	pack->next_object = pack->next_object->next_object;
}

object *pick_up(row, col, status)
short *status;
{
	object *obj, *object_at(), *add_to_pack();

	obj = object_at(&level_objects, row, col);
	*status = 1;

	if ((obj->what_is == SCROLL) && (obj->which_kind == SCARE_MONSTER) &&
	    (obj->picked_up > 0)) {
		message("the scroll turns to dust as you pick it up", 1);
		remove_from_pack(obj, &level_objects);
		remove_mask(row, col, SCROLL);
		free(obj);
		*status = 0;
		if (id_scrolls[SCARE_MONSTER].id_status == UNIDENTIFIED) {
			id_scrolls[SCARE_MONSTER].id_status = IDENTIFIED;
		}
		return(0);
	}
	if (obj->what_is == GOLD) {
		rogue.gold += obj->quantity;
		remove_mask(row, col, GOLD);
		remove_from_pack(obj, &level_objects);
		print_stats();
		return(obj);	/* obj will be free()ed in single_move() */
	}
	if (get_pack_count(obj) >= MAX_PACK_COUNT) {
		message("Pack too full", 1);
		return(0);
	}
	if (obj->what_is == AMULET) {
		has_amulet = 1;
	}

	remove_mask(row, col, obj->what_is);
	remove_from_pack(obj, &level_objects);
	obj = add_to_pack(obj, &rogue.pack, 1);
	obj->picked_up++;
	return(obj);
}

drop()
{
	object *obj, *new;
	object *get_letter_object();
	short ch;
	object *get_an_object();
	char description[SCOLS];

	if (screen[rogue.row][rogue.col] & IS_OBJECT) {
		message("There's already something there", 0);
		return;
	}
	if (!rogue.pack.next_object) {
		message("You have nothing to drop", 0);
		return;
	}
	ch = get_pack_letter("drop what? ", IS_OBJECT);

	if (ch == CANCEL) {
		return;
	}
	if (!(obj = get_letter_object(ch))) {
		message("No such item.", 0);
		return;
	}
	if (obj == rogue.weapon) {
		if (obj->is_cursed) {
			message(CURSE_MESSAGE, 0);
			return;
		}
		rogue.weapon = 0;
	} else if (obj == rogue.armor) {
		if (obj->is_cursed) {
			message(CURSE_MESSAGE, 0);
			return;
		}
		rogue.armor = 0;
		print_stats();
	}
	obj->row = rogue.row;
	obj->col = rogue.col;

	if ((obj->quantity > 1) && (obj->what_is != WEAPON)) {
		obj->quantity--;
		new = get_an_object();
		*new = *obj;
		new->quantity = 1;
		obj = new;
		goto ADD;
	}
	if (obj->what_is == AMULET) {
		has_amulet = 0;
	}
	make_avail_ichar(obj->ichar);
	remove_from_pack(obj, &rogue.pack);
ADD:	add_to_pack(obj, &level_objects, 0);
	add_mask(rogue.row, rogue.col, obj->what_is);
	strcpy(description, "dropped ");
	get_description(obj, description+8);
	message(description, 0);
	register_move();
}

object *check_duplicate(obj, pack)
object *obj, *pack;
{
	object *op;

	if (!(obj->what_is & (WEAPON | FOOD | SCROLL | POTION))) {
		return(0);
	}
	op = pack->next_object;

	while (op) {
		if ((op->what_is == obj->what_is) && 
		    (op->which_kind == obj->which_kind)) {

			if ((obj->what_is != WEAPON) ||
			((obj->what_is == WEAPON) &&
			((obj->which_kind == ARROW) ||
			(obj->which_kind == SHURIKEN)) &&
			(obj->quiver == op->quiver))) {
				op->quantity += obj->quantity;
				return(op);
			}
		}
		op = op->next_object;
	}
	return(0);
}

next_avail_ichar()
{
	short i;

	for (i = 'a'; i < 'z'; i++) {
		if (!ichars[i-'a']) {
			ichars[i-'a'] = 1;
			return(i);
		}
	}
	return(0);
}

make_avail_ichar(ch)
{
	ichars[ch - 'a'] = 0;
}

wait_for_ack(prompt)
{
	char getchartt();
	if (prompt) {
		printf("%s ", MORE);
		fflush(stdout);
	}
	while (getchartt() != ' ') ;
}

get_pack_letter(prompt, mask)
char *prompt;
unsigned short mask;
{
	char getchartt();
	short first_miss = 1;
	short ch;

	message(prompt, 0);
	while (!is_pack_letter(ch = getchartt())) {
		putchar(7);
		fflush(stdout);
		if (first_miss) {
WHICH:			message(prompt, 0);
			first_miss = 0;
		}
	}
	if (ch == LIST) {
		check_message();
		inventory(&rogue.pack, mask);
		goto WHICH;
	}
	check_message();
	return(ch);
}

take_off()
{
	char description[SCOLS];
	object *obj;

	if (rogue.armor) {
		if (rogue.armor->is_cursed) {
			message(CURSE_MESSAGE, 0);
		} else {
			mv_aquatars();
			obj = rogue.armor;
			rogue.armor = 0;
			strcpy(description, "was wearing ");
			get_description(obj, description+12);
			message(description, 0);
			print_stats();
			register_move();
		}
	} else {
		message("not wearing any", 0);
	}
}

wear()
{
	short ch;
	register object *obj;
	char description[SCOLS];
	object *get_letter_object();

	if (rogue.armor) {
		message("you are already wearing some", 0);
		return;
	}
	ch = get_pack_letter("wear what? ", ARMOR);

	if (ch == CANCEL) {
		return;
	}
	if (!(obj = get_letter_object(ch))) {
		message("No such item.", 0);
		return;
	}
	if (obj->what_is != ARMOR) {
		message("You can't wear that", 0);
		return;
	}
	rogue.armor = obj;
	obj->identified = 1;
	get_description(obj, description);
	message(description, 0);
	print_stats();
	register_move();
}

wield()
{
	short ch;
	register object *obj;
	char description[SCOLS];
	object *get_letter_object();

	if (rogue.weapon && rogue.weapon->is_cursed) {
		message(CURSE_MESSAGE, 0);
		return;
	}
	ch = get_pack_letter("wield what? ", WEAPON);

	if (ch == CANCEL) {
		return;
	}
	if (!(obj = get_letter_object(ch))) {
		message("No such item.", 0);
		return;
	}
	if (obj->what_is != WEAPON) {
		message("You can't wield that", 0);
		return;
	}
	if (obj == rogue.weapon) {
		message("in use", 0);
	} else {
		rogue.weapon = obj;
		get_description(obj, description);
		message(description, 0);
		register_move();
	}
}

call_it()
{
	short ch;
	register object *obj;
	struct identify *id_table, *get_id_table();
	char buf[MAX_TITLE_LENGTH+2];
	object *get_letter_object();

	ch = get_pack_letter("call what? ", (SCROLL | POTION | WAND));

	if (ch == CANCEL) {
		return;
	}
	if (!(obj = get_letter_object(ch))) {
		message("No such item.", 0);
		return;
	}
	if (!(obj->what_is & (SCROLL | POTION | WAND))) {
		message("surely you already know what that's called", 0);
		return;
	}
	id_table = get_id_table(obj);

	if (get_input_line(buf, id_table[obj->which_kind].title)) {
		id_table[obj->which_kind].id_status = CALLED;
		strcpy(id_table[obj->which_kind].title, buf);
	}
}

get_pack_count(new_obj)
object *new_obj;
{
	object *obj;
	short count = 0;

	if (!(obj = rogue.pack.next_object)) {
		return(0);
	}
	while (obj) {
		if (obj->what_is != WEAPON) {
			count += obj->quantity;
		} else {
			if ((new_obj->what_is != WEAPON) ||
			    ((obj->which_kind != ARROW) &&
			    (obj->which_kind != SHURIKEN)) ||
			    (new_obj->which_kind != obj->which_kind) ||
			    (obj->quiver != new_obj->quiver)) {
				count++;
			}
		}
		obj = obj->next_object;
	}
	return(count);
}
SHAR_EOF
fi
if test -f 'play.c'
then
	echo shar: "will not over-write existing file 'play.c'"
else
cat << \SHAR_EOF > 'play.c'
#include curses.h
#include setjmp
#include "object.h"
#include "move.h"

short interrupted = 0;
extern short party_room, detect_monster;
extern char hit_message[];
int val;

play_level()
{
	short ch;
 	char getchartt();
	int count = 0;
	char com_string[80];
	char mess[24][82];
	int a,b;
	WINDOW *tempwin;
	int quit();
	
	for (;;) {
		interrupted = 0;
		if (hit_message[0]) {
			message(hit_message);
			hit_message[0] = 0;
		}
		move(rogue.row, rogue.col);
		refresh_vms();
		ch = getchartt();
		check_message();
		count = 0;
CH:
		switch(ch) {
		case '\003':
			quit();
			break;
		case '.':
			rest((count > 0) ? count : 1);
			break;
		case 'i':
			inventory(&rogue.pack, IS_OBJECT);
			break;
		/*case 'p':
			inventory(&level_objects, IS_OBJECT);
			break;*/
		case 'f':
			fight(0);
			break;
		case 'F':
			fight(1);
			break;
		case 'h':
		case 'j':
		case 'k':
		case 'l':
		case 'y':
		case 'u':
		case 'n':
		case 'b':
			single_move_rogue(ch, 1);
			break;
		case 'H':
		case 'J':
		case 'K':
		case 'L':
		case 'B':
		case 'Y':
		case 'U':
		case 'N':
		case '\b':              /* ^H */
		case '\012':		/* ^J */
		case '\013':            /* ^K */
		case '\f':              /* ^L (form feed) */
		case '\031':
		case '\025':
		case '\016':
		case '\002':
			multiple_move_rogue(ch);
			break;
		case 'e':
			eat();
			break;
		case 'q':
			quaff();
			break;
		case 'r':
			read_scroll();
			break;
		case 'm':
			move_onto();
			break;
		case 'd':
			drop();
			break;
		case '\020':
			remessage();
			break;
		case '>':
			if (check_down()) {
				return;
			}
			break;
		case '<':
			if (check_up()) {
				return;
			}
			break;
		case 'I':
			single_inventory();
			break;
		case 'R':  /* again vms curses refuses to redraw the 
				nice way */
			tempwin=newwin(LINES,COLS,0,0);
			overlay(stdscr,tempwin);
			refresh();
			clear();
			overlay(tempwin,stdscr);
			delwin(tempwin);
			refresh();
			break;
		case 'T':
			take_off();
			break;
		case 'W':
		case 'P':
			wear();
			break;
		case 'w':
			wield();
			break;
		case 'c':
			call_it();
			break;
		case 'z':
			zapp();
			break;
		case 't':
			throw();
			break;
		case '\032':             /* ^Z */
			tempwin=newwin(LINES,COLS,0,0);
			overlay(stdscr,tempwin);
			move(1,1);
			refresh();
			com_string[0]='\0';
			spawn_command(com_string);
			clear();
			overlay(tempwin,stdscr);
			delwin(tempwin);
			refresh();
			break;
			/* tstp(); */
		case '!':
			tempwin=newwin(LINES,COLS,0,0);
			overlay(stdscr,tempwin);
			move(1,1);
			refresh();

			spawn_command(gets(com_string));
			clear();
			overlay(tempwin,stdscr);
			delwin(tempwin);
			refresh();
			break;
		case 'v':
			message("ve_rogue: VMS extended rogue , 1.0. ",0);
			break;
		case 'Q':
			quit();
			break;
		case '/':
			message("Identify what: ",1);
			identify_monst(getchartt());
			break;
		case '?':
			message("Help on what character: ",1);
			help(getchartt());
			break;
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
			count = 0;
			do {
				count = (10 * count) + (ch - '0');
				ch = getchartt();
			} while ((ch >= '0') && (ch <= '9'));
			goto CH;
			break;
		case ' ':
			break;
		default:
			message("unknown command");
			break;
		}
	}
}


SHAR_EOF
fi
exit 0
#	End of shell archive
-- 
ihnp4--\                                        
decvax--\	
akgua----\
dcdwest---\
somewhere--\
ucbvax-------- sdcsvax -- rich