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