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