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