kernel - Fix deadlock in sound system
[dragonfly.git] / games / battlestar / command2.c
blobca000669c2e11d79a06ba554a04f41390c4b2b2b
1 /*-
2 * Copyright (c) 1983, 1993
3 * The Regents of the University of California. All rights reserved.
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.
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.
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 * $DragonFly: src/games/battlestar/com2.c,v 1.3 2006/08/08 16:47:20 pavalos Exp $
34 #include "externs.h"
36 int
37 wearit(void) /* synonyms = {sheathe, sheath} */
39 int n;
40 int firstnumber, value;
42 firstnumber = wordnumber;
43 while(wordtype[++wordnumber] == ADJS)
44 ; /* nothing */
45 while(wordnumber <= wordcount) {
46 value = wordvalue[wordnumber];
47 if (value == -1) {
48 puts("Wear what?");
49 return (firstnumber);
51 for (n = 0; objsht[value][n]; n++);
52 switch (value) {
53 default:
54 printf("You can't wear%s%s!\n",
55 (objsht[value][n-1] == 's' ? " " : " a "), objsht[value]);
56 return(firstnumber);
58 case KNIFE:
59 /* case SHIRT: */
60 case ROBE:
61 case LEVIS: /* wearable things */
62 case SWORD:
63 case MAIL:
64 case HELM:
65 case SHOES:
66 case PAJAMAS:
67 case COMPASS:
68 case LASER:
69 case AMULET:
70 case TALISMAN:
71 case MEDALION:
72 case ROPE:
73 case RING:
74 case BRACELET:
75 case GRENADE:
77 if (testbit(inven, value)) {
78 clearbit(inven, value);
79 setbit(wear, value);
80 carrying -= objwt[value];
81 encumber -= objcumber[value];
82 gtime++;
83 printf("You are now wearing %s %s.\n",
84 (objsht[value][n-1] == 's' ? "the" : "a"), objsht[value]);
85 } else {
86 if (testbit(wear, value))
87 printf("You are already wearing the %s.\n", objsht[value]);
88 else
89 printf("You aren't holding the %s.\n", objsht[value]);
91 if (wordnumber < wordcount - 1 &&
92 wordvalue[++wordnumber] == AND)
93 wordnumber++;
94 else
95 return (firstnumber);
96 } /* end switch */
97 } /* end while */
98 puts("Don't be ridiculous.");
99 return (firstnumber);
103 put(void) /* synonyms = {buckle, strap, tie} */
105 if (wordvalue[wordnumber + 1] == ON) {
106 wordvalue[++wordnumber] = PUTON;
107 return (cypher());
109 if (wordvalue[wordnumber + 1] == DOWN) {
110 wordvalue[++wordnumber] = DROP;
111 return (cypher());
113 puts("I don't understand what you want to put.");
114 return(-1);
119 draw(void) /* synonyms = {pull, carry} */
121 return (take(wear));
125 use(void)
127 while (wordtype[++wordnumber] == ADJS && wordnumber < wordcount)
128 ; /* nothing */
129 if (wordvalue[wordnumber] == AMULET && testbit(inven, AMULET) &&
130 position != FINAL) {
131 puts("The amulet begins to glow.");
132 if (testbit(inven, MEDALION)) {
133 puts("The medallion comes to life too.");
134 if (position == 114) {
135 location[position].down = 160;
136 whichway(location[position]);
137 puts("The waves subside and it is possible to descend to the sea cave now.");
138 gtime++;
139 return (-1);
142 puts("A light mist falls over your eyes and the sound of purling water trickles in");
143 puts("your ears. When the mist lifts you are standing beside a cool stream.");
144 if (position == 229)
145 position = 224;
146 else
147 position = 229;
148 gtime++;
149 notes[CANTSEE] = 0;
150 return(0);
151 } else if (position == FINAL)
152 puts("The amulet won't work in here.");
153 else if (wordvalue[wordnumber] == COMPASS && testbit(inven, COMPASS))
154 printf("Your compass points %s.\n", truedirec(NORTH, '-'));
155 else if (wordvalue[wordnumber] == COMPASS)
156 puts("You aren't holding the compass.");
157 else if (wordvalue[wordnumber] == AMULET)
158 puts("You aren't holding the amulet.");
159 else
160 puts("There is no apparent use.");
161 return (-1);
164 void
165 murder(void)
167 int n;
169 for (n = 0;
170 !((n == SWORD || n == KNIFE || n == TWO_HANDED || n == MACE ||
171 n == CLEAVER || n == BROAD || n == CHAIN || n == SHOVEL ||
172 n == HALBERD) && testbit(inven, n)) && n < NUMOFOBJECTS;
173 n++);
174 if (n == NUMOFOBJECTS) {
175 puts("You don't have suitable weapons to kill.");
176 } else {
177 printf("Your %s should do the trick.\n", objsht[n]);
178 while (wordtype[++wordnumber] == ADJS)
179 ; /* nothing */
180 switch (wordvalue[wordnumber]) {
181 case NORMGOD:
182 if (testbit(location[position].objects, BATHGOD)) {
183 puts("The goddess's head slices off. Her corpse floats in the water.");
184 clearbit(location[position].objects, BATHGOD);
185 setbit(location[position].objects, DEADGOD);
186 power += 5;
187 notes[JINXED]++;
188 } else if (testbit(location[position].objects, NORMGOD)) {
189 puts("The goddess pleads but you strike her mercilessly. Her broken body lies in a\npool of blood.");
190 clearbit(location[position].objects, NORMGOD);
191 setbit(location[position].objects, DEADGOD);
192 power += 5;
193 notes[JINXED]++;
194 if (wintime)
195 live();
196 } else
197 puts("I dont see her anywhere.");
198 break;
199 case TIMER:
200 if (testbit(location[position].objects, TIMER)) {
201 puts("The old man offers no resistance.");
202 clearbit(location[position].objects, TIMER);
203 setbit(location[position].objects, DEADTIME);
204 power++;
205 notes[JINXED]++;
206 } else
207 puts("Who?");
208 break;
209 case NATIVE:
210 if (testbit(location[position].objects, NATIVE)) {
211 puts("The girl screams as you cut her body to shreds. She is dead.");
212 clearbit(location[position].objects, NATIVE);
213 setbit(location[position].objects, DEADNATIVE);
214 power += 5;
215 notes[JINXED]++;
216 } else
217 puts("What girl?");
218 break;
219 case MAN:
220 if (testbit(location[position].objects, MAN)) {
221 puts("You strike him to the ground, and he coughs up blood.");
222 puts("Your fantasy is over.");
223 die(0);
225 case -1:
226 puts("Kill what?");
227 break;
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]]);
239 void
240 ravage(void)
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);
282 break;
283 default:
284 puts("You are perverted.");
286 } else
287 puts("Who?");
291 follow(void)
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);