]> git.cameronkatri.com Git - bsdgames-darwin.git/blob - battlestar/com3.c
curses needs termcap
[bsdgames-darwin.git] / battlestar / com3.c
1 /* $NetBSD: com3.c,v 1.4 1997/01/07 11:56:35 tls 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 #ifndef lint
37 #if 0
38 static char sccsid[] = "@(#)com3.c 8.2 (Berkeley) 4/28/95";
39 #else
40 static char rcsid[] = "$NetBSD: com3.c,v 1.4 1997/01/07 11:56:35 tls Exp $";
41 #endif
42 #endif /* not lint */
43
44 #include "extern.h"
45
46 dig()
47 {
48 if (testbit(inven,SHOVEL)){
49 puts("OK");
50 time++;
51 switch(position){
52 case 144: /* copse near beach */
53 if (!notes[DUG]){
54 setbit(location[position].objects,DEADWOOD);
55 setbit(location[position].objects,COMPASS);
56 setbit(location[position].objects,KNIFE);
57 setbit(location[position].objects,MACE);
58 notes[DUG] = 1;
59 }
60 break;
61
62 default:
63 puts("Nothing happens.");
64 }
65 }
66 else
67 puts("You don't have a shovel.");
68 }
69
70 jump()
71 {
72 register 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
109 bury()
110 {
111 int value;
112
113 if (testbit(inven,SHOVEL)){
114 while(wordtype[++wordnumber] != OBJECT && wordtype[wordnumber] != NOUNS && wordnumber < wordcount);
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 }
165 else
166 puts("It doesn't seem to work.");
167 }
168 else
169 puts("You aren't holding a shovel.");
170 }
171
172 drink()
173 {
174 register int n;
175
176 if (testbit(inven,POTION)){
177 puts("The cool liquid runs down your throat but turns to fire and you choke.");
178 puts("The heat reaches your limbs and tingles your spirit. You feel like falling");
179 puts("asleep.");
180 clearbit(inven, POTION);
181 WEIGHT = MAXWEIGHT;
182 CUMBER = MAXCUMBER;
183 for (n=0; n < NUMOFINJURIES; n++)
184 injuries[n] = 0;
185 time++;
186 zzz();
187 }
188 else
189 puts("I'm not thirsty.");
190 }
191
192 shoot()
193 {
194 int firstnumber, value;
195 register int n;
196
197 if (!testbit(inven,LASER))
198 puts("You aren't holding a blaster.");
199 else {
200 firstnumber = wordnumber;
201 while(wordtype[++wordnumber] == ADJS);
202 while(wordnumber<=wordcount && wordtype[wordnumber] == OBJECT){
203 value = wordvalue[wordnumber];
204 printf("%s:\n", objsht[value]);
205 for (n=0; objsht[value][n]; n++);
206 if (testbit(location[position].objects,value)){
207 clearbit(location[position].objects,value);
208 time++;
209 printf("The %s explode%s\n",objsht[value],(objsht[value][n-1]=='s' ? (objsht[value][n-2]=='s' ? "s." : ".") : "s."));
210 if (value == BOMB)
211 die();
212 }
213 else
214 printf("I dont see any %s around here.\n", objsht[value]);
215 if (wordnumber < wordcount - 1 && wordvalue[++wordnumber] == AND)
216 wordnumber++;
217 else
218 return(firstnumber);
219 }
220 /* special cases with their own return()'s */
221
222 if (wordnumber <= wordcount && wordtype[wordnumber] == NOUNS){
223 time++;
224 switch(wordvalue[wordnumber]){
225
226 case DOOR:
227 switch(position){
228 case 189:
229 case 231:
230 puts("The door is unhinged.");
231 location[189].north = 231;
232 location[231].south = 189;
233 whichway(location[position]);
234 break;
235 case 30:
236 puts("The wooden door splinters.");
237 location[30].west = 25;
238 whichway(location[position]);
239 break;
240 case 31:
241 puts("The laser blast has no effect on the door.");
242 break;
243 case 20:
244 puts("The blast hits the door and it explodes into flame. The magnesium burns");
245 puts("so rapidly that we have no chance to escape.");
246 die();
247 default:
248 puts("Nothing happens.");
249 }
250 break;
251
252 case NORMGOD:
253 if (testbit(location[position].objects,BATHGOD)){
254 puts("The goddess is hit in the chest and splashes back against the rocks.");
255 puts("Dark blood oozes from the charred blast hole. Her naked body floats in the");
256 puts("pools and then off downstream.");
257 clearbit(location[position].objects,BATHGOD);
258 setbit(location[180].objects,DEADGOD);
259 power += 5;
260 ego -= 10;
261 notes[JINXED]++;
262 } else if (testbit(location[position].objects,NORMGOD)){
263 puts("The blast catches the goddess in the stomach, knocking her to the ground.");
264 puts("She writhes in the dirt as the agony of death taunts her.");
265 puts("She has stopped moving.");
266 clearbit(location[position].objects,NORMGOD);
267 setbit(location[position].objects,DEADGOD);
268 power += 5;
269 ego -= 10;
270 notes[JINXED]++;
271 if (wintime)
272 live();
273 break;
274 } else
275 puts("I don't see any goddess around here.");
276 break;
277
278 case TIMER:
279 if (testbit(location[position].objects,TIMER)){
280 puts("The old man slumps over the bar.");
281 power++;
282 ego -= 2;
283 notes[JINXED]++;
284 clearbit(location[position].objects,TIMER);
285 setbit(location[position].objects,DEADTIME);
286 }
287 else puts("What old timer?");
288 break;
289 case MAN:
290 if (testbit(location[position].objects,MAN)){
291 puts("The man falls to the ground with blood pouring all over his white suit.");
292 puts("Your fantasy is over.");
293 die();
294 }
295 else puts("What man?");
296 break;
297 case NATIVE:
298 if (testbit(location[position].objects,NATIVE)){
299 puts("The girl is blown backwards several feet and lies in a pool of blood.");
300 clearbit(location[position].objects,NATIVE);
301 setbit(location[position].objects,DEADNATIVE);
302 power += 5;
303 ego -= 2;
304 notes[JINXED]++;
305 } else puts("There is no girl here.");
306 break;
307 case -1:
308 puts("Shoot what?");
309 break;
310
311 default:
312 printf("You can't shoot the %s.\n",objsht[wordvalue[wordnumber]]);
313 }
314 }
315 else puts("You must be a looney.");
316 }
317 return(firstnumber);
318 }