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