-/* $NetBSD: com4.c,v 1.6 1997/10/11 02:07:04 lukem Exp $ */
+/* $NetBSD: com4.c,v 1.17 2000/09/24 09:46:57 jsm Exp $ */
/*
* Copyright (c) 1983, 1993
#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 $");
+__RCSID("$NetBSD: com4.c,v 1.17 2000/09/24 09:46:57 jsm Exp $");
#endif
#endif /* not lint */
unsigned int from[];
{
int firstnumber, heavy, bulky, value;
- int n;
firstnumber = wordnumber;
if (wordnumber < wordcount && wordvalue[wordnumber + 1] == OFF) {
wordvalue[wordnumber] = TAKEOFF;
return (cypher());
} else {
- while (wordtype[++wordnumber] == ADJS);
+ wordnumber++;
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)) {
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]);
+ } else if (testbit(inven, value))
+ printf("You're already holding%s%s.\n",
+ (is_plural_object(value) ? " " : " a "),
+ objsht[value]);
+ else if (!testbit(from, value))
+ printf("I don't see any %s around here.\n", objsht[value]);
+ else if (!heavy)
+ printf("The %s %s too heavy.\n", objsht[value],
+ (is_plural_object(value) ? "are" : "is"));
+ else
+ printf("The %s %s too cumbersome to hold.\n",
+ objsht[value],
+ (is_plural_object(value) ? "are" : "is"));
if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
wordnumber++;
else
wordvalue[wordnumber] = MAID;
wordtype[wordnumber--] = OBJECT;
return (take(from));
- } else
- if (testbit(from, DEADWOOD)) {
- wordvalue[wordnumber] = DEADWOOD;
+ } 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
- 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));
- }
+ } 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.");
+ puts("and sharper but far away as if in a dream. The sound of purling water");
+ puts("reaches you from afar. The mist falls again, and your heart leaps in horror.");
+ puts("The gold freezes your hands and fathomless darkness engulfs your soul.");
}
wordtype[wordnumber--] = OBJECT;
return (take(from));
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.");
+ puts("She bids you to follow her, and walks away.");
pleasure++;
followgod = ourtime;
clearbit(location[position].objects, BATHGOD);
int
throw(name)
- char *name;
+ const char *name;
{
- int n;
+ unsigned int n;
int deposit = 0;
int first, value;
deposit = location[position].down;
break;
}
- wordnumber = first;
- while (wordtype[++wordnumber] == ADJS);
+ wordnumber = first + 1;
while (wordnumber <= wordcount) {
value = wordvalue[wordnumber];
if (deposit && testbit(location[position].objects, value)) {
int
drop(name)
- char *name;
+ const char *name;
{
int firstnumber, value;
firstnumber = wordnumber;
- while (wordtype[++wordnumber] == ADJS);
+ wordnumber++;
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);
+ if (value == BODY) { /* special case */
+ wordtype[wordnumber] = OBJECT;
+ if (testbit(inven, MAID) || testbit(location[position].objects, MAID))
+ value = MAID;
+ else if (testbit(inven, DEADWOOD) || testbit(location[position].objects, DEADWOOD))
+ value = DEADWOOD;
+ else if (testbit(inven, DEADGOD) || testbit(location[position].objects, DEADGOD))
+ value = DEADGOD;
+ else if (testbit(inven, DEADTIME) || testbit(location[position].objects, DEADTIME))
+ value = DEADTIME;
+ else if (testbit(inven, DEADNATIVE) || testbit(location[position].objects, DEADNATIVE))
+ value = DEADNATIVE;
+ }
+ if (wordtype[wordnumber] == NOUNS && value == DOOR) {
+ if (*name == 'K')
+ puts("You hurt your foot.");
else
- tempwiz = 0;
- ourtime++;
+ puts("You're not holding a door.");
+ } else if (objsht[value] == NULL) {
if (*name == 'K')
- puts("Drop kicked.");
+ puts("That's not for kicking!");
else
- printf("%s.\n", name);
+ puts("You don't have that.");
} 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.");
+ 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();
}
- } else
- puts("Kicked.");
+ 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 if (testbit(location[position].objects, value))
+ puts("Kicked.");
+ else if (testbit(wear, value))
+ puts("Not while it's being worn.");
+ else
+ puts("Not found.");
+ }
}
if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
wordnumber++;
int firstnumber, value;
firstnumber = wordnumber;
- while (wordtype[++wordnumber] == ADJS);
+ wordnumber++;
while (wordnumber <= wordcount) {
value = wordvalue[wordnumber];
+ if (wordtype[wordnumber] != OBJECT || objsht[value] == NULL)
+ value = -2;
switch (value) {
+ case -2:
+ puts("You can't eat that!");
+ return (firstnumber);
+
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]);
+ is_plural_object(value) ? " " : " a ",
+ objsht[value]);
return (firstnumber);
case PAPAYAS:
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]);
+ } else if (!testbit(inven, value))
+ printf("You aren't holding the %s.\n", objsht[value]);
+ else if (!testbit(inven, KNIFE))
+ puts("You need a knife.");
+ else
+ puts("You're stuffed.");
if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
wordnumber++;
else