2005-07-01 10:04:46 +04:00
|
|
|
/* $NetBSD: command3.c,v 1.3 2005/07/01 06:04:54 jmc Exp $ */
|
1995-03-21 18:03:38 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1995-03-21 18:03:38 +03:00
|
|
|
* Copyright (c) 1983, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* 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.
|
2003-08-07 13:36:50 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
1997-10-10 15:39:08 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef lint
|
1995-03-21 18:03:38 +03:00
|
|
|
#if 0
|
1997-01-07 14:56:32 +03:00
|
|
|
static char sccsid[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95";
|
1995-03-21 18:03:38 +03:00
|
|
|
#else
|
2005-07-01 10:04:46 +04:00
|
|
|
__RCSID("$NetBSD: command3.c,v 1.3 2005/07/01 06:04:54 jmc Exp $");
|
1995-03-21 18:03:38 +03:00
|
|
|
#endif
|
1997-10-11 06:06:55 +04:00
|
|
|
#endif /* not lint */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-01-07 14:56:32 +03:00
|
|
|
#include "extern.h"
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-10 15:39:08 +04:00
|
|
|
void
|
2005-07-01 10:04:46 +04:00
|
|
|
dig(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-11 06:06:55 +04:00
|
|
|
if (testbit(inven, SHOVEL)) {
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("OK");
|
1997-10-10 15:39:08 +04:00
|
|
|
ourtime++;
|
1997-10-11 06:06:55 +04:00
|
|
|
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;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
default:
|
|
|
|
puts("Nothing happens.");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-11 06:06:55 +04:00
|
|
|
} else
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("You don't have a shovel.");
|
|
|
|
}
|
|
|
|
|
1997-10-10 15:39:08 +04:00
|
|
|
int
|
2005-07-01 10:04:46 +04:00
|
|
|
jump(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-11 06:06:55 +04:00
|
|
|
int n;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
switch (position) {
|
|
|
|
default:
|
|
|
|
puts("Nothing happens.");
|
|
|
|
return (-1);
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
case 242:
|
|
|
|
position = 133;
|
|
|
|
break;
|
|
|
|
case 214:
|
|
|
|
case 215:
|
|
|
|
case 162:
|
|
|
|
case 159:
|
|
|
|
position = 145;
|
|
|
|
break;
|
|
|
|
case 232:
|
2000-09-25 04:33:18 +04:00
|
|
|
position = FINAL;
|
1997-10-11 06:06:55 +04:00
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
position = 1;
|
|
|
|
break;
|
|
|
|
case 172:
|
|
|
|
position = 201;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
puts("Ahhhhhhh...");
|
|
|
|
injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1;
|
1997-10-11 06:06:55 +04:00
|
|
|
for (n = 0; n < NUMOFOBJECTS; n++)
|
|
|
|
if (testbit(inven, n)) {
|
|
|
|
clearbit(inven, n);
|
|
|
|
setbit(location[position].objects, n);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
carrying = 0;
|
|
|
|
encumber = 0;
|
1997-10-11 06:06:55 +04:00
|
|
|
return (0);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
1997-10-10 15:39:08 +04:00
|
|
|
void
|
2005-07-01 10:04:46 +04:00
|
|
|
bury(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-11 06:06:55 +04:00
|
|
|
int value;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
if (testbit(inven, SHOVEL)) {
|
2005-07-01 10:04:46 +04:00
|
|
|
while (wordtype[++wordnumber] != OBJECT &&
|
|
|
|
wordtype[wordnumber] != NOUNS && wordnumber < wordcount)
|
2000-09-24 18:20:23 +04:00
|
|
|
continue;
|
1993-03-21 12:45:37 +03:00
|
|
|
value = wordvalue[wordnumber];
|
2005-07-01 10:04:46 +04:00
|
|
|
if (wordtype[wordnumber] == NOUNS &&
|
|
|
|
(testbit(location[position].objects, value) ||
|
|
|
|
value == BODY))
|
1997-10-11 06:06:55 +04:00
|
|
|
switch (value) {
|
|
|
|
case BODY:
|
|
|
|
wordtype[wordnumber] = OBJECT;
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(inven, MAID) ||
|
|
|
|
testbit(location[position].objects, MAID))
|
1997-10-11 06:06:55 +04:00
|
|
|
value = MAID;
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(inven, DEADWOOD) ||
|
|
|
|
testbit(location[position].objects,
|
|
|
|
DEADWOOD))
|
1997-10-11 06:06:55 +04:00
|
|
|
value = DEADWOOD;
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(inven, DEADGOD) ||
|
|
|
|
testbit(location[position].objects,
|
|
|
|
DEADGOD))
|
1997-10-11 06:06:55 +04:00
|
|
|
value = DEADGOD;
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(inven, DEADTIME) ||
|
|
|
|
testbit(location[position].objects,
|
|
|
|
DEADTIME))
|
1997-10-11 06:06:55 +04:00
|
|
|
value = DEADTIME;
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(inven, DEADNATIVE) ||
|
|
|
|
testbit(location[position].objects,
|
|
|
|
DEADNATIVE))
|
1997-10-11 06:06:55 +04:00
|
|
|
value = DEADNATIVE;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
case NATIVE:
|
|
|
|
case NORMGOD:
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("She screams as you wrestle her into ");
|
|
|
|
puts("the hole.");
|
1997-10-11 06:06:55 +04:00
|
|
|
case TIMER:
|
|
|
|
power += 7;
|
|
|
|
ego -= 10;
|
|
|
|
case AMULET:
|
|
|
|
case MEDALION:
|
|
|
|
case TALISMAN:
|
|
|
|
wordtype[wordnumber] = OBJECT;
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
default:
|
|
|
|
puts("Wha..?");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
2005-07-01 10:04:46 +04:00
|
|
|
if (wordtype[wordnumber] == OBJECT && position > 88 &&
|
|
|
|
(testbit(inven, value) ||
|
|
|
|
testbit(location[position].objects, value))) {
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("Buried.");
|
1997-10-11 06:06:55 +04:00
|
|
|
if (testbit(inven, value)) {
|
|
|
|
clearbit(inven, value);
|
1993-03-21 12:45:37 +03:00
|
|
|
carrying -= objwt[value];
|
|
|
|
encumber -= objcumber[value];
|
|
|
|
}
|
1997-10-11 06:06:55 +04:00
|
|
|
clearbit(location[position].objects, value);
|
|
|
|
switch (value) {
|
|
|
|
case MAID:
|
|
|
|
case DEADWOOD:
|
|
|
|
case DEADNATIVE:
|
|
|
|
case DEADTIME:
|
|
|
|
case DEADGOD:
|
|
|
|
ego += 2;
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("The %s should rest easier now.\n",
|
|
|
|
objsht[value]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-11 06:06:55 +04:00
|
|
|
} else
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("It doesn't seem to work.");
|
1997-10-11 06:06:55 +04:00
|
|
|
} else
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("You aren't holding a shovel.");
|
|
|
|
}
|
|
|
|
|
1997-10-10 15:39:08 +04:00
|
|
|
void
|
2005-07-01 10:04:46 +04:00
|
|
|
drink(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-11 06:06:55 +04:00
|
|
|
int n;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
if (testbit(inven, POTION)) {
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("The cool liquid runs down your throat but turns to ");
|
|
|
|
puts("fire and you choke.");
|
|
|
|
printf("The heat reaches your limbs and tingles your spirit.");
|
|
|
|
puts(" You feel like falling");
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("asleep.");
|
|
|
|
clearbit(inven, POTION);
|
|
|
|
WEIGHT = MAXWEIGHT;
|
|
|
|
CUMBER = MAXCUMBER;
|
1997-10-11 06:06:55 +04:00
|
|
|
for (n = 0; n < NUMOFINJURIES; n++)
|
1993-03-21 12:45:37 +03:00
|
|
|
injuries[n] = 0;
|
1997-10-10 15:39:08 +04:00
|
|
|
ourtime++;
|
1993-03-21 12:45:37 +03:00
|
|
|
zzz();
|
1997-10-11 06:06:55 +04:00
|
|
|
} else
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("I'm not thirsty.");
|
|
|
|
}
|
|
|
|
|
1997-10-10 15:39:08 +04:00
|
|
|
int
|
2005-07-01 10:04:46 +04:00
|
|
|
shoot(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1997-10-11 06:06:55 +04:00
|
|
|
int firstnumber, value;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1998-08-24 04:19:25 +04:00
|
|
|
firstnumber = wordnumber;
|
1997-10-11 06:06:55 +04:00
|
|
|
if (!testbit(inven, LASER))
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("You aren't holding a blaster.");
|
|
|
|
else {
|
2000-09-22 12:19:21 +04:00
|
|
|
wordnumber++;
|
2005-07-01 10:04:46 +04:00
|
|
|
while (wordnumber <= wordcount &&
|
|
|
|
wordtype[wordnumber] == OBJECT) {
|
1993-03-21 12:45:37 +03:00
|
|
|
value = wordvalue[wordnumber];
|
|
|
|
printf("%s:\n", objsht[value]);
|
1997-10-11 06:06:55 +04:00
|
|
|
if (testbit(location[position].objects, value)) {
|
|
|
|
clearbit(location[position].objects, value);
|
1997-10-10 15:39:08 +04:00
|
|
|
ourtime++;
|
2000-09-23 23:23:57 +04:00
|
|
|
printf("The %s explode%s\n", objsht[value],
|
|
|
|
(is_plural_object(value) ? "." : "s."));
|
1993-03-21 12:45:37 +03:00
|
|
|
if (value == BOMB)
|
|
|
|
die();
|
1997-10-11 06:06:55 +04:00
|
|
|
} else
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("I don't see any %s around here.\n",
|
|
|
|
objsht[value]);
|
|
|
|
if (wordnumber < wordcount - 1 &&
|
|
|
|
wordvalue[++wordnumber] == AND)
|
1993-03-21 12:45:37 +03:00
|
|
|
wordnumber++;
|
|
|
|
else
|
1997-10-11 06:06:55 +04:00
|
|
|
return (firstnumber);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-11 06:06:55 +04:00
|
|
|
/* special cases with their own return()'s */
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) {
|
1997-10-10 15:39:08 +04:00
|
|
|
ourtime++;
|
1997-10-11 06:06:55 +04:00
|
|
|
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]);
|
1993-03-21 12:45:37 +03:00
|
|
|
break;
|
1997-10-11 06:06:55 +04:00
|
|
|
case 30:
|
|
|
|
puts("The wooden door splinters.");
|
|
|
|
location[30].west = 25;
|
|
|
|
whichway(location[position]);
|
|
|
|
break;
|
|
|
|
case 31:
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("The laser blast has no ");
|
|
|
|
puts("effect on the door.");
|
1997-10-11 06:06:55 +04:00
|
|
|
break;
|
|
|
|
case 20:
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("The blast hits the door and ");
|
|
|
|
printf("it explodes into flame. The ");
|
|
|
|
puts("magnesium burns");
|
|
|
|
printf("so rapidly that we have no ");
|
|
|
|
puts("chance to escape.");
|
1997-10-11 06:06:55 +04:00
|
|
|
die();
|
|
|
|
default:
|
|
|
|
puts("Nothing happens.");
|
|
|
|
}
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
case NORMGOD:
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(location[position].objects,
|
|
|
|
BATHGOD)) {
|
|
|
|
printf("The goddess is hit in the ");
|
|
|
|
printf("chest and splashes back ");
|
|
|
|
puts("against the rocks.");
|
|
|
|
printf("Dark blood oozes from the ");
|
|
|
|
printf("charred blast hole. Her ");
|
|
|
|
puts("naked body floats in the");
|
1997-10-11 06:06:55 +04:00
|
|
|
puts("pools and then off downstream.");
|
2005-07-01 10:04:46 +04:00
|
|
|
clearbit(location[position].objects,
|
|
|
|
BATHGOD);
|
1997-10-11 06:06:55 +04:00
|
|
|
setbit(location[180].objects, DEADGOD);
|
|
|
|
power += 5;
|
|
|
|
ego -= 10;
|
|
|
|
notes[JINXED]++;
|
|
|
|
} else
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(location[position].objects,
|
|
|
|
NORMGOD)) {
|
|
|
|
printf("The blast catches ");
|
|
|
|
printf("the goddess in the ");
|
|
|
|
printf("stomach, knocking ");
|
|
|
|
puts("her to the ground.");
|
|
|
|
printf("She writhes in the ");
|
|
|
|
printf("dirt as the agony of ");
|
|
|
|
puts("death taunts her.");
|
1993-03-21 12:45:37 +03:00
|
|
|
puts("She has stopped moving.");
|
1997-10-11 06:06:55 +04:00
|
|
|
clearbit(location[position].objects, NORMGOD);
|
|
|
|
setbit(location[position].objects, DEADGOD);
|
1993-03-21 12:45:37 +03:00
|
|
|
power += 5;
|
|
|
|
ego -= 10;
|
|
|
|
notes[JINXED]++;
|
|
|
|
if (wintime)
|
|
|
|
live();
|
|
|
|
break;
|
|
|
|
} else
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("I don't see any ");
|
|
|
|
puts("goddess around here.");
|
1997-10-11 06:06:55 +04:00
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
case TIMER:
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(location[position].objects,
|
|
|
|
TIMER)) {
|
|
|
|
printf("The old man slumps over ");
|
|
|
|
puts("the bar.");
|
1997-10-11 06:06:55 +04:00
|
|
|
power++;
|
|
|
|
ego -= 2;
|
|
|
|
notes[JINXED]++;
|
2005-07-01 10:04:46 +04:00
|
|
|
clearbit(location[position].objects,
|
|
|
|
TIMER);
|
|
|
|
setbit(location[position].objects,
|
|
|
|
DEADTIME);
|
1997-10-11 06:06:55 +04:00
|
|
|
} else
|
2000-09-10 14:51:16 +04:00
|
|
|
puts("What old-timer?");
|
1997-10-11 06:06:55 +04:00
|
|
|
break;
|
|
|
|
case MAN:
|
|
|
|
if (testbit(location[position].objects, MAN)) {
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("The man falls to the ground ");
|
|
|
|
printf("with blood pouring all over ");
|
|
|
|
puts("his white suit.");
|
1997-10-11 06:06:55 +04:00
|
|
|
puts("Your fantasy is over.");
|
|
|
|
die();
|
|
|
|
} else
|
|
|
|
puts("What man?");
|
|
|
|
break;
|
|
|
|
case NATIVE:
|
2005-07-01 10:04:46 +04:00
|
|
|
if (testbit(location[position].objects,
|
|
|
|
NATIVE)) {
|
|
|
|
printf("The girl is blown backwards ");
|
|
|
|
printf("several feet and lies in a ");
|
|
|
|
puts("pool of blood.");
|
|
|
|
clearbit(location[position].objects,
|
|
|
|
NATIVE);
|
|
|
|
setbit(location[position].objects,
|
|
|
|
DEADNATIVE);
|
1997-10-11 06:06:55 +04:00
|
|
|
power += 5;
|
|
|
|
ego -= 2;
|
|
|
|
notes[JINXED]++;
|
|
|
|
} else
|
|
|
|
puts("There is no girl here.");
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
puts("Shoot what?");
|
|
|
|
break;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1997-10-11 06:06:55 +04:00
|
|
|
default:
|
2005-07-01 10:04:46 +04:00
|
|
|
printf("You can't shoot the %s.\n",
|
|
|
|
objsht[wordvalue[wordnumber]]);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-11 06:06:55 +04:00
|
|
|
} else
|
|
|
|
puts("You must be a looney.");
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1997-10-11 06:06:55 +04:00
|
|
|
return (firstnumber);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|