Home | History | Annotate | Line # | Download | only in battlestar
command2.c revision 1.1
      1  1.1  tv /*	$NetBSD: command2.c,v 1.1 2001/10/19 03:06:11 tv Exp $	*/
      2  1.1  tv 
      3  1.1  tv /*
      4  1.1  tv  * Copyright (c) 1983, 1993
      5  1.1  tv  *	The Regents of the University of California.  All rights reserved.
      6  1.1  tv  *
      7  1.1  tv  * Redistribution and use in source and binary forms, with or without
      8  1.1  tv  * modification, are permitted provided that the following conditions
      9  1.1  tv  * are met:
     10  1.1  tv  * 1. Redistributions of source code must retain the above copyright
     11  1.1  tv  *    notice, this list of conditions and the following disclaimer.
     12  1.1  tv  * 2. Redistributions in binary form must reproduce the above copyright
     13  1.1  tv  *    notice, this list of conditions and the following disclaimer in the
     14  1.1  tv  *    documentation and/or other materials provided with the distribution.
     15  1.1  tv  * 3. All advertising materials mentioning features or use of this software
     16  1.1  tv  *    must display the following acknowledgement:
     17  1.1  tv  *	This product includes software developed by the University of
     18  1.1  tv  *	California, Berkeley and its contributors.
     19  1.1  tv  * 4. Neither the name of the University nor the names of its contributors
     20  1.1  tv  *    may be used to endorse or promote products derived from this software
     21  1.1  tv  *    without specific prior written permission.
     22  1.1  tv  *
     23  1.1  tv  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24  1.1  tv  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25  1.1  tv  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26  1.1  tv  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27  1.1  tv  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28  1.1  tv  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29  1.1  tv  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30  1.1  tv  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31  1.1  tv  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32  1.1  tv  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33  1.1  tv  * SUCH DAMAGE.
     34  1.1  tv  */
     35  1.1  tv 
     36  1.1  tv #include <sys/cdefs.h>
     37  1.1  tv #ifndef lint
     38  1.1  tv #if 0
     39  1.1  tv static char sccsid[] = "@(#)com2.c	8.2 (Berkeley) 4/28/95";
     40  1.1  tv #else
     41  1.1  tv __RCSID("$NetBSD: command2.c,v 1.1 2001/10/19 03:06:11 tv Exp $");
     42  1.1  tv #endif
     43  1.1  tv #endif				/* not lint */
     44  1.1  tv 
     45  1.1  tv #include "extern.h"
     46  1.1  tv 
     47  1.1  tv int
     48  1.1  tv wearit()
     49  1.1  tv {				/* synonyms = {sheathe, sheath} */
     50  1.1  tv 	int     firstnumber, value;
     51  1.1  tv 
     52  1.1  tv 	firstnumber = wordnumber;
     53  1.1  tv 	wordnumber++;
     54  1.1  tv 	while (wordnumber <= wordcount && (wordtype[wordnumber] == OBJECT ||
     55  1.1  tv 	    wordtype[wordnumber] == NOUNS) && wordvalue[wordnumber] != DOOR) {
     56  1.1  tv 		value = wordvalue[wordnumber];
     57  1.1  tv 		if (value >= 0 && objsht[value] == NULL)
     58  1.1  tv 			break;
     59  1.1  tv 		switch (value) {
     60  1.1  tv 
     61  1.1  tv 		case -1:
     62  1.1  tv 			puts("Wear what?");
     63  1.1  tv 			return (firstnumber);
     64  1.1  tv 
     65  1.1  tv 		default:
     66  1.1  tv 			printf("You can't wear %s%s!\n",
     67  1.1  tv 			    A_OR_AN_OR_BLANK(value), objsht[value]);
     68  1.1  tv 			return (firstnumber);
     69  1.1  tv 
     70  1.1  tv 		case KNIFE:
     71  1.1  tv 			/* case SHIRT:	 */
     72  1.1  tv 		case ROBE:
     73  1.1  tv 		case LEVIS:	/* wearable things */
     74  1.1  tv 		case SWORD:
     75  1.1  tv 		case MAIL:
     76  1.1  tv 		case HELM:
     77  1.1  tv 		case SHOES:
     78  1.1  tv 		case PAJAMAS:
     79  1.1  tv 		case COMPASS:
     80  1.1  tv 		case LASER:
     81  1.1  tv 		case AMULET:
     82  1.1  tv 		case TALISMAN:
     83  1.1  tv 		case MEDALION:
     84  1.1  tv 		case ROPE:
     85  1.1  tv 		case RING:
     86  1.1  tv 		case BRACELET:
     87  1.1  tv 		case GRENADE:
     88  1.1  tv 
     89  1.1  tv 			if (testbit(inven, value)) {
     90  1.1  tv 				clearbit(inven, value);
     91  1.1  tv 				setbit(wear, value);
     92  1.1  tv 				carrying -= objwt[value];
     93  1.1  tv 				encumber -= objcumber[value];
     94  1.1  tv 				ourtime++;
     95  1.1  tv 				printf("You are now wearing %s%s.\n",
     96  1.1  tv 				    A_OR_AN_OR_THE(value), objsht[value]);
     97  1.1  tv 			} else
     98  1.1  tv 				if (testbit(wear, value))
     99  1.1  tv 					printf("You are already wearing the %s.\n",
    100  1.1  tv 					    objsht[value]);
    101  1.1  tv 				else
    102  1.1  tv 					printf("You aren't holding the %s.\n",
    103  1.1  tv 					    objsht[value]);
    104  1.1  tv 			if (wordnumber < wordcount - 1 &&
    105  1.1  tv 			    wordvalue[++wordnumber] == AND)
    106  1.1  tv 				wordnumber++;
    107  1.1  tv 			else
    108  1.1  tv 				return (firstnumber);
    109  1.1  tv 		}		/* end switch */
    110  1.1  tv 	}			/* end while */
    111  1.1  tv 	puts("Don't be ridiculous.");
    112  1.1  tv 	return (firstnumber);
    113  1.1  tv }
    114  1.1  tv 
    115  1.1  tv int
    116  1.1  tv put()
    117  1.1  tv {				/* synonyms = {buckle, strap, tie} */
    118  1.1  tv 	if (wordvalue[wordnumber + 1] == ON) {
    119  1.1  tv 		wordvalue[++wordnumber] = PUTON;
    120  1.1  tv 		wordtype[wordnumber] = VERB;
    121  1.1  tv 		return (cypher());
    122  1.1  tv 	}
    123  1.1  tv 	if (wordvalue[wordnumber + 1] == DOWN) {
    124  1.1  tv 		wordvalue[++wordnumber] = DROP;
    125  1.1  tv 		wordtype[wordnumber] = VERB;
    126  1.1  tv 		return (cypher());
    127  1.1  tv 	}
    128  1.1  tv 	puts("I don't understand what you want to put.");
    129  1.1  tv 	return (-1);
    130  1.1  tv 
    131  1.1  tv }
    132  1.1  tv 
    133  1.1  tv int
    134  1.1  tv draw()
    135  1.1  tv {				/* synonyms = {pull, carry} */
    136  1.1  tv 	return (take(wear));
    137  1.1  tv }
    138  1.1  tv 
    139  1.1  tv int
    140  1.1  tv use()
    141  1.1  tv {
    142  1.1  tv 	wordnumber++;
    143  1.1  tv 	if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) &&
    144  1.1  tv 	    position != FINAL) {
    145  1.1  tv 		puts("The amulet begins to glow.");
    146  1.1  tv 		if (testbit(inven, MEDALION)) {
    147  1.1  tv 			puts("The medallion comes to life too.");
    148  1.1  tv 			if (position == 114) {
    149  1.1  tv 				location[position].down = 160;
    150  1.1  tv 				whichway(location[position]);
    151  1.1  tv 				puts("The waves subside and it is possible to descend to the sea cave now.");
    152  1.1  tv 				ourtime++;
    153  1.1  tv 				return (-1);
    154  1.1  tv 			}
    155  1.1  tv 		}
    156  1.1  tv 		puts("A light mist falls over your eyes and the sound of purling water trickles in");
    157  1.1  tv 		puts("your ears.   When the mist lifts you are standing beside a cool stream.");
    158  1.1  tv 		if (position == 229)
    159  1.1  tv 			position = 224;
    160  1.1  tv 		else
    161  1.1  tv 			position = 229;
    162  1.1  tv 		ourtime++;
    163  1.1  tv 		notes[CANTSEE] = 0;
    164  1.1  tv 		return (0);
    165  1.1  tv 	} else if (position == FINAL)
    166  1.1  tv 		puts("The amulet won't work in here.");
    167  1.1  tv 	else if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS))
    168  1.1  tv 		printf("Your compass points %s.\n", truedirec(NORTH, '-'));
    169  1.1  tv 	else if (wordvalue[wordnumber] == COMPASS)
    170  1.1  tv 		puts("You aren't holding the compass.");
    171  1.1  tv 	else if (wordvalue[wordnumber] == AMULET)
    172  1.1  tv 		puts("You aren't holding the amulet.");
    173  1.1  tv 	else
    174  1.1  tv 		puts("There is no apparent use.");
    175  1.1  tv 	return (-1);
    176  1.1  tv }
    177  1.1  tv 
    178  1.1  tv void
    179  1.1  tv murder()
    180  1.1  tv {
    181  1.1  tv 	int     n;
    182  1.1  tv 
    183  1.1  tv 	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++);
    184  1.1  tv 	if (n == NUMOFOBJECTS) {
    185  1.1  tv 		if (testbit(inven, LASER)) {
    186  1.1  tv 			printf("Your laser should do the trick.\n");
    187  1.1  tv 			wordnumber++;
    188  1.1  tv 			switch(wordvalue[wordnumber]) {
    189  1.1  tv 			case NORMGOD:
    190  1.1  tv 			case TIMER:
    191  1.1  tv 			case NATIVE:
    192  1.1  tv 			case MAN:
    193  1.1  tv 				wordvalue[--wordnumber] = SHOOT;
    194  1.1  tv 				cypher();
    195  1.1  tv 				break;
    196  1.1  tv 			case -1:
    197  1.1  tv 				puts("Kill what?");
    198  1.1  tv 				break;
    199  1.1  tv 			default:
    200  1.1  tv 				if (wordtype[wordnumber] != OBJECT ||
    201  1.1  tv 				    wordvalue[wordnumber] == EVERYTHING)
    202  1.1  tv 					puts("You can't kill that!");
    203  1.1  tv 				else
    204  1.1  tv 					printf("You can't kill %s%s!\n",
    205  1.1  tv 					    A_OR_AN_OR_BLANK(wordvalue[wordnumber]),
    206  1.1  tv 					    objsht[wordvalue[wordnumber]]);
    207  1.1  tv 				break;
    208  1.1  tv 			}
    209  1.1  tv 		} else
    210  1.1  tv 			puts("You don't have suitable weapons to kill.");
    211  1.1  tv 	} else {
    212  1.1  tv 		printf("Your %s should do the trick.\n", objsht[n]);
    213  1.1  tv 		wordnumber++;
    214  1.1  tv 		switch (wordvalue[wordnumber]) {
    215  1.1  tv 
    216  1.1  tv 		case NORMGOD:
    217  1.1  tv 			if (testbit(location[position].objects, BATHGOD)) {
    218  1.1  tv 				puts("The goddess's head slices off.  Her corpse floats in the water.");
    219  1.1  tv 				clearbit(location[position].objects, BATHGOD);
    220  1.1  tv 				setbit(location[position].objects, DEADGOD);
    221  1.1  tv 				power += 5;
    222  1.1  tv 				notes[JINXED]++;
    223  1.1  tv 			} else
    224  1.1  tv 				if (testbit(location[position].objects, NORMGOD)) {
    225  1.1  tv 					puts("The goddess pleads but you strike her mercilessly.  Her broken body lies in a\npool of blood.");
    226  1.1  tv 					clearbit(location[position].objects, NORMGOD);
    227  1.1  tv 					setbit(location[position].objects, DEADGOD);
    228  1.1  tv 					power += 5;
    229  1.1  tv 					notes[JINXED]++;
    230  1.1  tv 					if (wintime)
    231  1.1  tv 						live();
    232  1.1  tv 				} else
    233  1.1  tv 					puts("I don't see her anywhere.");
    234  1.1  tv 			break;
    235  1.1  tv 		case TIMER:
    236  1.1  tv 			if (testbit(location[position].objects, TIMER)) {
    237  1.1  tv 				puts("The old man offers no resistance.");
    238  1.1  tv 				clearbit(location[position].objects, TIMER);
    239  1.1  tv 				setbit(location[position].objects, DEADTIME);
    240  1.1  tv 				power++;
    241  1.1  tv 				notes[JINXED]++;
    242  1.1  tv 			} else
    243  1.1  tv 				puts("Who?");
    244  1.1  tv 			break;
    245  1.1  tv 		case NATIVE:
    246  1.1  tv 			if (testbit(location[position].objects, NATIVE)) {
    247  1.1  tv 				puts("The girl screams as you cut her body to shreds.  She is dead.");
    248  1.1  tv 				clearbit(location[position].objects, NATIVE);
    249  1.1  tv 				setbit(location[position].objects, DEADNATIVE);
    250  1.1  tv 				power += 5;
    251  1.1  tv 				notes[JINXED]++;
    252  1.1  tv 			} else
    253  1.1  tv 				puts("What girl?");
    254  1.1  tv 			break;
    255  1.1  tv 		case MAN:
    256  1.1  tv 			if (testbit(location[position].objects, MAN)) {
    257  1.1  tv 				puts("You strike him to the ground, and he coughs up blood.");
    258  1.1  tv 				puts("Your fantasy is over.");
    259  1.1  tv 				die();
    260  1.1  tv 			}
    261  1.1  tv 		case -1:
    262  1.1  tv 			puts("Kill what?");
    263  1.1  tv 			break;
    264  1.1  tv 
    265  1.1  tv 		default:
    266  1.1  tv 			if (wordtype[wordnumber] != OBJECT ||
    267  1.1  tv 			    wordvalue[wordnumber] == EVERYTHING)
    268  1.1  tv 				puts("You can't kill that!");
    269  1.1  tv 			else
    270  1.1  tv 				printf("You can't kill the %s!\n",
    271  1.1  tv 				    objsht[wordvalue[wordnumber]]);
    272  1.1  tv 		}
    273  1.1  tv 	}
    274  1.1  tv }
    275  1.1  tv 
    276  1.1  tv void
    277  1.1  tv ravage()
    278  1.1  tv {
    279  1.1  tv 	while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
    280  1.1  tv 		continue;
    281  1.1  tv 	if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, wordvalue[wordnumber])
    282  1.1  tv 	    || (wordvalue[wordnumber] == NORMGOD && testbit(location[position].objects, BATHGOD)))) {
    283  1.1  tv 		ourtime++;
    284  1.1  tv 		switch (wordvalue[wordnumber]) {
    285  1.1  tv 		case NORMGOD:
    286  1.1  tv 			puts("You attack the goddess, and she screams as you beat her.  She falls down");
    287  1.1  tv 			if (testbit(location[position].objects, BATHGOD))
    288  1.1  tv 				puts("crying and tries to cover her nakedness.");
    289  1.1  tv 			else
    290  1.1  tv 				puts("crying and tries to hold her torn and bloodied dress around her.");
    291  1.1  tv 			power += 5;
    292  1.1  tv 			pleasure += 8;
    293  1.1  tv 			ego -= 10;
    294  1.1  tv 			wordnumber--;
    295  1.1  tv 			godready = -30000;
    296  1.1  tv 			murder();
    297  1.1  tv 			win = -30000;
    298  1.1  tv 			break;
    299  1.1  tv 		case NATIVE:
    300  1.1  tv 			puts("The girl tries to run, but you catch her and throw her down.  Her face is");
    301  1.1  tv 			puts("bleeding, and she screams as you tear off her clothes.");
    302  1.1  tv 			power += 3;
    303  1.1  tv 			pleasure += 5;
    304  1.1  tv 			ego -= 10;
    305  1.1  tv 			wordnumber--;
    306  1.1  tv 			murder();
    307  1.1  tv 			if (rnd(100) < 50) {
    308  1.1  tv 				puts("Her screams have attracted attention.  I think we are surrounded.");
    309  1.1  tv 				setbit(location[ahead].objects, WOODSMAN);
    310  1.1  tv 				setbit(location[ahead].objects, DEADWOOD);
    311  1.1  tv 				setbit(location[ahead].objects, MALLET);
    312  1.1  tv 				setbit(location[back].objects, WOODSMAN);
    313  1.1  tv 				setbit(location[back].objects, DEADWOOD);
    314  1.1  tv 				setbit(location[back].objects, MALLET);
    315  1.1  tv 				setbit(location[left].objects, WOODSMAN);
    316  1.1  tv 				setbit(location[left].objects, DEADWOOD);
    317  1.1  tv 				setbit(location[left].objects, MALLET);
    318  1.1  tv 				setbit(location[right].objects, WOODSMAN);
    319  1.1  tv 				setbit(location[right].objects, DEADWOOD);
    320  1.1  tv 				setbit(location[right].objects, MALLET);
    321  1.1  tv 			}
    322  1.1  tv 			break;
    323  1.1  tv 		default:
    324  1.1  tv 			puts("You are perverted.");
    325  1.1  tv 		}
    326  1.1  tv 	} else
    327  1.1  tv 		puts("Who?");
    328  1.1  tv }
    329  1.1  tv 
    330  1.1  tv int
    331  1.1  tv follow()
    332  1.1  tv {
    333  1.1  tv 	if (followfight == ourtime) {
    334  1.1  tv 		puts("The Dark Lord leaps away and runs down secret tunnels and corridors.");
    335  1.1  tv 		puts("You chase him through the darkness and splash in pools of water.");
    336  1.1  tv 		puts("You have cornered him.  His laser sword extends as he steps forward.");
    337  1.1  tv 		position = FINAL;
    338  1.1  tv 		fight(DARK, 75);
    339  1.1  tv 		setbit(location[position].objects, TALISMAN);
    340  1.1  tv 		setbit(location[position].objects, AMULET);
    341  1.1  tv 		return (0);
    342  1.1  tv 	} else
    343  1.1  tv 		if (followgod == ourtime) {
    344  1.1  tv 			puts("The goddess leads you down a steamy tunnel and into a high, wide chamber.");
    345  1.1  tv 			puts("She sits down on a throne.");
    346  1.1  tv 			position = 268;
    347  1.1  tv 			setbit(location[position].objects, NORMGOD);
    348  1.1  tv 			notes[CANTSEE] = 1;
    349  1.1  tv 			return (0);
    350  1.1  tv 		} else
    351  1.1  tv 			puts("There is no one to follow.");
    352  1.1  tv 	return (-1);
    353  1.1  tv }
    354