Battlestar (Part 4 of 5)

Peter E. Yee yee at ucbvax.ARPA
Thu Jan 24 14:28:10 AEST 1985


This is part 4 of the Battlestar distribution.

#	This is a shell archive.
#	Remove everything above and including the cut line.
#	Then run the rest of the file through sh.
-----cut here-----cut here-----cut here-----cut here-----
#!/bin/sh
# shar:	Shell Archiver
#	Run the following text with /bin/sh to create:
#	battlestar/com1.c
#	battlestar/com2.c
#	battlestar/com3.c
#	battlestar/com4.c
#	battlestar/com5.c
#	battlestar/com6.c
# This archive created: Wed Jan 23 20:07:24 1985
cat << \SHAR_EOF > battlestar/com1.c
#ifndef lint
static char sccsid[] = "@(#)com1.c	1.2 11/28/84";
#endif

#include "externs.h"

move(thataway, token)
int thataway, token;
{
	wordnumber++;
	if ((!notes[CANTMOVE] && !notes[LAUNCHED]) || testbit(location[position].objects, LAND) || fuel > 0 && notes[LAUNCHED])
		if (thataway) {
			position = thataway;
			newway(token);
			time++;
		}
		else {
			puts("You can't go this way.");
			newway(token);
			whichway(location[position]);
			return(0);
		}
	else if (notes[CANTMOVE] && !notes[LAUNCHED])
		puts("You aren't able to move; you better drop something.");
	else
		puts("You are out of fuel; now you will rot in space forever!");
	return(1);
}

convert(tothis)		/* Converts day to night and vice versa. 	    */
int tothis;		/* Day objects are permanent.  Night objects are added*/
{			/* at dusk, and subtracted at dawn.		*/
	register struct objs *p;
	register i, j;

	if (tothis == TONIGHT) {
		for (i = 1; i <= NUMOFROOMS; i++)
			for (j = 0; j < NUMOFWORDS; j++)
				nightfile[i].objects[j] = dayfile[i].objects[j];
		for (p = nightobjs; p->room != 0; p++)
			setbit(nightfile[p->room].objects, p->obj);
		location = nightfile;
	} else {
		for (i = 1; i <= NUMOFROOMS; i++)
			for (j = 0; j < NUMOFWORDS; j++)
				dayfile[i].objects[j] = nightfile[i].objects[j];
		for (p = nightobjs; p->room != 0; p++)
			clearbit(dayfile[p->room].objects, p->obj);
		location = dayfile;
	}
}

news()
{
	register int n;
	int hurt;

	if (time > 30 && position < 32){
		puts("An explosion of shuddering magnitude splinters bulkheads and");
		puts("ruptures the battlestar's hull.  You are sucked out into the");
		puts("frozen void of space and killed.");
		die();
	}
	if (time > 20 && position < 32)
		puts("Explosions rock the battlestar.");
	if (time > snooze){
		puts("You drop from exhaustion...");
		zzz();
	}
	if (time > snooze - 5)
		puts("You're getting tired.");
	if (time > (rythmn + CYCLE)) {
		if (location == nightfile) {
			convert(TODAY);
			if (OUTSIDE && time - rythmn - CYCLE < 10) {
				puts("Dew lit sunbeams stretch out from a watery sunrise and herald the dawn.");
				puts("You awake from a misty dream-world into stark reality.");
				puts("It is day.");
			}
		} else {
			convert(TONIGHT);
			clearbit(location[POOLS].objects, BATHGOD);
			if (OUTSIDE && time - rythmn - CYCLE < 10) {
				puts("The dying sun sinks into the ocean, leaving a blood stained sunset.");
				puts("The sky slowly fades from orange to violet to black.  A few stars");
				puts("flicker on, and it is night.");
				puts("The world seems completly different at night.");
			}
		}
		rythmn = time - time % CYCLE;
	}
	if (!wiz && !tempwiz)
		if ((testbit(inven,TALISMAN) || testbit(wear,TALISMAN)) && (testbit(inven,MEDALION) || testbit(wear,MEDALION)) && (testbit(inven,AMULET) || testbit(wear,AMULET))){
			tempwiz = 1;
			puts("The three amulets glow and reenforce each other in power.\nYou are now a wizard.");
	}
	if (testbit(location[position].objects,ELF)){
		printf("%s\n",objdes[ELF]);
		fight(ELF,rnd(30));
	}
	if (testbit(location[position].objects,DARK)){
		printf("%s\n",objdes[DARK]);
		fight(DARK,100);
	}
	if (testbit(location[position].objects,WOODSMAN)){
		printf("%s\n",objdes[WOODSMAN]);
		fight(WOODSMAN,50);
	}
	switch(position){
		
		case 267:
		case 257:	/* entering a cave */
		case 274:
		case 246:
			notes[CANTSEE] = 1;
			break;
		case 160:
		case 216:	/* leaving a cave */
		case 230:
		case 231:
		case 232:
			notes[CANTSEE] = 0;
			break;
	}
	if (testbit(location[position].objects, GIRL))
		meetgirl = 1;
	if (meetgirl && CYCLE * 1.5 - time < 10){
		setbit(location[GARDEN].objects,GIRLTALK);
		setbit(location[GARDEN].objects,LAMPON);
		setbit(location[GARDEN].objects,ROPE);
	}
	if (position == DOCK && (beenthere[position] || time > CYCLE)){
		clearbit(location[DOCK].objects, GIRL);
		clearbit(location[DOCK].objects,MAN);
	}
	if (meetgirl && time - CYCLE * 1.5 > 10){
		clearbit(location[GARDEN].objects,GIRLTALK);
		clearbit(location[GARDEN].objects,LAMPON);
		clearbit(location[GARDEN].objects,ROPE);
		meetgirl = 0;
	}
	if (testbit(location[position].objects,CYLON)){
		puts("Oh my God, you're being shot at by an alien spacecraft!");
		printf("The targeting computer says we have %d seconds to attack!\n",clock);
		fflush(stdout);
		sleep(1);
		if (!visual()){
			hurt = rnd(NUMOFINJURIES);
			injuries[hurt] = 1;
			puts("Laser blasts sear the cockpit, and the alien veers off in a victory roll.");
			puts("The viper shudders under a terrible explosion.");
			printf("I'm afraid you have suffered %s.\n", ouch[hurt]);
		}
		else
			clearbit(location[position].objects,CYLON);
	}
	if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]){
		puts("I'm afraid you have suffered fatal injuries.");
		die();
	}
	for (n=0; n < NUMOFINJURIES; n++)
		if (injuries[n] == 1){
			injuries[n] = 2;
			if (WEIGHT > 5)
				WEIGHT -= 5;
			else
				WEIGHT = 0;
		}
	if (injuries[ARM] == 2){
		CUMBER -= 5;
		injuries[ARM]++;
	}
	if (injuries[RIBS] == 2){
		CUMBER -= 2;
		injuries[RIBS]++;
	}
	if (injuries[SPINE] == 2){
		WEIGHT = 0;
		injuries[SPINE]++;
	}
	if (carrying > WEIGHT || encumber > CUMBER)
		notes[CANTMOVE] = 1;
	else
		notes[CANTMOVE] = 0;
}

crash()
{
	int hurt1,hurt2;

	fuel--;
	if (!location[position].flyhere || (testbit(location[position].objects,LAND) && fuel <= 0)){
		if (!location[position].flyhere)
			puts("You're flying too low.  We're going to crash!");
		else{ 
			puts("You're out of fuel.  We'll have to crash land!");
			if (!location[position].down){
				puts("Your viper strikes the ground and explodes into firey fragments.");
				puts("Thick black smoke billows up from the wreckage.");
				die();
			}
			position = location[position].down;
		}
		notes[LAUNCHED] = 0;
		setbit(location[position].objects,CRASH);
		time += rnd(CYCLE/4);
		puts("The viper explodes into the ground and you lose consciousness...");
		zzz();
		hurt1 = rnd(NUMOFINJURIES - 2) + 2;
		hurt2 = rnd(NUMOFINJURIES - 2) + 2;
		injuries[hurt1] = 1;
		injuries[hurt2] = 1;
		injuries[0] = 1;	/* abrasions */
		injuries[1] = 1;	/* lacerations */
		printf("I'm afraid you have suffered %s and %s.\n",ouch[hurt1],ouch[hurt2]);
	}
}
SHAR_EOF
if test 6171 -ne "`wc -c battlestar/com1.c`"
then
echo shar: error transmitting battlestar/com1.c '(should have been 6171 characters)'
fi
cat << \SHAR_EOF > battlestar/com2.c
#ifndef lint
static char sccsid[] = "@(#)com2.c	1.2 11/28/84";
#endif

#include "externs.h"

wearit()		/* synonyms = {sheathe, sheath} */
{
	register int n;
	int firstnumber, value;

	firstnumber = wordnumber;
	while(wordtype[++wordnumber] == ADJS);
	while(wordnumber <= wordcount){
		value = wordvalue[wordnumber];
		for (n=0; objsht[value][n]; n++);
		switch(value){
			
			case -1:
				puts("Wear what?");
				return(firstnumber);

			default:
				printf("You can't wear%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
				return(firstnumber);

			case KNIFE:
		/*	case SHIRT:	*/
			case ROBE:
			case LEVIS:	/* wearable things */
			case SWORD:
			case MAIL:
			case HELM:
			case SHOES:
			case PAJAMAS:
			case COMPASS:
			case LASER:
			case AMULET:
			case TALISMAN:
			case MEDALION:
			case ROPE:
			case RING:
			case BRACELET:
			case GRENADE:

				if (testbit(inven,value)){
					clearbit(inven,value);
					setbit(wear,value);
					carrying -= objwt[value];
					encumber -= objcumber[value];
					time++;
					printf("You are now wearing %s %s.\n",(objsht[value][n-1] == 's' ? "the" : "a"), objsht[value]);
				}
				else if (testbit(wear,value))
					printf("You are already wearing the %s.\n", objsht[value]);
				else 
					printf("You aren't holding the %s.\n", objsht[value]);
				if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
					wordnumber++;
				else 
					return(firstnumber);
		} /* end switch */
	} /* end while */
	puts("Don't be ridiculous.");
	return(firstnumber);
}

put()		/* synonyms = {buckle, strap, tie} */
{
	if (wordvalue[wordnumber + 1] == ON){
		wordvalue[++wordnumber] = PUTON;
		return(cypher());
	}
	if (wordvalue[wordnumber + 1] == DOWN){
		wordvalue[++wordnumber] = DROP;
		return(cypher());
	}
	puts("I don't understand what you want to put.");
	return(-1);

}

draw() 			/* synonyms = {pull, carry} */
{
	return(take(wear));
}

use()
{
	while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount);
	if (wordvalue[wordnumber] == AMULET && testbit(inven,AMULET) && position != FINAL){
		puts("The amulet begins to glow.");
		if (testbit(inven,MEDALION)){
			puts("The medallion comes to life too.");
			if (position == 114){
				location[position].down = 160;
				whichway(location[position]);
				puts("The waves subside and it is possible to descend to the sea cave now.");
				time++;
				return(-1);
			}
		}
		puts("A light mist falls over your eyes and the sound of purling water trickles in");
		puts("your ears.   When the mist lifts you are standing beside a cool stream.");
		if (position == 229)
			position = 224;
		else
			position = 229;
		time++;
		return(0);
	}
	else if (position == FINAL)
		puts("The amulet won't work in here.");
	else if (wordvalue[wordnumber] == COMPASS && testbit(inven,COMPASS))
		printf("Your compass points %s.\n",truedirec(NORTH,'-'));
	else if (wordvalue[wordnumber] == COMPASS)
		puts("You aren't holding the compass.");
	else if (wordvalue[wordnumber] == AMULET)
		puts("You aren't holding the amulet.");
	else
		puts("There is no apparent use.");
	return(-1);
}

murder()
{
	register int n;

	for (n=0; !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE || n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL || n == HALBERD) && testbit(inven,n)) && n < NUMOFOBJECTS; n++);
	if (n == NUMOFOBJECTS)
		puts("You don't have suitable weapons to kill.");
	else {
		printf("Your %s should do the trick.\n",objsht[n]);
		while (wordtype[++wordnumber] == ADJS);
		switch(wordvalue[wordnumber]){
			
			case NORMGOD:
				if (testbit(location[position].objects,BATHGOD)){
					puts("The goddess's head slices off.  Her corpse floats in the water.");
					clearbit(location[position].objects,BATHGOD);
					setbit(location[position].objects,DEADGOD);
					power += 5;
					notes[JINXED]++;
				} else if (testbit(location[position].objects,NORMGOD)){
					puts("The goddess pleads but you strike her mercilessly.  Her broken body lies in a\npool of blood.");
					clearbit(location[position].objects,NORMGOD);
					setbit(location[position].objects,DEADGOD);
					power += 5;
					notes[JINXED]++;
					if (wintime)
						live();
				} else puts("I dont see her anywhere.");
				break;
			case TIMER:
				if (testbit(location[position].objects,TIMER)){
					puts("The old man offers no resistance.");
					clearbit(location[position].objects,TIMER);
					setbit(location[position].objects,DEADTIME);
					power++;
					notes[JINXED]++;
				} else puts("Who?");
				break;
			case NATIVE:
				if (testbit(location[position].objects,NATIVE)){
					puts("The girl screams as you cut her body to shreds.  She is dead.");
					clearbit(location[position].objects,NATIVE);
					setbit(location[position].objects,DEADNATIVE);
					power += 5;
					notes[JINXED]++;
				} else puts("What girl?");
				break;
			case MAN:
				if (testbit(location[position].objects,MAN)){
					puts("You strike him to the ground, and he coughs up blood.");
					puts("Your fantasy is over.");
					die();
				}
			case -1:
				puts("Kill what?");
				break;

			default:
				if (wordtype[wordnumber] != NOUNS)
					puts("Kill what?");
				else
					printf("You can't kill the %s!\n",objsht[wordvalue[wordnumber]]);
		}
	}
}

ravage()
{
	while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
	if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
		time++;
		switch(wordvalue[wordnumber]){
			case NORMGOD:
				puts("You attack the goddess, and she screams as you beat her.  She falls down");
				puts("crying and tries to hold her torn and bloodied dress around her.");
				power += 5;
				pleasure += 8;
				ego -= 10;
				wordnumber--;
				godready = -30000;
				murder();
				win = -30000;
				break;
			case NATIVE:
				puts("The girl tries to run, but you catch her and throw her down.  Her face is");
				puts("bleeding, and she screams as you tear off her clothes.");
				power += 3;
				pleasure += 5;
				ego -= 10;
				wordnumber--;
				murder();
				if (rnd(100) < 50){
					puts("Her screams have attracted attention.  I think we are surrounded.");
					setbit(location[ahead].objects,WOODSMAN);
					setbit(location[ahead].objects,DEADWOOD);
					setbit(location[ahead].objects,MALLET);
					setbit(location[back].objects,WOODSMAN);
					setbit(location[back].objects,DEADWOOD);
					setbit(location[back].objects,MALLET);
					setbit(location[left].objects,WOODSMAN);
					setbit(location[left].objects,DEADWOOD);
					setbit(location[left].objects,MALLET);
					setbit(location[right].objects,WOODSMAN);
					setbit(location[right].objects,DEADWOOD);
					setbit(location[right].objects,MALLET);
				}
				break;
			default:
				puts("You are perverted.");
		}
	}
	else
		puts("Who?");
}

follow()
{
	if (followfight == time){
		puts("The Dark Lord leaps away and runs down secret tunnels and corridoors.");
		puts("You chase him through the darkness and splash in pools of water.");
		puts("You have cornered him.  His laser sword extends as he steps forward.");
		position = FINAL;
		fight(DARK,75);
		setbit(location[position].objects,TALISMAN);
		setbit(location[position].objects,AMULET);
		return(0);
	}
	else if (followgod == time){
		puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
		puts("She sits down on a throne.");
		position = 268;
		setbit(location[position].objects,NORMGOD);
		notes[CANTSEE] = 1;
		return(0);
	}
	else 
		puts("There is no one to follow.");
	return(-1);
}
SHAR_EOF
if test 7508 -ne "`wc -c battlestar/com2.c`"
then
echo shar: error transmitting battlestar/com2.c '(should have been 7508 characters)'
fi
cat << \SHAR_EOF > battlestar/com3.c
#ifndef lint
static char sccsid[] = "@(#)com3.c	1.1 11/18/84";
#endif

#include "externs.h"

dig()
{
	if (testbit(inven,SHOVEL)){
		puts("OK");
		time++;
		switch(position){
			case 144:		/* copse near beach */
				if (!notes[DUG]){
					setbit(location[position].objects,DEADWOOD);
					setbit(location[position].objects,COMPASS);
					setbit(location[position].objects,KNIFE);
					setbit(location[position].objects,MACE);
					notes[DUG] = 1;
				}
				break;

			default:
				puts("Nothing happens.");
		}
	}
	else	
		puts("You don't have a shovel.");
}

jump()
{
	register int n;

	switch(position){
		default:
			puts("Nothing happens.");
			return(-1);

		case 242:
			position = 133;
			break;
		case 214:
		case 215:
		case 162:
		case 159:
			position = 145;
			break;
		case 232:
			position = 275;
			break;
		case 3:
			position = 1;
			break;
		case 172:
			position = 201;
	}
	puts("Ahhhhhhh...");
	injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1;
	for (n=0; n < NUMOFOBJECTS; n++)
		if (testbit(inven,n)){
			clearbit(inven,n);
			setbit(location[position].objects,n);
		}
	carrying = 0;
	encumber = 0;
	return(0);
}

bury()
{
	int value;

	if (testbit(inven,SHOVEL)){
		while(wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount);
		value = wordvalue[wordnumber];
		if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects,value) || value == BODY))
			switch(value){
				case BODY:
					wordtype[wordnumber] = OBJECT;
					if (testbit(inven,MAID) || testbit(location[position].objects,MAID))
						value = MAID;
					if (testbit(inven,DEADWOOD) || testbit(location[position].objects,DEADWOOD))
						value = DEADWOOD;
					if (testbit(inven,DEADGOD) || testbit(location[position].objects,DEADGOD))
						value = DEADGOD;
					if (testbit(inven,DEADTIME) || testbit(location[position].objects,DEADTIME))
						value = DEADTIME;
					if (testbit(inven,DEADNATIVE) || testbit(location[position].objects,DEADNATIVE))
						value = DEADNATIVE;
					break;

				case NATIVE:
				case NORMGOD:
					puts("She screams as you wrestle her into the hole.");
				case TIMER:
					power += 7;
					ego -= 10;
				case AMULET:
				case MEDALION:
				case TALISMAN:
					wordtype[wordnumber] = OBJECT;
					break;

				default:
					puts("Wha..?");
			}
		if (wordtype[wordnumber] == OBJECT && position > 88 && (testbit(inven,value) || testbit(location[position].objects,value))){
			puts("Buried.");
			if (testbit(inven,value)){
				clearbit(inven,value);
				carrying -= objwt[value];
				encumber -= objcumber[value];
			}
			clearbit(location[position].objects,value);
			switch(value){
				case MAID:
				case DEADWOOD:
				case DEADNATIVE:
				case DEADTIME:
				case DEADGOD:
					ego += 2;
					printf("The %s should rest easier now.\n",objsht[value]);
			}
		}
		else
			puts("It doesn't seem to work.");
	}
	else
		puts("You aren't holding a shovel.");
}

drink()
{
	register int n;

	if (testbit(inven,POTION)){
		puts("The cool liquid runs down your throat but turns to fire and you choke.");
		puts("The heat reaches your limbs and tingles your spirit.  You feel like falling");
		puts("asleep.");
		clearbit(inven, POTION);
		WEIGHT = MAXWEIGHT;
		CUMBER = MAXCUMBER;
		for (n=0; n < NUMOFINJURIES; n++)
			injuries[n] = 0;
		time++;
		zzz();
	}
	else
		puts("I'm not thirsty.");
}

shoot()
{
	int firstnumber, value;
	register int n;

	if (!testbit(inven,LASER))
		puts("You aren't holding a blaster.");
	else {
		firstnumber = wordnumber;
		while(wordtype[++wordnumber] == ADJS);
		while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
			value = wordvalue[wordnumber];
			printf("%s:\n", objsht[value]);
			for (n=0; objsht[value][n]; n++);
			if (testbit(location[position].objects,value)){
				clearbit(location[position].objects,value);
				time++;
				printf("The %s explode%s\n",objsht[value],(objsht[value][n-1]=='s' ? (objsht[value][n-2]=='s' ? "s." : ".") : "s."));
				if (value == BOMB)
					die();
			}
			else
				printf("I dont see any %s around here.\n", objsht[value]);
			if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
				wordnumber++;
			else
				return(firstnumber);
		}
			    /* special cases with their own return()'s */

		if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS){
			time++;
			switch(wordvalue[wordnumber]){
			
				case DOOR:
					switch(position){
						case 189:
						case 231:
							puts("The door is unhinged.");
							location[189].north = 231;
							location[231].south = 189;
							whichway(location[position]);
							break;
						case 30:
							puts("The wooden door splinters.");
							location[30].west = 25;
							whichway(location[position]);
							break;
						case 31:
							puts("The laser blast has no effect on the door.");
							break;
						case 20:
							puts("The blast hits the door and it explodes into flame.  The magnesium burns");
							puts("so rapidly that we have no chance to escape.");
							die();
						default:
							puts("Nothing happens.");
					}
					break;

				case NORMGOD:
					if (testbit(location[position].objects,BATHGOD)){
						puts("The goddess is hit in the chest and splashes back against the rocks.");
						puts("Dark blood oozes from the charred blast hole.  Her naked body floats in the");
						puts("pools and then off downstream.");
						clearbit(location[position].objects,BATHGOD);
						setbit(location[180].objects,DEADGOD);
						power += 5;
						ego -= 10;
						notes[JINXED]++;
					} else if (testbit(location[position].objects,NORMGOD)){
						puts("The blast catches the goddess in the stomach, knocking her to the ground.");
						puts("She writhes in the dirt as the agony of death taunts her.");
						puts("She has stopped moving.");
						clearbit(location[position].objects,NORMGOD);
						setbit(location[position].objects,DEADGOD);
						power += 5;
						ego -= 10;
						notes[JINXED]++;
						if (wintime)
							live();
						break;
					} else
						puts("I don't see any goddess around here.");
					break;

				case TIMER:
					if (testbit(location[position].objects,TIMER)){
						puts("The old man slumps over the bar.");
						power++;
						ego -= 2;
						notes[JINXED]++;
						clearbit(location[position].objects,TIMER);
						setbit(location[position].objects,DEADTIME);
					}
					else puts("What old timer?");
					break;
				case MAN:
					if (testbit(location[position].objects,MAN)){
						puts("The man falls to the ground with blood pouring all over his white suit.");
						puts("Your fantasy is over.");
						die();
					}
					else puts("What man?");
					break;
				case NATIVE:
					if (testbit(location[position].objects,NATIVE)){
						puts("The girl is blown backwards several feet and lies in a pool of blood.");
						clearbit(location[position].objects,NATIVE);
						setbit(location[position].objects,DEADNATIVE);
						power += 5;
						ego -= 2;
						notes[JINXED]++;
					} else puts("There is no girl here.");
					break;
				case -1:
					puts("Shoot what?");
					break;

				default:
					printf("You can't shoot the %s.\n",objsht[wordvalue[wordnumber]]);
			}
		}
		else puts("You must be a looney.");
	}
	return(firstnumber);
}
SHAR_EOF
if test 7231 -ne "`wc -c battlestar/com3.c`"
then
echo shar: error transmitting battlestar/com3.c '(should have been 7231 characters)'
fi
cat << \SHAR_EOF > battlestar/com4.c
#ifndef lint
static char sccsid[] = "@(#)com4.c	1.2 11/28/84";
#endif

#include "externs.h"

take(from)
unsigned int from[];
{
	int firstnumber, heavy, bulky, value;
	register int n;

	firstnumber = wordnumber;
	if (wordnumber < wordcount && wordvalue[wordnumber+1] == OFF){
		wordnumber++;
		wordvalue[wordnumber] = TAKEOFF;
		return(cypher());
	}
	else {
		while(wordtype[++wordnumber] == ADJS);
		while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
			value = wordvalue[wordnumber];
			printf("%s:\n", objsht[value]);
			for (n=0; objsht[value][n]; n++);
			heavy = (carrying + objwt[value]) <= WEIGHT;
			bulky = (encumber + objcumber[value]) <= CUMBER;
			if ((testbit(from,value) || wiz || tempwiz) && heavy && bulky && !testbit(inven,value)){
				setbit(inven,value);
				carrying += objwt[value];
				encumber += objcumber[value];
				time++;
				if (testbit(from,value))
					printf("Taken.\n");
				else
					printf("Zap! Taken from thin air.\n");
				clearbit(from,value);
				if (value == MEDALION)
					win--;
			}
			else if (testbit(inven,value))
				printf("You're already holding%s%s.\n", (objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
			else if (!heavy)
				printf("The %s %s too heavy.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is"));
			else if (!bulky)
				printf("The %s %s too cumbersome to hold.\n", objsht[value],(objsht[value][n-1] == 's' ? "are" : "is"));
			else
				printf("I dont see any %s around here.\n", objsht[value]);
			if (wordnumber < wordcount -1 && wordvalue[++wordnumber] == AND)
				wordnumber++;
			else
				return(firstnumber);
		}
	}
			    /* special cases with their own return()'s */

	if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS)
		switch(wordvalue[wordnumber]){
			
			case SWORD:
				if (testbit(from, SWORD)){
					wordtype[wordnumber--] = OBJECT;
					return(take(from));
				}
				if (testbit(from, TWO_HANDED)){
					wordvalue[wordnumber] = TWO_HANDED;
					wordtype[wordnumber--] = OBJECT;
					return(take(from));
				}
				wordvalue[wordnumber] = BROAD;
				wordtype[wordnumber--] = OBJECT;
				return(take(from));

			case BODY:
				if (testbit(from,MAID)){
					wordvalue[wordnumber] = MAID;
					wordtype[wordnumber--] = OBJECT;
					return(take(from));
				}
				else if (testbit(from,DEADWOOD)){
					wordvalue[wordnumber] = DEADWOOD;
					wordtype[wordnumber--] = OBJECT;
					return(take(from));
				}
				else if (testbit(from,DEADNATIVE)){
					wordvalue[wordnumber] = DEADNATIVE;
					wordtype[wordnumber--] = OBJECT;
					return(take(from));
				}
				else if (testbit(from,DEADGOD)){
					wordvalue[wordnumber] = DEADGOD;
					wordtype[wordnumber--] = OBJECT;
					return(take(from));
				}
				else {
					wordvalue[wordnumber] = DEADTIME;
					wordtype[wordnumber--] = OBJECT;
					return(take(from));
				}
				break;

			case AMULET:
				if (testbit(location[position].objects,AMULET)){
					puts("The amulet is warm to the touch, and its beauty catches your breath.");
					puts("A mist falls over your eyes, but then it is gone.  Sounds seem clearer");
					puts("and sharper but far away as if in a dream.  The sound of purling water reaches");
					puts("you from afar.  The mist falls again, and your heart leaps in horror.  The gold");
					puts("freezes your hands and fathomless darkness engulfs your soul.");
				}
				wordtype[wordnumber--] = OBJECT;
				return(take(from));

			case MEDALION:
				if (testbit(location[position].objects, MEDALION)){
					puts("The medallion is warm, and it rekindles your spirit with the warmth of life.");
					puts("Your amulet begins to glow as the medallion is brought near to it, and together\nthey radiate.");
				}
				wordtype[wordnumber--] = OBJECT;
				return(take(from));

			case TALISMAN:
				if (testbit(location[position].objects,TALISMAN)){
					puts("The talisman is cold to the touch, and it sends a chill down your spine.");
				}
				wordtype[wordnumber--] = OBJECT;
				return(take(from));

			case NORMGOD:
				if (testbit(location[position].objects,BATHGOD) && (testbit(wear,AMULET) || testbit(inven,AMULET))){
					puts("She offers a delicate hand, and you help her out of the sparkling springs.");
					puts("Water droplets like liquid silver bedew her golden skin, but when they part");
					puts("from her, they fall as teardrops.  She wraps a single cloth around her and");
					puts("ties it at the waist.  Around her neck hangs a golden amulet.");
					puts("She bids you to follow her.");
					pleasure++;
					followgod = time;
					clearbit(location[position].objects,BATHGOD);
				} else if (!testbit(location[position].objects,BATHGOD))
					puts("You're in no position to take her.");
				else 
					puts("She moves away from you.");
				break;

			default:
				puts("It doesn't seem to work.");
		}
	else
		puts("You've got to be kidding.");
	return(firstnumber);
}

throw(name)
	char *name;
{
	int n;
	int deposit = 0;
	int first, value;

	first = wordnumber;
	if (drop(name) != -1){
		switch(wordvalue[wordnumber]){
			
			case AHEAD:
				deposit = ahead;
				break;

			case BACK:
				deposit = back;
				break;

			case LEFT:
				deposit = left;
				break;

			case RIGHT:
				deposit = right;
				break;

			case UP:
				deposit = location[position].up * (location[position].access || position == FINAL);
				break;

			case DOWN:
				deposit = location[position].down;
				break;
		}
		wordnumber = first;
		while (wordtype[++wordnumber] == ADJS);
		while (wordnumber <= wordcount){
			value = wordvalue[wordnumber];
			if (deposit && testbit(location[position].objects,value)){
				clearbit(location[position].objects,value);
				if (value != GRENADE)
					setbit(location[deposit].objects,value);
				else{
					puts("A thundering explosion nearby sends up a cloud of smoke and shrapnel.");
					for (n = 0; n < NUMOFWORDS; n ++)
						location[deposit].objects[n] = 0;
					setbit(location[deposit].objects,CHAR);
				}
				if (value == ROPE && position == FINAL)
					location[position].access = 1;
				switch(deposit){
					case 189:
					case 231:
						puts("The stone door is unhinged.");
						location[189].north = 231;
						location[231].south = 189;
						break;
					case 30:
						puts("The wooden door is blown open.");
						location[30].west = 25;
						break;
					case 31:
						puts("The door is not damaged.");
				}
			}
			else if (value == GRENADE && testbit(location[position].objects,value)){
				puts("You are blown into shreds when your grenade explodes.");
				die();
			}
			if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
				wordnumber++;
			else 
				return(first);
		}
		return(first);
	}
	return(first);
}

drop(name)
char *name;
{
	
	int firstnumber, value;

	firstnumber = wordnumber;
	while (wordtype[++wordnumber] == ADJS)
		;
	while (wordnumber<=wordcount && (wordtype[wordnumber] == OBJECT || wordtype[wordnumber] == NOUNS)) {
		value = wordvalue[wordnumber];
		printf("%s:\n", objsht[value]);
		if (testbit(inven,value)){
			clearbit(inven,value);
			carrying -= objwt[value];
			encumber -= objcumber[value];
			if (value == BOMB){
				puts("The bomb explodes.  A blinding white light and immense concussion obliterate us.");
				die();
			}
			if (value != AMULET && value != MEDALION && value != TALISMAN)
				setbit(location[position].objects,value);
			else
				tempwiz = 0;
			time++;
			if (*name == 'K')
				puts("Drop kicked.");
			else
				printf("%s.\n", name);
		}
		else {
			if (*name != 'K') {
				printf("You aren't holding the %s.\n", objsht[value]);
				if (testbit(location[position].objects,value)) {
					if (*name == 'T')
						puts("Kicked instead.");
					else if (*name == 'G')
						puts("Given anyway.");
				}
			} else
				puts("Kicked.");
		}
		if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
			wordnumber++;
		else
			return(firstnumber);
	}
	puts("Do what?");
	return(-1);
}

takeoff()
{
	wordnumber = take(wear);
	return(drop("Dropped"));
}

puton()
{
	wordnumber = take(location[position].objects);
	return(wearit());
}

eat()
{
	register int n;
	int firstnumber, value;

	firstnumber = wordnumber;
	while(wordtype[++wordnumber] == ADJS);
	while(wordnumber <= wordcount){
		value = wordvalue[wordnumber];
		for (n=0; objsht[value][n]; n++);
		switch(value){
			
			case -1:
				puts("Eat what?");
				return(firstnumber);

			default:
				printf("You can't eat%s%s!\n",(objsht[value][n-1] == 's' ? " " : " a "),objsht[value]);
				return(firstnumber);

			case PAPAYAS:
			case PINEAPPLE:
			case KIWI:
			case COCONUTS:	/* eatable things */
			case MANGO:

				printf("%s:\n",objsht[value]);
				if (testbit(inven,value) && time > ate - CYCLE && testbit(inven,KNIFE)){
					clearbit(inven,value);
					carrying -= objwt[value];
					encumber -= objcumber[value];
					ate = max(time,ate) + CYCLE/3;
					snooze += CYCLE/10;
					time++;
					puts("Eaten.  You can explore a little longer now.");
				}
				else if (time < ate - CYCLE)
					puts("You're stuffed.");
				else if (!testbit(inven,KNIFE))
					puts("You need a knife.");
				else
					printf("You aren't holding the %s.\n", objsht[value]);
				if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
					wordnumber++;
				else 
					return(firstnumber);
		} /* end switch */
	} /* end while */
	return(firstnumber);
}
SHAR_EOF
if test 9323 -ne "`wc -c battlestar/com4.c`"
then
echo shar: error transmitting battlestar/com4.c '(should have been 9323 characters)'
fi
cat << \SHAR_EOF > battlestar/com5.c
#ifndef lint
static char sccsid[] = "@(#)com5.c	1.2 11/28/84";
#endif

#include "externs.h"

kiss()
{
	while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
	if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
		pleasure++;
		printf("Kissed.\n");
		switch (wordvalue[wordnumber]){
			case NORMGOD:
			switch(godready++){
				case 0:
					puts("She squirms and avoids your advances.");
					break;
				case 1:
					puts("She is coming around; she didn't fight it as much.");
					break;
				case 2:
					puts("She's begining to like it.");
					break;
				default:
					puts("She's gone limp.");
					
			}
			break;
			case NATIVE:
				puts("The lips are warm and her body robust.  She pulls you down to the ground.");
				break;
			case TIMER:
				puts("The old man blushes.");
				break;
			case MAN:
				puts("The dwarf punches you in the kneecap.");
				break;
			default:
				pleasure--;
		}
	}
	else	puts("I'd prefer not to.");
}

love()
{
	register int n;

	while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
	if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects,wordvalue[wordnumber])){
		if (wordvalue[wordnumber] == NORMGOD && !loved)
			if (godready >= 2){
				puts("She cuddles up to you, and her mouth starts to work:\n'That was my sister's amulet.  The lovely goddess, Purl, was she.  The Empire\ncaptured her just after the Darkness came.  My other sister, Vert, was killed\nby the Dark Lord himself.  He took her amulet and warped its power.\nYour quest was foretold by my father before he died, but to get the Dark Lord's\namulet you must use cunning and skill.  I will leave you my amulet.");
				puts("which you may use as you wish.  As for me, I am the last goddess of the\nwaters.  My father was the Island King, and the rule is rightfully mine.'\n\nShe pulls the throne out into a large bed.");
				power++;
				pleasure += 15;
				ego++;
				if (card(injuries, NUMOFINJURIES)){
					puts("Her kisses revive you; your wounds are healed.\n");
					for (n=0; n < NUMOFINJURIES; n++)
						injuries[n] = 0;
					WEIGHT = MAXWEIGHT;
					CUMBER = MAXCUMBER;
				}
				printf("Goddess:\n");
				if (!loved)
					setbit(location[position].objects,MEDALION);
				loved = 1;
				time += 10;
				zzz();
			}
			else {
				puts("You wish!");
				return;
			}
		if (wordvalue[wordnumber] == NATIVE){
			puts("The girl is easy prey.  She peals off her sarong and indulges you.");
			power++;
			pleasure += 5;
			printf("Girl:\n");
			time += 10;
			zzz();
		}
		printf("Loved.\n");
	}
	else puts("I't doesn't seem to work.");
}

zzz()
{
	int oldtime;
	register int n;

	oldtime = time;
	if ((snooze - time) < (0.75 * CYCLE)){
		time += 0.75 * CYCLE - (snooze - time);
		printf("<zzz>");
		for (n = 0; n < time - oldtime; n++)
			printf(".");
		printf("\n");
		snooze += 3 * (time - oldtime);
		if (notes[LAUNCHED]){
			fuel -= (time - oldtime);
			if (location[position].down){
				position = location[position].down;
				crash();
			}
			else
				notes[LAUNCHED] = 0;
		}
		if (OUTSIDE && rnd(100) < 50){
			puts("You are awakened abruptly by the sound of someone nearby.");
			switch(rnd(4)){
				case 0:
					if (ucard(inven)){
						n = rnd(NUMOFOBJECTS);
						while(!testbit(inven,n))
							n = rnd(NUMOFOBJECTS);
						clearbit(inven,n);
						if (n != AMULET && n != MEDALION && n != TALISMAN)
							setbit(location[position].objects,n);
						carrying -= objwt[n];
						encumber -= objcumber[n];
					}
					puts("A fiendish little Elf is stealing your treasures!");
					fight(ELF,10);
					break;
				case 1:
					setbit(location[position].objects,DEADWOOD);
					break;
				case 2:
					setbit(location[position].objects,HALBERD);
					break;
				default:
					break;
			}
		}
	}
	else
		return(0);
	return(1);
}

chime()
{
	if ((time / CYCLE + 1) % 2 && OUTSIDE)
		switch((time % CYCLE)/(CYCLE / 7)){
			case 0:
				puts("It is just after sunrise.");
				break;
			case 1:
				puts("It is early morning.");
				break;
			case 2:
				puts("It is late morning.");
				break;
			case 3:
				puts("It is near noon.");
				break;
			case 4:
				puts("It is early afternoon.");
				break;
			case 5:
				puts("It is late afternoon.");
				break;
			case 6:
				puts("It is near sunset.");
				break;
		}
	else if (OUTSIDE)
		switch((time % CYCLE)/(CYCLE / 7)){
			case 0:
				puts("It is just after sunset.");
				break;
			case 1:
				puts("It is early evening.");
				break;
			case 2:
				puts("The evening is getting old.");
				break;
			case 3:
				puts("It is near midnight.");
				break;
			case 4:
				puts("These are the wee hours of the morning.");
				break;
			case 5:
				puts("The night is waning.");
				break;
			case 6:
				puts("It is almost morning.");
				break;
		}
	else
		puts("I can't tell the time in here.");
}

give()
{
	int obj = -1, result = -1, person = 0, firstnumber, last1, last2;

	firstnumber = wordnumber;
	while (wordtype[++wordnumber] != OBJECT  && wordvalue[wordnumber] != AMULET && wordvalue[wordnumber] != MEDALION && wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount);
	if (wordnumber <= wordcount){
		obj = wordvalue[wordnumber];
		if (obj == EVERYTHING)
			wordtype[wordnumber] = -1;
		last1 = wordnumber;
	}
	wordnumber = firstnumber;
	while ((wordtype[++wordnumber] != NOUNS || wordvalue[wordnumber] == obj) && wordnumber <= wordcount);
	if (wordtype[wordnumber] == NOUNS){
		person = wordvalue[wordnumber];
		last2 = wordnumber;
	}
	wordnumber = last1 - 1;
	if (person && testbit(location[position].objects,person))
		if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET))
			puts("The goddess won't look at you.");
		else
			result = drop("Given");
	else {
		puts("I don't think that is possible.");
		return(0);
	}
	if (result != -1 && (testbit(location[position].objects,obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)){
		clearbit(location[position].objects,obj);
		time++;
		ego++;
		switch(person){
			case NATIVE:
				puts("She accepts it shyly.");
				ego += 2;
				break;
			case NORMGOD:
				if (obj == RING || obj == BRACELET){
					puts("She takes the charm and puts it on.  A little kiss on the cheek is");
					puts("your reward.");
					ego += 5;
					godready += 3;
				}
				if (obj == AMULET || obj == MEDALION || obj == TALISMAN){
					win++;
					ego += 5;
					power -= 5;
					if (win >= 3){
						puts("The powers of the earth are now legitimate.  You have destroyed the Darkness");
						puts("and restored the goddess to her thrown.  The entire island celebrates with");
						puts("dancing and spring feasts.  As a measure of her gratitude, the goddess weds you");
						puts("in the late summer and crowns you Prince Liverwort, Lord of Fungus.");
						puts("\nBut, as the year wears on and autumn comes along, you become restless and");
						puts("yearn for adventure.  The goddess, too, realizes that the marriage can't last.");
						puts("She becomes bored and takes several more natives as husbands.  One evening,");
						puts("after having been out drinking with the girls, she kicks the throne particulary");
						puts("hard and wakes you up.  (If you want to win this game, you're going to have to\nshoot her!)");
						clearbit(location[position].objects,MEDALION);
						wintime = time;
					}
				}
				break;
			case TIMER:
				if (obj == COINS){
					puts("He fingers the coins for a moment and then looks up agape.  `Kind you are and");
					puts("I mean to repay you as best I can.'  Grabbing a pencil and cocktail napkin...\n");
					printf(  "+-----------------------------------------------------------------------------+\n");
					printf(  "|				   xxxxxxxx\\				      |\n");
					printf(  "|				       xxxxx\\	CLIFFS			      |\n");
					printf(  "|		FOREST			  xxx\\				      |\n");
					printf(  "|				\\\\	     x\\        	OCEAN		      |\n");
					printf(  "|				||	       x\\			      |\n");
					printf(  "|				||  ROAD	x\\			      |\n");
					printf(  "|				||		x\\			      |\n");
					printf(  "|		SECRET		||	  .........			      |\n");
					printf(  "|		 - + -		||	   ........			      |\n");
					printf(  "|		ENTRANCE	||		...      BEACH		      |\n");
					printf(  "|				||		...		  E	      |\n");
					printf(  "|				||		...		  |	      |\n");
					printf(  "|				//		...	    N <-- + --- S     |\n");
					printf(  "|		PALM GROVE     //		...		  |	      |\n");
					printf(  "|			      //		...		  W	      |\n");
					printf(  "+-----------------------------------------------------------------------------+\n");
					puts("\n`This map shows a secret entrance to the catacombs.");
					puts("You will know when you arrive because I left an old pair of shoes there.'");
				}
				break;
		}
	}
	wordnumber = max(last1,last2);
	return(firstnumber);
}
SHAR_EOF
if test 8811 -ne "`wc -c battlestar/com5.c`"
then
echo shar: error transmitting battlestar/com5.c '(should have been 8811 characters)'
fi
cat << \SHAR_EOF > battlestar/com6.c
#ifndef lint
static char sccsid[] = "@(#)com6.c	1.2 11/28/84";
#endif

#include "externs.h"

launch()
{
	if (testbit(location[position].objects,VIPER) && !notes[CANTLAUNCH]){
		if (fuel > 4){
			clearbit(location[position].objects,VIPER);
			position = location[position].up;
			notes[LAUNCHED] = 1;
			time++;
			fuel -= 4;
			puts("You climb into the viper and prepare for launch.");
			puts("With a touch of your thumb the turbo engines ignite, thrusting you back into\nyour seat.");
			return(1);
		}
		else
			puts("Not enough fuel to launch.");
	 }
	 else
		puts("Can't launch.");
	 return(0);
}

land()
{
	if (notes[LAUNCHED] && testbit(location[position].objects,LAND) && location[position].down){
		notes[LAUNCHED] = 0;
		position = location[position].down;
		setbit(location[position].objects,VIPER);
		fuel -= 2;
		time++;
		puts("You are down.");
		return(1);
	}
	else
		puts("You can't land here.");
	return(0);
}

die() 		/* endgame */
{
	printf("bye.\nYour rating was %s.\n", rate());
	post(' ');
	exit(0);
}

live()
{
	puts("\nYou win!");
	post('!');
	exit(0);
}

#include <sys/time.h>
post(ch)
char ch;
{
	FILE *fp;
	struct timeval tv;
	char *date;
	int s = sigblock(sigmask(SIGINT));

	gettimeofday(&tv, (struct timezone *)0);	/* can't call time */
	date = ctime(&tv.tv_sec);
	date[24] = '\0';
	if (fp = fopen(logfile,"a")) {
		fprintf(fp, "%s  %8s  %c%20s", date, uname, ch, rate());
		if (wiz)
			fprintf(fp, "   wizard\n");
		else if (tempwiz)
			fprintf(fp, "   WIZARD!\n");
		else
			fprintf(fp, "\n");
	} else
		perror(logfile);
	sigsetmask(s);
}

char *
rate()
{
	int score;

	score = max(max(pleasure,power),ego);
	if (score == pleasure){
		if (score < 5)
			return("novice");
		else if (score < 20)
			return("junior voyeur");
		else if (score < 35)
			return("Don Juan");
		else return("Marquis De Sade");
	}
	else if (score == power){
		if (score < 5)
			return("serf");
		else if (score < 8)
			return("Samurai");
		else if (score < 13)
			return("Klingon");
		else if (score < 22)
			return("Darth Vader");
		else return("Sauron the Great");
	}
	else{
		if (score < 5)
			return("Polyanna");
		else if (score < 10)
			return("philanthropist");
		else if (score < 20)
			return("Tattoo");
		else return("Mr. Roarke");
	}
}

drive()
{
	if (testbit(location[position].objects,CAR)){
		puts("You hop in the car and turn the key.  There is a perceptible grating noise,");
		puts("and an explosion knocks you unconscious...");
		clearbit(location[position].objects,CAR);
		setbit(location[position].objects,CRASH);
		injuries[5] = injuries[6] = injuries[7] = injuries[8] = 1;
		time += 15;
		zzz();
		return(0);
	}
	else
		puts("There is nothing to drive here.");
	return(-1);
}

ride()
{
	if (testbit(location[position].objects,HORSE)){
		puts("You climb onto the stallion and kick it in the guts.  The stupid steed launches");
		puts("forward through bush and fern.  You are thrown and the horse gallups off.");
		clearbit(location[position].objects,HORSE);
		while (!(position = rnd(NUMOFROOMS+1)) || !OUTSIDE || !beenthere[position] || location[position].flyhere);
		setbit(location[position].objects,HORSE);
		if (location[position].north)
			position = location[position].north;
		else if (location[position].south)
			position = location[position].south;
		else if (location[position].east)
			position = location[position].east;
		else
			position = location[position].west;
		return(0);
	}
	else puts("There is no horse here.");
	return(-1);
}

light()		/* synonyms = {strike, smoke} */
{		/* for matches, cigars */
	if (testbit(inven,MATCHES) && matchcount){
		puts("Your match splutters to life.");
		time++;
		matchlight = 1;
		matchcount--;
		if (position == 217){
			puts("The whole bungalow explodes with an intense blast.");
			die();
		}
	}
	else puts("You're out of matches.");
}
SHAR_EOF
if test 3823 -ne "`wc -c battlestar/com6.c`"
then
echo shar: error transmitting battlestar/com6.c '(should have been 3823 characters)'
fi
#	End of shell archive
exit 0



More information about the Comp.sources.unix mailing list