Initial revision

git-svn-id: file:///srv/svn/joey/bsdgames-trunk@5086 a4a2c43b-8ac3-0310-8836-e0e880c912e2
This commit is contained in:
joey
1999-09-08 23:56:51 +00:00
commit 03272d67da
623 changed files with 243457 additions and 0 deletions

14
battlestar/Makefile.bsd Normal file
View File

@@ -0,0 +1,14 @@
# $NetBSD: Makefile,v 1.8 1998/02/18 22:37:30 jtc Exp $
# @(#)Makefile 8.1 (Berkeley) 5/31/93
PROG= battlestar
SRCS= battlestar.c com1.c com2.c com3.c com4.c com5.c com6.c com7.c \
init.c cypher.c getcom.c parse.c room.c save.c fly.c misc.c \
globals.c dayfile.c nightfile.c dayobjs.c nightobjs.c words.c
MAN= battlestar.6
DPADD= ${LIBCURSES}
LDADD= -lcurses
HIDEGAME=hidegame
SETGIDGAME=yes
.include <bsd.prog.mk>

11
battlestar/Makefrag Normal file
View File

@@ -0,0 +1,11 @@
# Makefrag - makefile fragment for battlestar
battlestar_DIRS := $(GAMESDIR) $(MAN6DIR)
battlestar_all: battlestar/battlestar battlestar/battlestar.6
battlestar_install: battlestar_all
$(INSTALL_SCORE_GAME) battlestar/battlestar $(INSTALL_PREFIX)$(GAMESDIR)/battlestar
$(HIDE_GAME) battlestar
$(INSTALL_MANUAL) battlestar/battlestar.6
$(INSTALL_SCORE_FILE) $(BATTLESTAR_SCOREFILE)

163
battlestar/battlestar.6 Normal file
View File

@@ -0,0 +1,163 @@
.\" $NetBSD: battlestar.6,v 1.6 1998/09/10 21:50:35 frueauf Exp $
.\"
.\" Copyright (c) 1983, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\" @(#)battlestar.6 8.1 (Berkeley) 5/31/93
.\"
.Dd May 31, 1993
.Dt BATTLESTAR 6
.Os
.Sh NAME
.Nm battlestar
.Nd a tropical adventure game
.Sh SYNOPSIS
.Nm
.Op Fl r
.Op saved-file
.Sh DESCRIPTION
.Nm
is an adventure game in the classic style. However, it's slightly less
of a
puzzle and more a game of exploration. There are a few magical words
in the game, but on the whole, simple English
should suffice to make one's desires understandable to the parser.
.Sh THE SETTING
In the days before the darkness came, when battlestars ruled the
heavens...
.Bd -literal -offset indent
Three He made and gave them to His daughters,
Beautiful nymphs, the goddesses of the waters.
One to bring good luck and simple feats of wonder,
Two to wash the lands and churn the waves asunder,
Three to rule the world and purge the skies with thunder.
.Ed
.Pp
In those times great wizards were known and their powers were beyond
belief. They could take any object from thin air, and, uttering the
word
.Sq su
could disappear.
.Pp
In those times men were known for their lust of gold and desire to
wear fine weapons. Swords and coats of mail were fashioned that could
withstand a laser blast.
.Pp
But when the darkness fell, the rightful reigns were toppled. Swords
and helms and heads of state went rolling across the grass. The entire
fleet of battlestars was reduced to a single ship.
.Sh SAMPLE COMMANDS
.Bd -literal -offset indent
take --- take an object
drop --- drop an object
wear --- wear an object you are holding
draw --- carry an object you are wearing
puton --- take an object and wear it
take off -- draw an object and drop it
throw <object> <direction>
! <shell esc>
.Ed
.Sh IMPLIED OBJECTS
.Bd -literal -offset indent
>-: take watermelon
watermelon:
Taken.
>-: eat
watermelon:
Eaten.
>-: take knife and sword and apple, drop all
knife:
Taken.
broadsword:
Taken.
apple:
Taken.
knife:
Dropped.
broadsword:
Dropped.
apple:
Dropped.
>-: get
knife:
Taken.
.Ed
.Pp
Notice that the "shadow" of the next word stays around if you
want to take advantage of it. That is, saying "take knife" and then
"drop"
will drop the knife you just took.
.Sh SCORE & INVEN
The two commands "score" and "inven" will print out your current status
in the game.
.Sh SAVING A GAME
The command "save" will save your game in a file, by default called
".Bstar" in your home directory. You
can recover a saved game by using the
.Fl r
option when you start up the
game, or by giving the name of the saved file as an argument.
.Sh DIRECTIONS
The compass directions N, S, E, and W can be used if you have a compass.
If you don't have a compass, you'll have to say R, L, A, or B, which
stand for Right, Left, Ahead, and Back.
Directions printed in room descriptions are
always printed in R, L, A, & B relative directions.
.Sh HISTORY
I wrote Battlestar in 1979 in order to experiment with the niceties of
the C Language.
Most interesting things that happen in the game are hardwired into the
code, so don't send me any hate mail about it!
Instead, enjoy art for art's sake!
.Sh AUTHOR
David Riggle
.Sh INSPIRATION & ASSISTANCE
.Bl -item -compact
.It
Chris Guthrie
.It
Peter Da Silva
.It
Kevin Brown
.It
Edward Wang
.It
Ken Arnold & Company
.El
.Sh BUGS
Countless.
.Sh FAN MAIL
Send to edward%ucbarpa@berkeley.arpa, chris%ucbcory@berkeley.arpa,
riggle.pa@xerox.arpa.

106
battlestar/battlestar.c Normal file
View File

@@ -0,0 +1,106 @@
/* $NetBSD: battlestar.c,v 1.6 1997/10/11 02:06:55 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
__COPYRIGHT("@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n");
#endif /* not lint */
#ifndef lint
#if 0
static char sccsid[] = "@(#)battlestar.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: battlestar.c,v 1.6 1997/10/11 02:06:55 lukem Exp $");
#endif
#endif /* not lint */
/*
* Battlestar - a stellar-tropical adventure game
*
* Originally written by His Lordship, Admiral David W. Horatio Riggle,
* on the Cory PDP-11/70, University of California, Berkeley.
*/
#include "extern.h"
int main __P((int, char *[]));
int
main(argc, argv)
int argc;
char **argv;
{
char mainbuf[LINELENGTH];
char *next;
/* Open the score file then revoke setgid privileges */
open_score_file();
setregid(getgid(), getgid());
initialize((argc < 2) ? NULL : (strcmp(argv[1], "-r") ? argv[1]
: (argv[2] ? argv[2]
: DEFAULT_SAVE_FILE)));
start:
news();
beenthere[position]++;
if (notes[LAUNCHED])
crash(); /* decrements fuel & crash */
if (matchlight) {
puts("Your match splutters out.");
matchlight = 0;
}
if (!notes[CANTSEE] || testbit(inven, LAMPON) ||
testbit(location[position].objects, LAMPON)) {
writedes();
printobjs();
} else
puts("It's too dark to see anything in here!");
whichway(location[position]);
run:
next = getcom(mainbuf, sizeof mainbuf, ">-: ",
"Please type in something.");
for (wordcount = 0; next && wordcount < 20; wordcount++)
next = getword(next, words[wordcount], -1);
parse();
switch (cypher()) {
case -1:
goto run;
case 0:
goto start;
default:
exit(1); /* Shouldn't happen */
}
}

266
battlestar/com1.c Normal file
View File

@@ -0,0 +1,266 @@
/* $NetBSD: com1.c,v 1.6 1997/10/11 02:06:58 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)com1.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com1.c,v 1.6 1997/10/11 02:06:58 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
int
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);
ourtime++;
} 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);
}
void
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. */
const struct objs *p;
unsigned int 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;
}
}
void
news()
{
int n;
int hurt;
if (ourtime > 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 (ourtime > 20 && position < 32)
puts("Explosions rock the battlestar.");
if (ourtime > snooze) {
puts("You drop from exhaustion...");
zzz();
}
if (ourtime > snooze - 5)
puts("You're getting tired.");
if (ourtime > (rythmn + CYCLE)) {
if (location == nightfile) {
convert(TODAY);
if (OUTSIDE && ourtime - 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 && ourtime - 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 = ourtime - ourtime % 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 - ourtime < 10) {
setbit(location[GARDEN].objects, GIRLTALK);
setbit(location[GARDEN].objects, LAMPON);
setbit(location[GARDEN].objects, ROPE);
}
if (position == DOCK && (beenthere[position] || ourtime > CYCLE)) {
clearbit(location[DOCK].objects, GIRL);
clearbit(location[DOCK].objects, MAN);
}
if (meetgirl && ourtime - 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",
ourclock);
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;
}
void
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);
ourtime += 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]);
}
}

323
battlestar/com2.c Normal file
View File

@@ -0,0 +1,323 @@
/* $NetBSD: com2.c,v 1.7 1998/08/24 00:22:45 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)com2.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com2.c,v 1.7 1998/08/24 00:22:45 hubertf Exp $");
#endif
#endif /* not lint */
#include "extern.h"
int
wearit()
{ /* synonyms = {sheathe, sheath} */
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];
ourtime++;
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);
}
int
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);
}
int
draw()
{ /* synonyms = {pull, carry} */
return (take(wear));
}
int
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.");
ourtime++;
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;
ourtime++;
notes[CANTSEE] = 0;
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);
}
void
murder()
{
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]]);
}
}
}
void
ravage()
{
while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount);
if (wordtype[wordnumber] == NOUNS && testbit(location[position].objects, wordvalue[wordnumber])) {
ourtime++;
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?");
}
int
follow()
{
if (followfight == ourtime) {
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 == ourtime) {
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);
}

321
battlestar/com3.c Normal file
View File

@@ -0,0 +1,321 @@
/* $NetBSD: com3.c,v 1.7 1998/08/24 00:19:25 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com3.c,v 1.7 1998/08/24 00:19:25 hubertf Exp $");
#endif
#endif /* not lint */
#include "extern.h"
void
dig()
{
if (testbit(inven, SHOVEL)) {
puts("OK");
ourtime++;
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.");
}
int
jump()
{
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);
}
void
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.");
}
void
drink()
{
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;
ourtime++;
zzz();
} else
puts("I'm not thirsty.");
}
int
shoot()
{
int firstnumber, value;
int n;
firstnumber = wordnumber;
if (!testbit(inven, LASER))
puts("You aren't holding a blaster.");
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++);
if (testbit(location[position].objects, value)) {
clearbit(location[position].objects, value);
ourtime++;
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) {
ourtime++;
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);
}

395
battlestar/com4.c Normal file
View File

@@ -0,0 +1,395 @@
/* $NetBSD: com4.c,v 1.6 1997/10/11 02:07:04 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)com4.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com4.c,v 1.6 1997/10/11 02:07:04 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
int
take(from)
unsigned int from[];
{
int firstnumber, heavy, bulky, value;
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];
ourtime++;
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 = ourtime;
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);
}
int
throw(name)
const char *name;
{
unsigned 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);
}
int
drop(name)
const 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;
ourtime++;
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);
}
int
takeoff()
{
wordnumber = take(wear);
return (drop("Dropped"));
}
int
puton()
{
wordnumber = take(location[position].objects);
return (wearit());
}
int
eat()
{
int firstnumber, value;
firstnumber = wordnumber;
while (wordtype[++wordnumber] == ADJS);
while (wordnumber <= wordcount) {
value = wordvalue[wordnumber];
switch (value) {
case -1:
puts("Eat what?");
return (firstnumber);
default:
printf("You can't eat%s%s!\n",
wordtype[wordnumber] == OBJECT &&
objsht[value]
[strlen(objsht[value]) - 1] == 's' ?
" " : " a ",
words[wordnumber]);
return (firstnumber);
case PAPAYAS:
case PINEAPPLE:
case KIWI:
case COCONUTS: /* eatable things */
case MANGO:
printf("%s:\n", objsht[value]);
if (testbit(inven, value) &&
ourtime > ate - CYCLE &&
testbit(inven, KNIFE)) {
clearbit(inven, value);
carrying -= objwt[value];
encumber -= objcumber[value];
ate = max(ourtime, ate) + CYCLE / 3;
snooze += CYCLE / 10;
ourtime++;
puts("Eaten. You can explore a little longer now.");
} else
if (ourtime < 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);
}

351
battlestar/com5.c Normal file
View File

@@ -0,0 +1,351 @@
/* $NetBSD: com5.c,v 1.9 1998/08/30 09:19:36 veego Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)com5.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com5.c,v 1.9 1998/08/30 09:19:36 veego Exp $");
#endif
#endif /* not lint */
#include "extern.h"
void
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.");
}
void
love()
{
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;
ourtime += 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");
ourtime += 10;
zzz();
}
printf("Loved.\n");
} else
puts("It doesn't seem to work.");
}
int
zzz()
{
int oldtime;
int n;
oldtime = ourtime;
if ((snooze - ourtime) < (0.75 * CYCLE)) {
ourtime += 0.75 * CYCLE - (snooze - ourtime);
printf("<zzz>");
for (n = 0; n < ourtime - oldtime; n++)
printf(".");
printf("\n");
snooze += 3 * (ourtime - oldtime);
if (notes[LAUNCHED]) {
fuel -= (ourtime - 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);
}
void
chime()
{
if ((ourtime / CYCLE + 1) % 2 && OUTSIDE)
switch ((ourtime % 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 ((ourtime % 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.");
}
int
give()
{
int obj = -1, result = -1, person = 0, firstnumber, last1, last2;
last1 = last2 = 0;
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;
}
/* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g.,
* plain `give'. However, detecting this case is liable to detect
* `give foo' as well, which would give a confusing error. We
* need to make sure the -1 value can cause no problems if it arises.
* If in the below we get to the drop("Given") then drop will look
* at word 0 for an object to give, and fail, which is OK; then
* result will be -1 and we get to the end, where wordnumber gets
* set to something more sensible. If we get to "I don't think
* that is possible" then again wordnumber is set to something
* sensible. The wordnumber we leave with still isn't right if
* you include words the game doesn't know in your command, but
* that's no worse than what other commands than give do in
* the same place. */
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.");
wordnumber = max(last1, last2) + 1;
return (0);
}
if (result != -1 && (testbit(location[position].objects, obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)) {
clearbit(location[position].objects, obj);
ourtime++;
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 = ourtime;
}
}
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) + 1;
return (firstnumber);
}

249
battlestar/com6.c Normal file
View File

@@ -0,0 +1,249 @@
/* $NetBSD: com6.c,v 1.9 1997/10/13 21:05:36 cjs Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)com6.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com6.c,v 1.9 1997/10/13 21:05:36 cjs Exp $");
#endif
#endif /* not lint */
#include <time.h>
#include "extern.h"
#include "pathnames.h"
int
launch()
{
if (testbit(location[position].objects, VIPER) && !notes[CANTLAUNCH]) {
if (fuel > 4) {
clearbit(location[position].objects, VIPER);
position = location[position].up;
notes[LAUNCHED] = 1;
ourtime++;
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);
}
int
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;
ourtime++;
puts("You are down.");
return (1);
} else
puts("You can't land here.");
return (0);
}
void
die()
{ /* endgame */
printf("bye.\nYour rating was %s.\n", rate());
post(' ');
exit(0);
}
void
diesig(dummy)
int dummy __attribute__((unused));
{
die();
}
void
live()
{
puts("\nYou win!");
post('!');
exit(0);
}
static FILE *score_fp;
void
open_score_file()
{
score_fp = fopen(_PATH_SCORE, "a");
if (score_fp == NULL)
warn("open %s for append", _PATH_SCORE);
}
void
post(ch)
char ch;
{
time_t tv;
char *date;
sigset_t sigset, osigset;
sigemptyset(&sigset);
sigaddset(&sigset, SIGINT);
sigprocmask(SIG_BLOCK, &sigset, &osigset);
tv = time(NULL);
date = ctime(&tv);
date[24] = '\0';
if (score_fp != NULL) {
fprintf(score_fp, "%s %8s %c%20s", date, username, ch, rate());
if (wiz)
fprintf(score_fp, " wizard\n");
else
if (tempwiz)
fprintf(score_fp, " WIZARD!\n");
else
fprintf(score_fp, "\n");
}
sigprocmask(SIG_SETMASK, &osigset, (sigset_t *) 0);
}
const 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");
}
}
int
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;
ourtime += 15;
zzz();
return (0);
} else
puts("There is nothing to drive here.");
return (-1);
}
int
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);
}
void
light()
{ /* synonyms = {strike, smoke} *//* for
* matches, cigars */
if (testbit(inven, MATCHES) && matchcount) {
puts("Your match splutters to life.");
ourtime++;
matchlight = 1;
matchcount--;
if (position == 217) {
puts("The whole bungalow explodes with an intense blast.");
die();
}
} else
puts("You're out of matches.");
}

276
battlestar/com7.c Normal file
View File

@@ -0,0 +1,276 @@
/* $NetBSD: com7.c,v 1.6 1997/10/11 02:07:10 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)com7.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: com7.c,v 1.6 1997/10/11 02:07:10 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
int
fight(enemy, strength)
int enemy, strength;
{
int lifeline = 0;
int hurt;
char auxbuf[LINELENGTH];
char *next;
int i;
int exhaustion;
exhaustion = 0;
fighton:
ourtime++;
snooze -= 5;
if (snooze > ourtime)
exhaustion = CYCLE / (snooze - ourtime);
else {
puts("You collapse exhausted, and he pulverizes your skull.");
die();
}
if (snooze - ourtime < 20)
puts("You look tired! I hope you're able to fight.");
next = getcom(auxbuf, LINELENGTH, "<fight!>-: ", 0);
for (i = 0; next && i < 10; i++)
next = getword(next, words[i], -1);
parse();
switch (wordvalue[wordnumber]) {
case KILL:
case SMITE:
if (testbit(inven, TWO_HANDED))
hurt = rnd(70) - 2 * card(injuries, NUMOFINJURIES) - ucard(wear) - exhaustion;
else
if (testbit(inven, SWORD) || testbit(inven, BROAD))
hurt = rnd(50) % (WEIGHT - carrying) - card(injuries, NUMOFINJURIES) - encumber - exhaustion;
else
if (testbit(inven, KNIFE) || testbit(inven, MALLET) || testbit(inven, CHAIN) || testbit(inven, MACE) || testbit(inven, HALBERD))
hurt = rnd(15) - card(injuries, NUMOFINJURIES) - exhaustion;
else
hurt = rnd(7) - encumber;
if (hurt < 5)
switch (rnd(3)) {
case 0:
puts("You swung wide and missed.");
break;
case 1:
puts("He checked your blow. CLASH! CLANG!");
break;
case 2:
puts("His filthy tunic hangs by one less thread.");
break;
}
else
if (hurt < 10) {
switch (rnd(3)) {
case 0:
puts("He's bleeding.");
break;
case 1:
puts("A trickle of blood runs down his face.");
break;
case 2:
puts("A huge purple bruise is forming on the side of his face.");
break;
}
lifeline++;
} else
if (hurt < 20) {
switch (rnd(3)) {
case 0:
puts("He staggers back quavering.");
break;
case 1:
puts("He jumps back with his hand over the wound.");
break;
case 2:
puts("His shirt falls open with a swath across the chest.");
break;
}
lifeline += 5;
} else
if (hurt < 30) {
switch (rnd(3)) {
case 0:
printf("A bloody gash opens up on his %s side.\n", (rnd(2) ? "left" : "right"));
break;
case 1:
puts("The steel bites home and scrapes along his ribs.");
break;
case 2:
puts("You pierce him, and his breath hisses through clenched teeth.");
break;
}
lifeline += 10;
} else
if (hurt < 40) {
switch (rnd(3)) {
case 0:
puts("You smite him to the ground.");
if (strength - lifeline > 20)
puts("But in a flurry of steel he regains his feet!");
break;
case 1:
puts("The force of your blow sends him to his knees.");
puts("His arm swings lifeless at his side.");
break;
case 2:
puts("Clutching his blood drenched shirt, he collapses stunned.");
break;
}
lifeline += 20;
} else {
switch (rnd(3)) {
case 0:
puts("His ribs crack under your powerful swing, flooding his lungs with blood.");
break;
case 1:
puts("You shatter his upheld arm in a spray of blood. The blade continues deep");
puts("into his back, severing the spinal cord.");
lifeline += 25;
break;
case 2:
puts("With a mighty lunge the steel slides in, and gasping, he falls to the ground.");
lifeline += 25;
break;
}
lifeline += 30;
}
break;
case BACK:
if (enemy == DARK && lifeline > strength * 0.33) {
puts("He throws you back against the rock and pummels your face.");
if (testbit(inven, AMULET) || testbit(wear, AMULET)) {
printf("Lifting the amulet from you, ");
if (testbit(inven, MEDALION) || testbit(wear, MEDALION)) {
puts("his power grows and the walls of\nthe earth tremble.");
puts("When he touches the medallion, your chest explodes and the foundations of the\nearth collapse.");
puts("The planet is consumed by darkness.");
die();
}
if (testbit(inven, AMULET)) {
clearbit(inven, AMULET);
carrying -= objwt[AMULET];
encumber -= objcumber[AMULET];
} else
clearbit(wear, AMULET);
puts("he flees down the dark caverns.");
clearbit(location[position].objects, DARK);
injuries[SKULL] = 1;
followfight = ourtime;
return (0);
} else {
puts("I'm afraid you have been killed.");
die();
}
} else {
puts("You escape stunned and disoriented from the fight.");
puts("A victorious bellow echoes from the battlescene.");
if (back && position != back)
move(back, BACK);
else
if (ahead && position != ahead)
move(ahead, AHEAD);
else
if (left && position != left)
move(left, LEFT);
else
if (right && position != right)
move(right, RIGHT);
else
move(location[position].down, AHEAD);
return (0);
}
case SHOOT:
if (testbit(inven, LASER)) {
if (strength - lifeline <= 50) {
printf("The %s took a direct hit!\n", objsht[enemy]);
lifeline += 50;
} else {
puts("With his bare hand he deflects the laser blast and whips the pistol from you!");
clearbit(inven, LASER);
setbit(location[position].objects, LASER);
carrying -= objwt[LASER];
encumber -= objcumber[LASER];
}
} else
puts("Unfortunately, you don't have a blaster handy.");
break;
case DROP:
case DRAW:
cypher();
ourtime--;
break;
default:
puts("You don't have a chance, he is too quick.");
break;
}
if (lifeline >= strength) {
printf("You have killed the %s.\n", objsht[enemy]);
if (enemy == ELF || enemy == DARK)
puts("A watery black smoke consumes his body and then vanishes with a peal of thunder!");
clearbit(location[position].objects, enemy);
power += 2;
notes[JINXED]++;
return (0);
}
puts("He attacks...");
/* some embellisments */
hurt = rnd(NUMOFINJURIES) - (testbit(inven, SHIELD) != 0) - (testbit(wear, MAIL) != 0) - (testbit(wear, HELM) != 0);
hurt += (testbit(wear, AMULET) != 0) + (testbit(wear, MEDALION) != 0) + (testbit(wear, TALISMAN) != 0);
hurt = hurt < 0 ? 0 : hurt;
hurt = hurt >= NUMOFINJURIES ? NUMOFINJURIES - 1 : hurt;
if (!injuries[hurt]) {
injuries[hurt] = 1;
printf("I'm afraid you have suffered %s.\n", ouch[hurt]);
} else
puts("You emerge unscathed.");
if (injuries[SKULL] && injuries[INCISE] && injuries[NECK]) {
puts("I'm afraid you have suffered fatal injuries.");
die();
}
goto fighton;
}

472
battlestar/cypher.c Normal file
View File

@@ -0,0 +1,472 @@
/* $NetBSD: cypher.c,v 1.7 1998/08/24 00:25:32 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)cypher.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: cypher.c,v 1.7 1998/08/24 00:25:32 hubertf Exp $");
#endif
#endif /* not lint */
#include "extern.h"
int
cypher()
{
int n;
int junk;
int lflag = -1;
char buffer[10];
char *filename;
size_t filename_len;
while (wordtype[wordnumber] == ADJS)
wordnumber++;
while (wordnumber <= wordcount) {
switch (wordvalue[wordnumber]) {
case UP:
if (location[position].access || wiz || tempwiz) {
if (!location[position].access)
puts("Zap! A gust of wind lifts you up.");
if (!move(location[position].up, AHEAD))
return (-1);
} else {
puts("There is no way up");
return (-1);
}
lflag = 0;
break;
case DOWN:
if (!move(location[position].down, AHEAD))
return (-1);
lflag = 0;
break;
case LEFT:
if (!move(left, LEFT))
return (-1);
lflag = 0;
break;
case RIGHT:
if (!move(right, RIGHT))
return (-1);
lflag = 0;
break;
case AHEAD:
if (!move(ahead, AHEAD))
return (-1);
lflag = 0;
break;
case BACK:
if (!move(back, BACK))
return (-1);
lflag = 0;
break;
case SHOOT:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects, n) && objsht[n]) {
wordvalue[wordnumber + 1] = n;
wordnumber = shoot();
}
wordnumber++;
wordnumber++;
} else
shoot();
break;
case TAKE:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects, n) && objsht[n]) {
wordvalue[wordnumber + 1] = n;
/* Some objects (type NOUNS)
* have special treatment in
* take(). For these we
* must set the type to NOUNS.
* However for SWORD and BODY
* all it does is find which
* of many objects is meant,
* so we need do nothing here.
* BATHGOD must become
* NORMGOD as well. NOUNS
* with no special case
* must be included here to
* get the right error. DOOR
* cannot occur as an object
* so need not be included. */
switch(n) {
case BATHGOD:
wordvalue[wordnumber + 1] = NORMGOD;
case NORMGOD:
case AMULET:
case MEDALION:
case TALISMAN:
case MAN:
case TIMER:
case NATIVE:
wordtype[wordnumber + 1] = NOUNS;
break;
default:
wordtype[wordnumber + 1] = OBJECT;
}
wordnumber = take(location[position].objects);
}
wordnumber++;
wordnumber++;
} else
take(location[position].objects);
break;
case DROP:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n)) {
wordvalue[wordnumber + 1] = n;
wordnumber = drop("Dropped");
}
wordnumber++;
wordnumber++;
} else
drop("Dropped");
break;
case KICK:
case THROW:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n) ||
(testbit(location[position].objects, n) && objsht[n])) {
wordvalue[wordnumber + 1] = n;
wordnumber = throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
}
wordnumber += 2;
} else
throw(wordvalue[wordnumber] == KICK ? "Kicked" : "Thrown");
break;
case TAKEOFF:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(wear, n)) {
wordvalue[wordnumber + 1] = n;
wordnumber = takeoff();
}
wordnumber += 2;
} else
takeoff();
break;
case DRAW:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(wear, n)) {
wordvalue[wordnumber + 1] = n;
wordnumber = draw();
}
wordnumber += 2;
} else
draw();
break;
case PUTON:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(location[position].objects, n) && objsht[n]) {
wordvalue[wordnumber + 1] = n;
wordnumber = puton();
}
wordnumber += 2;
} else
puton();
break;
case WEARIT:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n)) {
wordvalue[wordnumber + 1] = n;
wordnumber = wearit();
}
wordnumber += 2;
} else
wearit();
break;
case EAT:
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == EVERYTHING) {
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n)) {
wordvalue[wordnumber + 1] = n;
wordnumber = eat();
}
wordnumber += 2;
} else
eat();
break;
case PUT:
put();
break;
case INVEN:
if (ucard(inven)) {
puts("You are holding:\n");
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(inven, n))
printf("\t%s\n", objsht[n]);
printf("\n= %d kilogram%s (%d%%)\n", carrying, (carrying == 1 ? "." : "s."), (WEIGHT ? carrying * 100 / WEIGHT : -1));
printf("Your arms are %d%% full.\n", encumber * 100 / CUMBER);
} else
puts("You aren't carrying anything.");
if (ucard(wear)) {
puts("\nYou are wearing:\n");
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(wear, n))
printf("\t%s\n", objsht[n]);
} else
puts("\nYou are stark naked.");
if (card(injuries, NUMOFINJURIES)) {
puts("\nYou have suffered:\n");
for (n = 0; n < NUMOFINJURIES; n++)
if (injuries[n])
printf("\t%s\n", ouch[n]);
printf("\nYou can still carry up to %d kilogram%s\n", WEIGHT, (WEIGHT == 1 ? "." : "s."));
} else
puts("\nYou are in perfect health.");
break;
case USE:
lflag = use();
break;
case LOOK:
if (!notes[CANTSEE] || testbit(inven, LAMPON) ||
testbit(location[position].objects, LAMPON)
|| matchlight) {
beenthere[position] = 2;
writedes();
printobjs();
if (matchlight) {
puts("\nYour match splutters out.");
matchlight = 0;
}
} else
puts("I can't see anything.");
return (-1);
break;
case SU:
if (wiz || tempwiz) {
printf("\nRoom (was %d) = ", position);
fgets(buffer, 10, stdin);
if (*buffer != '\n')
sscanf(buffer, "%d", &position);
printf("Time (was %d) = ", ourtime);
fgets(buffer, 10, stdin);
if (*buffer != '\n')
sscanf(buffer, "%d", &ourtime);
printf("Fuel (was %d) = ", fuel);
fgets(buffer, 10, stdin);
if (*buffer != '\n')
sscanf(buffer, "%d", &fuel);
printf("Torps (was %d) = ", torps);
fgets(buffer, 10, stdin);
if (*buffer != '\n')
sscanf(buffer, "%d", &torps);
printf("CUMBER (was %d) = ", CUMBER);
fgets(buffer, 10, stdin);
if (*buffer != '\n')
sscanf(buffer, "%d", &CUMBER);
printf("WEIGHT (was %d) = ", WEIGHT);
fgets(buffer, 10, stdin);
if (*buffer != '\n')
sscanf(buffer, "%d", &WEIGHT);
printf("Clock (was %d) = ", ourclock);
fgets(buffer, 10, stdin);
if (*buffer != '\n')
sscanf(buffer, "%d", &ourclock);
printf("Wizard (was %d, %d) = ", wiz, tempwiz);
fgets(buffer, 10, stdin);
if (*buffer != '\n') {
sscanf(buffer, "%d", &junk);
if (!junk)
tempwiz = wiz = 0;
}
printf("\nDONE.\n");
return (0);
} else
puts("You aren't a wizard.");
break;
case SCORE:
printf("\tPLEASURE\tPOWER\t\tEGO\n");
printf("\t%3d\t\t%3d\t\t%3d\n\n", pleasure, power, ego);
printf("This gives you the rating of %s in %d turns.\n", rate(), ourtime);
printf("You have visited %d out of %d rooms this run (%d%%).\n", card(beenthere, NUMOFROOMS), NUMOFROOMS, card(beenthere, NUMOFROOMS) * 100 / NUMOFROOMS);
break;
case KNIFE:
case KILL:
murder();
break;
case UNDRESS:
case RAVAGE:
ravage();
break;
case SAVE:
printf("\nSave file name (default %s) ",
DEFAULT_SAVE_FILE);
filename = fgetln(stdin, &filename_len);
if (filename_len == 0
|| (filename_len == 1 && filename[0] == '\n'))
save(DEFAULT_SAVE_FILE,
strlen(DEFAULT_SAVE_FILE));
else {
if (filename[filename_len - 1] == '\n')
filename_len--;
save(filename, filename_len);
}
break;
case FOLLOW:
lflag = follow();
break;
case GIVE:
give();
break;
case KISS:
kiss();
break;
case LOVE:
love();
break;
case RIDE:
lflag = ride();
break;
case DRIVE:
lflag = drive();
break;
case LIGHT:
light();
break;
case LAUNCH:
if (!launch())
return (-1);
else
lflag = 0;
break;
case LANDIT:
if (!land())
return (-1);
else
lflag = 0;
break;
case TIME:
chime();
break;
case SLEEP:
zzz();
break;
case DIG:
dig();
break;
case JUMP:
lflag = jump();
break;
case BURY:
bury();
break;
case SWIM:
puts("Surf's up!");
break;
case DRINK:
drink();
break;
case QUIT:
die();
default:
puts("How's that?");
return (-1);
break;
}
if (wordnumber < wordcount && *words[wordnumber++] == ',')
continue;
else
return (lflag);
}
return (lflag);
}

1212
battlestar/dayfile.c Normal file

File diff suppressed because it is too large Load Diff

145
battlestar/dayobjs.c Normal file
View File

@@ -0,0 +1,145 @@
/* $NetBSD: dayobjs.c,v 1.6 1997/10/11 02:07:16 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dayobjs.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: dayobjs.c,v 1.6 1997/10/11 02:07:16 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
const struct objs dayobjs[] = {
{236, HORSE},
{237, CAR},
{275, POT},
{275, BAR},
{275, BLOCK},
{260, COINS},
{266, DARK},
{235, TIMER},
{51, 51},
{59, 51},
{48, 51},
{66, 52},
{65, 52},
{19, BOMB},
{167, NATIVE},
{21, KNIFE},
{30, KNIFE},
{30, CLEAVER},
{260, SWORD},
{70, LAND},
{71, LAND},
{72, LAND},
{73, LAND},
{74, LAND},
{75, LAND},
{76, LAND},
{77, LAND},
{78, LAND},
{79, LAND},
{81, LAND},
{82, LAND},
{83, LAND},
{84, LAND},
{85, LAND},
{86, LAND},
{87, LAND},
{88, LAND},
{90, LAND},
{95, LAND},
{96, LAND},
{97, LAND},
{99, LAND},
{100, LAND},
{104, LAND},
{172, WOODSMAN},
{172, DEADWOOD},
{172, MALLET},
{146, ELF},
{146, HALBERD},
{146, SHIELD},
{190, TWO_HANDED},
{190, POTION},
{142, BROAD},
{258, MAIL},
{258, HELM},
{21, MAID},
{7, VIPER},
{216, SHOES},
{64, CYLON},
{36, CYLON},
{49, CYLON},
{8, ROBE},
{13, AMULET},
{20, LASER},
{126, BATHGOD},
{26, GRENADE},
{256, GRENADE},
{237, CHAIN},
{237, COMPASS},
{218, LEVIS},
{164, MACE},
{137, SHOVEL},
{11, COINS},
{24, MATCHES},
{235, MATCHES},
{93, MAN},
{109, PAPAYAS},
{110, PINEAPPLE},
{152, PINEAPPLE},
{154, PINEAPPLE},
{111, KIWI},
{149, MANGO},
{112, COCONUTS},
{150, COCONUTS},
{151, COCONUTS},
{153, COCONUTS},
{192, COCONUTS},
{204, COCONUTS},
{207, COCONUTS},
{209, COCONUTS},
{213, COCONUTS},
{240, COCONUTS},
{218, RING},
{130, BRACELET},
{93, GIRL},
{268, LAMPON},
{0, 0}
};

376
battlestar/extern.h Normal file
View File

@@ -0,0 +1,376 @@
/* $NetBSD: extern.h,v 1.9 1998/09/13 15:27:26 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)externs.h 8.1 (Berkeley) 5/31/93
*/
#include <sys/time.h>
#include <ctype.h>
#include <err.h>
#include <pwd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#define BITS (8 * sizeof (int))
#define OUTSIDE (position > 68 && position < 246 && position != 218)
#define rnd(x) (rand() % (x))
#define max(a,b) ((a) < (b) ? (b) : (a))
#define testbit(array, index) (array[index/BITS] & (1 << (index % BITS)))
#define setbit(array, index) (array[index/BITS] |= (1 << (index % BITS)))
#define clearbit(array, index) (array[index/BITS] &= ~(1 << (index % BITS)))
/* well known rooms */
#define FINAL 275
#define GARDEN 197
#define POOLS 126
#define DOCK 93
/* word types */
#define VERB 0
#define OBJECT 1
#define NOUNS 2
#define PREPS 3
#define ADJS 4
#define CONJ 5
/* words numbers */
#define KNIFE 0
#define SWORD 1
#define LAND 2
#define WOODSMAN 3
#define TWO_HANDED 4
#define CLEAVER 5
#define BROAD 6
#define MAIL 7
#define HELM 8
#define SHIELD 9
#define MAID 10
#define BODY 10
#define VIPER 11
#define LAMPON 12
#define SHOES 13
#define CYLON 14
#define PAJAMAS 15
#define ROBE 16
#define AMULET 17
#define MEDALION 18
#define TALISMAN 19
#define DEADWOOD 20
#define MALLET 21
#define LASER 22
#define BATHGOD 23
#define NORMGOD 24
#define GRENADE 25
#define CHAIN 26
#define ROPE 27
#define LEVIS 28
#define MACE 29
#define SHOVEL 30
#define HALBERD 31
#define COMPASS 32
#define CRASH 33
#define ELF 34
#define FOOT 35
#define COINS 36
#define MATCHES 37
#define MAN 38
#define PAPAYAS 39
#define PINEAPPLE 40
#define KIWI 41
#define COCONUTS 42
#define MANGO 43
#define RING 44
#define POTION 45
#define BRACELET 46
#define GIRL 47
#define GIRLTALK 48
#define DARK 49
#define TIMER 50
#define CHAR 53
#define BOMB 54
#define DEADGOD 55
#define DEADTIME 56
#define DEADNATIVE 57
#define NATIVE 58
#define HORSE 59
#define CAR 60
#define POT 61
#define BAR 62
#define BLOCK 63
#define NUMOFOBJECTS 64
/* non-objects below */
#define UP 1000
#define DOWN 1001
#define AHEAD 1002
#define BACK 1003
#define RIGHT 1004
#define LEFT 1005
#define TAKE 1006
#define USE 1007
#define LOOK 1008
#define QUIT 1009
#define NORTH 1010
#define SOUTH 1011
#define EAST 1012
#define WEST 1013
#define SU 1014
#define DROP 1015
#define TAKEOFF 1016
#define DRAW 1017
#define PUTON 1018
#define WEARIT 1019
#define PUT 1020
#define INVEN 1021
#define EVERYTHING 1022
#define AND 1023
#define KILL 1024
#define RAVAGE 1025
#define UNDRESS 1026
#define THROW 1027
#define LAUNCH 1028
#define LANDIT 1029
#define LIGHT 1030
#define FOLLOW 1031
#define KISS 1032
#define LOVE 1033
#define GIVE 1034
#define SMITE 1035
#define SHOOT 1036
#define ON 1037
#define OFF 1038
#define TIME 1039
#define SLEEP 1040
#define DIG 1041
#define EAT 1042
#define SWIM 1043
#define DRINK 1044
#define DOOR 1045
#define SAVE 1046
#define RIDE 1047
#define DRIVE 1048
#define SCORE 1049
#define BURY 1050
#define JUMP 1051
#define KICK 1052
/* injuries */
#define ARM 6 /* broken arm */
#define RIBS 7 /* broken ribs */
#define SPINE 9 /* broken back */
#define SKULL 11 /* fractured skull */
#define INCISE 10 /* deep incisions */
#define NECK 12 /* broken NECK */
#define NUMOFINJURIES 13
/* notes */
#define CANTLAUNCH 0
#define LAUNCHED 1
#define CANTSEE 2
#define CANTMOVE 3
#define JINXED 4
#define DUG 5
#define NUMOFNOTES 6
/* fundamental constants */
#define NUMOFROOMS 275
#define NUMOFWORDS ((NUMOFOBJECTS + BITS - 1) / BITS)
#define LINELENGTH 81
#define TODAY 0
#define TONIGHT 1
#define CYCLE 100
/* initial variable values */
#define TANKFULL 250
#define TORPEDOES 10
#define MAXWEIGHT 60
#define MAXCUMBER 10
struct room {
const char *name;
int link[8];
#define north link[0]
#define south link[1]
#define east link[2]
#define west link[3]
#define up link[4]
#define access link[5]
#define down link[6]
#define flyhere link[7]
const char *desc;
unsigned int objects[NUMOFWORDS];
};
extern struct room dayfile[];
extern struct room nightfile[];
struct room *location;
/* object characteristics */
extern const char *const objdes[NUMOFOBJECTS];
extern const char *const objsht[NUMOFOBJECTS];
extern const char *const ouch[NUMOFINJURIES];
extern const int objwt[NUMOFOBJECTS];
extern const int objcumber[NUMOFOBJECTS];
/* current input line */
#define NWORD 20 /* words per line */
char words[NWORD][15];
int wordvalue[NWORD];
int wordtype[NWORD];
int wordcount, wordnumber;
/* state of the game */
int ourtime;
int position;
int direction;
int left, right, ahead, back;
int ourclock, fuel, torps;
int carrying, encumber;
int rythmn;
extern int followfight;
int ate;
int snooze;
int meetgirl;
extern int followgod;
int godready;
extern int win;
int wintime;
int wiz;
int tempwiz;
int matchlight;
extern int matchcount;
int loved;
int pleasure, power, ego;
extern int WEIGHT;
extern int CUMBER;
int notes[NUMOFNOTES];
unsigned int inven[NUMOFWORDS];
unsigned int wear[NUMOFWORDS];
char beenthere[NUMOFROOMS + 1];
char injuries[NUMOFINJURIES];
char username[9];
struct wlist {
const char *string;
int value, article;
struct wlist *next;
};
#define HASHSIZE 256
#define HASHMUL 81
#define HASHMASK (HASHSIZE - 1)
struct wlist *hashtab[HASHSIZE];
extern struct wlist wlist[];
struct objs {
short room;
short obj;
};
extern const struct objs dayobjs[];
extern const struct objs nightobjs[];
#define DEFAULT_SAVE_FILE ".Bstar"
void blast __P((void));
void bury __P((void));
int card __P((const char *, int));
int checkout __P((const char *));
void chime __P((void));
void convert __P((int));
void crash __P((void));
int cypher __P((void));
void die __P((void)) __attribute__((__noreturn__));
void diesig __P((int)) __attribute__((__noreturn__));
void dig __P((void));
int draw __P((void));
void drink __P((void));
int drive __P((void));
int drop __P((const char *));
int eat __P((void));
void endfly __P((void));
int fight __P((int, int));
int follow __P((void));
void getutmp __P((char *));
int give __P((void));
int hash __P((const char *));
void initialize __P((const char *));
void install __P((struct wlist *));
int jump __P((void));
void kiss __P((void));
int land __P((void));
int launch __P((void));
void light __P((void));
void live __P((void)) __attribute__((__noreturn__));
void love __P((void));
int move __P((int, int));
void moveenemy __P((int));
void murder __P((void));
void news __P((void));
void newway __P((int));
void notarget __P((void));
void open_score_file __P((void));
void parse __P((void));
void post __P((char));
void printobjs __P((void));
int put __P((void));
int puton __P((void));
void ravage __P((void));
void restore __P((const char *, size_t));
int ride __P((void));
void save __P((const char *, size_t));
void screen __P((void));
int shoot __P((void));
void succumb __P((int));
int take __P((unsigned int[]));
int takeoff __P((void));
void target __P((void));
int throw __P((const char *));
int ucard __P((const unsigned int *));
int use __P((void));
int visual __P((void));
int wearit __P((void));
void whichway __P((struct room));
int wizard __P((const char *));
void wordinit __P((void));
void writedes __P((void));
int zzz __P((void));
char *getcom __P((char *, int, const char *, const char *));
char *getword __P((char *, char *, int));
const char *rate __P((void));
const char *truedirec __P((int, char));
struct wlist *lookup __P((const char *));

296
battlestar/fly.c Normal file
View File

@@ -0,0 +1,296 @@
/* $NetBSD: fly.c,v 1.6 1997/10/11 02:07:20 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)fly.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: fly.c,v 1.6 1997/10/11 02:07:20 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
#undef UP
#include <curses.h>
#define abs(a) ((a) < 0 ? -(a) : (a))
#define MIDR (LINES/2 - 1)
#define MIDC (COLS/2 - 1)
int row, column;
int dr = 0, dc = 0;
char destroyed;
int ourclock = 120; /* time for all the flights in the game */
char cross = 0;
sig_t oldsig;
void
succumb(dummy)
int dummy __attribute__((unused));
{
if (oldsig == SIG_DFL) {
endfly();
exit(1);
}
if (oldsig != SIG_IGN) {
endfly();
(*oldsig) (SIGINT);
}
}
int
visual()
{
destroyed = 0;
if (initscr() == NULL) {
puts("Whoops! No more memory...");
return (0);
}
oldsig = signal(SIGINT, succumb);
crmode();
noecho();
screen();
row = rnd(LINES - 3) + 1;
column = rnd(COLS - 2) + 1;
moveenemy(0);
for (;;) {
switch (getchar()) {
case 'h':
case 'r':
dc = -1;
fuel--;
break;
case 'H':
case 'R':
dc = -5;
fuel -= 10;
break;
case 'l':
dc = 1;
fuel--;
break;
case 'L':
dc = 5;
fuel -= 10;
break;
case 'j':
case 'u':
dr = 1;
fuel--;
break;
case 'J':
case 'U':
dr = 5;
fuel -= 10;
break;
case 'k':
case 'd':
dr = -1;
fuel--;
break;
case 'K':
case 'D':
dr = -5;
fuel -= 10;
break;
case '+':
if (cross) {
cross = 0;
notarget();
} else
cross = 1;
break;
case ' ':
case 'f':
if (torps) {
torps -= 2;
blast();
if (row == MIDR && column - MIDC < 2 && MIDC - column < 2) {
destroyed = 1;
alarm(0);
}
} else
mvaddstr(0, 0, "*** Out of torpedoes. ***");
break;
case 'q':
endfly();
return (0);
default:
mvaddstr(0, 26, "Commands = r,R,l,L,u,U,d,D,f,+,q");
continue;
case EOF:
break;
}
if (destroyed) {
endfly();
return (1);
}
if (ourclock <= 0) {
endfly();
die();
}
}
}
void
screen()
{
int r, c, n;
int i;
clear();
i = rnd(100);
for (n = 0; n < i; n++) {
r = rnd(LINES - 3) + 1;
c = rnd(COLS);
mvaddch(r, c, '.');
}
mvaddstr(LINES - 1 - 1, 21, "TORPEDOES FUEL TIME");
refresh();
}
void
target()
{
int n;
move(MIDR, MIDC - 10);
addstr("------- + -------");
for (n = MIDR - 4; n < MIDR - 1; n++) {
mvaddch(n, MIDC, '|');
mvaddch(n + 6, MIDC, '|');
}
}
void
notarget()
{
int n;
move(MIDR, MIDC - 10);
addstr(" ");
for (n = MIDR - 4; n < MIDR - 1; n++) {
mvaddch(n, MIDC, ' ');
mvaddch(n + 6, MIDC, ' ');
}
}
void
blast()
{
int n;
alarm(0);
move(LINES - 1, 24);
printw("%3d", torps);
for (n = LINES - 1 - 2; n >= MIDR + 1; n--) {
mvaddch(n, MIDC + MIDR - n, '/');
mvaddch(n, MIDC - MIDR + n, '\\');
refresh();
}
mvaddch(MIDR, MIDC, '*');
for (n = LINES - 1 - 2; n >= MIDR + 1; n--) {
mvaddch(n, MIDC + MIDR - n, ' ');
mvaddch(n, MIDC - MIDR + n, ' ');
refresh();
}
alarm(1);
}
void
moveenemy(dummy)
int dummy __attribute__((unused));
{
double d;
int oldr, oldc;
oldr = row;
oldc = column;
if (fuel > 0) {
if (row + dr <= LINES - 3 && row + dr > 0)
row += dr;
if (column + dc < COLS - 1 && column + dc > 0)
column += dc;
} else
if (fuel < 0) {
fuel = 0;
mvaddstr(0, 60, "*** Out of fuel ***");
}
d = (double) ((row - MIDR) * (row - MIDR) + (column - MIDC) * (column - MIDC));
if (d < 16) {
row += (rnd(9) - 4) % (4 - abs(row - MIDR));
column += (rnd(9) - 4) % (4 - abs(column - MIDC));
}
ourclock--;
mvaddstr(oldr, oldc - 1, " ");
if (cross)
target();
mvaddstr(row, column - 1, "/-\\");
move(LINES - 1, 24);
printw("%3d", torps);
move(LINES - 1, 42);
printw("%3d", fuel);
move(LINES - 1, 57);
printw("%3d", ourclock);
refresh();
signal(SIGALRM, moveenemy);
alarm(1);
}
void
endfly()
{
alarm(0);
signal(SIGALRM, SIG_DFL);
mvcur(0, COLS - 1, LINES - 1, 0);
endwin();
setvbuf(stdout, NULL, _IOLBF, BUFSIZ); /* Needed for ncurses */
signal(SIGTSTP, SIG_DFL);
signal(SIGINT, oldsig);
}

106
battlestar/getcom.c Normal file
View File

@@ -0,0 +1,106 @@
/* $NetBSD: getcom.c,v 1.5 1997/10/11 02:07:21 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)getcom.c 8.1 (Berkeley) 5/31/93";
#else
__RCSID("$NetBSD: getcom.c,v 1.5 1997/10/11 02:07:21 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
char *
getcom(buf, size, prompt, error)
char *buf;
int size;
const char *prompt, *error;
{
for (;;) {
fputs(prompt, stdout);
if (fgets(buf, size, stdin) == 0) {
clearerr(stdin);
continue;
}
while (isspace(*buf))
buf++;
if (*buf)
break;
if (error)
puts(error);
}
return (buf);
}
/*
* shifts to UPPERCASE if flag > 0, lowercase if flag < 0,
* and leaves it unchanged if flag = 0
*/
char *
getword(buf1, buf2, flag)
char *buf1, *buf2;
int flag;
{
while (isspace(*buf1))
buf1++;
if (*buf1 != ',') {
if (!*buf1) {
*buf2 = 0;
return (0);
}
while (*buf1 && !isspace(*buf1) && *buf1 != ',')
if (flag < 0)
if (isupper(*buf1))
*buf2++ = tolower(*buf1++);
else
*buf2++ = *buf1++;
else
if (flag > 0)
if (islower(*buf1))
*buf2++ = toupper(*buf1++);
else
*buf2++ = *buf1++;
else
*buf2++ = *buf1++;
} else
*buf2++ = *buf1++;
*buf2 = 0;
while (isspace(*buf1))
buf1++;
return (*buf1 ? buf1 : 0);
}

226
battlestar/globals.c Normal file
View File

@@ -0,0 +1,226 @@
/* $NetBSD: globals.c,v 1.6 1997/10/11 02:07:23 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)globals.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: globals.c,v 1.6 1997/10/11 02:07:23 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
int WEIGHT = MAXWEIGHT;
int CUMBER = MAXCUMBER;
const char *const objdes[NUMOFOBJECTS] = {
"There is a knife here",
"There is an exquisitely crafted sword and scabbard here.",
0, /* can land from here */
"There is a fierce woodsman here brandishing a heavy mallet.",
"There is an unweildly two-handed sword here.",
"There is a bloody meat cleaver here.",
"A rusty broadsword is lying here.",
"There is an ancient coat of finely woven mail here.",
"There is a old dented helmet with an ostrich plume here.",
"There is a shield of some native tribe here.",
"The maid's body is lying here. She was murdered!",
"There is a Viper ready for launch here.",
"A kerosene lantern is burning luridly here.",
"An old pair of shoes has been discarded here.",
0, /* cylon */
"There is a pair of pajamas here.",
"A kingly robe of royal purple and spun gold is draped here.",
"There is a strange golden amulet on the floor here.",
"A medallion of solid gold shimmers on the ground nearby.",
"A talisman of gold is lying here.",
"A dead woodsman has fallen here. He was savagely murdered.",
"A heavy wooden mallet lies nearby.",
"There is a laser pistol here.",
"A flower-like young goddess is bathing in the hot mineral pools. She is \nwatching you, but continues to steep and sing softly.",
"The goddess is reclining on a bed of ferns and studying you intently.",
"There is a grenade here",
"There is a length of heavy chain here.",
"There is a stout rope here.",
"There is a pair of Levi's here.",
"A bloody mace is lying on the ground here.",
"There is a shovel here.",
"A long, sharp halberd is propped up here.",
"There is a compass here",
"Wreckage and smoldering debris from a crash litter the ground here.",
"A woodland Elf armed with a shield and deadly halberd lunges toward you!",
"I think I hear footsteps behind us.",
"There are a few coins here.",
"There are some matches here.",
"An unctuous man in a white suit and a dwarf are standing here.",
"There are some ripe papayas here.",
"There is a ripe pineapple here.",
"There are some kiwi fruit here.",
"There are some coconuts here.",
"There is a ripe mango here.",
"There is a sparkling diamond ring here.",
"There is a colorful pink potion in a small crystal vial here.",
"A gold bracelet is on the ground here.",
"A swarthy woman with stern features pulls you aside from the crowd,\n'I must talk to you -- but not here. Meet me at midnight in the gardens.'",
"The swarthy woman has been awaiting you anxiousy. 'I must warn you that the\nIsland has anticipated your Quest. You will not be welcomed. The Darkness is\nstrong where you must search. Seek not the shadows save only at night, for\nthen are they the weakest. In the mountains far from here a canyon winds\nwith ferns and streams and forgotten vines. There you must go. Take this\nrope.'",
"Out from the shadows a figure leaps! His black cape swirls around, and he\nholds a laser sword at your chest. 'So, you have come to fulfill the Quest.\nHa! Your weapons are no match for me!'",
"An old timer with one eye missing and no money for a drink sits at the bar.",
"You are flying through an asteroid field!",
"A planet is nearby.",
"The ground is charred here.",
"There is a thermonuclear warhead here.",
"The fragile, beautiful young goddess lies here. You murdered her horribly.",
"The old timer is lying here. He is dead.",
"The native girl's body is lying here.",
"A native girl is sitting here.",
"A gorgeous white stallion is standing here.",
"The keys are in the ignition.",
"A pot of pearls and jewels is sitting here.",
"A bar of solid gold is here.",
"There is a 10 kilogram diamond block here."
};
const char *const objsht[NUMOFOBJECTS] = {
"knife",
"fine sword",
0,
"Woodsman",
"two-handed sword",
"meat cleaver",
"broadsword",
"coat of mail",
"plumed helmet",
"shield",
"maid's body",
"viper",
"lantern",
"shoes",
0,
"pajamas",
"robe",
"amulet",
"medallion",
"talisman",
"woodsman's body",
"wooden mallet",
"laser",
0,
0,
"grenade",
"chain",
"rope",
"levis",
"mace",
"shovel",
"halberd",
"compass",
0,
"Elf",
0,
"coins",
"match book",
0,
"papayas",
"pineapple",
"kiwi",
"coconuts",
"mango",
"ring",
"potion",
"bracelet",
0,
0,
"Dark Lord",
0,
0,
0,
0,
"warhead",
"goddess's body",
"old timer's body",
"girl's body",
0,
"stallion",
"car",
"pot of jewels",
"bar of gold",
"diamond block"
};
const char *const ouch[NUMOFINJURIES] = {
"some minor abrasions",
"some minor lacerations",
"a minor puncture wound",
"a minor amputation",
"a sprained wrist",
"a fractured ankle and shattered kneecap",
"a broken arm and dislocated shoulder",
"a few broken ribs",
"a broken leg and torn ligaments",
"a broken back and ruptured spleen",
"some deep incisions and a loss of blood",
"a fractured skull and mashed face",
"a broken neck"
};
const int objwt[NUMOFOBJECTS] = {
1, 5, 0, 10, 15, 2, 10, 10,
3, 5, 50, 2500, 2, 1, 100, 1,
2, 1, 1, 1, 60, 10, 5, 0,
50, 5, 15, 5, 1, 20, 10, 10,
0, 0, 0, 0, 1, 0, 0, 1,
1, 1, 2, 1, 0, 0, 0, 0,
0, 0, 100, 0, 0, 0, 55, 47,
50, 45, 45, 100, 2000, 30, 20, 10
};
const int objcumber[NUMOFOBJECTS] = {
1, 5, 0, 150, 10, 1, 5, 2,
2, 1, 5, 10, 1, 1, 10, 1,
1, 1, 1, 1, 7, 5, 4, 0,
0, 1, 1, 1, 1, 5, 4, 4,
1, 0, 0, 0, 1, 0, 0, 1,
1, 1, 3, 1, 0, 0, 1, 0,
0, 0, 10, 0, 0, 0, 7, 8,
10, 8, 8, 10, 10, 3, 1, 2
};
int win = 1;
int matchcount = 20;
int followgod = -1;
int followfight = -1;

138
battlestar/init.c Normal file
View File

@@ -0,0 +1,138 @@
/* $NetBSD: init.c,v 1.7 1997/10/11 02:07:25 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)init.c 8.4 (Berkeley) 4/30/95";
#else
__RCSID("$NetBSD: init.c,v 1.7 1997/10/11 02:07:25 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
void
initialize(startup)
const char *startup;
{
const struct objs *p;
puts("Version 4.2, fall 1984.");
puts("First Adventure game written by His Lordship, the honorable");
puts("Admiral D.W. Riggle\n");
location = dayfile;
srand(getpid());
getutmp(username);
wordinit();
if (startup == NULL) {
direction = NORTH;
ourtime = 0;
snooze = CYCLE * 1.5;
position = 22;
setbit(wear, PAJAMAS);
fuel = TANKFULL;
torps = TORPEDOES;
for (p = dayobjs; p->room != 0; p++)
setbit(location[p->room].objects, p->obj);
} else
restore(startup, strlen(startup));
wiz = wizard(username);
signal(SIGINT, diesig);
}
void
getutmp(uname)
char *uname;
{
struct passwd *ptr;
ptr = getpwuid(getuid());
strncpy(uname, ptr ? ptr->pw_name : "", 8);
}
const char *const list[] = { /* hereditary wizards */
"riggle",
"chris",
"edward",
"comay",
"yee",
"dmr",
"ken",
0
};
const char *const badguys[] = {
"wnj",
"root",
"ted",
0
};
int
wizard(uname)
const char *uname;
{
int flag;
if ((flag = checkout(uname)) != 0)
printf("You are the Great wizard %s.\n", uname);
return flag;
}
int
checkout(uname)
const char *uname;
{
const char *const *ptr;
for (ptr = list; *ptr; ptr++)
if (strcmp(*ptr, uname) == 0)
return 1;
for (ptr = badguys; *ptr; ptr++)
if (strcmp(*ptr, uname) == 0) {
printf("You are the Poor anti-wizard %s. Good Luck!\n",
uname);
CUMBER = 3;
WEIGHT = 9; /* that'll get him! */
ourclock = 10;
setbit(location[7].objects, WOODSMAN); /* viper room */
setbit(location[20].objects, WOODSMAN); /* laser " */
setbit(location[13].objects, DARK); /* amulet " */
setbit(location[8].objects, ELF); /* closet */
return 0; /* anything else, Chris? */
}
return 0;
}

71
battlestar/misc.c Normal file
View File

@@ -0,0 +1,71 @@
/* $NetBSD: misc.c,v 1.6 1997/10/11 02:07:27 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)misc.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: misc.c,v 1.6 1997/10/11 02:07:27 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
int
card(array, size) /* for beenthere, injuries */
const char *array;
int size;
{
const char *end = array + size;
int i = 0;
while (array < end)
if (*array++)
i++;
return (i);
}
int
ucard(array)
const unsigned int *array;
{
int j = 0, n;
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(array, n))
j++;
return (j);
}

1184
battlestar/nightfile.c Normal file

File diff suppressed because it is too large Load Diff

107
battlestar/nightobjs.c Normal file
View File

@@ -0,0 +1,107 @@
/* $NetBSD: nightobjs.c,v 1.6 1997/10/11 02:07:31 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)nightobjs.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: nightobjs.c,v 1.6 1997/10/11 02:07:31 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
const struct objs nightobjs[] = {
{218, PAJAMAS},
{235, NATIVE},
{92, PAPAYAS},
{92, PINEAPPLE},
{92, KIWI},
{92, MANGO},
{92, NATIVE},
{92, MAN},
{181, LAMPON},
{236, LAMPON},
{92, LAMPON},
{216, WOODSMAN},
{216, DEADWOOD},
{216, MALLET},
{168, WOODSMAN},
{168, DEADWOOD},
{168, MALLET},
{170, WOODSMAN},
{170, DEADWOOD},
{170, MALLET},
{124, SHIELD},
{124, HALBERD},
{124, ELF},
{144, SHIELD},
{144, HALBERD},
{144, ELF},
{113, SHIELD},
{113, HALBERD},
{113, ELF},
{161, SHIELD},
{161, HALBERD},
{161, ELF},
{169, SHIELD},
{169, HALBERD},
{169, ELF},
{182, SHIELD},
{182, HALBERD},
{182, ELF},
{198, SHIELD},
{198, HALBERD},
{198, ELF},
{212, SHIELD},
{212, HALBERD},
{212, ELF},
{216, SHIELD},
{216, HALBERD},
{216, ELF},
{226, SHIELD},
{226, HALBERD},
{226, ELF},
{228, SHIELD},
{228, HALBERD},
{228, ELF},
{68, CYLON},
{144, SHOVEL},
{249, FOOT},
{250, FOOT},
{93, PAPAYAS},
{0, 0}
};

112
battlestar/parse.c Normal file
View File

@@ -0,0 +1,112 @@
/* $NetBSD: parse.c,v 1.6 1997/10/11 02:07:33 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)parse.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: parse.c,v 1.6 1997/10/11 02:07:33 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
void
wordinit()
{
struct wlist *w;
for (w = wlist; w->string; w++)
install(w);
}
int
hash(s)
const char *s;
{
int hashval = 0;
while (*s) {
hashval += *s++;
hashval *= HASHMUL;
hashval &= HASHMASK;
}
return hashval;
}
struct wlist *
lookup(s)
const char *s;
{
struct wlist *wp;
for (wp = hashtab[hash(s)]; wp != NULL; wp = wp->next)
if (*s == *wp->string && strcmp(s, wp->string) == 0)
return wp;
return NULL;
}
void
install(wp)
struct wlist *wp;
{
int hashval;
if (lookup(wp->string) == NULL) {
hashval = hash(wp->string);
wp->next = hashtab[hashval];
hashtab[hashval] = wp;
} else
printf("Multiply defined %s.\n", wp->string);
}
void
parse()
{
struct wlist *wp;
int n;
wordnumber = 0; /* for cypher */
for (n = 0; n <= wordcount; n++) {
if ((wp = lookup(words[n])) == NULL) {
wordvalue[n] = -1;
wordtype[n] = -1;
} else {
wordvalue[n] = wp->value;
wordtype[n] = wp->article;
}
}
}

38
battlestar/pathnames.h.in Normal file
View File

@@ -0,0 +1,38 @@
/* $NetBSD: pathnames.h,v 1.3 1995/03/21 15:07:51 cgd Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)pathnames.h 8.1 (Berkeley) 5/31/93
*/
#define _PATH_SCORE "@battlestar_scorefile@"

241
battlestar/room.c Normal file
View File

@@ -0,0 +1,241 @@
/* $NetBSD: room.c,v 1.6 1997/10/11 02:07:35 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)room.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: room.c,v 1.6 1997/10/11 02:07:35 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
void
writedes()
{
int compass;
const char *p;
int c;
printf("\n\t%s\n", location[position].name);
if (beenthere[position] < 3) {
compass = NORTH;
for (p = location[position].desc; (c = *p++) != 0;)
if (c != '-' && c != '*' && c != '+')
putchar(c);
else {
if (c != '*')
printf(truedirec(compass, c));
compass++;
}
}
}
void
printobjs()
{
unsigned int *p = location[position].objects;
int n;
printf("\n");
for (n = 0; n < NUMOFOBJECTS; n++)
if (testbit(p, n) && objdes[n])
puts(objdes[n]);
}
void
whichway(here)
struct room here;
{
switch (direction) {
case NORTH:
left = here.west;
right = here.east;
ahead = here.north;
back = here.south;
break;
case SOUTH:
left = here.east;
right = here.west;
ahead = here.south;
back = here.north;
break;
case EAST:
left = here.north;
right = here.south;
ahead = here.east;
back = here.west;
break;
case WEST:
left = here.south;
right = here.north;
ahead = here.west;
back = here.east;
break;
}
}
const char *
truedirec(way, option)
int way;
char option;
{
switch (way) {
case NORTH:
switch (direction) {
case NORTH:
return ("ahead");
case SOUTH:
return (option == '+' ? "behind you" :
"back");
case EAST:
return ("left");
case WEST:
return ("right");
}
case SOUTH:
switch (direction) {
case NORTH:
return (option == '+' ? "behind you" :
"back");
case SOUTH:
return ("ahead");
case EAST:
return ("right");
case WEST:
return ("left");
}
case EAST:
switch (direction) {
case NORTH:
return ("right");
case SOUTH:
return ("left");
case EAST:
return ("ahead");
case WEST:
return (option == '+' ? "behind you" :
"back");
}
case WEST:
switch (direction) {
case NORTH:
return ("left");
case SOUTH:
return ("right");
case EAST:
return (option == '+' ? "behind you" :
"back");
case WEST:
return ("ahead");
}
default:
printf("Error: room %d. More than four directions wanted.", position);
return ("!!");
}
}
void
newway(thisway)
int thisway;
{
switch (direction) {
case NORTH:
switch (thisway) {
case LEFT:
direction = WEST;
break;
case RIGHT:
direction = EAST;
break;
case BACK:
direction = SOUTH;
break;
}
break;
case SOUTH:
switch (thisway) {
case LEFT:
direction = EAST;
break;
case RIGHT:
direction = WEST;
break;
case BACK:
direction = NORTH;
break;
}
break;
case EAST:
switch (thisway) {
case LEFT:
direction = NORTH;
break;
case RIGHT:
direction = SOUTH;
break;
case BACK:
direction = WEST;
break;
}
break;
case WEST:
switch (thisway) {
case LEFT:
direction = SOUTH;
break;
case RIGHT:
direction = NORTH;
break;
case BACK:
direction = EAST;
break;
}
break;
}
}

211
battlestar/save.c Normal file
View File

@@ -0,0 +1,211 @@
/* $NetBSD: save.c,v 1.8 1998/09/13 15:24:41 hubertf Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)save.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: save.c,v 1.8 1998/09/13 15:24:41 hubertf Exp $");
#endif
#endif /* not lint */
#include "extern.h"
void
restore(filename, len)
const char *filename;
size_t len;
{
char *home;
char *home1;
int n;
int tmp;
size_t tmpl;
FILE *fp;
if (memchr(filename, '/', len)) {
home1 = malloc(len + 1);
if (home1 == NULL)
errx(1, "out of memory");
memcpy(home1, filename, len);
home1[len] = 0;
} else {
home = getenv("HOME");
if (home != NULL) {
tmpl = strlen(home);
home1 = malloc(tmpl + len + 2);
if (home1 == NULL)
errx(1, "out of memory");
memcpy(home1, home, tmpl);
home1[tmpl] = '/';
memcpy(home1 + tmpl + 1, filename, len);
home1[tmpl + len + 1] = 0;
} else {
home1 = malloc(len + 1);
if (home1 == NULL)
errx(1, "out of memory");
memcpy(home1, filename, len);
home1[len] = 0;
}
}
if ((fp = fopen(home1, "r")) == 0) {
err(1, "fopen %s", home1);
}
fread(&WEIGHT, sizeof WEIGHT, 1, fp);
fread(&CUMBER, sizeof CUMBER, 1, fp);
fread(&ourclock, sizeof ourclock, 1, fp);
fread(&tmp, sizeof tmp, 1, fp);
location = tmp ? dayfile : nightfile;
for (n = 1; n <= NUMOFROOMS; n++) {
fread(location[n].link, sizeof location[n].link, 1, fp);
fread(location[n].objects, sizeof location[n].objects, 1, fp);
}
fread(inven, sizeof inven, 1, fp);
fread(wear, sizeof wear, 1, fp);
fread(injuries, sizeof injuries, 1, fp);
fread(notes, sizeof notes, 1, fp);
fread(&direction, sizeof direction, 1, fp);
fread(&position, sizeof position, 1, fp);
fread(&ourtime, sizeof ourtime, 1, fp);
fread(&fuel, sizeof fuel, 1, fp);
fread(&torps, sizeof torps, 1, fp);
fread(&carrying, sizeof carrying, 1, fp);
fread(&encumber, sizeof encumber, 1, fp);
fread(&rythmn, sizeof rythmn, 1, fp);
fread(&followfight, sizeof followfight, 1, fp);
fread(&ate, sizeof ate, 1, fp);
fread(&snooze, sizeof snooze, 1, fp);
fread(&meetgirl, sizeof meetgirl, 1, fp);
fread(&followgod, sizeof followgod, 1, fp);
fread(&godready, sizeof godready, 1, fp);
fread(&win, sizeof win, 1, fp);
fread(&wintime, sizeof wintime, 1, fp);
fread(&matchlight, sizeof matchlight, 1, fp);
fread(&matchcount, sizeof matchcount, 1, fp);
fread(&loved, sizeof loved, 1, fp);
fread(&pleasure, sizeof pleasure, 1, fp);
fread(&power, sizeof power, 1, fp);
/* We must check the last read, to catch truncated save files */
if (fread(&ego, sizeof ego, 1, fp) < 1)
errx(1, "save file %s too short", home1);
fclose(fp);
free(home1);
}
void
save(filename, len)
const char *filename;
size_t len;
{
char *home;
char *home1;
int n;
int tmp;
size_t tmpl;
FILE *fp;
if (memchr(filename, '/', len)) {
home1 = malloc(len + 1);
if (home1 == NULL)
errx(1, "out of memory");
memcpy(home1, filename, len);
home1[len] = 0;
} else {
home = getenv("HOME");
if (home != NULL) {
tmpl = strlen(home);
home1 = malloc(tmpl + len + 2);
if (home1 == NULL)
errx(1, "out of memory");
memcpy(home1, home, tmpl);
home1[tmpl] = '/';
memcpy(home1 + tmpl + 1, filename, len);
home1[tmpl + len + 1] = 0;
} else {
home1 = malloc(len + 1);
if (home1 == NULL)
errx(1, "out of memory");
memcpy(home1, filename, len);
home1[len] = 0;
}
}
if ((fp = fopen(home1, "w")) == NULL) {
warn("fopen %s", home1);
return;
}
printf("Saved in %s.\n", home1);
fwrite(&WEIGHT, sizeof WEIGHT, 1, fp);
fwrite(&CUMBER, sizeof CUMBER, 1, fp);
fwrite(&ourclock, sizeof ourclock, 1, fp);
tmp = location == dayfile;
fwrite(&tmp, sizeof tmp, 1, fp);
for (n = 1; n <= NUMOFROOMS; n++) {
fwrite(location[n].link, sizeof location[n].link, 1, fp);
fwrite(location[n].objects, sizeof location[n].objects, 1, fp);
}
fwrite(inven, sizeof inven, 1, fp);
fwrite(wear, sizeof wear, 1, fp);
fwrite(injuries, sizeof injuries, 1, fp);
fwrite(notes, sizeof notes, 1, fp);
fwrite(&direction, sizeof direction, 1, fp);
fwrite(&position, sizeof position, 1, fp);
fwrite(&ourtime, sizeof ourtime, 1, fp);
fwrite(&fuel, sizeof fuel, 1, fp);
fwrite(&torps, sizeof torps, 1, fp);
fwrite(&carrying, sizeof carrying, 1, fp);
fwrite(&encumber, sizeof encumber, 1, fp);
fwrite(&rythmn, sizeof rythmn, 1, fp);
fwrite(&followfight, sizeof followfight, 1, fp);
fwrite(&ate, sizeof ate, 1, fp);
fwrite(&snooze, sizeof snooze, 1, fp);
fwrite(&meetgirl, sizeof meetgirl, 1, fp);
fwrite(&followgod, sizeof followgod, 1, fp);
fwrite(&godready, sizeof godready, 1, fp);
fwrite(&win, sizeof win, 1, fp);
fwrite(&wintime, sizeof wintime, 1, fp);
fwrite(&matchlight, sizeof matchlight, 1, fp);
fwrite(&matchcount, sizeof matchcount, 1, fp);
fwrite(&loved, sizeof loved, 1, fp);
fwrite(&pleasure, sizeof pleasure, 1, fp);
fwrite(&power, sizeof power, 1, fp);
fwrite(&ego, sizeof ego, 1, fp);
fflush(fp);
if (ferror(fp))
warn("fwrite %s", home1);
fclose(fp);
free(home1);
}

213
battlestar/words.c Normal file
View File

@@ -0,0 +1,213 @@
/* $NetBSD: words.c,v 1.6 1997/10/11 02:07:39 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)words.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: words.c,v 1.6 1997/10/11 02:07:39 lukem Exp $");
#endif
#endif /* not lint */
#include "extern.h"
struct wlist wlist[] = {
{"knife", KNIFE, OBJECT},
{"sword", SWORD, NOUNS},
{"scabbard", SWORD, OBJECT},
{"fine", SWORD, OBJECT},
{"two-handed", TWO_HANDED, OBJECT},
{"cleaver", CLEAVER, OBJECT},
{"broadsword", BROAD, OBJECT},
{"mail", MAIL, OBJECT},
{"coat", MAIL, OBJECT},
{"helmet", HELM, OBJECT},
{"shield", SHIELD, OBJECT},
{"maid", MAID, OBJECT},
{"maid's", MAID, OBJECT},
{"body", BODY, NOUNS},
{"viper", VIPER, OBJECT},
{"lamp", LAMPON, OBJECT},
{"lantern", LAMPON, OBJECT},
{"shoes", SHOES, OBJECT},
{"pajamas", PAJAMAS, OBJECT},
{"robe", ROBE, OBJECT},
{"amulet", AMULET, NOUNS},
{"medallion", MEDALION, NOUNS},
{"talisman", TALISMAN, NOUNS},
{"woodsman", DEADWOOD, OBJECT},
{"woodsman's", DEADWOOD, OBJECT},
{"mallet", MALLET, OBJECT},
{"laser", LASER, OBJECT},
{"pistol", LASER, OBJECT},
{"blaster", LASER, OBJECT},
{"gun", LASER, OBJECT},
{"goddess", NORMGOD, NOUNS},
{"grenade", GRENADE, OBJECT},
{"chain", CHAIN, OBJECT},
{"rope", ROPE, OBJECT},
{"levis", LEVIS, OBJECT},
{"pants", LEVIS, OBJECT},
{"mace", MACE, OBJECT},
{"shovel", SHOVEL, OBJECT},
{"halberd", HALBERD, OBJECT},
{"compass", COMPASS, OBJECT},
{"elf", ELF, OBJECT},
{"coins", COINS, OBJECT},
{"matches", MATCHES, OBJECT},
{"match", MATCHES, OBJECT},
{"book", MATCHES, OBJECT},
{"man", MAN, NOUNS},
{"papayas", PAPAYAS, OBJECT},
{"pineapple", PINEAPPLE, OBJECT},
{"kiwi", KIWI, OBJECT},
{"coconuts", COCONUTS, OBJECT},
{"mango", MANGO, OBJECT},
{"ring", RING, OBJECT},
{"potion", POTION, OBJECT},
{"bracelet", BRACELET, OBJECT},
{"timer", TIMER, NOUNS},
{"bomb", BOMB, OBJECT},
{"warhead", BOMB, OBJECT},
{"girl", NATIVE, NOUNS},
{"native", NATIVE, NOUNS},
{"horse", HORSE, OBJECT},
{"stallion", HORSE, OBJECT},
{"car", CAR, OBJECT},
{"volare", CAR, OBJECT},
{"pot", POT, OBJECT},
{"jewels", POT, OBJECT},
{"bar", BAR, OBJECT},
{"diamond", BLOCK, OBJECT},
{"block", BLOCK, OBJECT},
{"up", UP, VERB},
{"u", UP, VERB},
{"down", DOWN, VERB},
{"d", DOWN, VERB},
{"ahead", AHEAD, VERB},
{"a", AHEAD, VERB},
{"back", BACK, VERB},
{"b", BACK, VERB},
{"right", RIGHT, VERB},
{"r", RIGHT, VERB},
{"left", LEFT, VERB},
{"l", LEFT, VERB},
{"take", TAKE, VERB},
{"get", TAKE, VERB},
{"use", USE, VERB},
{"look", LOOK, VERB},
{"lo", LOOK, VERB},
{"quit", QUIT, VERB},
{"q", QUIT, VERB},
{"su", SU, VERB},
{"drop", DROP, VERB},
{"draw", DRAW, VERB},
{"pull", DRAW, VERB},
{"carry", DRAW, VERB},
{"wear", WEARIT, VERB},
{"sheathe", WEARIT, VERB},
{"put", PUT, VERB},
{"buckle", PUT, VERB},
{"strap", PUT, VERB},
{"tie", PUT, VERB},
{"inven", INVEN, VERB},
{"i", INVEN, VERB},
{"everything", EVERYTHING, OBJECT},
{"all", EVERYTHING, OBJECT},
{"and", AND, CONJ},
{"kill", KILL, VERB},
{"fight", KILL, VERB},
{"ravage", RAVAGE, VERB},
{"rape", RAVAGE, VERB},
{"undress", UNDRESS, VERB},
{"throw", THROW, VERB},
{"launch", LAUNCH, VERB},
{"land", LANDIT, VERB},
{"light", LIGHT, VERB},
{"strike", LIGHT, VERB},
{"follow", FOLLOW, VERB},
{"chase", FOLLOW, VERB},
{"kiss", KISS, VERB},
{"love", LOVE, VERB},
{"fuck", LOVE, VERB},
{"give", GIVE, VERB},
{"smite", SMITE, VERB},
{"attack", SMITE, VERB},
{"swing", SMITE, VERB},
{"stab", SMITE, VERB},
{"slice", SMITE, VERB},
{"cut", SMITE, VERB},
{"hack", SMITE, VERB},
{"shoot", SHOOT, VERB},
{"blast", SHOOT, VERB},
{"on", ON, PREPS},
{"off", OFF, PREPS},
{"time", TIME, VERB},
{"sleep", SLEEP, VERB},
{"dig", DIG, VERB},
{"eat", EAT, VERB},
{"swim", SWIM, VERB},
{"drink", DRINK, VERB},
{"door", DOOR, NOUNS},
{"save", SAVE, VERB},
{"ride", RIDE, VERB},
{"mount", RIDE, VERB},
{"drive", DRIVE, VERB},
{"start", DRIVE, VERB},
{"score", SCORE, VERB},
{"points", SCORE, VERB},
{"bury", BURY, VERB},
{"jump", JUMP, VERB},
{"kick", KICK, VERB},
{"kerosene", 0, ADJS},
{"plumed", 0, ADJS},
{"ancient", 0, ADJS},
{"golden", 0, ADJS},
{"gold", 0, ADJS},
{"ostrich", 0, ADJS},
{"rusty", 0, ADJS},
{"old", 0, ADJS},
{"dented", 0, ADJS},
{"blue", 0, ADJS},
{"purple", 0, ADJS},
{"kingly", 0, ADJS},
{"the", 0, ADJS},
{"climb", 0, ADJS},
{"move", 0, ADJS},
{"make", 0, ADJS},
{"to", 0, ADJS},
{0}
};