Remove some more unused headers.
[dragonfly.git] / games / battlestar / command3.c
CommitLineData
6693db17 1/*-
984263bc
MD
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.
6693db17 13 * 3. Neither the name of the University nor the names of its contributors
984263bc
MD
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.
1de703da
MD
28 *
29 * @(#)com3.c 8.1 (Berkeley) 5/31/93
30 * $FreeBSD: src/games/battlestar/com3.c,v 1.8.2.1 2001/03/05 11:45:35 kris Exp $
5c7cac79 31 * $DragonFly: src/games/battlestar/com3.c,v 1.3 2006/08/08 16:47:20 pavalos Exp $
984263bc
MD
32 */
33
984263bc
MD
34#include "externs.h"
35
36void
5c7cac79 37dig(void)
984263bc 38{
6693db17 39 if (testbit(inven, SHOVEL)) {
984263bc
MD
40 puts("OK");
41 gtime++;
6693db17
SW
42 switch (position) {
43 case 144: /* copse near beach */
44 if (!notes[DUG]) {
45 setbit(location[position].objects, DEADWOOD);
46 setbit(location[position].objects, COMPASS);
47 setbit(location[position].objects, KNIFE);
48 setbit(location[position].objects, MACE);
49 notes[DUG] = 1;
50 }
51 break;
984263bc 52
6693db17
SW
53 default:
54 puts("Nothing happens.");
984263bc 55 }
6693db17 56 } else
984263bc
MD
57 puts("You don't have a shovel.");
58}
59
60int
5c7cac79 61jump(void)
984263bc
MD
62{
63 int n;
64
6693db17
SW
65 switch (position) {
66 default:
67 puts("Nothing happens.");
68 return (-1);
984263bc 69
6693db17
SW
70 case 242:
71 position = 133;
72 break;
73 case 214:
74 case 215:
75 case 162:
76 case 159:
77 position = 145;
78 break;
79 case 232:
80 position = 275;
81 break;
82 case 3:
83 position = 1;
84 break;
85 case 172:
86 position = 201;
984263bc
MD
87 }
88 puts("Ahhhhhhh...");
89 injuries[12] = injuries[8] = injuries[7] = injuries[6] = 1;
6693db17
SW
90 for (n = 0; n < NUMOFOBJECTS; n++)
91 if (testbit(inven, n)) {
92 clearbit(inven, n);
93 setbit(location[position].objects, n);
984263bc
MD
94 }
95 carrying = 0;
96 encumber = 0;
6693db17 97 return (0);
984263bc
MD
98}
99
100void
5c7cac79 101bury(void)
984263bc
MD
102{
103 int value;
104
6693db17
SW
105 if (testbit(inven, SHOVEL)) {
106 while (wordtype[++wordnumber] != OBJECT &&
107 wordtype[wordnumber] != NOUNS && wordnumber < wordcount)
108 ; /* nothing */
984263bc 109 value = wordvalue[wordnumber];
6693db17
SW
110 if (wordtype[wordnumber] == NOUNS &&
111 (testbit(location[position].objects, value) ||
112 value == BODY))
113 switch (value) {
114 case BODY:
115 wordtype[wordnumber] = OBJECT;
116 if (testbit(inven, MAID) ||
117 testbit(location[position].objects, MAID))
118 value = MAID;
119 if (testbit(inven, DEADWOOD) ||
120 testbit(location[position].objects,
121 DEADWOOD))
122 value = DEADWOOD;
123 if (testbit(inven, DEADGOD) ||
124 testbit(location[position].objects,
125 DEADGOD))
126 value = DEADGOD;
127 if (testbit(inven, DEADTIME) ||
128 testbit(location[position].objects,
129 DEADTIME))
130 value = DEADTIME;
131 if (testbit(inven, DEADNATIVE) ||
132 testbit(location[position].objects,
133 DEADNATIVE))
134 value = DEADNATIVE;
135 break;
984263bc 136
6693db17
SW
137 case NATIVE:
138 case NORMGOD:
139 puts("She screams as you wrestle her into the hole.");
140 case TIMER:
141 power += 7;
142 ego -= 10;
143 case AMULET:
144 case MEDALION:
145 case TALISMAN:
146 wordtype[wordnumber] = OBJECT;
147 break;
984263bc 148
6693db17
SW
149 default:
150 puts("Wha..?");
984263bc 151 }
6693db17
SW
152 if (wordtype[wordnumber] == OBJECT && position > 88 &&
153 (testbit(inven, value) ||
154 testbit(location[position].objects, value))) {
984263bc 155 puts("Buried.");
6693db17
SW
156 if (testbit(inven, value)) {
157 clearbit(inven, value);
984263bc
MD
158 carrying -= objwt[value];
159 encumber -= objcumber[value];
160 }
6693db17
SW
161 clearbit(location[position].objects, value);
162 switch (value) {
163 case MAID:
164 case DEADWOOD:
165 case DEADNATIVE:
166 case DEADTIME:
167 case DEADGOD:
168 ego += 2;
169 printf("The %s should rest easier now.\n",
170 objsht[value]);
984263bc 171 }
6693db17 172 } else
984263bc 173 puts("It doesn't seem to work.");
6693db17 174 } else
984263bc
MD
175 puts("You aren't holding a shovel.");
176}
177
178void
5c7cac79 179drink(void)
984263bc
MD
180{
181 int n;
182
6693db17 183 if (testbit(inven, POTION)) {
984263bc
MD
184 puts("The cool liquid runs down your throat but turns to fire and you choke.");
185 puts("The heat reaches your limbs and tingles your spirit. You feel like falling");
186 puts("asleep.");
187 clearbit(inven, POTION);
188 WEIGHT = MAXWEIGHT;
189 CUMBER = MAXCUMBER;
6693db17 190 for (n = 0; n < NUMOFINJURIES; n++)
984263bc
MD
191 injuries[n] = 0;
192 gtime++;
193 zzz();
6693db17 194 } else
984263bc
MD
195 puts("I'm not thirsty.");
196}
197
198int
5c7cac79 199shoot(void)
984263bc
MD
200{
201 int firstnumber, value;
202 int n;
203
204 firstnumber = wordnumber;
6693db17 205 if (!testbit(inven, LASER))
984263bc
MD
206 puts("You aren't holding a blaster.");
207 else {
6693db17
SW
208 while (wordtype[++wordnumber] == ADJS)
209 ; /* nothing */
210 while (wordnumber <= wordcount &&
211 wordtype[wordnumber] == OBJECT) {
984263bc
MD
212 value = wordvalue[wordnumber];
213 printf("%s:\n", objsht[value]);
6693db17
SW
214 for (n = 0; objsht[value][n]; n++)
215 ; /* nothing */
216 if (testbit(location[position].objects, value)) {
217 clearbit(location[position].objects, value);
984263bc 218 gtime++;
6693db17
SW
219 printf("The %s explode%s\n", objsht[value],
220 (objsht[value][n - 1] ==
221 's' ? (objsht[value][n - 2] ==
222 's' ? "s." : ".") : "s."));
984263bc
MD
223 if (value == BOMB)
224 die(0);
6693db17
SW
225 } else
226 printf("I dont see any %s around here.\n",
227 objsht[value]);
228 if (wordnumber < wordcount - 1 &&
229 wordvalue[++wordnumber] == AND)
984263bc
MD
230 wordnumber++;
231 else
6693db17 232 return (firstnumber);
984263bc 233 }
6693db17 234 /* special cases with their own return()'s */
984263bc 235
6693db17 236 if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) {
984263bc 237 gtime++;
6693db17
SW
238 switch (wordvalue[wordnumber]) {
239 case DOOR:
240 switch (position) {
241 case 189:
242 case 231:
243 puts("The door is unhinged.");
244 location[189].north = 231;
245 location[231].south = 189;
246 whichway(location[position]);
984263bc 247 break;
6693db17
SW
248 case 30:
249 puts("The wooden door splinters.");
250 location[30].west = 25;
251 whichway(location[position]);
252 break;
253 case 31:
254 puts("The laser blast has no effect on the door.");
255 break;
256 case 20:
257 puts("The blast hits the door and it explodes into flame. The magnesium burns");
258 puts("so rapidly that we have no chance to escape.");
259 die(0);
260 default:
261 puts("Nothing happens.");
262 }
263 break;
984263bc 264
6693db17
SW
265 case NORMGOD:
266 if (testbit(location[position].objects,
267 BATHGOD)) {
268 puts("The goddess is hit in the chest and splashes back against the rocks.");
269 puts("Dark blood oozes from the charred blast hole. Her naked body floats in the");
270 puts("pools and then off downstream.");
271 clearbit(location[position].objects,
272 BATHGOD);
273 setbit(location[180].objects, DEADGOD);
274 power += 5;
275 ego -= 10;
276 notes[JINXED]++;
277 } else
278 if (testbit(location[position].objects,
279 NORMGOD)) {
984263bc
MD
280 puts("The blast catches the goddess in the stomach, knocking her to the ground.");
281 puts("She writhes in the dirt as the agony of death taunts her.");
282 puts("She has stopped moving.");
6693db17
SW
283 clearbit(location[position].objects, NORMGOD);
284 setbit(location[position].objects, DEADGOD);
984263bc
MD
285 power += 5;
286 ego -= 10;
287 notes[JINXED]++;
288 if (wintime)
289 live();
290 break;
291 } else
292 puts("I don't see any goddess around here.");
6693db17 293 break;
984263bc 294
6693db17
SW
295 case TIMER:
296 if (testbit(location[position].objects,
297 TIMER)) {
298 puts("The old man slumps over the bar.");
299 power++;
300 ego -= 2;
301 notes[JINXED]++;
302 clearbit(location[position].objects,
303 TIMER);
304 setbit(location[position].objects,
305 DEADTIME);
306 } else
307 puts("What old timer?");
308 break;
309 case MAN:
310 if (testbit(location[position].objects, MAN)) {
311 puts("The man falls to the ground with blood pouring all over his white suit.");
312 puts("Your fantasy is over.");
313 die(0);
314 } else
315 puts("What man?");
316 break;
317 case NATIVE:
318 if (testbit(location[position].objects,
319 NATIVE)) {
320 puts("The girl is blown backwards several feet and lies in a pool of blood.");
321 clearbit(location[position].objects,
322 NATIVE);
323 setbit(location[position].objects,
324 DEADNATIVE);
325 power += 5;
326 ego -= 2;
327 notes[JINXED]++;
328 } else
329 puts("There is no girl here.");
330 break;
331 case -1:
332 puts("Shoot what?");
333 break;
984263bc 334
6693db17
SW
335 default:
336 printf("You can't shoot the %s.\n",
337 objsht[wordvalue[wordnumber]]);
984263bc 338 }
6693db17
SW
339 } else
340 puts("You must be a looney.");
984263bc 341 }
6693db17 342 return (firstnumber);
984263bc 343}