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