Home | History | Annotate | Line # | Download | only in battlestar
command3.c revision 1.1
      1  1.1  tv /*	$NetBSD: command3.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[] = "@(#)com3.c	8.2 (Berkeley) 4/28/95";
     40  1.1  tv #else
     41  1.1  tv __RCSID("$NetBSD: command3.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 void
     48  1.1  tv dig()
     49  1.1  tv {
     50  1.1  tv 	if (testbit(inven, SHOVEL)) {
     51  1.1  tv 		puts("OK");
     52  1.1  tv 		ourtime++;
     53  1.1  tv 		switch (position) {
     54  1.1  tv 		case 144:	/* copse near beach */
     55  1.1  tv 			if (!notes[DUG]) {
     56  1.1  tv 				setbit(location[position].objects, DEADWOOD);
     57  1.1  tv 				setbit(location[position].objects, COMPASS);
     58  1.1  tv 				setbit(location[position].objects, KNIFE);
     59  1.1  tv 				setbit(location[position].objects, MACE);
     60  1.1  tv 				notes[DUG] = 1;
     61  1.1  tv 			}
     62  1.1  tv 			break;
     63  1.1  tv 
     64  1.1  tv 		default:
     65  1.1  tv 			puts("Nothing happens.");
     66  1.1  tv 		}
     67  1.1  tv 	} else
     68  1.1  tv 		puts("You don't have a shovel.");
     69  1.1  tv }
     70  1.1  tv 
     71  1.1  tv int
     72  1.1  tv jump()
     73  1.1  tv {
     74  1.1  tv 	int     n;
     75  1.1  tv 
     76  1.1  tv 	switch (position) {
     77  1.1  tv 	default:
     78  1.1  tv 		puts("Nothing happens.");
     79  1.1  tv 		return (-1);
     80  1.1  tv 
     81  1.1  tv 	case 242:
     82  1.1  tv 		position = 133;
     83  1.1  tv 		break;
     84  1.1  tv 	case 214:
     85  1.1  tv 	case 215:
     86  1.1  tv 	case 162:
     87  1.1  tv 	case 159:
     88  1.1  tv 		position = 145;
     89  1.1  tv 		break;
     90  1.1  tv 	case 232:
     91  1.1  tv 		position = FINAL;
     92  1.1  tv 		break;
     93  1.1  tv 	case 3:
     94  1.1  tv 		position = 1;
     95  1.1  tv 		break;
     96  1.1  tv 	case 172:
     97  1.1  tv 		position = 201;
     98  1.1  tv 	}
     99  1.1  tv 	puts("Ahhhhhhh...");
    100  1.1  tv 	injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1;
    101  1.1  tv 	for (n = 0; n < NUMOFOBJECTS; n++)
    102  1.1  tv 		if (testbit(inven, n)) {
    103  1.1  tv 			clearbit(inven, n);
    104  1.1  tv 			setbit(location[position].objects, n);
    105  1.1  tv 		}
    106  1.1  tv 	carrying = 0;
    107  1.1  tv 	encumber = 0;
    108  1.1  tv 	return (0);
    109  1.1  tv }
    110  1.1  tv 
    111  1.1  tv void
    112  1.1  tv bury()
    113  1.1  tv {
    114  1.1  tv 	int     value;
    115  1.1  tv 
    116  1.1  tv 	if (testbit(inven, SHOVEL)) {
    117  1.1  tv 		while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount)
    118  1.1  tv 			continue;
    119  1.1  tv 		value = wordvalue[wordnumber];
    120  1.1  tv 		if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, value) || value == BODY))
    121  1.1  tv 			switch (value) {
    122  1.1  tv 			case BODY:
    123  1.1  tv 				wordtype[wordnumber] = OBJECT;
    124  1.1  tv 				if (testbit(inven, MAID) || testbit(location[position].objects, MAID))
    125  1.1  tv 					value = MAID;
    126  1.1  tv 				if (testbit(inven, DEADWOOD) || testbit(location[position].objects, DEADWOOD))
    127  1.1  tv 					value = DEADWOOD;
    128  1.1  tv 				if (testbit(inven, DEADGOD) || testbit(location[position].objects, DEADGOD))
    129  1.1  tv 					value = DEADGOD;
    130  1.1  tv 				if (testbit(inven, DEADTIME) || testbit(location[position].objects, DEADTIME))
    131  1.1  tv 					value = DEADTIME;
    132  1.1  tv 				if (testbit(inven, DEADNATIVE) || testbit(location[position].objects, DEADNATIVE))
    133  1.1  tv 					value = DEADNATIVE;
    134  1.1  tv 				break;
    135  1.1  tv 
    136  1.1  tv 			case NATIVE:
    137  1.1  tv 			case NORMGOD:
    138  1.1  tv 				puts("She screams as you wrestle her into the hole.");
    139  1.1  tv 			case TIMER:
    140  1.1  tv 				power += 7;
    141  1.1  tv 				ego -= 10;
    142  1.1  tv 			case AMULET:
    143  1.1  tv 			case MEDALION:
    144  1.1  tv 			case TALISMAN:
    145  1.1  tv 				wordtype[wordnumber] = OBJECT;
    146  1.1  tv 				break;
    147  1.1  tv 
    148  1.1  tv 			default:
    149  1.1  tv 				puts("Wha..?");
    150  1.1  tv 			}
    151  1.1  tv 		if (wordtype[wordnumber] == OBJECT && position > 88 && (testbit(inven, value) || testbit(location[position].objects, value))) {
    152  1.1  tv 			puts("Buried.");
    153  1.1  tv 			if (testbit(inven, value)) {
    154  1.1  tv 				clearbit(inven, value);
    155  1.1  tv 				carrying -= objwt[value];
    156  1.1  tv 				encumber -= objcumber[value];
    157  1.1  tv 			}
    158  1.1  tv 			clearbit(location[position].objects, value);
    159  1.1  tv 			switch (value) {
    160  1.1  tv 			case MAID:
    161  1.1  tv 			case DEADWOOD:
    162  1.1  tv 			case DEADNATIVE:
    163  1.1  tv 			case DEADTIME:
    164  1.1  tv 			case DEADGOD:
    165  1.1  tv 				ego += 2;
    166  1.1  tv 				printf("The %s should rest easier now.\n", objsht[value]);
    167  1.1  tv 			}
    168  1.1  tv 		} else
    169  1.1  tv 			puts("It doesn't seem to work.");
    170  1.1  tv 	} else
    171  1.1  tv 		puts("You aren't holding a shovel.");
    172  1.1  tv }
    173  1.1  tv 
    174  1.1  tv void
    175  1.1  tv drink()
    176  1.1  tv {
    177  1.1  tv 	int     n;
    178  1.1  tv 
    179  1.1  tv 	if (testbit(inven, POTION)) {
    180  1.1  tv 		puts("The cool liquid runs down your throat but turns to fire and you choke.");
    181  1.1  tv 		puts("The heat reaches your limbs and tingles your spirit.  You feel like falling");
    182  1.1  tv 		puts("asleep.");
    183  1.1  tv 		clearbit(inven, POTION);
    184  1.1  tv 		WEIGHT = MAXWEIGHT;
    185  1.1  tv 		CUMBER = MAXCUMBER;
    186  1.1  tv 		for (n = 0; n < NUMOFINJURIES; n++)
    187  1.1  tv 			injuries[n] = 0;
    188  1.1  tv 		ourtime++;
    189  1.1  tv 		zzz();
    190  1.1  tv 	} else
    191  1.1  tv 		puts("I'm not thirsty.");
    192  1.1  tv }
    193  1.1  tv 
    194  1.1  tv int
    195  1.1  tv shoot()
    196  1.1  tv {
    197  1.1  tv 	int     firstnumber, value;
    198  1.1  tv 
    199  1.1  tv 	firstnumber = wordnumber;
    200  1.1  tv 	if (!testbit(inven, LASER))
    201  1.1  tv 		puts("You aren't holding a blaster.");
    202  1.1  tv 	else {
    203  1.1  tv 		wordnumber++;
    204  1.1  tv 		while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
    205  1.1  tv 			value = wordvalue[wordnumber];
    206  1.1  tv 			printf("%s:\n", objsht[value]);
    207  1.1  tv 			if (testbit(location[position].objects, value)) {
    208  1.1  tv 				clearbit(location[position].objects, value);
    209  1.1  tv 				ourtime++;
    210  1.1  tv 				printf("The %s explode%s\n", objsht[value],
    211  1.1  tv 				    (is_plural_object(value) ? "." : "s."));
    212  1.1  tv 				if (value == BOMB)
    213  1.1  tv 					die();
    214  1.1  tv 			} else
    215  1.1  tv 				printf("I don't see any %s around here.\n", objsht[value]);
    216  1.1  tv 			if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
    217  1.1  tv 				wordnumber++;
    218  1.1  tv 			else
    219  1.1  tv 				return (firstnumber);
    220  1.1  tv 		}
    221  1.1  tv 		/* special cases with their own return()'s */
    222  1.1  tv 
    223  1.1  tv 		if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) {
    224  1.1  tv 			ourtime++;
    225  1.1  tv 			switch (wordvalue[wordnumber]) {
    226  1.1  tv 
    227  1.1  tv 			case DOOR:
    228  1.1  tv 				switch (position) {
    229  1.1  tv 				case 189:
    230  1.1  tv 				case 231:
    231  1.1  tv 					puts("The door is unhinged.");
    232  1.1  tv 					location[189].north = 231;
    233  1.1  tv 					location[231].south = 189;
    234  1.1  tv 					whichway(location[position]);
    235  1.1  tv 					break;
    236  1.1  tv 				case 30:
    237  1.1  tv 					puts("The wooden door splinters.");
    238  1.1  tv 					location[30].west = 25;
    239  1.1  tv 					whichway(location[position]);
    240  1.1  tv 					break;
    241  1.1  tv 				case 31:
    242  1.1  tv 					puts("The laser blast has no effect on the door.");
    243  1.1  tv 					break;
    244  1.1  tv 				case 20:
    245  1.1  tv 					puts("The blast hits the door and it explodes into flame.  The magnesium burns");
    246  1.1  tv 					puts("so rapidly that we have no chance to escape.");
    247  1.1  tv 					die();
    248  1.1  tv 				default:
    249  1.1  tv 					puts("Nothing happens.");
    250  1.1  tv 				}
    251  1.1  tv 				break;
    252  1.1  tv 
    253  1.1  tv 			case NORMGOD:
    254  1.1  tv 				if (testbit(location[position].objects, BATHGOD)) {
    255  1.1  tv 					puts("The goddess is hit in the chest and splashes back against the rocks.");
    256  1.1  tv 					puts("Dark blood oozes from the charred blast hole.  Her naked body floats in the");
    257  1.1  tv 					puts("pools and then off downstream.");
    258  1.1  tv 					clearbit(location[position].objects, BATHGOD);
    259  1.1  tv 					setbit(location[180].objects, DEADGOD);
    260  1.1  tv 					power += 5;
    261  1.1  tv 					ego -= 10;
    262  1.1  tv 					notes[JINXED]++;
    263  1.1  tv 				} else
    264  1.1  tv 					if (testbit(location[position].objects, NORMGOD)) {
    265  1.1  tv 						puts("The blast catches the goddess in the stomach, knocking her to the ground.");
    266  1.1  tv 						puts("She writhes in the dirt as the agony of death taunts her.");
    267  1.1  tv 						puts("She has stopped moving.");
    268  1.1  tv 						clearbit(location[position].objects, NORMGOD);
    269  1.1  tv 						setbit(location[position].objects, DEADGOD);
    270  1.1  tv 						power += 5;
    271  1.1  tv 						ego -= 10;
    272  1.1  tv 						notes[JINXED]++;
    273  1.1  tv 						if (wintime)
    274  1.1  tv 							live();
    275  1.1  tv 						break;
    276  1.1  tv 					} else
    277  1.1  tv 						puts("I don't see any goddess around here.");
    278  1.1  tv 				break;
    279  1.1  tv 
    280  1.1  tv 			case TIMER:
    281  1.1  tv 				if (testbit(location[position].objects, TIMER)) {
    282  1.1  tv 					puts("The old man slumps over the bar.");
    283  1.1  tv 					power++;
    284  1.1  tv 					ego -= 2;
    285  1.1  tv 					notes[JINXED]++;
    286  1.1  tv 					clearbit(location[position].objects, TIMER);
    287  1.1  tv 					setbit(location[position].objects, DEADTIME);
    288  1.1  tv 				} else
    289  1.1  tv 					puts("What old-timer?");
    290  1.1  tv 				break;
    291  1.1  tv 			case MAN:
    292  1.1  tv 				if (testbit(location[position].objects, MAN)) {
    293  1.1  tv 					puts("The man falls to the ground with blood pouring all over his white suit.");
    294  1.1  tv 					puts("Your fantasy is over.");
    295  1.1  tv 					die();
    296  1.1  tv 				} else
    297  1.1  tv 					puts("What man?");
    298  1.1  tv 				break;
    299  1.1  tv 			case NATIVE:
    300  1.1  tv 				if (testbit(location[position].objects, NATIVE)) {
    301  1.1  tv 					puts("The girl is blown backwards several feet and lies in a pool of blood.");
    302  1.1  tv 					clearbit(location[position].objects, NATIVE);
    303  1.1  tv 					setbit(location[position].objects, DEADNATIVE);
    304  1.1  tv 					power += 5;
    305  1.1  tv 					ego -= 2;
    306  1.1  tv 					notes[JINXED]++;
    307  1.1  tv 				} else
    308  1.1  tv 					puts("There is no girl here.");
    309  1.1  tv 				break;
    310  1.1  tv 			case -1:
    311  1.1  tv 				puts("Shoot what?");
    312  1.1  tv 				break;
    313  1.1  tv 
    314  1.1  tv 			default:
    315  1.1  tv 				printf("You can't shoot the %s.\n", objsht[wordvalue[wordnumber]]);
    316  1.1  tv 			}
    317  1.1  tv 		} else
    318  1.1  tv 			puts("You must be a looney.");
    319  1.1  tv 	}
    320  1.1  tv 	return (firstnumber);
    321  1.1  tv }
    322