]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/command3.c
Move UCB-licensed code from 4-clause to 3-clause licence.
[bsdgames-darwin.git] / battlestar / command3.c
1 /* $NetBSD: command3.c,v 1.2 2003/08/07 09:37:00 agc 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.2 2003/08/07 09:37:00 agc Exp $");
38 #endif
39 #endif /* not lint */
40
41 #include "extern.h"
42
43 void
44 dig()
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()
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()
109 {
110 int value;
111
112 if (testbit(inven, SHOVEL)) {
113 while (wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount)
114 continue;
115 value = wordvalue[wordnumber];
116 if (wordtype[wordnumber] == NOUNS && (testbit(location[position].objects, value) || value == BODY))
117 switch (value) {
118 case BODY:
119 wordtype[wordnumber] = OBJECT;
120 if (testbit(inven, MAID) || testbit(location[position].objects, MAID))
121 value = MAID;
122 if (testbit(inven, DEADWOOD) || testbit(location[position].objects, DEADWOOD))
123 value = DEADWOOD;
124 if (testbit(inven, DEADGOD) || testbit(location[position].objects, DEADGOD))
125 value = DEADGOD;
126 if (testbit(inven, DEADTIME) || testbit(location[position].objects, DEADTIME))
127 value = DEADTIME;
128 if (testbit(inven, DEADNATIVE) || testbit(location[position].objects, DEADNATIVE))
129 value = DEADNATIVE;
130 break;
131
132 case NATIVE:
133 case NORMGOD:
134 puts("She screams as you wrestle her into the hole.");
135 case TIMER:
136 power += 7;
137 ego -= 10;
138 case AMULET:
139 case MEDALION:
140 case TALISMAN:
141 wordtype[wordnumber] = OBJECT;
142 break;
143
144 default:
145 puts("Wha..?");
146 }
147 if (wordtype[wordnumber] == OBJECT && position > 88 && (testbit(inven, value) || testbit(location[position].objects, value))) {
148 puts("Buried.");
149 if (testbit(inven, value)) {
150 clearbit(inven, value);
151 carrying -= objwt[value];
152 encumber -= objcumber[value];
153 }
154 clearbit(location[position].objects, value);
155 switch (value) {
156 case MAID:
157 case DEADWOOD:
158 case DEADNATIVE:
159 case DEADTIME:
160 case DEADGOD:
161 ego += 2;
162 printf("The %s should rest easier now.\n", objsht[value]);
163 }
164 } else
165 puts("It doesn't seem to work.");
166 } else
167 puts("You aren't holding a shovel.");
168 }
169
170 void
171 drink()
172 {
173 int n;
174
175 if (testbit(inven, POTION)) {
176 puts("The cool liquid runs down your throat but turns to fire and you choke.");
177 puts("The heat reaches your limbs and tingles your spirit. You feel like falling");
178 puts("asleep.");
179 clearbit(inven, POTION);
180 WEIGHT = MAXWEIGHT;
181 CUMBER = MAXCUMBER;
182 for (n = 0; n < NUMOFINJURIES; n++)
183 injuries[n] = 0;
184 ourtime++;
185 zzz();
186 } else
187 puts("I'm not thirsty.");
188 }
189
190 int
191 shoot()
192 {
193 int firstnumber, value;
194
195 firstnumber = wordnumber;
196 if (!testbit(inven, LASER))
197 puts("You aren't holding a blaster.");
198 else {
199 wordnumber++;
200 while (wordnumber <= wordcount && wordtype[wordnumber] == OBJECT) {
201 value = wordvalue[wordnumber];
202 printf("%s:\n", objsht[value]);
203 if (testbit(location[position].objects, value)) {
204 clearbit(location[position].objects, value);
205 ourtime++;
206 printf("The %s explode%s\n", objsht[value],
207 (is_plural_object(value) ? "." : "s."));
208 if (value == BOMB)
209 die();
210 } else
211 printf("I don't see any %s around here.\n", objsht[value]);
212 if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
213 wordnumber++;
214 else
215 return (firstnumber);
216 }
217 /* special cases with their own return()'s */
218
219 if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS) {
220 ourtime++;
221 switch (wordvalue[wordnumber]) {
222
223 case DOOR:
224 switch (position) {
225 case 189:
226 case 231:
227 puts("The door is unhinged.");
228 location[189].north = 231;
229 location[231].south = 189;
230 whichway(location[position]);
231 break;
232 case 30:
233 puts("The wooden door splinters.");
234 location[30].west = 25;
235 whichway(location[position]);
236 break;
237 case 31:
238 puts("The laser blast has no effect on the door.");
239 break;
240 case 20:
241 puts("The blast hits the door and it explodes into flame. The magnesium burns");
242 puts("so rapidly that we have no chance to escape.");
243 die();
244 default:
245 puts("Nothing happens.");
246 }
247 break;
248
249 case NORMGOD:
250 if (testbit(location[position].objects, BATHGOD)) {
251 puts("The goddess is hit in the chest and splashes back against the rocks.");
252 puts("Dark blood oozes from the charred blast hole. Her naked body floats in the");
253 puts("pools and then off downstream.");
254 clearbit(location[position].objects, BATHGOD);
255 setbit(location[180].objects, DEADGOD);
256 power += 5;
257 ego -= 10;
258 notes[JINXED]++;
259 } else
260 if (testbit(location[position].objects, NORMGOD)) {
261 puts("The blast catches the goddess in the stomach, knocking her to the ground.");
262 puts("She writhes in the dirt as the agony of death taunts her.");
263 puts("She has stopped moving.");
264 clearbit(location[position].objects, NORMGOD);
265 setbit(location[position].objects, DEADGOD);
266 power += 5;
267 ego -= 10;
268 notes[JINXED]++;
269 if (wintime)
270 live();
271 break;
272 } else
273 puts("I don't see any goddess around here.");
274 break;
275
276 case TIMER:
277 if (testbit(location[position].objects, TIMER)) {
278 puts("The old man slumps over the bar.");
279 power++;
280 ego -= 2;
281 notes[JINXED]++;
282 clearbit(location[position].objects, TIMER);
283 setbit(location[position].objects, DEADTIME);
284 } else
285 puts("What old-timer?");
286 break;
287 case MAN:
288 if (testbit(location[position].objects, MAN)) {
289 puts("The man falls to the ground with blood pouring all over his white suit.");
290 puts("Your fantasy is over.");
291 die();
292 } else
293 puts("What man?");
294 break;
295 case NATIVE:
296 if (testbit(location[position].objects, NATIVE)) {
297 puts("The girl is blown backwards several feet and lies in a pool of blood.");
298 clearbit(location[position].objects, NATIVE);
299 setbit(location[position].objects, DEADNATIVE);
300 power += 5;
301 ego -= 2;
302 notes[JINXED]++;
303 } else
304 puts("There is no girl here.");
305 break;
306 case -1:
307 puts("Shoot what?");
308 break;
309
310 default:
311 printf("You can't shoot the %s.\n", objsht[wordvalue[wordnumber]]);
312 }
313 } else
314 puts("You must be a looney.");
315 }
316 return (firstnumber);
317 }