Home | History | Annotate | Line # | Download | only in battlestar
command5.c revision 1.1
      1  1.1  tv /*	$NetBSD: command5.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[] = "@(#)com5.c	8.2 (Berkeley) 4/28/95";
     40  1.1  tv #else
     41  1.1  tv __RCSID("$NetBSD: command5.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 kiss()
     49  1.1  tv {
     50  1.1  tv 	while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
     51  1.1  tv 		continue;
     52  1.1  tv 	/* The goddess must be "taken" first if bathing. */
     53  1.1  tv 	if (wordtype[wordnumber] == NOUNS && wordvalue[wordnumber] == NORMGOD
     54  1.1  tv 	    && testbit(location[position].objects, BATHGOD)) {
     55  1.1  tv 		wordvalue[--wordnumber] = TAKE;
     56  1.1  tv 		cypher();
     57  1.1  tv 		return;
     58  1.1  tv 	}
     59  1.1  tv 	if (wordtype[wordnumber] == NOUNS) {
     60  1.1  tv 		if (testbit(location[position].objects, wordvalue[wordnumber])) {
     61  1.1  tv 			pleasure++;
     62  1.1  tv 			printf("Kissed.\n");
     63  1.1  tv 			switch (wordvalue[wordnumber]) {
     64  1.1  tv 			case NORMGOD:
     65  1.1  tv 				switch (godready++) {
     66  1.1  tv 				case 0:
     67  1.1  tv 					puts("She squirms and avoids your advances.");
     68  1.1  tv 					break;
     69  1.1  tv 				case 1:
     70  1.1  tv 					puts("She is coming around; she didn't fight it as much.");
     71  1.1  tv 					break;
     72  1.1  tv 				case 2:
     73  1.1  tv 					puts("She's beginning to like it.");
     74  1.1  tv 					break;
     75  1.1  tv 				default:
     76  1.1  tv 					puts("She's gone limp.");
     77  1.1  tv 
     78  1.1  tv 				}
     79  1.1  tv 				break;
     80  1.1  tv 			case NATIVE:
     81  1.1  tv 				puts("Her lips are warm and her body robust.  She pulls you down to the ground.");
     82  1.1  tv 				break;
     83  1.1  tv 			case TIMER:
     84  1.1  tv 				puts("The old man blushes.");
     85  1.1  tv 				break;
     86  1.1  tv 			case MAN:
     87  1.1  tv 				puts("The dwarf punches you in the kneecap.");
     88  1.1  tv 				break;
     89  1.1  tv 			default:
     90  1.1  tv 				pleasure--;
     91  1.1  tv 			}
     92  1.1  tv 		} else
     93  1.1  tv 			puts("I see nothing like that here.");
     94  1.1  tv 	} else
     95  1.1  tv 		puts("I'd prefer not to.");
     96  1.1  tv }
     97  1.1  tv 
     98  1.1  tv void
     99  1.1  tv love()
    100  1.1  tv {
    101  1.1  tv 	int     n;
    102  1.1  tv 
    103  1.1  tv 	while (wordtype[++wordnumber] != NOUNS && wordnumber <= wordcount)
    104  1.1  tv 		continue;
    105  1.1  tv 	if (wordtype[wordnumber] == NOUNS) {
    106  1.1  tv 		if ((testbit(location[position].objects, BATHGOD) ||
    107  1.1  tv 		    testbit(location[position].objects, NORMGOD)) &&
    108  1.1  tv 		    wordvalue[wordnumber] == NORMGOD) {
    109  1.1  tv 			if (loved) {
    110  1.1  tv 				printf("Loved.\n");
    111  1.1  tv 				return;
    112  1.1  tv 			}
    113  1.1  tv 			if (godready >= 2) {
    114  1.1  tv 				puts("She cuddles up to you, and her mouth starts to work:\n'That was my sister's amulet.  The lovely goddess, Purl, was she.  The Empire\ncaptured her just after the Darkness came.  My other sister, Vert, was killed\nby the Dark Lord himself.  He took her amulet and warped its power.\nYour quest was foretold by my father before he died, but to get the Dark Lord's\namulet you must use cunning and skill.  I will leave you my amulet,");
    115  1.1  tv 				puts("which you may use as you wish.  As for me, I am the last goddess of the\nwaters.  My father was the Island King, and the rule is rightfully mine.'\n\nShe pulls the throne out into a large bed.");
    116  1.1  tv 				power++;
    117  1.1  tv 				pleasure += 15;
    118  1.1  tv 				ego++;
    119  1.1  tv 				if (card(injuries, NUMOFINJURIES)) {
    120  1.1  tv 					puts("Her kisses revive you; your wounds are healed.\n");
    121  1.1  tv 					for (n = 0; n < NUMOFINJURIES; n++)
    122  1.1  tv 						injuries[n] = 0;
    123  1.1  tv 					WEIGHT = MAXWEIGHT;
    124  1.1  tv 					CUMBER = MAXCUMBER;
    125  1.1  tv 				}
    126  1.1  tv 				printf("Goddess:\n");
    127  1.1  tv 				if (!loved)
    128  1.1  tv 					setbit(location[position].objects, MEDALION);
    129  1.1  tv 				loved = 1;
    130  1.1  tv 				ourtime += 10;
    131  1.1  tv 				printf("Loved.\n");
    132  1.1  tv 				zzz();
    133  1.1  tv 				return;
    134  1.1  tv 			} else {
    135  1.1  tv 				puts("You wish!");
    136  1.1  tv 				return;
    137  1.1  tv 			}
    138  1.1  tv 		}
    139  1.1  tv 		if (testbit(location[position].objects, wordvalue[wordnumber])) {
    140  1.1  tv 			if (wordvalue[wordnumber] == NATIVE) {
    141  1.1  tv 				puts("The girl is easy prey.  She peels off her sarong and indulges you.");
    142  1.1  tv 				power++;
    143  1.1  tv 				pleasure += 5;
    144  1.1  tv 				printf("Girl:\n");
    145  1.1  tv 				ourtime += 10;
    146  1.1  tv 				printf("Loved.\n");
    147  1.1  tv 				zzz();
    148  1.1  tv 			}
    149  1.1  tv 			if (wordvalue[wordnumber] == MAN ||
    150  1.1  tv 			    wordvalue[wordnumber] == BODY ||
    151  1.1  tv 			    wordvalue[wordnumber] == ELF ||
    152  1.1  tv 			    wordvalue[wordnumber] == TIMER)
    153  1.1  tv 				puts("Kinky!");
    154  1.1  tv 			else
    155  1.1  tv 				puts("It doesn't seem to work.");
    156  1.1  tv 		} else
    157  1.1  tv 			puts("Where's your lover?");
    158  1.1  tv 	} else
    159  1.1  tv 		puts("It doesn't seem to work.");
    160  1.1  tv }
    161  1.1  tv 
    162  1.1  tv int
    163  1.1  tv zzz()
    164  1.1  tv {
    165  1.1  tv 	int     oldtime;
    166  1.1  tv 	int     n;
    167  1.1  tv 
    168  1.1  tv 	oldtime = ourtime;
    169  1.1  tv 	if ((snooze - ourtime) < (0.75 * CYCLE)) {
    170  1.1  tv 		ourtime += 0.75 * CYCLE - (snooze - ourtime);
    171  1.1  tv 		printf("<zzz>");
    172  1.1  tv 		for (n = 0; n < ourtime - oldtime; n++)
    173  1.1  tv 			printf(".");
    174  1.1  tv 		printf("\n");
    175  1.1  tv 		snooze += 3 * (ourtime - oldtime);
    176  1.1  tv 		if (notes[LAUNCHED]) {
    177  1.1  tv 			fuel -= (ourtime - oldtime);
    178  1.1  tv 			if (location[position].down) {
    179  1.1  tv 				position = location[position].down;
    180  1.1  tv 				crash();
    181  1.1  tv 			} else
    182  1.1  tv 				notes[LAUNCHED] = 0;
    183  1.1  tv 		}
    184  1.1  tv 		if (OUTSIDE && rnd(100) < 50) {
    185  1.1  tv 			puts("You are awakened abruptly by the sound of someone nearby.");
    186  1.1  tv 			switch (rnd(4)) {
    187  1.1  tv 			case 0:
    188  1.1  tv 				if (ucard(inven)) {
    189  1.1  tv 					n = rnd(NUMOFOBJECTS);
    190  1.1  tv 					while (!testbit(inven, n))
    191  1.1  tv 						n = rnd(NUMOFOBJECTS);
    192  1.1  tv 					clearbit(inven, n);
    193  1.1  tv 					if (n != AMULET && n != MEDALION && n != TALISMAN)
    194  1.1  tv 						setbit(location[position].objects, n);
    195  1.1  tv 					carrying -= objwt[n];
    196  1.1  tv 					encumber -= objcumber[n];
    197  1.1  tv 				}
    198  1.1  tv 				puts("A fiendish little Elf is stealing your treasures!");
    199  1.1  tv 				fight(ELF, 10);
    200  1.1  tv 				break;
    201  1.1  tv 			case 1:
    202  1.1  tv 				setbit(location[position].objects, DEADWOOD);
    203  1.1  tv 				break;
    204  1.1  tv 			case 2:
    205  1.1  tv 				setbit(location[position].objects, HALBERD);
    206  1.1  tv 				break;
    207  1.1  tv 			default:
    208  1.1  tv 				break;
    209  1.1  tv 			}
    210  1.1  tv 		}
    211  1.1  tv 	} else
    212  1.1  tv 		return (0);
    213  1.1  tv 	return (1);
    214  1.1  tv }
    215  1.1  tv 
    216  1.1  tv void
    217  1.1  tv chime()
    218  1.1  tv {
    219  1.1  tv 	if ((ourtime / CYCLE + 1) % 2 && OUTSIDE)
    220  1.1  tv 		switch ((ourtime % CYCLE) / (CYCLE / 7)) {
    221  1.1  tv 		case 0:
    222  1.1  tv 			puts("It is just after sunrise.");
    223  1.1  tv 			break;
    224  1.1  tv 		case 1:
    225  1.1  tv 			puts("It is early morning.");
    226  1.1  tv 			break;
    227  1.1  tv 		case 2:
    228  1.1  tv 			puts("It is late morning.");
    229  1.1  tv 			break;
    230  1.1  tv 		case 3:
    231  1.1  tv 			puts("It is near noon.");
    232  1.1  tv 			break;
    233  1.1  tv 		case 4:
    234  1.1  tv 			puts("It is early afternoon.");
    235  1.1  tv 			break;
    236  1.1  tv 		case 5:
    237  1.1  tv 			puts("It is late afternoon.");
    238  1.1  tv 			break;
    239  1.1  tv 		case 6:
    240  1.1  tv 			puts("It is near sunset.");
    241  1.1  tv 			break;
    242  1.1  tv 		}
    243  1.1  tv 	else if (OUTSIDE)
    244  1.1  tv 		switch ((ourtime % CYCLE) / (CYCLE / 7)) {
    245  1.1  tv 		case 0:
    246  1.1  tv 			puts("It is just after sunset.");
    247  1.1  tv 			break;
    248  1.1  tv 		case 1:
    249  1.1  tv 			puts("It is early evening.");
    250  1.1  tv 			break;
    251  1.1  tv 		case 2:
    252  1.1  tv 			puts("The evening is getting old.");
    253  1.1  tv 			break;
    254  1.1  tv 		case 3:
    255  1.1  tv 			puts("It is near midnight.");
    256  1.1  tv 			break;
    257  1.1  tv 		case 4:
    258  1.1  tv 			puts("These are the wee hours of the morning.");
    259  1.1  tv 			break;
    260  1.1  tv 		case 5:
    261  1.1  tv 			puts("The night is waning.");
    262  1.1  tv 			break;
    263  1.1  tv 		case 6:
    264  1.1  tv 			puts("It is almost morning.");
    265  1.1  tv 			break;
    266  1.1  tv 		}
    267  1.1  tv 	else
    268  1.1  tv 		puts("I can't tell the time in here.");
    269  1.1  tv }
    270  1.1  tv 
    271  1.1  tv int
    272  1.1  tv give()
    273  1.1  tv {
    274  1.1  tv 	int     obj = -1, result = -1, person = 0, firstnumber, last1, last2;
    275  1.1  tv 
    276  1.1  tv 	last1 = last2 = 0;
    277  1.1  tv 	firstnumber = wordnumber;
    278  1.1  tv 	while (wordtype[++wordnumber] != OBJECT && wordvalue[wordnumber] != AMULET && wordvalue[wordnumber] != MEDALION && wordvalue[wordnumber] != TALISMAN && wordnumber <= wordcount)
    279  1.1  tv 		continue;
    280  1.1  tv 	if (wordnumber <= wordcount) {
    281  1.1  tv 		obj = wordvalue[wordnumber];
    282  1.1  tv 		if (obj == EVERYTHING)
    283  1.1  tv 			wordtype[wordnumber] = -1;
    284  1.1  tv 		last1 = wordnumber;
    285  1.1  tv 	}
    286  1.1  tv 	wordnumber = firstnumber;
    287  1.1  tv 	while ((wordtype[++wordnumber] != NOUNS || wordvalue[wordnumber] == obj) && wordnumber <= wordcount);
    288  1.1  tv 	if (wordtype[wordnumber] == NOUNS) {
    289  1.1  tv 		person = wordvalue[wordnumber];
    290  1.1  tv 		last2 = wordnumber;
    291  1.1  tv 	}
    292  1.1  tv 	/* Setting wordnumber to last1 - 1 looks wrong if last1 is 0, e.g.,
    293  1.1  tv 	 * plain `give'.  However, detecting this case is liable to detect
    294  1.1  tv 	 * `give foo' as well, which would give a confusing error.  We
    295  1.1  tv 	 * need to make sure the -1 value can cause no problems if it arises.
    296  1.1  tv 	 * If in the below we get to the drop("Given") then drop will look
    297  1.1  tv 	 * at word 0 for an object to give, and fail, which is OK; then
    298  1.1  tv 	 * result will be -1 and we get to the end, where wordnumber gets
    299  1.1  tv 	 * set to something more sensible.  If we get to "I don't think
    300  1.1  tv 	 * that is possible" then again wordnumber is set to something
    301  1.1  tv 	 * sensible.  The wordnumber we leave with still isn't right if
    302  1.1  tv 	 * you include words the game doesn't know in your command, but
    303  1.1  tv 	 * that's no worse than what other commands than give do in
    304  1.1  tv 	 * the same place.  */
    305  1.1  tv 	wordnumber = last1 - 1;
    306  1.1  tv 	if (person && testbit(location[position].objects, person)) {
    307  1.1  tv 		if (person == NORMGOD && godready < 2 && !(obj == RING || obj == BRACELET))
    308  1.1  tv 			puts("The goddess won't look at you.");
    309  1.1  tv 		else
    310  1.1  tv 			result = drop("Given");
    311  1.1  tv 	} else {
    312  1.1  tv 		puts("I don't think that is possible.");
    313  1.1  tv 		wordnumber = max(last1, last2) + 1;
    314  1.1  tv 		return (0);
    315  1.1  tv 	}
    316  1.1  tv 	if (result != -1 && (testbit(location[position].objects, obj) || obj == AMULET || obj == MEDALION || obj == TALISMAN)) {
    317  1.1  tv 		clearbit(location[position].objects, obj);
    318  1.1  tv 		ourtime++;
    319  1.1  tv 		ego++;
    320  1.1  tv 		switch (person) {
    321  1.1  tv 		case NATIVE:
    322  1.1  tv 			puts("She accepts it shyly.");
    323  1.1  tv 			ego += 2;
    324  1.1  tv 			break;
    325  1.1  tv 		case NORMGOD:
    326  1.1  tv 			if (obj == RING || obj == BRACELET) {
    327  1.1  tv 				puts("She takes the charm and puts it on.  A little kiss on the cheek is");
    328  1.1  tv 				puts("your reward.");
    329  1.1  tv 				ego += 5;
    330  1.1  tv 				godready += 3;
    331  1.1  tv 			}
    332  1.1  tv 			if (obj == AMULET || obj == MEDALION || obj == TALISMAN) {
    333  1.1  tv 				win++;
    334  1.1  tv 				ego += 5;
    335  1.1  tv 				power -= 5;
    336  1.1  tv 				if (win >= 3) {
    337  1.1  tv 					puts("The powers of the earth are now legitimate.  You have destroyed the Darkness");
    338  1.1  tv 					puts("and restored the goddess to her throne.  The entire island celebrates with");
    339  1.1  tv 					puts("dancing and spring feasts.  As a measure of her gratitude, the goddess weds you");
    340  1.1  tv 					puts("in the late summer and crowns you Prince Liverwort, Lord of Fungus.");
    341  1.1  tv 					puts("\nBut, as the year wears on and autumn comes along, you become restless and");
    342  1.1  tv 					puts("yearn for adventure.  The goddess, too, realizes that the marriage can't last.");
    343  1.1  tv 					puts("She becomes bored and takes several more natives as husbands.  One evening,");
    344  1.1  tv 					puts("after having been out drinking with the girls, she kicks the throne particularly");
    345  1.1  tv 					puts("hard and wakes you up.  (If you want to win this game, you're going to have to\nshoot her!)");
    346  1.1  tv 					clearbit(location[position].objects, MEDALION);
    347  1.1  tv 					wintime = ourtime;
    348  1.1  tv 				}
    349  1.1  tv 			}
    350  1.1  tv 			break;
    351  1.1  tv 		case TIMER:
    352  1.1  tv 			if (obj == COINS) {
    353  1.1  tv 				puts("He fingers the coins for a moment and then looks up agape.  `Kind you are and");
    354  1.1  tv 				puts("I mean to repay you as best I can.'  Grabbing a pencil and cocktail napkin...\n");
    355  1.1  tv 				printf("+-----------------------------------------------------------------------------+\n");
    356  1.1  tv 				printf("|				   xxxxxxxx\\				      |\n");
    357  1.1  tv 				printf("|				       xxxxx\\	CLIFFS			      |\n");
    358  1.1  tv 				printf("|		FOREST			  xxx\\				      |\n");
    359  1.1  tv 				printf("|				\\\\	     x\\        	OCEAN		      |\n");
    360  1.1  tv 				printf("|				||	       x\\			      |\n");
    361  1.1  tv 				printf("|				||  ROAD	x\\			      |\n");
    362  1.1  tv 				printf("|				||		x\\			      |\n");
    363  1.1  tv 				printf("|		SECRET		||	  .........			      |\n");
    364  1.1  tv 				printf("|		 - + -		||	   ........			      |\n");
    365  1.1  tv 				printf("|		ENTRANCE	||		...      BEACH		      |\n");
    366  1.1  tv 				printf("|				||		...		  E	      |\n");
    367  1.1  tv 				printf("|				||		...		  |	      |\n");
    368  1.1  tv 				printf("|				//		...	    N <-- + --- S     |\n");
    369  1.1  tv 				printf("|		PALM GROVE     //		...		  |	      |\n");
    370  1.1  tv 				printf("|			      //		...		  W	      |\n");
    371  1.1  tv 				printf("+-----------------------------------------------------------------------------+\n");
    372  1.1  tv 				puts("\n`This map shows a secret entrance to the catacombs.");
    373  1.1  tv 				puts("You will know when you arrive because I left an old pair of shoes there.'");
    374  1.1  tv 			}
    375  1.1  tv 			break;
    376  1.1  tv 		}
    377  1.1  tv 	}
    378  1.1  tv 	wordnumber = max(last1, last2) + 1;
    379  1.1  tv 	return (firstnumber);
    380  1.1  tv }
    381