]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/command3.c
fix for OpenSSL-1.1
[bsdgames-darwin.git] / battlestar / command3.c
1 /* $NetBSD: command3.c,v 1.4 2018/02/04 08:48:05 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.4 2018/02/04 08:48:05 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 case TIMER:
149 power += 7;
150 ego -= 10;
151 case AMULET:
152 case MEDALION:
153 case TALISMAN:
154 wordtype[wordnumber] = OBJECT;
155 break;
156
157 default:
158 puts("Wha..?");
159 }
160 if (wordtype[wordnumber] == OBJECT && position > 88 &&
161 (testbit(inven, value) ||
162 testbit(location[position].objects, value))) {
163 puts("Buried.");
164 if (testbit(inven, value)) {
165 clearbit(inven, value);
166 carrying -= objwt[value];
167 encumber -= objcumber[value];
168 }
169 clearbit(location[position].objects, value);
170 switch (value) {
171 case MAID:
172 case DEADWOOD:
173 case DEADNATIVE:
174 case DEADTIME:
175 case DEADGOD:
176 ego += 2;
177 printf("The %s should rest easier now.\n",
178 objsht[value]);
179 }
180 } else
181 puts("It doesn't seem to work.");
182 } else
183 puts("You aren't holding a shovel.");
184 }
185
186 void
187 drink(void)
188 {
189 int n;
190
191 if (testbit(inven, POTION)) {
192 printf("The cool liquid runs down your throat but turns to ");
193 puts("fire and you choke.");
194 printf("The heat reaches your limbs and tingles your spirit.");
195 puts(" You feel like falling");
196 puts("asleep.");
197 clearbit(inven, POTION);
198 WEIGHT = MAXWEIGHT;
199 CUMBER = MAXCUMBER;
200 for (n = 0; n < NUMOFINJURIES; n++)
201 injuries[n] = 0;
202 ourtime++;
203 zzz();
204 } else
205 puts("I'm not thirsty.");
206 }
207
208 int
209 shoot(void)
210 {
211 int firstnumber, value;
212
213 firstnumber = wordnumber;
214 if (!testbit(inven, LASER))
215 puts("You aren't holding a blaster.");
216 else {
217 wordnumber++;
218 while (wordnumber <= wordcount &&
219 wordtype[wordnumber] == OBJECT) {
220 value = wordvalue[wordnumber];
221 printf("%s:\n", objsht[value]);
222 if (testbit(location[position].objects, value)) {
223 clearbit(location[position].objects, value);
224 ourtime++;
225 printf("The %s explode%s\n", objsht[value],
226 (is_plural_object(value) ? "." : "s."));
227 if (value == BOMB)
228 die();
229 } else
230 printf("I don't see any %s around here.\n",
231 objsht[value]);
232 if (wordnumber < wordcount - 1 &&
233 wordvalue[++wordnumber] == AND)
234 wordnumber++;
235 else
236 return (firstnumber);
237 }
238 /* special cases with their own return()'s */
239
240 if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) {
241 ourtime++;
242 switch (wordvalue[wordnumber]) {
243
244 case DOOR:
245 switch (position) {
246 case 189:
247 case 231:
248 puts("The door is unhinged.");
249 location[189].north = 231;
250 location[231].south = 189;
251 whichway(location[position]);
252 break;
253 case 30:
254 puts("The wooden door splinters.");
255 location[30].west = 25;
256 whichway(location[position]);
257 break;
258 case 31:
259 printf("The laser blast has no ");
260 puts("effect on the door.");
261 break;
262 case 20:
263 printf("The blast hits the door and ");
264 printf("it explodes into flame. The ");
265 puts("magnesium burns");
266 printf("so rapidly that we have no ");
267 puts("chance to escape.");
268 die();
269 default:
270 puts("Nothing happens.");
271 }
272 break;
273
274 case NORMGOD:
275 if (testbit(location[position].objects,
276 BATHGOD)) {
277 printf("The goddess is hit in the ");
278 printf("chest and splashes back ");
279 puts("against the rocks.");
280 printf("Dark blood oozes from the ");
281 printf("charred blast hole. Her ");
282 puts("naked body floats in the");
283 puts("pools and then off downstream.");
284 clearbit(location[position].objects,
285 BATHGOD);
286 setbit(location[180].objects, DEADGOD);
287 power += 5;
288 ego -= 10;
289 notes[JINXED]++;
290 } else
291 if (testbit(location[position].objects,
292 NORMGOD)) {
293 printf("The blast catches ");
294 printf("the goddess in the ");
295 printf("stomach, knocking ");
296 puts("her to the ground.");
297 printf("She writhes in the ");
298 printf("dirt as the agony of ");
299 puts("death taunts her.");
300 puts("She has stopped moving.");
301 clearbit(location[position].objects, NORMGOD);
302 setbit(location[position].objects, DEADGOD);
303 power += 5;
304 ego -= 10;
305 notes[JINXED]++;
306 if (wintime)
307 live();
308 break;
309 } else {
310 printf("I don't see any ");
311 puts("goddess around here.");
312 }
313 break;
314
315 case TIMER:
316 if (testbit(location[position].objects,
317 TIMER)) {
318 printf("The old man slumps over ");
319 puts("the bar.");
320 power++;
321 ego -= 2;
322 notes[JINXED]++;
323 clearbit(location[position].objects,
324 TIMER);
325 setbit(location[position].objects,
326 DEADTIME);
327 } else
328 puts("What old-timer?");
329 break;
330 case MAN:
331 if (testbit(location[position].objects, MAN)) {
332 printf("The man falls to the ground ");
333 printf("with blood pouring all over ");
334 puts("his white suit.");
335 puts("Your fantasy is over.");
336 die();
337 } else
338 puts("What man?");
339 break;
340 case NATIVE:
341 if (testbit(location[position].objects,
342 NATIVE)) {
343 printf("The girl is blown backwards ");
344 printf("several feet and lies in a ");
345 puts("pool of blood.");
346 clearbit(location[position].objects,
347 NATIVE);
348 setbit(location[position].objects,
349 DEADNATIVE);
350 power += 5;
351 ego -= 2;
352 notes[JINXED]++;
353 } else
354 puts("There is no girl here.");
355 break;
356 case -1:
357 puts("Shoot what?");
358 break;
359
360 default:
361 printf("You can't shoot the %s.\n",
362 objsht[wordvalue[wordnumber]]);
363 }
364 } else
365 puts("You must be a looney.");
366 }
367 return (firstnumber);
368 }