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